Skip to content

fix(flashcard): render the Android NFC scan sheet inline, with Cancel in reach - #751

Merged
islandbitcoin merged 3 commits into
mainfrom
jabariennis/flashcard-scan-sheet-android
Oct 5, 2026
Merged

islandbitcoin merged 3 commits into
mainfrom
jabariennis/flashcard-scan-sheet-android

Conversation

@islandbitcoin

@islandbitcoin islandbitcoin commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Android has no system NFC sheet, so the Flashcard provider shows its own ("Ready to Scan", with a Cancel) while a card read waits for a tap. On the Pixel 8 Pro (Android 17) it was broken: the sheet's window opened, but only part of the NFC illustration was drawn, in the top-left corner. There was no dimmed backdrop, no text and no Cancel, so Back was the only way out. Found during the 2026-10-02 device test by tapping refresh on the home screen's card row.

Cause: the sheet was a transparent core React Native Modal with a bottom-pinned sheet. That's the case the Fabric Modal host measures wrongly on Android (#545). The #674 sweep fixed it for the react-native-modal sheets, modal-nfc among them, but couldn't cover core Modal usages.

Fix:

  • Inline: the sheet renders through react-native-modal with coverScreen={false}, as modal-nfc does. It sits in a full-size frame the provider now wraps around the app, so the frame is the whole screen.
  • Bottom inset: a SafeAreaView keeps Cancel above the navigation bar under Android 16's forced edge-to-edge.
  • Ways out: Cancel, Back and a tap on the backdrop each end the read (cancelTechnologyRequest).
  • iOS is unchanged and keeps its system sheet.

Back and React Navigation: inline, no native dialog catches Back. It reaches the sheet through react-native-modal's BackHandler listener, added when the provider mounts, and BackHandler runs the newest listener first. The sheet hears Back before React Navigation only because NavigationContainer adds its own listener while it still renders nothing, waiting on the async getInitialURL, and mounts the provider later. Comments at the sheet and at FlashcardProvider in app.tsx say so: the provider has to stay inside NavigationContainerWrapper.

