From 4520c533cee5adada9a51be342eb923b068262e1 Mon Sep 17 00:00:00 2001 From: "Daniel W. Steinbrook" Date: Thu, 5 Sep 2024 17:46:35 -0400 Subject: [PATCH] Replace static DestinationManager attributes with direct settings references --- .../Code/Behaviors/Default/BeaconCalloutGenerator.swift | 2 +- .../Behaviors/Default/Callouts/DestinationCallout.swift | 2 +- .../Code/Behaviors/Preview/PreviewGenerator.swift | 2 +- .../Code/Data/Destination Manager/DestinationManager.swift | 7 ++----- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/apps/ios/GuideDogs/Code/Behaviors/Default/BeaconCalloutGenerator.swift b/apps/ios/GuideDogs/Code/Behaviors/Default/BeaconCalloutGenerator.swift index 8f78b964..2d16cac9 100644 --- a/apps/ios/GuideDogs/Code/Behaviors/Default/BeaconCalloutGenerator.swift +++ b/apps/ios/GuideDogs/Code/Behaviors/Default/BeaconCalloutGenerator.swift @@ -281,7 +281,7 @@ class BeaconCalloutGenerator: AutomaticGenerator, ManualGenerator { } // Don't do a location update for the destination if we have already entered the immediate vicinity - guard destination.distanceToClosestLocation(from: location) > DestinationManager.EnterImmediateVicinityDistance else { + guard destination.distanceToClosestLocation(from: location) > SettingsContext.shared.enterImmediateVicinityDistance else { return nil } } diff --git a/apps/ios/GuideDogs/Code/Behaviors/Default/Callouts/DestinationCallout.swift b/apps/ios/GuideDogs/Code/Behaviors/Default/Callouts/DestinationCallout.swift index 57c3fbd5..00180996 100644 --- a/apps/ios/GuideDogs/Code/Behaviors/Default/Callouts/DestinationCallout.swift +++ b/apps/ios/GuideDogs/Code/Behaviors/Default/Callouts/DestinationCallout.swift @@ -86,7 +86,7 @@ struct DestinationCallout: POICalloutProtocol { return Sounds(sounds) case .beaconGeofence: - let formattedDistance = LanguageFormatter.formattedDistance(from: DestinationManager.EnterImmediateVicinityDistance) + let formattedDistance = LanguageFormatter.formattedDistance(from: SettingsContext.shared.enterImmediateVicinityDistance) // Inform the user why the audio beacon has stopped if causedAudioDisabled { diff --git a/apps/ios/GuideDogs/Code/Behaviors/Preview/PreviewGenerator.swift b/apps/ios/GuideDogs/Code/Behaviors/Preview/PreviewGenerator.swift index a3565674..63478ee6 100644 --- a/apps/ios/GuideDogs/Code/Behaviors/Preview/PreviewGenerator.swift +++ b/apps/ios/GuideDogs/Code/Behaviors/Preview/PreviewGenerator.swift @@ -103,7 +103,7 @@ struct PreviewGenerator: ManualGenerator { var callouts: [CalloutProtocol] = [] if event.arrived { - let formattedDistance = LanguageFormatter.formattedDistance(from: DestinationManager.EnterImmediateVicinityDistance) + let formattedDistance = LanguageFormatter.formattedDistance(from: SettingsContext.shared.enterImmediateVicinityDistance) callouts.append(GenericCallout(.preview, description: "arrived at beacon (in preview)") { (_, _, _) -> [Sound] in let earcon = GlyphSound(.beaconFound) diff --git a/apps/ios/GuideDogs/Code/Data/Destination Manager/DestinationManager.swift b/apps/ios/GuideDogs/Code/Data/Destination Manager/DestinationManager.swift index 15f72de3..89bc159d 100644 --- a/apps/ios/GuideDogs/Code/Data/Destination Manager/DestinationManager.swift +++ b/apps/ios/GuideDogs/Code/Data/Destination Manager/DestinationManager.swift @@ -25,9 +25,6 @@ enum DestinationManagerError: Error { class DestinationManager: DestinationManagerProtocol { - static let LeaveImmediateVicinityDistance: CLLocationDistance = SettingsContext.shared.leaveImmediateVicinityDistance - static let EnterImmediateVicinityDistance: CLLocationDistance = SettingsContext.shared.enterImmediateVicinityDistance - // MARK: Notification Keys struct Keys { @@ -614,10 +611,10 @@ class DestinationManager: DestinationManagerProtocol { let distance = origin.distanceToClosestLocation(from: location) - if isWithinGeofence && distance >= DestinationManager.LeaveImmediateVicinityDistance { + if isWithinGeofence && distance >= SettingsContext.shared.leaveImmediateVicinityDistance { // Left immediate vicinity return false - } else if !isWithinGeofence && distance <= DestinationManager.EnterImmediateVicinityDistance { + } else if !isWithinGeofence && distance <= SettingsContext.shared.enterImmediateVicinityDistance { // Entered immediate vicinity return true }