mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-09-09 12:21:28 -04:00
Move Action view to a separate file
This commit is contained in:
parent
ea69bfa6a6
commit
c61824d07e
@ -13,4 +13,31 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Kiwix; If not, see https://www.gnu.org/licenses/.
|
// along with Kiwix; If not, see https://www.gnu.org/licenses/.
|
||||||
|
|
||||||
import Foundation
|
import SwiftUI
|
||||||
|
|
||||||
|
struct Action: View {
|
||||||
|
let title: String
|
||||||
|
let isDestructive: Bool
|
||||||
|
let action: @MainActor () async -> Void
|
||||||
|
|
||||||
|
init(title: String,
|
||||||
|
isDestructive: Bool = false,
|
||||||
|
action: @MainActor @escaping () async -> Void = {}
|
||||||
|
) {
|
||||||
|
self.title = title
|
||||||
|
self.isDestructive = isDestructive
|
||||||
|
self.action = action
|
||||||
|
}
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
AsyncButton(action: action, label: {
|
||||||
|
HStack {
|
||||||
|
Spacer()
|
||||||
|
Text(title)
|
||||||
|
.fontWeight(.medium)
|
||||||
|
.foregroundColor(isDestructive ? .red : nil)
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -341,33 +341,6 @@ private struct DownloadTaskDetail: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Action: View {
|
|
||||||
let title: String
|
|
||||||
let isDestructive: Bool
|
|
||||||
let action: @MainActor () async -> Void
|
|
||||||
|
|
||||||
init(title: String,
|
|
||||||
isDestructive: Bool = false,
|
|
||||||
action: @MainActor @escaping () async -> Void = {}
|
|
||||||
) {
|
|
||||||
self.title = title
|
|
||||||
self.isDestructive = isDestructive
|
|
||||||
self.action = action
|
|
||||||
}
|
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
AsyncButton(action: action, label: {
|
|
||||||
HStack {
|
|
||||||
Spacer()
|
|
||||||
Text(title)
|
|
||||||
.fontWeight(.medium)
|
|
||||||
.foregroundColor(isDestructive ? .red : nil)
|
|
||||||
Spacer()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private struct ServiceWorkerWarning: View {
|
private struct ServiceWorkerWarning: View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Label {
|
Label {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user