Tests: a new provider spec covers:

  • the sheet rendering inline while a read waits: no core Modal in the tree, so no RCTModalHostView (feat: enable React Native New Architecture (Fabric + TurboModules) #545);
  • Cancel, Back and the backdrop each ending the read, with Back pressed through React Native's own BackHandler mock and the backdrop pressed where react-native-modal draws it;
  • Back under the app's real NavigationContainerWrapper, over a two-screen stack: with the sheet up it ends the read and the screen stays; with the sheet down it pops the screen;
  • the sheet never showing on iOS.

Each test fails when the behaviour it names is removed. That was checked by removing coverScreen={false}, onBackButtonPress and onBackdropPress in turn, by making getInitialURL synchronous, and by adding a Back listener that always handles the press. Full suite: 159 suites, 1,859 tests.

Device check (Pixel 8 Pro): still to do. Jest has no layout engine, so none of the above shows the sheet drawing right on the phone. A build of this branch was installed on the Pixel on 2026-10-04 with adb install -r, keeping app data; its JS bundle is byte-identical to one built from 9457e052c. The phone was PIN-locked and then disconnected, so the check itself has not been run. To do, in both gesture and 3-button navigation: start a read from Home's card row and one from FlashcardV2TopUp, and confirm the dimmed backdrop, "Ready to Scan" and Cancel above the navigation bar. On FlashcardV2TopUp, Back should end the read and leave the screen where it is.

🤖 Generated with Claude Code

… in reach

Android has no system NFC sheet, so the Flashcard provider shows its own
("Ready to Scan" with a Cancel) while a read waits for a card. It was a
transparent core React Native Modal with a bottom-pinned sheet, the case
the Fabric Modal host measures wrongly on Android (#545): on the Pixel only
part of the NFC illustration showed, top-left, with no backdrop, no text
and no Cancel. Back was the only way out.

The sheet now renders inline through react-native-modal (coverScreen
false), as modal-nfc does since #674, in a full-size frame the provider
wraps around the app. A SafeAreaView keeps Cancel above the navigation bar
under Android 16's edge-to-edge. Cancel, Back and a tap on the backdrop
each end the read. iOS keeps its system sheet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@islandbitcoin
islandbitcoin force-pushed the jabariennis/flashcard-scan-sheet-android branch from 493ea3e to 2688601 Compare October 4, 2026 23:04
Dread and others added 2 commits October 4, 2026 18:34
…ation container

Review fixes for #751.

- Back: the spec called the sheet's onBackButtonPress prop, so it could not
  see how Back really arrives. Inline there is no native dialog to catch it;
  react-native-modal's BackHandler listener does, and BackHandler runs the
  newest listener first. The spec now presses Back through React Native's own
  BackHandler mock, and again under the app's real NavigationContainerWrapper
  over a two-screen stack: with the sheet up, Back ends the read and the card
  screen stays; with the sheet down, Back pops the screen. Making the
  wrapper's getInitialURL synchronous fails that test.
- Inline: the test only read the coverScreen prop. It now asserts no core
  Modal is in the tree while the sheet is up, as
  app-update-inline-modal.spec.tsx does.
- Backdrop: pressed where react-native-modal draws it, not through the prop.
- Comments at the sheet and at FlashcardProvider in app.tsx say why the
  provider has to stay inside NavigationContainerWrapper.

No runtime change: the app bundle is byte-identical to the previous commit's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review fixes for #751.

The Pixel was not attached, so the device check ran on an API 35
emulator instead (Pixel 7 Pro profile, Fabric, a debug build of this
branch, NFC faked in JS for the run and not committed). The sheet drew
right in gesture and in 3-button navigation: dimmed backdrop, "Ready to
Scan", and Cancel ending one navigation-bar height plus the sheet's 20 dp
padding above the bottom. Cancel, Back and a backdrop tap each closed it,
and Back over a pushed screen left that screen up. The Pixel check is now
an Android RC blocker in the 0.7.3 Linear project rather than a line in
this PR's body.

The spec now pins the two facts that run depends on: Cancel sits in a
SafeAreaView padded on the bottom edge only, and the sheet's parent is the
flex: 1 frame the app renders in. Each assertion fails when its fact is
removed (bottom edge dropped or joined by top, SafeAreaView swapped for a
View, Cancel moved out of it, flex dropped, sheet or app moved out of the
frame). The spec's gate note names the Linear issue.

No runtime change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@islandbitcoin

Copy link
Copy Markdown
Contributor Author

Device check: run on an emulator; the Pixel check is still owed and is now tracked outside this PR

The Pixel 8 Pro was not attached (adb devices listed nothing), so the check ran on an emulator:

  • Android 15 (API 35), Pixel 7 Pro profile, 1344×2992. Fabric on ("fabric":true at launch). The debug APK built from this branch (targetSdk 36), with JS served from this branch.
  • The emulator has no NFC. A temporary JS fake (not committed) made a read wait until cancelled, and a dev-menu item started a read on any screen. The sheet's own code ran unchanged.
Gesture navigation (82 px bar, from y=2910) 3-button navigation (163 px bar, from y=2829)
Sheet Fills the app frame (0,0, 1344×2992). Backdrop dimmed, "Ready to Scan" and the illustration drawn Same
Cancel y=2652 to 2842, 68 px (the 20 dp padding) above the bar y=2571 to 2761, 68 px above the bar
Ways out Cancel, a backdrop tap and Back (key event) each closed the sheet and ended the read Cancel closed it
Back over a pushed screen (Login options) Sheet closed, screen stayed; the next Back popped it Same, using the navigation bar's Back button
Back over the root screen Sheet closed, app stayed open Not run

In both modes the bottom inset equals the navigation bar's height, so the SafeAreaView gets the right inset under edge-to-edge.

Not covered: real NFC, the Pixel's Android 17, and the two signed-in entry points (Home's card row, FlashcardV2TopUp). FlashcardV2TopUp adds no BackHandler listener of its own, only beforeRemove, so Back should reach the sheet there as it did on the pushed screen. That comes from reading the code. No device has shown it.

Pixel check: it is now an issue in the v0.7.3 Linear project (P-ENG-57), assigned and marked as blocking the API 36 ticket. It has this PR's checklist plus one more item: after each way out, the next read starts cleanly. The issue is left unlinked from this PR so that merging can't close it. Its ID is in the spec comment.

063ee28 pins the two facts the emulator run depends on. Cancel sits in a SafeAreaView padded on the bottom edge only, and the sheet's parent is the flex: 1 frame the app renders in. Seven mutants each fail the new test. Full suite: 159 suites, 1,860 tests. tsc, the lint-changed gate, prettier and typos are clean.

@islandbitcoin
islandbitcoin merged commit 11977b9 into main Oct 5, 2026
8 of 9 checks passed
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.

1 participant