react-native-screen
Recipe and conventions for building screens and flows in the MediBooker v2 React Native patient app (apps/mobile) — navigation, theming with design tokens and dark mode, data fetching and offline beha
SKILL.md.claude/skills/react-native-screen/SKILL.md
GitHubReact Native screen recipe
Toolchain proposal: Expo with Expo Router and EAS Build, Submit and Update. Check CLAUDE.md for the status.
Many patients are older or not used to apps. Clarity, large text and robustness on bad networks matter more than visual effects.
Structure
apps/mobile/
app/ Expo Router
(auth)/login.tsx, register/[step].tsx, verify-email.tsx, forgot-password.tsx
(tabs)/index.tsx Home: next appointment, "Book appointment"
(tabs)/appointments/index.tsx, (tabs)/appointments/[id].tsx
(tabs)/profile/index.tsx
booking/service.tsx, booking/date-time.tsx, booking/review.tsx, booking/success.tsx
_layout.tsx providers, auth gate, theme
src/
components/ui/ design-system components (same names and props as in Figma)
features/<feature>/ hooks, components, schemas
lib/ API client setup, auth storage, notifications, format helpers
theme/ generated tokens + useTheme()
locales/ar.json, locales/en.json (Arabic is the default; more locales later)
Rules
- Design system. Use
components/ui, mirroring the Figma names and props. Style only throughuseTheme()tokens (theme.color.bg.surface,theme.spacing[4],theme.radius.md, typography presets). Follow the system colour scheme (light and dark). The practice theme (brand scale from the practice configuration, ADR 0002) is applied in the theme provider; never hard-code a brand colour. - Layout. Safe-area insets on every screen; keyboard avoidance on forms. Test on a small device (375 pt wide, for example iPhone SE) and a large one, on iOS and Android. From 600 dp width (tablets) use the two-pane layouts of the Figma page "Tablet Layouts" (T1–T3); the tab bar stays.
- Touch and text. Touch targets of at least 44×44 pt (use
hitSlopfor small icons). Never disable font scaling. Layouts must work at the largest accessibility text sizes: text wraps, no fixed heights. 3a. Motion (ADR 0008). Animate withreact-native-reanimated(the version the Expo SDK pins); GSAP and shadcn/ui are web-only. Durations and easings come from the motion tokens (Easing.bezierfrom the token control points). Respect reduced motion (useReducedMotion(): jump to the end state). Horizontal motion followsI18nManager.isRTL. Animate transforms and opacity, not layout. - Accessibility. Every touchable element has
accessibilityRole,accessibilityLabeland state (selected,disabled,checked). Logical focus order. Announce async results (AccessibilityInfo.announceForAccessibility(t('booking.success'))). Test with VoiceOver and TalkBack in Arabic and English. 4a. Languages and RTL. Arabic is the default locale, English the second; locale from the user profile, falling back to the device (expo-localization). Direction follows the locale:I18nManager.allowRTL(true)andforceRTL(isRTL), then reload the app (expo-updatesreloadAsync) when the direction changes. Style withstart/endprops (marginStart,paddingEnd,start,end), neverleft/right. Mirror directional icons whenI18nManager.isRTL(transform: [{ scaleX: -1 }]); never mirror clocks, check marks or the logo. Fonts: Noto Sans Arabic forar, Inter foren(bundled viaexpo-font); typography presets switch with the locale. Numbers and dates viaIntlwith the practice'snumberingSystem,hourCycleand time zone. Mixed Arabic/Latin text follows the bidi table indesign-system: phone numbers, e-mails and IDs inside Arabic text are wrapped in U+2066 … U+2069 (LTR isolate); security-code inputs stay LTR; Latin tokens go last in Arabic strings. - Data. Generated hooks from
@medibooker/api-clientwith TanStack Query. ConnectfocusManagertoAppStateandonlineManagerto NetInfo. Offline: show cached upcoming appointments read-only with an offline banner; booking and cancelling need a connection. Bookings send anIdempotency-Keyand handle retries. - Auth. Tokens only in
expo-secure-store. Refresh on 401 with a single in-flight refresh. Logout clears secure storage, the query cache and the push token registration. Biometric unlock (expo-local-authentication) is optional. - Notifications.
expo-notifications. Ask for permission in context (after the first booking), not at app start. Push texts are in the user's locale and contain no health data ("Reminder: your appointment tomorrow at 09:30" / "تذكير: موعدك غدًا الساعة 09:30"). Deep links to an appointment require login and validated parameters. SMS are sent by the server; the app only offers the phone verification (one-time code) and the SMS switches in the notification settings (screen 29). - Calendar. "Add to calendar" via
expo-calendar; ask for permission only on tap. The event title does not name the service ("Doctor's appointment – <clinic>"). - Privacy. No third-party analytics or trackers. Consider hiding sensitive screens in the app switcher. No personal data in logs or crash reports.
- Navigation and states. The Android back button behaves predictably. The booking flow keeps its state when going back. Every screen handles loading, empty, error and offline.
Tests and release
- Jest + React Native Testing Library for components and hooks, with a mocked client or MSW.
- Maestro flows for register → verify → book → cancel, run in CI against preview builds.
- EAS profiles
development,preview,production. OTA updates (expo-updates) only for JS-only changes with a matching runtime version. RespectminimumSupportedVersionfrom/app-config.
Checklist
- Matches Figma (links in the handoff) in light and dark mode, on small and large screens
- VoiceOver and TalkBack pass; largest text size pass; touch targets ≥ 44 pt
- Offline and error states; idempotent booking
- Strings in
aranden; RTL and LTR checked on iOS and Android; dates/times in the practice time zone - No personal data in logs, push texts or calendar entries
- Lint, typecheck and tests green; Maestro flow passes (commands and results in the handoff)