metatext/Shared/Views/RootView.swift

41 lines
1.1 KiB
Swift
Raw Normal View History

2020-08-03 15:20:51 +00:00
// Copyright © 2020 Metabolist. All rights reserved.
import SwiftUI
struct RootView: View {
@StateObject var viewModel: RootViewModel
var body: some View {
if
let identityID = viewModel.identityID,
let mainNavigationViewModel = viewModel.mainNavigationViewModel(identityID: identityID) {
Self.mainNavigation(viewModel: mainNavigationViewModel)
} else {
addIdentity
}
}
}
private extension RootView {
private static func mainNavigation(viewModel: MainNavigationViewModel) -> some View {
#if os(macOS)
2020-08-04 00:48:22 +00:00
return SidebarNavigation(viewModel: viewModel)
2020-08-03 15:20:51 +00:00
.frame(minWidth: 900, maxWidth: .infinity, minHeight: 500, maxHeight: .infinity)
#else
2020-08-04 00:48:22 +00:00
return TabNavigation(viewModel: viewModel)
2020-08-03 15:20:51 +00:00
#endif
}
private var addIdentity: some View {
AddIdentityView(viewModel: viewModel.addIdentityViewModel())
}
}
#if DEBUG
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
RootView(viewModel: .development)
}
}
#endif