1
0
mirror of https://github.com/metabolist/metatext synced 2024-12-26 17:52:26 +01:00
metatext-app-ios-iphone-ipad/Shared/Views/ContentView.swift

47 lines
1.3 KiB
Swift
Raw Normal View History

// Copyright © 2020 Metabolist. All rights reserved.
import SwiftUI
struct ContentView: View {
@EnvironmentObject var sceneViewModel: SceneViewModel
@Environment(\.scenePhase) private var scenePhase
var body: some View {
2020-07-31 23:40:57 +02:00
if let identity = sceneViewModel.identity {
mainNavigation(identity: identity)
.onChange(of: scenePhase) {
if case .active = $0 {
sceneViewModel.refreshIdentity()
}
}
.alertItem($sceneViewModel.alertItem)
} else {
addIdentity
}
}
}
private extension ContentView {
2020-07-31 23:40:57 +02:00
private func mainNavigation(identity: Identity) -> some View {
#if os(macOS)
2020-08-03 00:23:01 +02:00
return SidebarNavigation(identity: identity)
.frame(minWidth: 900, maxWidth: .infinity, minHeight: 500, maxHeight: .infinity)
#else
2020-07-31 23:40:57 +02:00
return TabNavigation(identity: identity)
#endif
}
private var addIdentity: some View {
AddIdentityView(viewModel: sceneViewModel.addIdentityViewModel())
}
}
2020-07-31 23:40:57 +02:00
#if DEBUG
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
.environmentObject(SceneViewModel.development)
}
}
#endif