Implement color scheme switching on Mac app

This commit is contained in:
Angelo Stavrow 2020-08-11 17:03:17 -04:00
parent 6dba087295
commit 264298160b
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE
2 changed files with 5 additions and 4 deletions

View File

@ -19,7 +19,7 @@ struct WriteFreely_MultiPlatformApp: App {
#if os(macOS)
Settings {
SettingsView(preferences: preferences)
SettingsView(preferences: preferences, account: account)
.frame(minWidth: 300, maxWidth: 300, minHeight: 200, maxHeight: 200)
.padding()
.preferredColorScheme(preferences.preferredColorScheme)

View File

@ -2,6 +2,7 @@ import SwiftUI
struct SettingsView: View {
@ObservedObject var preferences: PreferencesModel
@ObservedObject var account: AccountModel
@State var selectedView = 0
@ -9,7 +10,7 @@ struct SettingsView: View {
TabView(selection: $selectedView) {
Form {
Section(header: Text("Login Details")) {
AccountView()
AccountView(account: account)
}
}
.tabItem {
@ -32,12 +33,12 @@ struct SettingsView: View {
struct SettingsView_AccountTabPreviews: PreviewProvider {
static var previews: some View {
SettingsView(preferences: PreferencesModel(), selectedView: 0)
SettingsView(preferences: PreferencesModel(), account: AccountModel(), selectedView: 0)
}
}
struct SettingsView_PreferencesTabPreviews: PreviewProvider {
static var previews: some View {
SettingsView(preferences: PreferencesModel(), selectedView: 1)
SettingsView(preferences: PreferencesModel(), account: AccountModel(), selectedView: 1)
}
}