twigs-ios/BudgetApp/ContentView.swift

48 lines
1.1 KiB
Swift
Raw Normal View History

2019-09-26 00:00:59 +00:00
//
// ContentView.swift
// Budget
//
// 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 {
@ObservedObject var authenticationDataStore: AuthenticationDataStore
2019-09-26 00:00:59 +00:00
var body: some View {
stateContent
}
var stateContent: AnyView {
if showLogin() {
return AnyView(LoginView(authenticationDataStore))
} else {
return AnyView(TabbedBudgetView(authenticationDataStore, dataStoreProvider: dataStoreProvider))
}
2019-09-26 00:00:59 +00:00
}
func showLogin() -> Bool {
switch authenticationDataStore.currentUser {
case .failure:
return true
default:
return false
}
}
private let dataStoreProvider: DataStoreProvider
init (_ dataStoreProvider: DataStoreProvider) {
self.dataStoreProvider = dataStoreProvider
self.authenticationDataStore = dataStoreProvider.authenticationDataStore()
}
2019-09-26 00:00:59 +00:00
}
//struct ContentView_Previews: PreviewProvider {
// static var previews: some View {
// ContentView()
// }
//}