Files
bsky-social-app/modules/expo-bluesky-context-menu/ios/PreviewFactory.swift
T
Claude 1856c36221 Share expo-image cache; thumb placeholder; smoother dismiss
Two UX fixes for the peek preview:

1. Black flash on first peek — the preview VC now depends on SDWebImage
   directly (same version pinned by expo-image) and reads from
   `SDImageCache.shared`. On open it paints the fullsize synchronously if it's
   cached (common, since onPressIn prefetches), otherwise paints the thumb as a
   placeholder while the fullsize loads and swaps in. Also switches the image
   view to autoresizingMask so the dismiss animation interpolates cleanly
   without AutoLayout relayout mid-animation.

2. Two-stage dismiss animation on aspect-mismatched thumbnails — drop the
   explicit `previewForDismissingMenuWithConfiguration` override. With only
   the highlight provider implemented iOS reverses it end-to-end, which
   interpolates size and position together instead of snapping back to the
   preview's original size before translating.

https://claude.ai/code/session_015REmux3R9uuEMMJUHxTyQT
2026-05-25 14:35:14 +03:00

28 lines
869 B
Swift

import UIKit
/// Decodes the `preview` prop shipped from JS and constructs the right
/// `UIViewController` for the peek. Day-one only handles `image`. Add cases
/// here for `video` and `externalCard` follow-ups.
enum PreviewFactory {
static func makeController(from spec: [String: Any]?) -> UIViewController? {
guard let spec = spec,
let type = spec["type"] as? String else { return nil }
switch type {
case "image":
let uri = spec["uri"] as? String
let thumbUri = spec["thumbUri"] as? String
let url = uri.flatMap(URL.init(string:))
let thumbURL = thumbUri.flatMap(URL.init(string:))
let aspect = CGFloat((spec["aspectRatio"] as? Double) ?? 1)
return ImagePreviewController(
imageURL: url,
thumbURL: thumbURL,
aspectRatio: aspect
)
default:
return nil
}
}
}