2019-09-26 00:00:59 +00:00
|
|
|
//
|
|
|
|
// ContentView.swift
|
|
|
|
// Budget
|
|
|
|
//
|
2019-09-30 03:02:10 +00:00
|
|
|
// Created by Billy Brawner on 9/29/19.
|
2019-09-26 00:00:59 +00:00
|
|
|
// Copyright © 2019 William Brawner. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct ContentView: View {
|
2019-10-13 01:22:09 +00:00
|
|
|
@ObservedObject var authenticationDataStore: AuthenticationDataStore
|
2019-09-26 05:26:29 +00:00
|
|
|
|
2019-09-26 00:00:59 +00:00
|
|
|
var body: some View {
|
2019-10-03 02:52:40 +00:00
|
|
|
stateContent
|
|
|
|
}
|
|
|
|
|
|
|
|
var stateContent: AnyView {
|
|
|
|
if showLogin() {
|
2019-10-13 01:22:09 +00:00
|
|
|
return AnyView(LoginView(authenticationDataStore))
|
2019-10-03 02:52:40 +00:00
|
|
|
} else {
|
2019-10-13 01:22:09 +00:00
|
|
|
return AnyView(TabbedBudgetView(authenticationDataStore, dataStoreProvider: dataStoreProvider))
|
2019-09-26 05:26:29 +00:00
|
|
|
}
|
2019-09-26 00:00:59 +00:00
|
|
|
}
|
2019-09-30 03:02:10 +00:00
|
|
|
|
2019-10-01 03:31:22 +00:00
|
|
|
func showLogin() -> Bool {
|
2019-10-13 01:22:09 +00:00
|
|
|
switch authenticationDataStore.currentUser {
|
2019-10-01 03:31:22 +00:00
|
|
|
case .failure:
|
|
|
|
return true
|
|
|
|
default:
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-02 04:57:27 +00:00
|
|
|
private let dataStoreProvider: DataStoreProvider
|
2019-09-30 03:02:10 +00:00
|
|
|
|
2019-10-02 04:57:27 +00:00
|
|
|
init (_ dataStoreProvider: DataStoreProvider) {
|
|
|
|
self.dataStoreProvider = dataStoreProvider
|
2019-10-13 01:22:09 +00:00
|
|
|
self.authenticationDataStore = dataStoreProvider.authenticationDataStore()
|
2019-09-30 03:02:10 +00:00
|
|
|
}
|
2019-09-26 00:00:59 +00:00
|
|
|
}
|
|
|
|
|
2019-09-26 05:26:29 +00:00
|
|
|
//struct ContentView_Previews: PreviewProvider {
|
|
|
|
// static var previews: some View {
|
2019-09-30 03:02:10 +00:00
|
|
|
// ContentView()
|
2019-09-26 05:26:29 +00:00
|
|
|
// }
|
|
|
|
//}
|