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
|
|
|
|
|
|
|
|
struct TabbedBudgetView: View {
|
2021-10-10 03:23:49 +00:00
|
|
|
@EnvironmentObject var budgetDataStore: BudgetsDataStore
|
2021-10-10 00:32:57 +00:00
|
|
|
@EnvironmentObject var categoryDataStore: CategoryDataStore
|
2021-10-06 01:26:54 +00:00
|
|
|
let budget: Budget
|
2019-10-11 02:30:43 +00:00
|
|
|
@State var isAddingTransaction = false
|
2021-10-10 00:32:57 +00:00
|
|
|
@State var categoryRequestId: String = ""
|
2019-09-30 03:49:03 +00:00
|
|
|
|
2019-09-30 03:02:10 +00:00
|
|
|
var body: some View {
|
2019-10-01 03:31:22 +00:00
|
|
|
TabView {
|
2021-10-10 02:27:54 +00:00
|
|
|
BudgetDetailsView(budget: self.budget)
|
|
|
|
.tabItem {
|
2021-10-10 03:23:49 +00:00
|
|
|
Image(systemName: "chart.line.uptrend.xyaxis.circle.fill")
|
2021-10-10 02:27:54 +00:00
|
|
|
Text("Overview")
|
|
|
|
}
|
|
|
|
.tag(0)
|
|
|
|
.onAppear {
|
|
|
|
if categoryRequestId == "" {
|
|
|
|
categoryRequestId = categoryDataStore.getCategories(budgetId: budget.id, archived: false)
|
|
|
|
}
|
|
|
|
}
|
2021-10-06 01:26:54 +00:00
|
|
|
TransactionListView(self.budget)
|
2021-10-10 02:03:01 +00:00
|
|
|
.sheet(isPresented: $isAddingTransaction,
|
|
|
|
onDismiss: {
|
|
|
|
isAddingTransaction = false
|
|
|
|
},
|
|
|
|
content: {
|
|
|
|
AddTransactionView(showSheet: self.$isAddingTransaction, budgetId: self.budget.id)
|
2021-09-11 15:01:22 +00:00
|
|
|
.navigationBarTitle("add_transaction")
|
|
|
|
})
|
|
|
|
.tabItem {
|
|
|
|
Image(systemName: "dollarsign.circle.fill")
|
|
|
|
Text("transactions")
|
|
|
|
}
|
2019-10-11 02:30:43 +00:00
|
|
|
|
2021-10-10 00:32:57 +00:00
|
|
|
// TODO: Figure out why this is breaking when requestId is set from inside CategoryListView
|
|
|
|
CategoryListView(self.budget, requestId: categoryRequestId).tabItem {
|
2019-10-01 03:31:22 +00:00
|
|
|
Image(systemName: "chart.pie.fill")
|
2021-09-11 15:01:22 +00:00
|
|
|
Text("categories")
|
|
|
|
}
|
2019-10-11 02:30:43 +00:00
|
|
|
|
2021-10-06 01:26:54 +00:00
|
|
|
ProfileView().tabItem {
|
2019-10-01 03:31:22 +00:00
|
|
|
Image(systemName: "person.circle.fill")
|
|
|
|
Text("profile")
|
2019-09-30 03:49:03 +00:00
|
|
|
}
|
2021-09-11 15:01:22 +00:00
|
|
|
}.navigationBarItems(
|
|
|
|
trailing: HStack {
|
|
|
|
NavigationLink(destination: EmptyView()) {
|
|
|
|
Image(systemName: "magnifyingglass")
|
|
|
|
}
|
|
|
|
Button(action: {
|
|
|
|
self.isAddingTransaction = true
|
|
|
|
}) {
|
|
|
|
Image(systemName: "plus")
|
|
|
|
.padding()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
2019-09-30 03:02:10 +00:00
|
|
|
}
|
|
|
|
|
2021-10-06 01:26:54 +00:00
|
|
|
init (_ budget: Budget) {
|
2021-09-11 15:01:22 +00:00
|
|
|
self.budget = budget
|
2019-09-30 03:02:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
//struct TabbedBudgetView_Previews: PreviewProvider {
|
|
|
|
// static var previews: some View {
|
|
|
|
// TabbedBudgetView()
|
|
|
|
// }
|
|
|
|
//}
|