Move Action view to a separate file

This commit is contained in:
Balazs Perlaki-Horvath 2025-04-12 14:19:14 +02:00
parent ea69bfa6a6
commit c61824d07e
2 changed files with 28 additions and 28 deletions

View File

@ -13,4 +13,31 @@
// You should have received a copy of the GNU General Public License
// 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()
}
})
}
}

View File

@ -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 {
var body: some View {
Label {