@@ -25,8 +25,10 @@ struct CorkApp: App
2525{
2626 @NSApplicationDelegateAdaptor ( AppDelegate . self) var appDelegate : AppDelegate
2727
28+ @InjectedObservable ( \. appState) var appState : AppState
2829 @InjectedObservable ( \. brewfileManager) var brewfileManager : BrewfileManager
2930
31+
3032 @State var brewPackagesTracker : BrewPackagesTracker = . init( )
3133 @State var tapTracker : TapTracker = . init( )
3234
@@ -88,7 +90,6 @@ struct CorkApp: App
8890 LicensingView ( )
8991 . interactiveDismissDisabled ( )
9092 } )
91- . environment ( appDelegate. appState)
9293 . environment ( brewPackagesTracker)
9394 . environment ( tapTracker)
9495 . environment ( cachedDownloadsTracker)
@@ -105,7 +106,7 @@ struct CorkApp: App
105106
106107 if areNotificationsEnabled
107108 {
108- await appDelegate . appState. setupNotifications ( )
109+ await appState. setupNotifications ( )
109110 }
110111 }
111112 . task
@@ -160,12 +161,12 @@ struct CorkApp: App
160161 { _, newValue in // Remove the badge from the app icon if the user turns off notifications, put it back when they turn them back on
161162 Task
162163 {
163- await appDelegate . appState. requestNotificationAuthorization ( )
164+ await appState. requestNotificationAuthorization ( )
164165
165- if appDelegate . appState. notificationEnabledInSystemSettings == true
166+ if appState. notificationEnabledInSystemSettings == true
166167 {
167- await appDelegate . appState. requestNotificationAuthorization ( )
168- if appDelegate . appState. notificationAuthStatus == . denied
168+ await appState. requestNotificationAuthorization ( )
169+ if appState. notificationAuthStatus == . denied
169170 {
170171 areNotificationsEnabled = false
171172 }
@@ -299,7 +300,7 @@ struct CorkApp: App
299300
300301 PackagePreview ( packageToPreview: convertedMinimalPackage)
301302 . navigationTitle ( packageToPreview? . name ?? " " )
302- . environment ( appDelegate . appState)
303+ . environment ( appState)
303304 . environment ( brewPackagesTracker)
304305 . environment ( outdatedPackagesTracker)
305306 }
@@ -318,7 +319,7 @@ struct CorkApp: App
318319 Settings
319320 {
320321 SettingsView ( )
321- . environment ( appDelegate . appState)
322+ . environment ( appState)
322323 }
323324 . windowResizability ( . contentSize)
324325
@@ -327,7 +328,7 @@ struct CorkApp: App
327328 MenuBarExtra ( " app-name " , systemImage: outdatedPackagesTracker. allDisplayableOutdatedPackages. isEmpty ? " mug " : " mug.fill " , isInserted: $showInMenuBar)
328329 {
329330 MenuBarItem ( )
330- . environment ( appDelegate . appState)
331+ . environment ( appState)
331332 . environment ( brewPackagesTracker)
332333 . environment ( tapTracker)
333334 . environment ( cachedDownloadsTracker)
@@ -417,11 +418,11 @@ struct CorkApp: App
417418 {
418419 Button
419420 {
420- appDelegate . appState. navigationManager. dismissScreen ( )
421+ appState. navigationManager. dismissScreen ( )
421422 } label: {
422423 Label ( " action.go-to-status-page.menu-bar " , systemImage: " house " )
423424 }
424- . disabled ( !appDelegate . appState. navigationManager. isAnyScreenOpened)
425+ . disabled ( !appState. navigationManager. isAnyScreenOpened)
425426 Divider ( )
426427 }
427428
@@ -432,7 +433,9 @@ struct CorkApp: App
432433 {
433434 do throws ( BrewfileManager . BrewfileDumpingError)
434435 {
435- brewfileContents = try await brewfileManager. exportBrewfile ( appState: appDelegate. appState)
436+ brewfileContents = try await brewfileManager. exportBrewfile (
437+ appState: appState
438+ )
436439
437440 isShowingBrewfileExporter = true
438441 }
@@ -443,13 +446,13 @@ struct CorkApp: App
443446 switch brewfileExportError
444447 {
445448 case . couldNotDetermineWorkingDirectory:
446- appDelegate . appState. showAlert ( errorToShow: . couldNotGetWorkingDirectory)
449+ appState. showAlert ( errorToShow: . couldNotGetWorkingDirectory)
447450
448451 case . errorWhileDumpingBrewfile( let error) :
449- appDelegate . appState. showAlert ( errorToShow: . couldNotDumpBrewfile( error: error) )
452+ appState. showAlert ( errorToShow: . couldNotDumpBrewfile( error: error) )
450453
451454 case . couldNotReadBrewfile:
452- appDelegate . appState. showAlert ( errorToShow: . couldNotReadBrewfile( error: brewfileExportError. localizedDescription) )
455+ appState. showAlert ( errorToShow: . couldNotReadBrewfile( error: brewfileExportError. localizedDescription) )
453456 }
454457 }
455458 } label: {
@@ -480,7 +483,7 @@ struct CorkApp: App
480483 {
481484 try await brewfileManager. importBrewfile (
482485 from: brewfileURL,
483- appState: appDelegate . appState,
486+ appState: appState,
484487 brewPackagesTracker: brewPackagesTracker,
485488 cachedDownloadsTracker: cachedDownloadsTracker
486489 )
@@ -489,9 +492,9 @@ struct CorkApp: App
489492 {
490493 AppConstants . shared. logger. error ( " \( brewfileImportingError. localizedDescription, privacy: . public) " )
491494
492- appDelegate . appState. showAlert ( errorToShow: . malformedBrewfile)
495+ appState. showAlert ( errorToShow: . malformedBrewfile)
493496
494- appDelegate . appState. showSheet ( ofType: . brewfileImport)
497+ appState. showSheet ( ofType: . brewfileImport)
495498 }
496499 }
497500 }
@@ -500,10 +503,10 @@ struct CorkApp: App
500503 switch error
501504 {
502505 case . couldNotGetBrewfileLocation:
503- appDelegate . appState. showAlert ( errorToShow: . couldNotGetBrewfileLocation)
506+ appState. showAlert ( errorToShow: . couldNotGetBrewfileLocation)
504507
505508 case . couldNotImportFile:
506- appDelegate . appState. showAlert ( errorToShow: . couldNotImportBrewfile)
509+ appState. showAlert ( errorToShow: . couldNotImportBrewfile)
507510 }
508511 }
509512 } label: {
@@ -519,7 +522,7 @@ struct CorkApp: App
519522
520523 Button
521524 {
522- appDelegate . appState. isSearchFieldFocused = true
525+ appState. isSearchFieldFocused = true
523526 } label: {
524527 Label ( " navigation.menu.search " , systemImage: " magnifyingglass " )
525528 }
@@ -529,20 +532,20 @@ struct CorkApp: App
529532 @ViewBuilder
530533 var packagesMenuBarSection : some View
531534 {
532- InstallPackageButton ( appState: appDelegate . appState)
535+ InstallPackageButton ( appState: appState)
533536 . keyboardShortcut ( " n " )
534537
535- AddTapButton ( appState: appDelegate . appState)
538+ AddTapButton ( appState: appState)
536539 . keyboardShortcut ( " n " , modifiers: [ . command, . option] )
537540
538541 Divider ( )
539542
540543 CheckForOutdatedPackagesButton ( )
541544 . keyboardShortcut ( " r " )
542- . environment ( appDelegate . appState)
545+ . environment ( appState)
543546 . environment ( outdatedPackagesTracker)
544547
545- UpgradePackagesButton ( appState: appDelegate . appState)
548+ UpgradePackagesButton ( appState: appState)
546549 . keyboardShortcut ( " r " , modifiers: [ . control, . command] )
547550 }
548551
@@ -561,10 +564,10 @@ struct CorkApp: App
561564 @ViewBuilder
562565 var maintenanceMenuBarSection : some View
563566 {
564- OpenMaintenanceSheetButton ( appState: appDelegate . appState, labelType: . performMaintenance)
567+ OpenMaintenanceSheetButton ( appState: appState, labelType: . performMaintenance)
565568 . keyboardShortcut ( " m " , modifiers: [ . command, . shift] )
566569
567- DeleteCachedDownloadsButton ( appState: appDelegate . appState)
570+ DeleteCachedDownloadsButton ( appState: appState)
568571 . keyboardShortcut ( " m " , modifiers: [ . command, . option] )
569572 . disabled ( cachedDownloadsTracker. cachedDownloadsSize == 0 )
570573 }
@@ -578,7 +581,7 @@ struct CorkApp: App
578581 {
579582 demoActivatedAt = nil
580583 hasValidatedEmail = false
581- appDelegate . appState. licensingState = . notBoughtOrHasNotActivatedDemo
584+ appState. licensingState = . notBoughtOrHasNotActivatedDemo
582585 hasFinishedLicensingWorkflow = false
583586 } label: {
584587 Text ( " debug.action.reset-license-state " )
@@ -588,7 +591,7 @@ struct CorkApp: App
588591 {
589592 demoActivatedAt = nil
590593 hasValidatedEmail = false
591- appDelegate . appState. licensingState = . demo
594+ appState. licensingState = . demo
592595 hasFinishedLicensingWorkflow = false
593596 } label: {
594597 Text ( " debug.action.activate-demo " )
@@ -742,15 +745,15 @@ struct CorkApp: App
742745 // MARK: - Licensing
743746 func handleLicensing( )
744747 {
745- print ( " Licensing state: \( appDelegate . appState. licensingState) " )
748+ print ( " Licensing state: \( appState. licensingState) " )
746749
747750 #if SELF_COMPILED
748751 AppConstants . shared. logger. debug ( " Will set licensing state to Self Compiled " )
749- appDelegate . appState. licensingState = . selfCompiled
752+ appState. licensingState = . selfCompiled
750753 #else
751754 if !hasValidatedEmail
752755 {
753- if appDelegate . appState. licensingState != . selfCompiled
756+ if appState. licensingState != . selfCompiled
754757 {
755758 if let demoActivatedAt
756759 {
0 commit comments