Skip to content

Commit 44b3c48

Browse files
klopez4212Terp
andauthored
Add swipeable photo stacks and native iOS gallery preview (block#9259)
## Summary Replace bubble photo carousels with swipeable, overlapping photo stacks, with distinct sent/received layouts and a stationary photo count. Opening and closing the gallery preserves the selected photo. Photo frames follow the active theme. Add an opt-in iOS 18+ native zoom gallery (`BUZZ_NATIVE_PHOTO_ZOOM=true`) with paging, continuous dot scrubbing, preview-backed loading, Reply/More actions, and Liquid Glass controls on iOS 26+. The existing gallery remains the fallback. UIKit’s late corner settling and brief return-transition input lockout remain known preview limitations. ### Related issue None found. ### Testing Validation: full mobile pre-push checks/tests passed on `2b5bac3075`; light/dark sent/received widget renders verified. Earlier native simulator checks covered paging, scrubbing, downward close, and Reply. Snapshots below are actual Flutter widget renders with sample photos (not device screenshots). | Before: carousel | After: sent | After: received | | --- | --- | --- | | ![Original photo carousel](https://github.com/user-attachments/assets/9fb13b0a-d2b9-4429-9bb1-396deeb126da) | ![Sent photo stack](https://github.com/user-attachments/assets/ab6a3094-5460-45fb-8020-68c454d6474f) | ![Received photo stack](https://github.com/user-attachments/assets/0ec2e803-a5b5-4812-8159-2e0585eea199) | | Dark mode: sent | Dark mode: received | | --- | --- | | ![Dark sent photo stack](https://github.com/user-attachments/assets/3d4f993a-4e59-4da8-a30b-c6a0c19ad7eb) | ![Dark received photo stack](https://github.com/user-attachments/assets/e552070a-e516-434c-ae76-0f8811184d2e) | --------- Signed-off-by: kenny lopez <[email protected]> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
1 parent e8a4bc1 commit 44b3c48

21 files changed

Lines changed: 2770 additions & 123 deletions
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Concatenated with the production source by test-mobile-photo-zoom.sh so this
2+
// fixture can exercise the private controller without widening its app API.
3+
@main
4+
struct NativePhotoZoomTests {
5+
@MainActor static func main() {
6+
if #available(iOS 18.0, *) {
7+
let data = UIGraphicsImageRenderer(size: CGSize(width: 2, height: 2)).pngData { context in
8+
UIColor.red.setFill(); context.fill(CGRect(x: 0, y: 0, width: 2, height: 2))
9+
}
10+
let viewer = NativePhotoZoomViewController(
11+
image: UIImage(data: data)!, labels: (0..<100).map { "Photo \($0)" },
12+
initialIndex: 0, canReply: false, canMore: false, canDelete: false
13+
)
14+
var requests: [(String, Int, FlutterResult)] = []
15+
viewer.request = { method, index, _, completion in
16+
if method == "select" { completion(nil) }
17+
else { requests.append((method, index, completion)) }
18+
}
19+
viewer.loadViewIfNeeded()
20+
viewer.view.frame = CGRect(x: 0, y: 0, width: 390, height: 844)
21+
viewer.view.layoutIfNeeded()
22+
precondition(!requests.isEmpty && requests.allSatisfy { $0.1 <= 2 }, "Initial requests must stay adjacent")
23+
let pager = viewer.children.compactMap { $0 as? UIPageViewController }.first!
24+
let indicator = descendants(viewer.view).compactMap { $0 as? UIPageControl }.first!
25+
let stale = requests
26+
requests.removeAll()
27+
indicator.currentPage = 50; sendValueChanged(indicator)
28+
precondition(!requests.isEmpty && requests.allSatisfy { (48...52).contains($0.1) }, "Scrubbing must move the request window")
29+
let page = pager.viewControllers!.first!
30+
page.loadViewIfNeeded()
31+
let photo = descendants(page.view).compactMap { $0 as? UIImageView }.first!
32+
for request in stale { request.2(FlutterStandardTypedData(bytes: data)) }
33+
precondition(photo.image == nil, "Late old-window responses cannot paint the selected photo")
34+
let current = requests
35+
requests.removeAll()
36+
for request in current { request.2(FlutterStandardTypedData(bytes: data)) }
37+
precondition(photo.image != nil, "Current-window responses must paint the actual page")
38+
indicator.currentPage = 0; sendValueChanged(indicator)
39+
precondition(requests.contains { $0.1 == 0 }, "Leaving the window evicts old decoded images")
40+
let closing = requests
41+
requests.removeAll()
42+
var closed = false
43+
viewer.onClose = { _ in closed = true }
44+
viewer.viewDidDisappear(false)
45+
for request in closing { request.2(FlutterStandardTypedData(bytes: data)) }
46+
precondition(closed && requests.isEmpty, "Teardown must ignore late loads and stop requesting")
47+
print("PASS: native photo window, stale responses, eviction and teardown")
48+
}
49+
}
50+
@MainActor static func sendValueChanged(_ control: UIControl) {
51+
// A command-line UIKit fixture has no UIApplication action dispatcher.
52+
for target in control.allTargets {
53+
for action in control.actions(forTarget: target, forControlEvent: .valueChanged) ?? [] {
54+
_ = (target as AnyObject).perform(NSSelectorFromString(action), with: control)
55+
}
56+
}
57+
}
58+
@MainActor static func descendants(_ view: UIView) -> [UIView] {
59+
[view] + view.subviews.flatMap { descendants($0) }
60+
}
61+
}

