Fix needing to tap twice on category tab
This commit is contained in:
parent
b3f62348cb
commit
85f462cd07
4 changed files with 17 additions and 10 deletions
|
@ -571,7 +571,7 @@
|
|||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.7;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
|
@ -628,7 +628,7 @@
|
|||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.7;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_NAME = "";
|
||||
|
|
|
@ -13,7 +13,7 @@ struct BudgetDetailsView: View {
|
|||
ScrollView {
|
||||
VStack {
|
||||
// ProgressView(value: .constant(50.0, maxValue: 100))
|
||||
CategoryListView(budget)
|
||||
// CategoryListView(budget)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import Combine
|
|||
|
||||
struct CategoryListView: View {
|
||||
@EnvironmentObject var categoryDataStore: CategoryDataStore
|
||||
@State var requestId: String = ""
|
||||
let requestId: String
|
||||
|
||||
@ViewBuilder
|
||||
var body: some View {
|
||||
|
@ -25,10 +25,6 @@ struct CategoryListView: View {
|
|||
case .failure(.loading):
|
||||
VStack {
|
||||
ActivityIndicator(isAnimating: .constant(true), style: .large)
|
||||
}.onAppear {
|
||||
if self.requestId == "" {
|
||||
self.requestId = categoryDataStore.getCategories(budgetId: budget.id)
|
||||
}
|
||||
}
|
||||
default:
|
||||
// TODO: Handle each network failure type
|
||||
|
@ -37,8 +33,9 @@ struct CategoryListView: View {
|
|||
}
|
||||
|
||||
private let budget: Budget
|
||||
init(_ budget: Budget) {
|
||||
init(_ budget: Budget, requestId: String) {
|
||||
self.budget = budget
|
||||
self.requestId = requestId
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,9 +9,11 @@
|
|||
import SwiftUI
|
||||
|
||||
struct TabbedBudgetView: View {
|
||||
@EnvironmentObject var categoryDataStore: CategoryDataStore
|
||||
let budget: Budget
|
||||
@State var isAddingTransaction = false
|
||||
@State var selectedTab: Int = 0
|
||||
@State var categoryRequestId: String = ""
|
||||
|
||||
var body: some View {
|
||||
TabView {
|
||||
|
@ -27,9 +29,13 @@ struct TabbedBudgetView: View {
|
|||
.tag(0)
|
||||
.onAppear {
|
||||
selectedTab = 0
|
||||
if categoryRequestId == "" {
|
||||
categoryRequestId = categoryDataStore.getCategories(budgetId: budget.id, archived: false)
|
||||
}
|
||||
}
|
||||
|
||||
CategoryListView(self.budget).tabItem {
|
||||
// TODO: Figure out why this is breaking when requestId is set from inside CategoryListView
|
||||
CategoryListView(self.budget, requestId: categoryRequestId).tabItem {
|
||||
Image(systemName: "chart.pie.fill")
|
||||
Text("categories")
|
||||
}
|
||||
|
@ -59,6 +65,10 @@ struct TabbedBudgetView: View {
|
|||
}
|
||||
}
|
||||
)
|
||||
.onAppear {
|
||||
// Prefetch categories to avoid tab switching bug
|
||||
_ = categoryDataStore.getCategories(budgetId: budget.id)
|
||||
}
|
||||
}
|
||||
|
||||
init (_ budget: Budget) {
|
||||
|
|
Loading…
Reference in a new issue