Skip to content

Swipe, double tap to zoom, drag away and save images in a viewer that grows out of the thumbnail - #175

Draft
simonhamp wants to merge 5 commits into
mainfrom
feat/picture-viewer
Draft

simonhamp wants to merge 5 commits into
mainfrom
feat/picture-viewer

Conversation

@simonhamp

@simonhamp simonhamp commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Reworks the full-screen image viewer.

  • No more band across the top for the close button. The image sits on black that reaches the screen edges, and the round sheet buttons (sheet-bar-button, same as the composer's cross) float over it: close on the left, save on the right.
  • Swipe sideways to move between a commit's images. The chevrons are gone. Dashes at the bottom show where you are, and the bright one slides to the new image as the page changes.
  • Drag an image up or down to close the viewer. It follows the finger and the black and buttons fade with it. Let go past about 120pt, or flick, and it closes. A short drag springs back.
  • Save puts the showing image in the phone's photo library and shows the usual toast. No NativePHP plugin does this, so there's a small local plugin in packages/photos, like packages/calls. iOS asks for add-only access with a new NSPhotoLibraryAddUsageDescription. Android 10+ needs no permission and saves to Pictures/devnull. It uses the copy in the image cache, or downloads the image first.
  • Double tap an image to zoom to twice its size (half the 4x maximum), aimed at the spot you tapped and kept inside the picture's edges. Double tap again, at any zoom, to go back to its whole size. Both animate.
  • The viewer no longer slides up. The black fades in while the tapped picture grows out of its thumbnail into place, and closing does the reverse. If you paged to another image, it shrinks into that image's thumbnail. If there's no thumbnail on screen it just fades. Each commit image has its own ref for this (thumb-{id}).
  • The viewer's state and actions moved from ShowsCommits into a new ShowsImageViewer trait. Any screen can use it by calling showImagesInViewer($images, $index, $sources), where $sources are the refs of the images it was opened from, and including the partial once. Remotes is next.

Things to know:

  • Merge Double tap to zoom a gesture area, glide after a drag, and hand drags it can't use to its parent mobile-ui#220 and Let a gesture area zoom on a double tap (@doubleTap.zoom), and name its scale zoom mobile-air#716 first. Each page keeps its pans bound all the time, and without those PRs a bound pan takes every drag, so the pager wouldn't page and a drag wouldn't close. The fade and the morph need Fade a modal in and out, and grow a picture into it from the screen mobile-ui#221, which is merged.
  • A screen can't morph into a pushed screen inside tabs on 4.8 (that's Run Transition::Morph for pushes inside native tabs and stacks mobile-air#709), and pushing the viewer as a full-screen route would tear down the tabs and lose the Log's scroll position, and close any open sheet. So the viewer stays a modal and mobile-ui#221 teaches the modal to fade and to fly a picture in and out of it.
  • Zoomed in, a drag pans the image and glides on when let go. At its edge a drag that way pulls the pager on to the next image, as Photos does, but a zoomed image never starts the drag to close. At whole size a drag pages and closes. The phone decides: with mobile-ui#220 a bounded gesture area only takes a drag while its zoomed image has room to move. So the pans stay bound, PHP no longer hears about zooms ($viewerZoomed, viewerZoomEnded() and @pinchEnd are gone), a pinch zooms around the fingers and a double tap aims at the tapped spot from the first.
  • Panning still stops dead when the finger lifts. mobile-ui's bounded gesture area has no momentum, so this needs a change there (iOS and Android renderers), not in the app.
  • Android keeps the modal's own close row. mobile-ui's modal only closes on Android's back while dismissible is on, and dismissible is what draws the row. Turning it off made back do nothing. A modal option to hide the row but keep back would fix this.
  • The drag fades to the modal's theme background (light grey in light mode), not to the screen underneath, because mobile-ui's modal isn't see-through. After a drag to close, the picture shrinks back from where the drag left it.
  • An image at no web address gets an empty page. The pager can't skip it, but the viewer never moves to it or loads it.
  • This touches the same partial and trait as Show the commit under the viewer's image, as the web docks it #138, which already conflicts with main. One of them will need a rebase.

Tested on an iOS 27.0 simulator and an Android 35 emulator against a local API with real photo commits: paging both ways, short and long drags, save (it landed in the simulator's Photos and the emulator's Pictures/devnull, toast shown over the viewer). Pinch, pan while zoomed and pinch back were checked on Android with injected two-finger touches. The iOS simulator tools here can't pinch, so on iOS I opened an image already zoomed to check that a drag pans it and doesn't page or close.

For the double tap and the morph I built the app with the three upstream branches swapped into vendor (not committed): open and close from a single image and from a grid, in light and dark, closing with the button, Android's back and a drag; page then close (it shrinks into the third thumbnail); double tap in, pan without paging, double tap out, then page and drag to close. On Android the double taps and pinches were real injected touches. On iOS I couldn't make a real double tap on the simulator: AXe takes over a second per tap here and SimDeck taps don't land. So on iOS the zoom was checked by firing it from a single tap in a local build, and the double tap recognizer itself (SwiftUI's own count-2 tap, as core's @doubleTap uses) still wants a try on a phone.

After the drag rule moved into the renderers I tested again, with this branch, mobile-ui#220 and mobile-air#716 in vendor, on an iOS 27.0 simulator and an Android 35 emulator against the local API. Real double taps and two-finger pinches on both platforms this time (the iOS Simulator tool's two-finger paths, and injected MotionEvents on Android). Checked: paging and drag to close at whole size, panning without paging or closing when zoomed, a pinch ending at 1.007x still pages, double tap in and out, a swipe or drag during the double tap's zoom-out pages or closes while the zoom finishes, a pinch after a double tap, a second finger landing while paging, and back at whole size after paging away or reopening. php artisan test: 1907 passed.

Screenshots

doubletap

iOS light iOS dark Android light Android dark
Before
After

Recordings: Android light, after, iOS light, after (zoom fired by a single tap, see Testing)

morph

iOS light iOS dark Android light Android dark
Before
After

Recordings: Android dark, after, Android dark, before, Android light, after, Android light, before, iOS dark, after, iOS dark, before, iOS light, after, iOS light, before

pagedclose

iOS light iOS dark Android light Android dark
After

Recordings: Android light, after

viewer

iOS light iOS dark Android light Android dark
Before
After

Recordings: Android dark, after, iOS light, after

  • No visible change

🤖 Generated with Claude Code

The viewer drew a band across the top just to hold the modal's close
button, and moved between images with chevrons. Now the image sits on
black that reaches the edges, with the app's round sheet buttons
floating over it: close on the left, save on the right.

Swiping sideways pages through a commit's images, with dashes at the
bottom that slide to the current one. At its whole size an image can be
dragged up or down: it follows the finger, the black fades, and letting
go far enough (or flicking) closes the viewer. A short drag springs
back. Once zoomed, a drag pans instead, until a pinch brings the image
back to its whole size.

Save puts the image in the phone's photo library through a small local
plugin (packages/photos), since no NativePHP plugin does this. iOS asks
for add-only photo access with a new usage string. Android 10 and up
needs no permission. A toast says how it went.

The viewer's state moved out of ShowsCommits into its own
ShowsImageViewer trait, so other screens (Remotes next) can use it.

Android keeps the modal's own close row for now: mobile-ui's modal only
closes on Android's back while it's dismissible, and dismissible draws
the row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A double tap on an image at its whole size zooms to half the most it
zooms (twice), with the tapped point brought to the middle as far as the
picture's bounds allow. A double tap on a zoomed image goes back to its
whole size. Both animate on the phone and report through the same
@pinchEnd as a pinch, so the pans bind and let go as before.

The viewer no longer slides up. The black fades in over the screen while
the tapped picture grows out of its thumbnail into place, and closing
runs that backwards. After paging, it shrinks into the thumbnail of the
image it's showing. With no thumbnail on screen it only fades. Each
commit image now has a ref of its own (thumb-{id}) for this, beside the
pressable's, and showImagesInViewer() takes those refs.

Every page also hands its pans to the zoom as zoom-pan, which takes no
drags. That's what lets a double tap at whole size aim, and it means the
first pinch now zooms around the fingers rather than the middle.

This needs NativePHP/mobile-ui#220 and #221 and NativePHP/mobile-air#716.
Until they're in, mobile-ui ignores the new attributes: the viewer slides
up as before and a double tap does nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@simonhamp simonhamp changed the title Swipe through, drag away and save images in the full-screen viewer Swipe, double tap to zoom, drag away and save images in a viewer that grows out of the thumbnail Nov 18, 2026
simonhamp and others added 2 commits November 19, 2026 22:23
mobile-air#716 renamed `double-tap-zoom` to `@doubleTap.zoom`. The pinch
names stay, since they work with and without that PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With NativePHP/mobile-ui#220 and NativePHP/mobile-air#716, a bounded gesture
area only takes a one-finger drag while its zoomed image has room to move, so
at whole size the pager pages and the drag to close closes with the pans
bound. Each page now binds its pans all the time. $viewerZoomed,
viewerZoomEnded(), ImageViewer::ZoomedPast, @pinchEnd, zoom-pan and the
swapped close area are gone.

This needs those two PRs: without them a bound pan takes every drag, so the
pager wouldn't page and the drag to close wouldn't close.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e pager

With NativePHP/mobile-ui#220's latest commit, a drag past a zoomed
image's edge pulls the pager on to the next image, a drag that way at
the edge pages, and a drag let go glides on. The drag to close still
only gets drags at whole size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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