twigs-ios/Twigs/TabbedBudgetView.swift

104 lines
3.2 KiB
Swift
Raw Normal View History

//
// TabbedBudgetView.swift
// Budget
//
// Created by Billy Brawner on 9/29/19.
// Copyright © 2019 William Brawner. All rights reserved.
//
import SwiftUI
2022-01-03 17:56:43 +00:00
import TwigsCore
struct TabbedBudgetView: View {
@EnvironmentObject var dataStore: DataStore
2022-01-07 00:24:50 +00:00
@EnvironmentObject var apiService: TwigsApiService
@AppStorage("budget_tab") var tabSelection: Int = 0
2021-11-03 17:17:18 +00:00
@ViewBuilder
var mainView: some View {
if case let .success(budget) = dataStore.budget {
2021-11-03 17:17:18 +00:00
TabView(selection: $tabSelection) {
NavigationView {
BudgetDetailsView(budget: budget)
.navigationBarTitle("overview")
2021-12-08 03:21:46 +00:00
.navigationBarItems(leading: HStack {
Button("budgets", action: {
self.dataStore.showBudgetSelection = true
2021-12-08 03:21:46 +00:00
}).padding()
})
2021-11-03 17:17:18 +00:00
}
2021-10-10 02:27:54 +00:00
.tabItem {
Image(systemName: "chart.line.uptrend.xyaxis.circle.fill")
2021-10-22 03:08:06 +00:00
Text("overview")
2021-10-10 02:27:54 +00:00
}
.tag(0)
.keyboardShortcut("1")
2021-11-03 17:17:18 +00:00
NavigationView {
TransactionListView<EmptyView>()
2021-11-03 17:17:18 +00:00
.navigationBarTitle("transactions")
}
.tabItem {
Image(systemName: "dollarsign.circle.fill")
Text("transactions")
}
.tag(1)
.keyboardShortcut("2")
2021-11-03 17:17:18 +00:00
NavigationView {
CategoryListView(budget)
.navigationBarTitle("categories")
}
2021-11-03 17:17:18 +00:00
.tabItem {
Image(systemName: "chart.pie.fill")
Text("categories")
}
2021-11-03 17:17:18 +00:00
.tag(2)
.keyboardShortcut("3")
NavigationView {
RecurringTransactionsListView()
.navigationBarTitle("recurring_transactions")
2021-11-03 17:17:18 +00:00
}
.tabItem {
Image(systemName: "arrow.triangle.2.circlepath.circle.fill")
Text("recurring")
2021-11-03 17:17:18 +00:00
}
.tag(3)
.keyboardShortcut("4")
}
2021-11-03 17:17:18 +00:00
} else {
ActivityIndicator(isAnimating: .constant(true), style: .large)
2021-11-03 17:17:18 +00:00
}
}
2021-11-03 17:17:18 +00:00
var body: some View {
mainView.sheet(isPresented: $dataStore.showLogin,
2021-11-03 17:17:18 +00:00
onDismiss: {
2022-01-03 17:56:43 +00:00
Task {
await self.dataStore.getBudgets()
2022-01-03 17:56:43 +00:00
}
2021-11-03 17:17:18 +00:00
},
content: {
LoginView()
.environmentObject(dataStore)
.onDisappear {
2022-01-03 17:56:43 +00:00
Task {
await self.dataStore.getBudgets()
2022-01-03 17:56:43 +00:00
}
}
}).sheet(isPresented: $dataStore.showBudgetSelection,
2021-11-03 17:17:18 +00:00
content: {
2021-12-08 03:21:46 +00:00
List {
BudgetListsView().environmentObject(dataStore)
2021-12-08 03:21:46 +00:00
}
2021-11-03 17:17:18 +00:00
})
.interactiveDismissDisabled(true)
}
}
2021-11-03 17:17:18 +00:00
//
//struct TabbedBudgetView_Previews: PreviewProvider {
// static var previews: some View {
// TabbedBudgetView()
// }
//}