diff --git a/ShadowsocksX-NG2/App/UI/Home/QuickActionCard.swift b/ShadowsocksX-NG2/App/UI/Home/QuickActionCard.swift new file mode 100644 index 00000000..e9988eb0 --- /dev/null +++ b/ShadowsocksX-NG2/App/UI/Home/QuickActionCard.swift @@ -0,0 +1,41 @@ +import SwiftUI + +/// 「快速操作」卡:更新全部订阅。 +struct QuickActionCard: View { + @ObservedObject var workflow: CatalogWorkflow + + @State private var isRefreshingAll = false + + var body: some View { + HomeCard( + title: "快速操作", + subtitle: nil, + trailing: { EmptyView() }, + content: { + VStack(spacing: 10) { + QuickActionButton( + icon: "arrow.triangle.2.circlepath", + title: isRefreshingAll ? "正在更新…" : "更新全部订阅", + help: nil, + action: refreshAll + ) + .disabled(workflow.subscriptions.isEmpty || isRefreshingAll) + if isRefreshingAll { + ProgressView() + .controlSize(.small) + .frame(maxWidth: .infinity, alignment: .leading) + } + } + .padding(.top, 6) + }) + } + + private func refreshAll() { + isRefreshingAll = true + Task { + await workflow.refreshAllSubscriptions() + isRefreshingAll = false + } + } + +} diff --git a/ShadowsocksX-NG2/App/UI/Home/HomeView+Cards.swift b/ShadowsocksX-NG2/App/UI/Home/TerminalProxyEnvironmentCard.swift similarity index 84% rename from ShadowsocksX-NG2/App/UI/Home/HomeView+Cards.swift rename to ShadowsocksX-NG2/App/UI/Home/TerminalProxyEnvironmentCard.swift index 9135b202..db949186 100644 --- a/ShadowsocksX-NG2/App/UI/Home/HomeView+Cards.swift +++ b/ShadowsocksX-NG2/App/UI/Home/TerminalProxyEnvironmentCard.swift @@ -144,43 +144,3 @@ extension TerminalCommandShell { } } } - -/// 「快速操作」卡:更新全部订阅。 -struct QuickActionCard: View { - @ObservedObject var workflow: CatalogWorkflow - - @State private var isRefreshingAll = false - - var body: some View { - HomeCard( - title: "快速操作", - subtitle: nil, - trailing: { EmptyView() }, - content: { - VStack(spacing: 10) { - QuickActionButton( - icon: "arrow.triangle.2.circlepath", - title: isRefreshingAll ? "正在更新…" : "更新全部订阅", - help: nil, - action: refreshAll - ) - .disabled(workflow.subscriptions.isEmpty || isRefreshingAll) - if isRefreshingAll { - ProgressView() - .controlSize(.small) - .frame(maxWidth: .infinity, alignment: .leading) - } - } - .padding(.top, 6) - }) - } - - private func refreshAll() { - isRefreshingAll = true - Task { - await workflow.refreshAllSubscriptions() - isRefreshingAll = false - } - } - -}