2019-09-30 03:02:10 +00:00
|
|
|
//
|
|
|
|
// 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
|
2019-09-30 03:02:10 +00:00
|
|
|
|
|
|
|
struct TabbedBudgetView: View {
|
2022-05-18 01:04:27 +00:00
|
|
|
@EnvironmentObject var dataStore: DataStore
|
2022-01-07 00:24:50 +00:00
|
|
|
@EnvironmentObject var apiService: TwigsApiService
|
2022-04-16 02:20:31 +00:00
|
|
|
@AppStorage("budget_tab") var tabSelection: Int = 0
|
2019-09-30 03:49:03 +00:00
|
|
|
|
2021-11-03 17:17:18 +00:00
|
|
|
@ViewBuilder
|
|
|
|
var mainView: some View {
|
2022-05-18 01:04:27 +00:00
|
|
|
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: {
|
2022-05-18 01:04:27 +00:00
|
|
|
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 {
|
2021-10-10 03:23:49 +00:00
|
|
|
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)
|
2021-10-18 12:34:17 +00:00
|
|
|
.keyboardShortcut("1")
|
2021-11-03 17:17:18 +00:00
|
|
|
NavigationView {
|
2022-05-18 01:04:27 +00:00
|
|
|
TransactionListView<EmptyView>()
|
2021-11-03 17:17:18 +00:00
|
|
|
.navigationBarTitle("transactions")
|
|
|
|
}
|
2021-09-11 15:01:22 +00:00
|
|
|
.tabItem {
|
|
|
|
Image(systemName: "dollarsign.circle.fill")
|
|
|
|
Text("transactions")
|
|
|
|
}
|
2021-10-13 12:32:58 +00:00
|
|
|
.tag(1)
|
2021-10-18 12:34:17 +00:00
|
|
|
.keyboardShortcut("2")
|
2021-11-03 17:17:18 +00:00
|
|
|
NavigationView {
|
|
|
|
CategoryListView(budget)
|
|
|
|
.navigationBarTitle("categories")
|
2021-09-11 15:01:22 +00:00
|
|
|
}
|
2021-11-03 17:17:18 +00:00
|
|
|
.tabItem {
|
|
|
|
Image(systemName: "chart.pie.fill")
|
|
|
|
Text("categories")
|
2021-10-18 12:34:17 +00:00
|
|
|
}
|
2021-11-03 17:17:18 +00:00
|
|
|
.tag(2)
|
|
|
|
.keyboardShortcut("3")
|
|
|
|
NavigationView {
|
2022-05-18 01:04:27 +00:00
|
|
|
RecurringTransactionsListView()
|
2021-12-08 03:22:06 +00:00
|
|
|
.navigationBarTitle("recurring_transactions")
|
2021-11-03 17:17:18 +00:00
|
|
|
}
|
|
|
|
.tabItem {
|
2021-12-08 03:22:06 +00:00
|
|
|
Image(systemName: "arrow.triangle.2.circlepath.circle.fill")
|
|
|
|
Text("recurring")
|
2021-11-03 17:17:18 +00:00
|
|
|
}
|
|
|
|
.tag(3)
|
|
|
|
.keyboardShortcut("4")
|
2022-01-05 02:51:38 +00:00
|
|
|
}
|
2021-11-03 17:17:18 +00:00
|
|
|
} else {
|
2021-12-01 03:03:46 +00:00
|
|
|
ActivityIndicator(isAnimating: .constant(true), style: .large)
|
2021-11-03 17:17:18 +00:00
|
|
|
}
|
2019-09-30 03:02:10 +00:00
|
|
|
}
|
|
|
|
|
2021-11-03 17:17:18 +00:00
|
|
|
var body: some View {
|
2022-05-18 01:04:27 +00:00
|
|
|
mainView.sheet(isPresented: $dataStore.showLogin,
|
2021-11-03 17:17:18 +00:00
|
|
|
onDismiss: {
|
2022-01-03 17:56:43 +00:00
|
|
|
Task {
|
2022-05-18 01:04:27 +00:00
|
|
|
await self.dataStore.getBudgets()
|
2022-01-03 17:56:43 +00:00
|
|
|
}
|
2021-11-03 17:17:18 +00:00
|
|
|
},
|
|
|
|
content: {
|
|
|
|
LoginView()
|
2022-05-18 01:04:27 +00:00
|
|
|
.environmentObject(dataStore)
|
2021-12-01 03:03:46 +00:00
|
|
|
.onDisappear {
|
2022-01-03 17:56:43 +00:00
|
|
|
Task {
|
2022-05-18 01:04:27 +00:00
|
|
|
await self.dataStore.getBudgets()
|
2022-01-03 17:56:43 +00:00
|
|
|
}
|
2021-12-01 03:03:46 +00:00
|
|
|
}
|
2022-05-18 01:04:27 +00:00
|
|
|
}).sheet(isPresented: $dataStore.showBudgetSelection,
|
2021-11-03 17:17:18 +00:00
|
|
|
content: {
|
2021-12-08 03:21:46 +00:00
|
|
|
List {
|
2022-05-18 01:04:27 +00:00
|
|
|
BudgetListsView().environmentObject(dataStore)
|
2021-12-08 03:21:46 +00:00
|
|
|
}
|
2021-11-03 17:17:18 +00:00
|
|
|
})
|
2021-12-01 03:03:46 +00:00
|
|
|
.interactiveDismissDisabled(true)
|
2019-09-30 03:02:10 +00:00
|
|
|
}
|
|
|
|
}
|
2021-11-03 17:17:18 +00:00
|
|
|
|
|
|
|
|
2019-09-30 03:02:10 +00:00
|
|
|
//
|
|
|
|
//struct TabbedBudgetView_Previews: PreviewProvider {
|
|
|
|
// static var previews: some View {
|
|
|
|
// TabbedBudgetView()
|
|
|
|
// }
|
|
|
|
//}
|