Skip to content

Commit d8780f4

Browse files
fix: put errorModal on NavigationStack
1 parent 3a90dff commit d8780f4

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/AuthPickerView.swift

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ extension AuthPickerView: View {
4141
@Bindable var navigator = authService.navigator
4242
NavigationStack(path: $navigator.routes) {
4343
authPickerViewInternal
44-
.environment(\.reportError, reportError)
4544
.navigationTitle(authService.authenticationState == .unauthenticated ? authService
4645
.string.authPickerTitle : "")
4746
.navigationBarTitleDisplayMode(.large)
@@ -72,6 +71,11 @@ extension AuthPickerView: View {
7271
}
7372
}
7473
}
74+
.environment(\.reportError, reportError)
75+
.errorAlert(
76+
error: $error,
77+
okButtonLabel: authService.string.okButtonLabel
78+
)
7579
.interactiveDismissDisabled(authService.configuration.interactiveDismissEnabled)
7680
}
7781
// View-layer logic: Handle account conflicts (auto-handle anonymous upgrade, store others for
@@ -89,10 +93,12 @@ extension AuthPickerView: View {
8993

9094
/// Closure for reporting errors from child views
9195
private func reportError(_ error: Error) {
92-
self.error = AlertError(
93-
message: authService.string.localizedErrorMessage(for: error),
94-
underlyingError: error
95-
)
96+
Task { @MainActor in
97+
self.error = AlertError(
98+
message: authService.string.localizedErrorMessage(for: error),
99+
underlyingError: error
100+
)
101+
}
96102
}
97103

98104
/// View-layer logic: Handle account conflicts with type-specific behavior
@@ -181,10 +187,6 @@ extension AuthPickerView: View {
181187
.background(.black.opacity(0.7))
182188
}
183189
}
184-
.errorAlert(
185-
error: $error,
186-
okButtonLabel: authService.string.okButtonLabel
187-
)
188190
}
189191

190192
@ViewBuilder

0 commit comments

Comments
 (0)