diff --git a/Twigs/SidebarBudgetView.swift b/Twigs/SidebarBudgetView.swift index 8133cec..ecdccb0 100644 --- a/Twigs/SidebarBudgetView.swift +++ b/Twigs/SidebarBudgetView.swift @@ -75,12 +75,6 @@ struct SidebarBudgetView: View { } } }) - .sheet(isPresented: $budgetDataStore.showBudgetSelection, - content: { - List { - BudgetListsView().environmentObject(budgetDataStore) - } - }) .interactiveDismissDisabled(true) } } diff --git a/Twigs/TabbedBudgetView.swift b/Twigs/TabbedBudgetView.swift index 029faf2..a89cc7a 100644 --- a/Twigs/TabbedBudgetView.swift +++ b/Twigs/TabbedBudgetView.swift @@ -12,7 +12,7 @@ import TwigsCore struct TabbedBudgetView: View { @EnvironmentObject var authenticationDataStore: AuthenticationDataStore @EnvironmentObject var budgetDataStore: BudgetsDataStore - @EnvironmentObject var apiService: TwigsInMemoryCacheService + @EnvironmentObject var apiService: TwigsApiService @State var tabSelection: Int = 0 @ViewBuilder diff --git a/Twigs/Transaction/TransactionDataStore.swift b/Twigs/Transaction/TransactionDataStore.swift index 81b7b26..c6c42cb 100644 --- a/Twigs/Transaction/TransactionDataStore.swift +++ b/Twigs/Transaction/TransactionDataStore.swift @@ -11,6 +11,7 @@ import Combine import Collections import TwigsCore +@MainActor class TransactionDataStore: ObservableObject { @Published var transactions: AsyncData> = .empty @Published var transaction: AsyncData = .empty { diff --git a/Twigs/Transaction/TransactionFormSheet.swift b/Twigs/Transaction/TransactionFormSheet.swift index dbc5672..c169e8d 100644 --- a/Twigs/Transaction/TransactionFormSheet.swift +++ b/Twigs/Transaction/TransactionFormSheet.swift @@ -56,7 +56,7 @@ struct TransactionFormSheet: View { } else { EmptyView() } - } + }.environmentObject(transactionForm) } } } diff --git a/Twigs/Views/MainView.swift b/Twigs/Views/MainView.swift index d6feffc..d04a5e2 100644 --- a/Twigs/Views/MainView.swift +++ b/Twigs/Views/MainView.swift @@ -11,11 +11,21 @@ import TwigsCore struct MainView: View { @StateObject var authenticationDataStore: AuthenticationDataStore + @StateObject var budgetDataStore: BudgetsDataStore + @StateObject var transactionList: TransactionDataStore + @StateObject var categoryList: CategoryListDataStore + @StateObject var userDataStore: UserDataStore + @StateObject var recurringTransactionList: RecurringTransactionDataStore let apiService: TwigsApiService init(_ apiService: TwigsApiService, baseUrl: Binding, token: Binding, userId: Binding) { self.apiService = apiService self._authenticationDataStore = StateObject(wrappedValue: AuthenticationDataStore(apiService, baseUrl: baseUrl, token: token, userId: userId)) + self._budgetDataStore = StateObject(wrappedValue: BudgetsDataStore(budgetRepository: apiService, categoryRepository: apiService, transactionRepository: apiService)) + self._categoryList = StateObject(wrappedValue: CategoryListDataStore(apiService)) + self._userDataStore = StateObject(wrappedValue: UserDataStore(apiService)) + self._transactionList = StateObject(wrappedValue: TransactionDataStore(apiService)) + self._recurringTransactionList = StateObject(wrappedValue: RecurringTransactionDataStore(apiService)) } @ViewBuilder @@ -29,11 +39,11 @@ struct MainView: View { var body: some View { mainView - .environmentObject(TransactionDataStore(apiService)) - .environmentObject(CategoryListDataStore(apiService)) - .environmentObject(BudgetsDataStore(budgetRepository: apiService, categoryRepository: apiService, transactionRepository: apiService)) - .environmentObject(UserDataStore(apiService)) - .environmentObject(RecurringTransactionDataStore(apiService)) + .environmentObject(transactionList) + .environmentObject(categoryList) + .environmentObject(budgetDataStore) + .environmentObject(userDataStore) + .environmentObject(recurringTransactionList) .environmentObject(authenticationDataStore) .onAppear { Task {