feat(android): opt-in Partial Custom Tab via androidCustomTabPartialHeightFraction#1119
Open
omeratt wants to merge 2 commits into
Open
feat(android): opt-in Partial Custom Tab via androidCustomTabPartialHeightFraction#1119omeratt wants to merge 2 commits into
omeratt wants to merge 2 commits into
Conversation
…eightFraction Adds an optional fraction-based config that renders the Chrome Custom Tab as a user-resizable bottom sheet on Chrome 107+, matching the modal feel of iOS's ASWebAuthenticationSession. When omitted, behavior is unchanged. - index.d.ts: new optional `androidCustomTabPartialHeightFraction: number` - index.js: validation (must be a number in (0, 1]) + Android-only bridge arg - RNAppAuthModule.java: threads the fraction through `authorize` and `authorizeWithConfiguration`; between `createCustomTabsIntentBuilder()` and `build()`, calls `setInitialActivityHeightPx(displayHeight * fraction, ACTIVITY_HEIGHT_ADJUSTABLE)` when the fraction is non-null and the request is not a Trusted Web Activity - android/build.gradle: bump androidx.browser:browser 1.4.0 -> 1.5.0 for the setInitialActivityHeightPx API - docs/usage/config.md: documents the new option, the Chrome 107+ floor, and the prefetchConfiguration warmup recommendation for first-launch - index.spec.js: 5 new tests for the option (valid fraction passthrough, default null, invalid type, fraction <= 0, fraction > 1) + updates the existing 5 native-bridge assertions to include the new positional arg - changeset: minor bump (additive, opt-in, backward compatible)
🦋 Changeset detectedLatest commit: 14239ab The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@omeratt is attempting to deploy a commit to the formidable-labs Team on Vercel. A member of the Team first needs to authorize it. |
… non-Chrome browsers, compileSdk 33+)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1118
Description
Adds an opt-in
androidCustomTabPartialHeightFractionAuthConfigurationfield that, on Chrome 107+, renders the authorization Chrome Custom Tab as
a user-resizable bottom sheet at the caller-specified fraction of the
screen height — matching the modal feel of iOS's
ASWebAuthenticationSession. See #1118 for the UX motivation andside-by-side screenshots.
The feature is gracefully degrading and zero-regression:
Custom Tab as today.
(0, 1]→ betweenauthService.createCustomTabsIntentBuilder()and.build(), thelibrary calls
setInitialActivityHeightPx(displayHeight * fraction, CustomTabsIntent.ACTIVITY_HEIGHT_ADJUSTABLE).Older Chrome silently ignores the extra and falls back to the
full-screen Custom Tab — no crash, no warning, no behavior surprise.
androidTrustedWebActivityis true (TWAs intentionallyrender full-screen).
What changed
packages/react-native-app-auth/index.d.tsandroidCustomTabPartialHeightFraction?: numberonAuthConfiguration.packages/react-native-app-auth/index.js(0, 1], otherwiseinvariantthrows); Android-only positional argument to the native bridge. iOS path is untouched (Platform.OS === 'android'guard).packages/react-native-app-auth/android/build.gradleandroidx.browser:browser1.4.0 → 1.5.0for thesetInitialActivityHeightPxAPI.packages/react-native-app-auth/android/src/main/java/com/rnappauth/RNAppAuthModule.javaauthorizeandauthorizeWithConfiguration; conditionally callssetInitialActivityHeightPxbetween builder creation and.build().packages/react-native-app-auth/index.spec.jsnull; throw on non-number; throw on≤ 0; throw on> 1). Updates the existing 5 native-bridge assertions to include the new positional arg.docs/docs/usage/config.mdprefetchConfigurationwarmup recommendation needed for the bottom sheet to render on the first invocation..changeset/android-partial-custom-tabs.mdUsage
Steps to verify
yarn installat the repo root, then inpackages/react-native-app-auth/:yarn lint→ passes (no new warnings introduced by this PR).yarn test→ 78 tests pass, including 5 new tests forandroidCustomTabPartialHeightFractionvalidation + native-bridgepassthrough.
repo's CI emulator at API 35 ships Chrome 147, which works). Add
androidCustomTabPartialHeightFraction: 0.85to the example config andcall
prefetchConfigurationon screen mount, then tap the authorizebutton → the Chrome Custom Tab renders as a bottom sheet at ~85% of the
screen height; the host activity is visible behind it; the user can
drag the sheet up to full-screen via the handle. Cancel via the X
button → returns to the host app.
androidCustomTabPartialHeightFractionunset, the flow renders full-screen exactly as before this PR.
ignored (TWA renders full-screen as before).
import { AuthConfiguration }and try{ androidCustomTabPartialHeightFraction: 0.85 } satisfies AuthConfiguration→ typechecks;
{ androidCustomTabPartialHeightFraction: 'half' }→type error. Confirms the
index.d.tschange is correct.Tests, README, and TypeScript definitions are updated.