metatext/Views/SwiftUI/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
2020-09-01 07:33:49 +00:00
import ViewModels
2020-08-03 15:20:51 +00:00
struct RootView: View {
@StateObject var viewModel: RootViewModel
var body: some View {
2020-09-09 22:48:56 +00:00
if let navigationViewModel = viewModel.navigationViewModel {
2021-01-20 23:33:53 +00:00
MainNavigationView { navigationViewModel }
2021-01-26 00:06:35 +00:00
.id(navigationViewModel.identityContext.identity.id)
2020-08-07 01:41:59 +00:00
.environmentObject(viewModel)
.transition(.opacity)
2021-01-20 23:33:53 +00:00
.edgesIgnoringSafeArea(.all)
2020-08-07 01:41:59 +00:00
} else {
2020-09-11 09:55:06 +00:00
NavigationView {
2021-01-27 20:31:32 +00:00
AddIdentityView(
viewModelClosure: { viewModel.addIdentityViewModel() },
displayWelcome: true)
2020-09-11 09:55:06 +00:00
.navigationBarTitleDisplayMode(.inline)
.navigationBarHidden(true)
}
.environmentObject(viewModel)
2020-09-12 07:36:59 +00:00
.navigationViewStyle(StackNavigationViewStyle())
2020-09-11 09:55:06 +00:00
.transition(.opacity)
2020-08-03 15:20:51 +00:00
}
}
}
#if DEBUG
2020-09-08 02:12:38 +00:00
import Combine
2020-09-01 07:33:49 +00:00
import PreviewViewModels
2020-08-03 15:20:51 +00:00
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
2020-09-08 02:12:38 +00:00
RootView(viewModel: .preview)
2020-08-03 15:20:51 +00:00
}
}
#endif