|
@@ -8,47 +8,13 @@
|
|
|
import SwiftUI
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct SettingsView: View {
|
|
struct SettingsView: View {
|
|
|
- @AppStorage(UserDefaultsKeys.UrlHints) var allHints = URLHintArray()
|
|
|
|
|
- @State var active = URLHint()
|
|
|
|
|
-
|
|
|
|
|
var body: some View {
|
|
var body: some View {
|
|
|
TabView {
|
|
TabView {
|
|
|
Tab("URL Hints", systemImage: "link") {
|
|
Tab("URL Hints", systemImage: "link") {
|
|
|
- Text("Custom rules to expand a tag into a URL")
|
|
|
|
|
- Table(of: Binding<URLHint>.self) {
|
|
|
|
|
- TableColumn("Tag Prefix") { hint in
|
|
|
|
|
- TextField("", text: hint.prefix)
|
|
|
|
|
- .onSubmit(addHint)
|
|
|
|
|
- }
|
|
|
|
|
- TableColumn("URL Expansion") { hint in
|
|
|
|
|
- TextField("", text: hint.replacement)
|
|
|
|
|
- .onSubmit(addHint)
|
|
|
|
|
- }
|
|
|
|
|
- TableColumn("") { hint in
|
|
|
|
|
- if hint.id != active.id {
|
|
|
|
|
- Button() {
|
|
|
|
|
- allHints.removeAll(where: { $0.id == hint.id })
|
|
|
|
|
- } label: {
|
|
|
|
|
- Label("", systemImage: "trash")
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }.width(max: 20)
|
|
|
|
|
- } rows: {
|
|
|
|
|
- ForEach($allHints) { hint in
|
|
|
|
|
- TableRow(hint)
|
|
|
|
|
- }
|
|
|
|
|
- TableRow($active)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ URLHintMappingView()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- private func addHint() {
|
|
|
|
|
- if active.valid {
|
|
|
|
|
- allHints.append(active)
|
|
|
|
|
- active = URLHint()
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#Preview {
|
|
#Preview {
|