Open History to see the last commit
1# Mobile navigation
2
3The iOS Home and thread routes share the root native stack in
4[`Stack.tsx`](../../apps/mobile/src/Stack.tsx). Keeping them in one navigation
5controller lets UIKit animate the header between routes. The iPad sidebar owns
6a separate, single-screen stack; Android uses its own in-flow headers.
7
8Home and the iPad sidebar render their brand and connection status through
9`headerTitle`, with `Threads` retained as the route title. The editor-style native
10bar aligns that title on the leading side. Do not model the brand as a toolbar
11button: on iOS 26.5 UIKit morphs a background-free custom leading item's rectangle
12into the next screen's glass back button, even with distinct item identifiers.
13Using the title slot lets the brand and native back button animate separately.
14
15The connection-status title has a maximum width based on its header's width and
16trailing actions. A long environment name or larger text must not push Settings
17into UIKit's overflow menu. Keep the full status as the accessibility label
18while visually truncating it. The iPad sidebar uses its pane width, not the full
19window width.
20
21On iOS 26, UIKit does not recognize Fabric's custom text views when shaping the
22native scroll-edge fade. The screens patch gives custom title subviews an empty,
23non-interactive native label matching their bounds. This supplies the fade's
24geometry without drawing anything or turning the title back into a toolbar item.
25Check the top scroll fade as well as push/pop when changing these title views.
26
27The react-native-screens patch caches leading, trailing, and center item groups
28independently. A button can belong to only one group: constructing another group
29with the same button removes it from the previous one. Unrelated menu updates
30must therefore preserve the other groups while UIKit may be animating them.
31
32Each cache includes the owning header config, its item values, and custom native
33item identities, so changed content or remounted event emitters still rebuild.
34
35Custom header identifiers require native code generation and a new mobile build;
36an over-the-air JavaScript update alone is insufficient. The Android view manager
37implements the generated identifier setter as a no-op because this behavior is
38specific to iOS 26 and later.
39
40On iOS 26 the full-screen back swipe is UIKit's `interactiveContentPopGestureRecognizer`,
41and react-native-screens makes it wait for any horizontally scrollable ScrollView to
42fail first. Upstream applies that to every horizontal ScrollView regardless of
43position, so a back swipe on a code block or table that is already at its leading
44edge only bounces. The patch narrows the rule to ScrollViews with content still
45hidden to the left; at the leading edge they yield to the pop gesture like plain
46text does.
47
48After changing a dependency patch, refresh CocoaPods before rebuilding an
49existing iOS project. pnpm installs each patch hash in a different directory;
50an old Pods project can keep compiling the previous directory even though Metro
51and `apps/mobile/node_modules` resolve to the new patch.
52
53`ControlPillMenu` resolves semantic icon colors through `withUniwind` and supplies them to every
54iOS `MenuView` action, including nested actions. The menu library's Fabric bridge converts a missing
55`imageColor` to transparent, so callers should use this wrapper instead of
56rendering `MenuView` directly. Explicit colors are preserved, and destructive
57actions default to the theme's danger foreground color. Native stack header menus
58use a separate implementation and do not need this workaround.
59
60## Native media presentations
61
62`PresentationSource` in `NativePresentation` registers a thumbnail for AVKit,
63image zoom transitions, and UIKit's share sheet. Wrap the thumbnail as its single child
64and pass the stable identifier to the presentation. The registry keeps weak
65references to source views; recycled or compact composer thumbnails can register
66the same identifier. Identifiers must distinguish simultaneously visible attachments.
67The source registration does not own the preview. Android uses a regular view.
68
69On iOS, video previews mount `AVPlayerViewController` temporarily inside the
70registered source and enter full screen through AVKit. AVKit
71owns that zoom, its playback controls, Close button, and interactive dismissal.
72Do not replace AVKit's transition with `preferredTransition`: in the iOS 27
73simulator, that leaves native Close unable to exit full screen. When the source is unavailable,
74the player uses a standard modal presentation. Programmatic entry uses the same
75guarded `enterFullScreenAnimated:completionHandler:` selector as Expo Video;
76if that selector is unavailable, the player also falls back to a standard modal.
77
78`FilePreviewModal` resolves image and PDF sources from a URI, a signed environment asset,
79or a retained composer file. On iOS, Quick Look owns image and document layout, controls,
80zooming, sharing, and interactive dismissal. Its delegate supplies the registered thumbnail
81and its bounds for Quick Look's source-view zoom. Do not layer `preferredTransition` or
82another image scroll view over that presentation: Quick Look coordinates its image gestures
83with the return to the thumbnail. Missing sources use the standard transition, and Reduce
84Motion disables animation. A pending programmatic Close waits until the current presentation
85or cancelled dismissal has settled before starting another transition.
86
87The shared native presenter copies original bytes into its own temporary directory and
88removes that copy after dismissal. Network downloads write to disk, and sharing never edits
89the source attachment. Draft images use their stored upload data rather than a potentially
90expired picker URI. No React Navigation route or custom transition animator is needed.
91
92The same viewer handles message images, markdown images, PDF attachments and links,
93composer thumbnails, and workspace image previews. The workspace PDF web preview has an
94Open PDF action for the native viewer. Android retains its image viewer and uses the
95system chooser for PDFs. Saving images on iOS uses the add-only photo-library permission.
96
97Every full-screen video preview on iOS is AVKit, playing directly from the signed asset
98URL: sent attachments, composer drafts, and file links that point at a video. Inline
99markdown embeds and the workspace file screen play in place with the Expo Video player.
100AVKit handles buffering; the client does not download the entire file or show a separate
101opening overlay before presentation.
102The URL is captured once per preview so credential refresh does not restart playback.
103Media actions (copy path, open in file viewer, save or share) belong to the surface that
104opened the video, a long-press on the thumbnail, so the player carries no
105menu. AVKit has no retry; a failure alerts and closes, re-mints the URL in the background, and the next open plays from the fresh one.
106
107The native presentation promise completes after dismissal. Local draft previews
108hold their file lease until that promise settles. The iOS preview component requests
109native dismissal when its source screen unmounts. Playback pauses in the background.
110AVPlayer activates audio as playback starts. The presenter pauses and releases
111its own player on close, then restores the previous audio-session configuration
112if no other component changed it during playback. It does not deactivate the
113shared session, which may still serve another player or recorder. Android plays every
114video, attachments included, in its React Native modal with the Expo Video player.
115Composer drafts play and share from their local file; other videos stream from the
116signed URL and download only for save or share.
117
118`shareFileFromSource` uses the same source registration to anchor UIKit's activity
119controller. Its promise completes when the native share flow finishes, keeping
120the existing attachment lease and foreground handoff active for that duration.
121Android uses Expo Sharing. On iOS, received and draft video attachments expose
122Save or share through `VideoAttachmentMenu`. The attachment supplies the source
123identifier, and the native share presentation inherits its appearance. AVKit's
124iOS playback controls do not expose a public custom-share-action API.
125
126Video attachment thumbnails use Expo Video's native frame extraction and Expo Image.
127Received attachments use their signed asset URL; drafts retain and resolve their local file
128until extraction ends. Extraction is serial; temporary players never play or change audio settings. Leaving the screen cancels
129pending work; a 15-second limit prevents an unreachable source from holding up the queue.
130The client keeps at most 32 native images, each bounded to 480 pixels per side, keyed by
131environment and attachment identity rather than expiring URLs. Images still displayed keep
132their own references when evicted from that cache.
133
134The asset HTTP route supports single byte ranges for videos so iOS can read metadata and
135frames without first downloading the whole file. Normal downloads keep their full response;
136unsupported ranges and conditional `If-Range` requests also fall back to the full file.
137An older environment without range support may still show the play-card fallback. Thumbnail
138failure never disables playback or sharing.