Create a two-tab settings view for macOS

This commit is contained in:
Angelo Stavrow 2020-08-07 16:30:09 -04:00
parent ea6e9491c2
commit fb7c188ca0
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE
2 changed files with 41 additions and 0 deletions

View File

@ -12,5 +12,12 @@ struct WriteFreely_MultiPlatformApp: App {
WindowGroup {
ContentView(postStore: store)
}
#if os(macOS)
Settings {
SettingsView()
.frame(minWidth: 300, maxWidth: 600, minHeight: 200, maxHeight: 800)
}
#endif
}
}

View File

@ -0,0 +1,34 @@
import SwiftUI
struct SettingsView: View {
@State var selectedView = 0
var body: some View {
TabView(selection: $selectedView) {
AccountLogin()
.tabItem {
Image(systemName: "person.crop.circle")
Text("Account")
}
.tag(0)
Preferences()
.tabItem {
Image(systemName: "gear")
Text("Preferences")
}
.tag(1)
}
}
}
struct SettingsView_AccountTabPreviews: PreviewProvider {
static var previews: some View {
SettingsView(selectedView: 0)
}
}
struct SettingsView_PreferencesTabPreviews: PreviewProvider {
static var previews: some View {
SettingsView(selectedView: 1)
}
}