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