Skip to content

Liquid Glass chevron back button on iOS, in the side rail on iPhone Duo - #303

Draft
ninovanhooff wants to merge 2 commits into
mainfrom
285-liquid-glass-back-button
Draft

ninovanhooff wants to merge 2 commits into
mainfrom
285-liquid-glass-back-button

Conversation

@ninovanhooff

@ninovanhooff ninovanhooff commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • Chevron on Apple devices. Res.drawable.navigation_back_24 is an arrow on Android and a chevron on iOS
  • AppBackButton, used by TopAppBar / ScaffoldWithAppBar when no custom navIconPainter is given:
    • Android: the Material icon button, as before.
    • iOS 26+: a native UIButton with glassButtonConfiguration, placed as an overlay so the glass sees the Compose content behind it.
    • iOS < 26: the chevron in a Compose icon button.
    • iOS 27.1+ with a vertical bar (iPhone Duo side rail): the back button moves into the rail. The system only moves bar items of a UINavigationController into the rail, so the root is wrapped in a NativeNavigationController. It never pushes anything, navigation stays in Compose, and its navigation bar is only visible while there is a rail.
  • Accessibility: the native button is exposed to VoiceOver (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.
  • The sample onboarding screen gets a back button to demo it.

Notes

  • Only tested on simulators, no real devices:
    • iPhone 17 Pro, iOS 26.5: glass button; light, dark, Increase Contrast, Reduce Transparency, largest text size.
    • iPhone Duo, iOS 27.1: back button in the side rail.
    • iPad Pro, iOS 27.0: glass button.
    • iPhone 15, iOS 17.0: plain chevron fallback (possible since Fix launch crash on iOS 16 and 17 by weak-linking UIKit #302).
  • VoiceOver was checked by dumping the accessibility tree; the simulator has no VoiceOver itself. The button reads as "Back", button.
  • Not tested: tapping the buttons (no tap tool), folding/unfolding the Duo, long-press large content viewer, Android.
  • New iOS APIs follow the guidance from Fix launch crash on iOS 16 and 17 by weak-linking UIKit #302: glassButtonConfiguration stays behind isLiquidGlassAvailable, the vertical bar code only runs on 27.1+ and reads verticalBarEdge by key, as it is not in the Kotlin/Native bindings yet.

Screenshots

🤖 Generated with Claude Code

ninovanhooff and others added 2 commits November 24, 2026 15:30
- 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>
@ninovanhooff
ninovanhooff requested a review from a team as a code owner November 24, 2026 14:37
@ninovanhooff ninovanhooff linked an issue Nov 24, 2026 that may be closed by this pull request
Copilot AI balanced review requested due to automatic review settings November 24, 2026 14:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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 AppBackButton with 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

@ninovanhooff
ninovanhooff marked this pull request as draft November 24, 2026 15:34
@ninovanhooff

Copy link
Copy Markdown
Collaborator Author

Draft: needs self-review, test on reals devices

@mbernson mbernson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +87 to +89
// A fixed size, otherwise the symbol outgrows the button at large text sizes
preferredSymbolConfigurationForImage =
UIImageSymbolConfiguration.configurationWithPointSize(Dimens.glassButtonIconSizeIos.value.toDouble())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Odd that this doesn't work correctly on large text sizes out of the box

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Liquid glass back button

3 participants