mirror of
https://github.com/shadowsocks/ShadowsocksX-NG.git
synced 2026-11-23 22:36:55 +00:00
outcome 加 .superseded(事务门拒绝词汇,与 runtime「被取代」一致); deleteCustomRules 改 Void,忙碌/超期发布反馈;CustomRuleDeletionResult 与 RulesDeletionButton 本地 alert 删除——同一确认手势的失败呈现归一。
40 lines
1.5 KiB
Swift
40 lines
1.5 KiB
Swift
import SwiftUI
|
|
|
|
/// A single confirmation captures custom UUIDs before starting the shared transaction.
|
|
/// Gate rejections and commit failures surface through the workflow's commit
|
|
/// feedback, not a local alert.
|
|
struct RulesDeletionButton: View {
|
|
@ObservedObject var workflow: RulesWorkflow
|
|
@State private var confirmation: CustomRuleDeletion?
|
|
|
|
var body: some View {
|
|
Button {
|
|
confirmation = workflow.prepareCustomRuleDeletion()
|
|
} label: {
|
|
Text(verbatim: countText("删除 %lld 条自定义规则…", workflow.deletableSelection.count))
|
|
}
|
|
.disabled(
|
|
workflow.deletableSelection.isEmpty || !workflow.snapshot.isComplete
|
|
|| workflow.snapshot.isCommitting
|
|
)
|
|
.alert(
|
|
countText("删除 %lld 条自定义规则?", confirmation?.customIDs.count ?? 0),
|
|
isPresented: Binding(
|
|
get: { confirmation != nil }, set: { if !$0 { confirmation = nil } }),
|
|
presenting: confirmation
|
|
) { captured in
|
|
Button(RulesCopy.text("删除"), role: .destructive) {
|
|
confirmation = nil
|
|
Task { await workflow.deleteCustomRules(captured) }
|
|
}
|
|
Button(RulesCopy.text("取消"), role: .cancel) { confirmation = nil }
|
|
} message: { _ in
|
|
Text(RulesCopy.text("只删除所选自定义条目。其他来源的规则和已有禁用记录将保留。"))
|
|
}
|
|
}
|
|
|
|
private func countText(_ key: String, _ count: Int) -> String {
|
|
String.localizedStringWithFormat(RulesCopy.text(key), Int64(count))
|
|
}
|
|
}
|