diff --git a/android/build.gradle b/android/build.gradle index 6bd6d5acf6ac3da78232170a6ea8c2b0f6e5504e..a827dad53dcd8c1b2f47fce30ea8bf9140787f38 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -146,6 +146,12 @@ dependencies { implementation "androidx.activity:activity-compose:$activityComposeVersion" implementation "androidx.lifecycle:lifecycle-runtime-compose:$lifecycleVersion" implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycleVersion" + // ClerkComposeNativeViewHost imports LocalSavedStateRegistryOwner and + // LocalLifecycleOwner from these artifacts. Earlier SDKs leaked them onto + // the compile classpath through clerk-android-ui's navigation3 runtime + // dependency; AGP 9 resolves the compile classpath on its own. + implementation "androidx.savedstate:savedstate-compose:1.4.0" + implementation "androidx.lifecycle:lifecycle-runtime-compose:2.10.0" testImplementation "junit:junit:4.13.2" } diff --git a/ios/ClerkAuthNativeView.swift b/ios/ClerkAuthNativeView.swift index 5f8d2ba66d5b232890af75c22b173c86d2ef546b..b170304cbf2fbaae8032db8dd6f89b6a59c6e3fe 100644 --- a/ios/ClerkAuthNativeView.swift +++ b/ios/ClerkAuthNativeView.swift @@ -111,7 +111,12 @@ public class ClerkAuthNativeView: ClerkNativeViewHost { override func makeHostedController() -> UIViewController? { let hostBackAction: (() -> Void)? = currentHostBackButton - ? { [weak self] in self?.onHostBack([:]) } + ? { [weak self] in + guard let self else { return } + if !self.popEnclosingNavigationRoute() { + self.onHostBack([:]) + } + } : nil return ClerkNativeBridge.shared.makeAuthViewController( diff --git a/ios/ClerkNativeBridge.swift b/ios/ClerkNativeBridge.swift index c90ad2ef1162cc2ac025c8b0b4aa135e8913dc21..ce8cb68764b1a3d3537672fc83e4e3077fceb97a 100644 --- a/ios/ClerkNativeBridge.swift +++ b/ios/ClerkNativeBridge.swift @@ -1470,6 +1470,8 @@ private struct ClerkReactEmbeddedUserProfileCustomPage: View { } private struct ClerkReactUserProfileCustomPageContent: View { + @Environment(\.clerkTheme) private var theme + let path: String let rows: [ClerkUserProfileCustomRowConfig] let state: ClerkUserProfileCustomPageState @@ -1483,8 +1485,13 @@ private struct ClerkReactUserProfileCustomPageContent: View { } } .frame(maxWidth: .infinity, maxHeight: .infinity) + // Match Clerk's own profile pages so the navigation bar and page share + // the theme's page background instead of a bare hosting container. + .background(theme.colors.muted) .navigationTitle(userProfileCustomPageLabel(for: path, rows: rows)) .navigationBarTitleDisplayMode(.inline) + .preGlassSolidNavBar() + .background(theme.colors.background) } } diff --git a/ios/ClerkNativeViewHost.swift b/ios/ClerkNativeViewHost.swift index 4e6540aceeaaab56ddf327bb3f16e120438f066f..cc16c94ca7a6eb91a97e76d5de02dc586f02a766 100644 --- a/ios/ClerkNativeViewHost.swift +++ b/ios/ClerkNativeViewHost.swift @@ -5,6 +5,7 @@ public class ClerkNativeViewHost: ExpoView { private lazy var hostingCoordinator = ClerkNativeHostingCoordinator(containerView: self) private var hasInitialized: Bool = false private var configuredObserver: NSObjectProtocol? + private var isPoppingHostRoute = false public required init(appContext: AppContext? = nil) { super.init(appContext: appContext) @@ -58,6 +59,30 @@ public class ClerkNativeViewHost: ExpoView { func hostedViewDidDetachFromWindow() {} + /// Pops the React Navigation route that contains this view without waiting for + /// the JavaScript event loop. React Native Screens reports the native dismissal + /// back to React Navigation so its state remains synchronized. + func popEnclosingNavigationRoute() -> Bool { + guard !isPoppingHostRoute else { return true } + + var responder: UIResponder? = self + + while let nextResponder = responder?.next { + if let viewController = nextResponder as? UIViewController, + let navigationController = viewController.navigationController, + navigationController.viewControllers.count > 1 { + isPoppingHostRoute = true + if navigationController.popViewController(animated: true) != nil { + return true + } + isPoppingHostRoute = false + } + responder = nextResponder + } + + return false + } + private func addConfiguredObserver() { guard configuredObserver == nil else { return } diff --git a/ios/ClerkUserProfileNativeView.swift b/ios/ClerkUserProfileNativeView.swift index f2ca604d41f50d05de8ac334879126cdc0414f84..46f406d5361b9a560a7c4ce855e344cbddd1d0b6 100644 --- a/ios/ClerkUserProfileNativeView.swift +++ b/ios/ClerkUserProfileNativeView.swift @@ -47,7 +47,12 @@ public class ClerkUserProfileNativeView: ClerkUserProfileCustomPageHost { override func makeHostedController() -> UIViewController? { let hostBackAction: (() -> Void)? = currentHostBackButton - ? { [weak self] in self?.onHostBack([:]) } + ? { [weak self] in + guard let self else { return } + if !self.popEnclosingNavigationRoute() { + self.onHostBack([:]) + } + } : nil return ClerkNativeBridge.shared.makeUserProfileViewController(