|
@@ -8,7 +8,7 @@
|
|
|
import SwiftUI
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct SettingsView: View {
|
|
struct SettingsView: View {
|
|
|
- @EnvironmentObject var allHints: URLHintArray
|
|
|
|
|
|
|
+ @AppStorage(UserDefaultsKeys.UrlHints) var allHints = URLHintArray()
|
|
|
@State var active = URLHint()
|
|
@State var active = URLHint()
|
|
|
|
|
|
|
|
var body: some View {
|
|
var body: some View {
|
|
@@ -27,16 +27,14 @@ struct SettingsView: View {
|
|
|
TableColumn("") { hint in
|
|
TableColumn("") { hint in
|
|
|
if hint.id != active.id {
|
|
if hint.id != active.id {
|
|
|
Button() {
|
|
Button() {
|
|
|
- allHints.array.removeAll(where: { $0.id == hint.id })
|
|
|
|
|
- UserDefaults.standard.set(allHints.serial,
|
|
|
|
|
- forKey: UserDefaultsKeys.UrlHints)
|
|
|
|
|
|
|
+ allHints.removeAll(where: { $0.id == hint.id })
|
|
|
} label: {
|
|
} label: {
|
|
|
Label("", systemImage: "trash")
|
|
Label("", systemImage: "trash")
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}.width(max: 20)
|
|
}.width(max: 20)
|
|
|
} rows: {
|
|
} rows: {
|
|
|
- ForEach($allHints.array) { hint in
|
|
|
|
|
|
|
+ ForEach($allHints) { hint in
|
|
|
TableRow(hint)
|
|
TableRow(hint)
|
|
|
}
|
|
}
|
|
|
TableRow($active)
|
|
TableRow($active)
|
|
@@ -47,9 +45,7 @@ struct SettingsView: View {
|
|
|
|
|
|
|
|
private func addHint() {
|
|
private func addHint() {
|
|
|
if active.valid {
|
|
if active.valid {
|
|
|
- allHints.array.append(active)
|
|
|
|
|
- UserDefaults.standard.set(allHints.serial,
|
|
|
|
|
- forKey: UserDefaultsKeys.UrlHints)
|
|
|
|
|
|
|
+ allHints.append(active)
|
|
|
active = URLHint()
|
|
active = URLHint()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -57,5 +53,4 @@ struct SettingsView: View {
|
|
|
|
|
|
|
|
#Preview {
|
|
#Preview {
|
|
|
SettingsView()
|
|
SettingsView()
|
|
|
- .environmentObject(URLHintArray())
|
|
|
|
|
}
|
|
}
|