Repository navigation
Liquid Glass chevron back button on iOS, in the side rail on iPhone Duo - #303
ninovanhooff wants to merge 2 commits into
Conversation
- Apple devices use a chevron for back navigation, Android keeps the arrow - iOS 26+: native glass UIButton in the top bar - iOS 27.1 with a vertical bar (iPhone Duo side rail): the back button moves into the rail via a hidden root UINavigationController - Sample onboarding gets a back button to demo it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Expose the native UIButton to VoiceOver, Compose left it out of the accessibility tree - Keep the chevron a fixed size so it stays inside the button at large text sizes, and show the large content viewer instead, like bar buttons Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The UIKit navigation-controller and side-rail integration requires iOS runtime validation because button taps, VoiceOver activation, and fold/unfold behavior remain untested.
No open issues 🎉
What changed in this PR
Adds platform-specific back navigation to the shared UI, addressing #285 with native Liquid Glass styling on supported iOS versions while preserving Android’s Material button.
Changes:
- Introduces
AppBackButtonwith an iOS chevron, Liquid Glass styling, native accessibility, and an older-iOS fallback. - Adds a navigation-controller wrapper to place the back button in the iPhone Duo side rail while keeping navigation in Compose.
- Integrates the platform button into shared app bars and demonstrates it in sample onboarding.
| File | Description |
|---|---|
shared/src/iosMain/kotlin/main.kt |
Applies the native navigation-controller wrapper. |
feature/sampleonboarding/src/commonMain/kotlin/nl/q42/template/feature/sampleonboarding/SampleOnboardingScreen.kt |
Adds an app bar with back navigation. |
feature/sampleonboarding/src/commonMain/kotlin/nl/q42/template/feature/sampleonboarding/presentation/SampleOnboardingViewModel.kt |
Handles the back-button event. |
core/ui/src/iosMain/kotlin/nl/q42/template/core/ui/resources/PlatformDrawables.ios.kt |
Selects the iOS chevron drawable. |
core/ui/src/iosMain/kotlin/nl/q42/template/core/ui/compose/composables/window/AppBackButton.ios.kt |
Implements glass, side-rail, and fallback buttons. |
core/ui/src/iosMain/kotlin/nl/q42/template/core/ui/compose/composables/navigation/NativeNavigationController.kt |
Manages side-rail detection and native back items. |
core/ui/src/commonMain/kotlin/nl/q42/template/core/ui/theme/Dimens.kt |
Defines iOS glass-button and symbol sizes. |
core/ui/src/commonMain/kotlin/nl/q42/template/core/ui/resources/PlatformDrawables.kt |
Declares the platform-specific back drawable. |
core/ui/src/commonMain/kotlin/nl/q42/template/core/ui/compose/composables/window/TopAppBar.kt |
Uses the platform button unless a custom icon is supplied. |
core/ui/src/commonMain/kotlin/nl/q42/template/core/ui/compose/composables/window/ScaffoldWithAppBar.kt |
Defaults to the platform back button. |
core/ui/src/commonMain/kotlin/nl/q42/template/core/ui/compose/composables/window/AppBackButton.kt |
Declares the shared API and Compose fallback. |
core/ui/src/commonMain/composeResources/drawable/chevron_back_24.xml |
Adds an auto-mirrored chevron asset. |
core/ui/src/androidMain/kotlin/nl/q42/template/core/ui/resources/PlatformDrawables.android.kt |
Retains Android’s back-arrow drawable. |
core/ui/src/androidMain/kotlin/nl/q42/template/core/ui/compose/composables/window/AppBackButton.android.kt |
Implements the Android Material back button. |
Review effort: Balanced
|
Draft: needs self-review, test on reals devices |
mbernson
left a comment
There was a problem hiding this comment.
For this one, it's going to be difficult if not impossible to get the native behaviour, I'm afraid. So we will have to compromise.
For example: in a native iOS app, the liquid glass controls in the navigation bar morph into each other or fade in/out during screen transitions. (That's the "liquid" part of the design language.) Whereas in the CMP implementation, the screen we navigate to simply slides in from the right wholesale, including all of its glass controls. They are wholly separate screens, and the system cannot morph or fade the controls.
https://github.com/user-attachments/assets/59d34eed-d4d8-48c9-ad8b-928be8b93361
https://github.com/user-attachments/assets/2bb7661f-5e83-43a6-a893-058bd1e47fbd
This gets us 90% of the way there though.
| // A fixed size, otherwise the symbol outgrows the button at large text sizes | ||
| preferredSymbolConfigurationForImage = | ||
| UIImageSymbolConfiguration.configurationWithPointSize(Dimens.glassButtonIconSizeIos.value.toDouble()) |
There was a problem hiding this comment.
Odd that this doesn't work correctly on large text sizes out of the box
Closes #285
Why is this important?
The back button in the top bar was a Material arrow on every platform. On Apple devices that looks out of place: iOS uses a chevron, on iOS 26+ in a Liquid Glass button, and on iPhone Duo the system moves navigation bar items into the side rail.
What changed
Res.drawable.navigation_back_24is an arrow on Android and a chevron on iOSAppBackButton, used byTopAppBar/ScaffoldWithAppBarwhen no customnavIconPainteris given:UIButtonwithglassButtonConfiguration, placed as an overlay so the glass sees the Compose content behind it.UINavigationControllerinto the rail, so the root is wrapped in aNativeNavigationController. It never pushes anything, navigation stays in Compose, and its navigation bar is only visible while there is a rail.isNativeAccessibilityEnabled), and its symbol keeps a fixed size with the large content viewer instead, like bar buttons. Without that it outgrew the button at the largest text sizes.Notes
glassButtonConfigurationstays behindisLiquidGlassAvailable, the vertical bar code only runs on 27.1+ and readsverticalBarEdgeby key, as it is not in the Kotlin/Native bindings yet.Screenshots
🤖 Generated with Claude Code