Skip to content

Commit

Permalink
Using the new observation framework
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelacaron committed Oct 9, 2023
1 parent ff08495 commit 06263f3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions Basic-Car-Maintenance/Shared/BasicCarMaintenanceApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import SwiftUI

@main
struct BasicCarMaintenanceApp: App {
private let actionService = ActionService.shared
@State private var actionService = ActionService.shared
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate

var body: some Scene {
WindowGroup {
MainTabView()
.environmentObject(actionService)
.environment(actionService)
}
}
}
Expand All @@ -25,7 +25,8 @@ class AppDelegate: NSObject, UIApplicationDelegate {
private let actionService = ActionService.shared

func application(
_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
FirebaseApp.configure()
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import SwiftUI

struct DashboardView: View {
@EnvironmentObject var actionService: ActionService
@Environment(ActionService.self) var actionService
@Environment(\.scenePhase) var scenePhase
@State private var isShowingAddView = false
@Bindable private var viewModel: DashboardViewModel
Expand Down
3 changes: 2 additions & 1 deletion Basic-Car-Maintenance/Shared/MainTabView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ enum TabSelection: Int {
case settings = 1
}

@MainActor
struct MainTabView: View {
@EnvironmentObject var actionService: ActionService
@Environment(ActionService.self) var actionService
@Environment(\.scenePhase) var scenePhase
@State var authenticationViewModel = AuthenticationViewModel()
@State var selectedTab: TabSelection = .dashboard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ struct SettingsView: View {
@State private var viewModel: SettingsViewModel
@State private var isShowingAddVehicle = false
@State private var showDeleteVehicleError = false
@EnvironmentObject var actionService: ActionService
@Environment(ActionService.self) var actionService
@Environment(\.scenePhase) var scenePhase
@State var errorDetails: Error?
@State private var errorDetails: Error?

init(authenticationViewModel: AuthenticationViewModel) {
let settingsViewModel = SettingsViewModel(authenticationViewModel: authenticationViewModel)
Expand Down

0 comments on commit 06263f3

Please sign in to comment.