mirror of
https://github.com/block/buzz.git
synced 2026-11-16 06:11:34 +00:00
## 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 | | --- | --- | --- | |  |  |  | | Dark mode: sent | Dark mode: received | | --- | --- | |  |  | --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
62 lines
3.2 KiB
Swift
62 lines
3.2 KiB
Swift
// Concatenated with the production source by test-mobile-photo-zoom.sh so this
|
|
// fixture can exercise the private controller without widening its app API.
|
|
@main
|
|
struct NativePhotoZoomTests {
|
|
@MainActor static func main() {
|
|
if #available(iOS 18.0, *) {
|
|
let data = UIGraphicsImageRenderer(size: CGSize(width: 2, height: 2)).pngData { context in
|
|
UIColor.red.setFill(); context.fill(CGRect(x: 0, y: 0, width: 2, height: 2))
|
|
}
|
|
let viewer = NativePhotoZoomViewController(
|
|
image: UIImage(data: data)!, labels: (0..<100).map { "Photo \($0)" },
|
|
initialIndex: 0, canReply: false, canMore: false, canDelete: false
|
|
)
|
|
var requests: [(String, Int, FlutterResult)] = []
|
|
viewer.request = { method, index, _, completion in
|
|
if method == "select" { completion(nil) }
|
|
else { requests.append((method, index, completion)) }
|
|
}
|
|
viewer.loadViewIfNeeded()
|
|
viewer.view.frame = CGRect(x: 0, y: 0, width: 390, height: 844)
|
|
viewer.view.layoutIfNeeded()
|
|
precondition(!requests.isEmpty && requests.allSatisfy { $0.1 <= 2 }, "Initial requests must stay adjacent")
|
|
let pager = viewer.children.compactMap { $0 as? UIPageViewController }.first!
|
|
let indicator = descendants(viewer.view).compactMap { $0 as? UIPageControl }.first!
|
|
let stale = requests
|
|
requests.removeAll()
|
|
indicator.currentPage = 50; sendValueChanged(indicator)
|
|
precondition(!requests.isEmpty && requests.allSatisfy { (48...52).contains($0.1) }, "Scrubbing must move the request window")
|
|
let page = pager.viewControllers!.first!
|
|
page.loadViewIfNeeded()
|
|
let photo = descendants(page.view).compactMap { $0 as? UIImageView }.first!
|
|
for request in stale { request.2(FlutterStandardTypedData(bytes: data)) }
|
|
precondition(photo.image == nil, "Late old-window responses cannot paint the selected photo")
|
|
let current = requests
|
|
requests.removeAll()
|
|
for request in current { request.2(FlutterStandardTypedData(bytes: data)) }
|
|
precondition(photo.image != nil, "Current-window responses must paint the actual page")
|
|
indicator.currentPage = 0; sendValueChanged(indicator)
|
|
precondition(requests.contains { $0.1 == 0 }, "Leaving the window evicts old decoded images")
|
|
let closing = requests
|
|
requests.removeAll()
|
|
var closed = false
|
|
viewer.onClose = { _ in closed = true }
|
|
viewer.viewDidDisappear(false)
|
|
for request in closing { request.2(FlutterStandardTypedData(bytes: data)) }
|
|
precondition(closed && requests.isEmpty, "Teardown must ignore late loads and stop requesting")
|
|
print("PASS: native photo window, stale responses, eviction and teardown")
|
|
}
|
|
}
|
|
@MainActor static func sendValueChanged(_ control: UIControl) {
|
|
// A command-line UIKit fixture has no UIApplication action dispatcher.
|
|
for target in control.allTargets {
|
|
for action in control.actions(forTarget: target, forControlEvent: .valueChanged) ?? [] {
|
|
_ = (target as AnyObject).perform(NSSelectorFromString(action), with: control)
|
|
}
|
|
}
|
|
}
|
|
@MainActor static func descendants(_ view: UIView) -> [UIView] {
|
|
[view] + view.subviews.flatMap { descendants($0) }
|
|
}
|
|
}
|