Files
bsky-social-app/modules/expo-bluesky-context-menu/ios/PreviewFactory.swift
T
Claude d4fd15dc20 Add iOS peek long-press context menu for image embeds
Introduces expo-bluesky-context-menu, a compositional Root/Trigger/Menu/MenuItem
wrapper around UIContextMenuInteraction. The preview ViewController is sized to
the image's true aspect ratio so tall/panorama previews don't stretch mid-lift,
and menu icons are rasterized from the app's SVG icon set on the native side.

The preview prop is a discriminated union (image today; video and externalCard
reserved) so the same module can back those embeds in follow-ups.

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

22 lines
711 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 url = uri.flatMap(URL.init(string:))
let aspect = CGFloat((spec["aspectRatio"] as? Double) ?? 1)
return ImagePreviewController(imageURL: url, aspectRatio: aspect)
default:
return nil
}
}
}