mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-29 19:41:01 +00:00
46 lines
1.3 KiB
Swift
46 lines
1.3 KiB
Swift
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
import SwiftUI
|
|
|
|
#if os(macOS)
|
|
typealias MainNavigationViewModel = SidebarNavigationViewModel
|
|
#else
|
|
typealias MainNavigationViewModel = TabNavigationViewModel
|
|
#endif
|
|
|
|
struct RootView: View {
|
|
@StateObject var viewModel: RootViewModel
|
|
|
|
var body: some View {
|
|
if let mainNavigationViewModel = viewModel.mainNavigationViewModel {
|
|
Self.mainNavigation(mainNavigationViewModel: mainNavigationViewModel)
|
|
.id(UUID())
|
|
.environmentObject(viewModel)
|
|
.transition(.opacity)
|
|
} else {
|
|
AddIdentityView(viewModel: viewModel.addIdentityViewModel())
|
|
.environmentObject(viewModel)
|
|
.transition(.opacity)
|
|
}
|
|
}
|
|
}
|
|
|
|
private extension RootView {
|
|
@ViewBuilder
|
|
private static func mainNavigation(mainNavigationViewModel: MainNavigationViewModel) -> some View {
|
|
#if os(macOS)
|
|
SidebarNavigationView(viewModel: mainNavigationViewModel)
|
|
.frame(minWidth: 900, maxWidth: .infinity, minHeight: 500, maxHeight: .infinity)
|
|
#else
|
|
TabNavigationView(viewModel: mainNavigationViewModel)
|
|
#endif
|
|
}
|
|
}
|
|
|
|
#if DEBUG
|
|
struct ContentView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
RootView(viewModel: .development)
|
|
}
|
|
}
|
|
#endif
|