swiftui-multiplatform/Shared/WriteFreely_MultiPlatformApp.swift

54 lines
1.5 KiB
Swift
Raw Normal View History

2020-07-22 13:57:10 +00:00
import SwiftUI
@main
struct WriteFreely_MultiPlatformApp: App {
@StateObject private var preferences = PreferencesModel()
@StateObject private var account = AccountModel()
#if os(macOS)
@State private var selectedTab = 0
#endif
#if DEBUG
@StateObject private var store = testPostStore
#else
@StateObject private var store = PostStore()
#endif
2020-07-22 13:57:10 +00:00
var body: some Scene {
WindowGroup {
ContentView(postStore: store, preferences: preferences, account: account)
.preferredColorScheme(preferences.preferredColorScheme)
2020-07-22 13:57:10 +00:00
}
#if os(macOS)
Settings {
TabView(selection: $selectedTab) {
Form {
Section(header: Text("Login Details")) {
AccountView(account: account)
}
}
.tabItem {
Image(systemName: "person.crop.circle")
Text("Account")
}
.tag(0)
VStack {
PreferencesView(preferences: preferences)
Spacer()
}
.tabItem {
Image(systemName: "gear")
Text("Preferences")
}
.tag(1)
}
.frame(minWidth: 300, maxWidth: 300, minHeight: 200, maxHeight: 200)
.padding()
.preferredColorScheme(preferences.preferredColorScheme)
}
#endif
2020-07-22 13:57:10 +00:00
}
}