2021-03-03 16:17:54 -08:00
|
|
|
//
|
|
|
|
|
// SettingsView.swift
|
|
|
|
|
// App
|
|
|
|
|
//
|
|
|
|
|
// Created by James Magahern on 3/3/21.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
|
|
struct SettingsCategoryCell: View {
|
|
|
|
|
@State var title: String = ""
|
|
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
|
HStack {
|
|
|
|
|
Text(title)
|
|
|
|
|
.bold()
|
|
|
|
|
.frame(height: 34.0)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-29 18:09:42 -07:00
|
|
|
struct AmberSettingsView: View {
|
2021-03-03 16:17:54 -08:00
|
|
|
@Environment(\.presentationMode)
|
|
|
|
|
@Binding private var presentationMode
|
|
|
|
|
|
2025-09-28 21:10:31 -07:00
|
|
|
@State private var defaultSearchEngineName = Settings.shared.defaultSearchEngineName {
|
|
|
|
|
didSet { Settings.shared.defaultSearchEngineName = defaultSearchEngineName }
|
2021-03-09 12:20:51 -08:00
|
|
|
}
|
|
|
|
|
|
2021-03-03 16:17:54 -08:00
|
|
|
var body: some View {
|
|
|
|
|
NavigationView {
|
|
|
|
|
List {
|
|
|
|
|
Section(header: Text("Redirect Rules"), content: {
|
|
|
|
|
Text("To Do")
|
|
|
|
|
})
|
2021-03-09 12:20:51 -08:00
|
|
|
|
|
|
|
|
Section(header: Text("Search Provider"), content: {
|
2025-09-28 21:10:31 -07:00
|
|
|
ForEach(Array(Settings.shared.searchEngines.keys).sorted(), id: \.self, content: { name in
|
|
|
|
|
Button(action: { defaultSearchEngineName = name }, label: {
|
2021-03-09 12:20:51 -08:00
|
|
|
HStack {
|
2025-09-28 21:10:31 -07:00
|
|
|
Text(name)
|
2021-03-09 12:20:51 -08:00
|
|
|
Spacer()
|
2025-09-28 21:10:31 -07:00
|
|
|
if defaultSearchEngineName == name {
|
2021-03-09 12:20:51 -08:00
|
|
|
Image(systemName: "checkmark")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}).buttonStyle(PlainButtonStyle())
|
|
|
|
|
})
|
|
|
|
|
})
|
2021-03-03 16:17:54 -08:00
|
|
|
}
|
|
|
|
|
.listStyle(InsetGroupedListStyle())
|
|
|
|
|
.navigationBarTitle("Settings", displayMode: .inline)
|
|
|
|
|
.toolbar(content: {
|
|
|
|
|
#if !targetEnvironment(macCatalyst)
|
|
|
|
|
Button("Done", action: { presentationMode.dismiss() })
|
|
|
|
|
#endif
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
.navigationViewStyle(StackNavigationViewStyle())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct SettingsView_Previews: PreviewProvider {
|
|
|
|
|
static var previews: some View {
|
2021-06-29 18:09:42 -07:00
|
|
|
AmberSettingsView()
|
2021-03-03 16:17:54 -08:00
|
|
|
}
|
|
|
|
|
}
|