Fix location/weather error handling and complete localization
Add authorization pre-check and 15s timeout to LocationManager to prevent hanging continuations. WeatherManager now skips retry queue when location permission is denied. Settings weather toggle shows alert directing users to Settings when location is denied. Fill remaining 32 untranslated strings to reach 100% localization. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -41,6 +41,7 @@ struct SettingsContentView: View {
|
||||
@AppStorage(UserDefaultsStore.Keys.hapticFeedbackEnabled.rawValue, store: GroupUserDefaults.groupDefaults) private var hapticFeedbackEnabled = true
|
||||
@AppStorage(UserDefaultsStore.Keys.weatherEnabled.rawValue, store: GroupUserDefaults.groupDefaults) private var weatherEnabled = true
|
||||
@State private var showWeatherSubscriptionStore = false
|
||||
@State private var showLocationDeniedAlert = false
|
||||
|
||||
private var textColor: Color { theme.currentTheme.labelColor }
|
||||
|
||||
@@ -995,6 +996,15 @@ struct SettingsContentView: View {
|
||||
|
||||
if newValue {
|
||||
LocationManager.shared.requestAuthorization()
|
||||
// Check if permission was denied after a brief delay
|
||||
Task {
|
||||
try? await Task.sleep(for: .seconds(1))
|
||||
let status = LocationManager.shared.authorizationStatus
|
||||
if status == .denied || status == .restricted {
|
||||
weatherEnabled = false
|
||||
showLocationDeniedAlert = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AnalyticsManager.shared.track(.weatherToggled(enabled: newValue))
|
||||
@@ -1026,6 +1036,19 @@ struct SettingsContentView: View {
|
||||
.sheet(isPresented: $showWeatherSubscriptionStore) {
|
||||
ReflectSubscriptionStoreView(source: "settings")
|
||||
}
|
||||
.alert(
|
||||
String(localized: "Location Access Required"),
|
||||
isPresented: $showLocationDeniedAlert
|
||||
) {
|
||||
Button(String(localized: "Open Settings")) {
|
||||
if let url = URL(string: UIApplication.openSettingsURLString) {
|
||||
UIApplication.shared.open(url)
|
||||
}
|
||||
}
|
||||
Button(String(localized: "Cancel"), role: .cancel) {}
|
||||
} message: {
|
||||
Text("Reflect needs location access to show weather. You can enable it in Settings.")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Export Data Button
|
||||
@@ -1311,6 +1334,7 @@ struct SettingsView: View {
|
||||
@AppStorage(UserDefaultsStore.Keys.hapticFeedbackEnabled.rawValue, store: GroupUserDefaults.groupDefaults) private var hapticFeedbackEnabled = true
|
||||
@AppStorage(UserDefaultsStore.Keys.weatherEnabled.rawValue, store: GroupUserDefaults.groupDefaults) private var weatherEnabled = true
|
||||
@State private var showWeatherSubscriptionStore = false
|
||||
@State private var showLocationDeniedAlert = false
|
||||
|
||||
private var textColor: Color { theme.currentTheme.labelColor }
|
||||
|
||||
@@ -1665,6 +1689,15 @@ struct SettingsView: View {
|
||||
|
||||
if newValue {
|
||||
LocationManager.shared.requestAuthorization()
|
||||
// Check if permission was denied after a brief delay
|
||||
Task {
|
||||
try? await Task.sleep(for: .seconds(1))
|
||||
let status = LocationManager.shared.authorizationStatus
|
||||
if status == .denied || status == .restricted {
|
||||
weatherEnabled = false
|
||||
showLocationDeniedAlert = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AnalyticsManager.shared.track(.weatherToggled(enabled: newValue))
|
||||
@@ -1692,6 +1725,19 @@ struct SettingsView: View {
|
||||
.sheet(isPresented: $showWeatherSubscriptionStore) {
|
||||
ReflectSubscriptionStoreView(source: "settings")
|
||||
}
|
||||
.alert(
|
||||
String(localized: "Location Access Required"),
|
||||
isPresented: $showLocationDeniedAlert
|
||||
) {
|
||||
Button(String(localized: "Open Settings")) {
|
||||
if let url = URL(string: UIApplication.openSettingsURLString) {
|
||||
UIApplication.shared.open(url)
|
||||
}
|
||||
}
|
||||
Button(String(localized: "Cancel"), role: .cancel) {}
|
||||
} message: {
|
||||
Text("Reflect needs location access to show weather. You can enable it in Settings.")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Export Data Button
|
||||
|
||||
Reference in New Issue
Block a user