2020-07-22 13:57:10 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
@main
|
|
|
|
struct WriteFreely_MultiPlatformApp: App {
|
2020-08-11 18:32:45 +00:00
|
|
|
@StateObject private var preferences = PreferencesModel()
|
2020-08-11 20:27:14 +00:00
|
|
|
@StateObject private var account = AccountModel()
|
2020-08-12 14:34:12 +00:00
|
|
|
|
|
|
|
#if os(macOS)
|
2020-08-12 14:21:15 +00:00
|
|
|
@State private var selectedTab = 0
|
2020-08-12 14:34:12 +00:00
|
|
|
#endif
|
2020-08-11 18:32:45 +00:00
|
|
|
|
2020-08-03 16:16:41 +00:00
|
|
|
#if DEBUG
|
|
|
|
@StateObject private var store = testPostStore
|
|
|
|
#else
|
2020-07-25 11:02:11 +00:00
|
|
|
@StateObject private var store = PostStore()
|
2020-08-03 16:16:41 +00:00
|
|
|
#endif
|
2020-07-31 17:40:40 +00:00
|
|
|
|
2020-07-22 13:57:10 +00:00
|
|
|
var body: some Scene {
|
|
|
|
WindowGroup {
|
2020-08-11 20:27:14 +00:00
|
|
|
ContentView(postStore: store, preferences: preferences, account: account)
|
2020-08-11 18:44:34 +00:00
|
|
|
.preferredColorScheme(preferences.preferredColorScheme)
|
2020-07-22 13:57:10 +00:00
|
|
|
}
|
2020-08-07 20:30:09 +00:00
|
|
|
|
|
|
|
#if os(macOS)
|
|
|
|
Settings {
|
2020-08-12 14:21:15 +00:00
|
|
|
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)
|
2020-08-07 20:30:09 +00:00
|
|
|
}
|
|
|
|
#endif
|
2020-07-22 13:57:10 +00:00
|
|
|
}
|
|
|
|
}
|