‎mobile/ios/Runner.xcodeproj/project.pbxproj‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
4A71C0012F40100100A17E01 /* InlinePhotoPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A71C0022F40100100A17E01 /* InlinePhotoPicker.swift */; };
3131
4A71C0032F40200100A17E01 /* NativeAttachmentPopover.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A71C0042F40200100A17E01 /* NativeAttachmentPopover.swift */; };
3232
4A71C0052F40300100A17E01 /* NativeAttachmentPopoverCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A71C0062F40300100A17E01 /* NativeAttachmentPopoverCoordinator.swift */; };
33+
7B82D0053F40300100B28E02 /* NativePhotoZoomCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B82D0063F40300100B28E02 /* NativePhotoZoomCoordinator.swift */; };
3334
4A71C0072F40400100A17E01 /* ConcentricSheetSurface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A71C0082F40400100A17E01 /* ConcentricSheetSurface.swift */; };
3435
4A71C0092F40500100A17E01 /* JumpToLatestGlassButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A71C00A2F40500100A17E01 /* JumpToLatestGlassButton.swift */; };
3536
4A71C00B2F40600100A17E01 /* StickyDateGlassHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A71C00C2F40600100A17E01 /* StickyDateGlassHeader.swift */; };
@@ -130,6 +131,7 @@
130131
4A71C0022F40100100A17E01 /* InlinePhotoPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InlinePhotoPicker.swift; sourceTree = "<group>"; };
131132
4A71C0042F40200100A17E01 /* NativeAttachmentPopover.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeAttachmentPopover.swift; sourceTree = "<group>"; };
132133
4A71C0062F40300100A17E01 /* NativeAttachmentPopoverCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeAttachmentPopoverCoordinator.swift; sourceTree = "<group>"; };
134+
7B82D0063F40300100B28E02 /* NativePhotoZoomCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativePhotoZoomCoordinator.swift; sourceTree = "<group>"; };
133135
4A71C0082F40400100A17E01 /* ConcentricSheetSurface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConcentricSheetSurface.swift; sourceTree = "<group>"; };
134136
4A71C00A2F40500100A17E01 /* JumpToLatestGlassButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JumpToLatestGlassButton.swift; sourceTree = "<group>"; };
135137
4A71C00C2F40600100A17E01 /* StickyDateGlassHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickyDateGlassHeader.swift; sourceTree = "<group>"; };
@@ -309,6 +311,7 @@
309311
4A71C0022F40100100A17E01 /* InlinePhotoPicker.swift */,
310312
4A71C0042F40200100A17E01 /* NativeAttachmentPopover.swift */,
311313
4A71C0062F40300100A17E01 /* NativeAttachmentPopoverCoordinator.swift */,
314+
7B82D0063F40300100B28E02 /* NativePhotoZoomCoordinator.swift */,
312315
4A71C0082F40400100A17E01 /* ConcentricSheetSurface.swift */,
313316
4A71C00A2F40500100A17E01 /* JumpToLatestGlassButton.swift */,
314317
4A71C00C2F40600100A17E01 /* StickyDateGlassHeader.swift */,
@@ -657,6 +660,7 @@
657660
4A71C0012F40100100A17E01 /* InlinePhotoPicker.swift in Sources */,
658661
4A71C0032F40200100A17E01 /* NativeAttachmentPopover.swift in Sources */,
659662
4A71C0052F40300100A17E01 /* NativeAttachmentPopoverCoordinator.swift in Sources */,
663+
7B82D0053F40300100B28E02 /* NativePhotoZoomCoordinator.swift in Sources */,
660664
4A71C0072F40400100A17E01 /* ConcentricSheetSurface.swift in Sources */,
661665
4A71C0092F40500100A17E01 /* JumpToLatestGlassButton.swift in Sources */,
662666
4A71C00B2F40600100A17E01 /* StickyDateGlassHeader.swift in Sources */,

‎mobile/ios/Runner/AppDelegate.swift‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import os.log
4343
private var ageSignalRequestID: UUID?
4444
private var ageSignalResult: FlutterResult?
4545
private var concentricSheetSurfaceChannel: FlutterMethodChannel?
46+
private var nativePhotoZoomCoordinator: NativePhotoZoomCoordinator?
4647
private var nativeAttachmentPopoverCoordinator: NativeAttachmentPopoverCoordinator?
4748
private var nativeEmojiPickerCoordinator: NativeEmojiPickerCoordinator?
4849
private var nativeCreateChannelSheetCoordinator: NativeCreateChannelSheetCoordinator?
@@ -300,6 +301,13 @@ import os.log
300301
)?.viewController
301302
)
302303

304+
nativePhotoZoomCoordinator = NativePhotoZoomCoordinator(
305+
messenger: messenger,
306+
parentViewController: engineBridge.pluginRegistry.registrar(
307+
forPlugin: "BuzzNativePhotoZoom"
308+
)?.viewController
309+
)
310+
303311
let nativeAttachmentRegistrar = engineBridge.pluginRegistry.registrar(
304312
forPlugin: "BuzzNativeAttachmentPopover"
305313
)

0 commit comments

Comments
 (0)