From c61824d07e1fced19a75c798e089dda54f222d27 Mon Sep 17 00:00:00 2001 From: Balazs Perlaki-Horvath Date: Sat, 12 Apr 2025 14:19:14 +0200 Subject: [PATCH] Move Action view to a separate file --- Views/Library/Action.swift | 29 ++++++++++++++++++++++++++++- Views/Library/ZimFileDetail.swift | 27 --------------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Views/Library/Action.swift b/Views/Library/Action.swift index 971db770..901372b3 100644 --- a/Views/Library/Action.swift +++ b/Views/Library/Action.swift @@ -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() + } + }) + } +} diff --git a/Views/Library/ZimFileDetail.swift b/Views/Library/ZimFileDetail.swift index cf39fd2c..e7830083 100644 --- a/Views/Library/ZimFileDetail.swift +++ b/Views/Library/ZimFileDetail.swift @@ -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 {