mirror of
https://github.com/stablyai/orca.git
synced 2026-11-13 17:37:40 +00:00
* feat(mobile): copy, save and share an image from the chat image viewer * refactor(mobile): pass image viewer actions in so diagrams skip them * fix(mobile): name the image verb native.image.act and serialize image actions * fix(mobile): queue image actions per page and skip SVG links * refactor(mobile): share the cache-folder helper and table the viewer's image actions * fix(mobile): keep the toast's live region mounted so screen readers hear it * test(mobile): re-record agent history goldens for the always-mounted toast region * test(mobile): import the declared routes in the moved routes test
62 lines
2.0 KiB
Swift
62 lines
2.0 KiB
Swift
import ExpoModulesCore
|
|
import QuickLook
|
|
|
|
public class OrcaMobileWebShellModule: Module {
|
|
private var pdfPreview: MobileWebShellPdfPreview?
|
|
|
|
public func definition() -> ModuleDefinition {
|
|
Name("OrcaMobileWebShell")
|
|
|
|
AsyncFunction("presentPdf") { (url: URL) in
|
|
guard let presenter = self.appContext?.utilities?.currentViewController() else {
|
|
throw PdfPresenterUnavailableException()
|
|
}
|
|
let preview = MobileWebShellPdfPreview(url: url)
|
|
let controller = QLPreviewController()
|
|
controller.dataSource = preview
|
|
self.pdfPreview = preview
|
|
presenter.present(controller, animated: true)
|
|
}.runOnQueue(.main)
|
|
|
|
AsyncFunction("shareImage") { (url: URL, _: String) in
|
|
guard let presenter = self.appContext?.utilities?.currentViewController() else {
|
|
throw ImagePresenterUnavailableException()
|
|
}
|
|
presentImageShareSheet(url: url, from: presenter)
|
|
}.runOnQueue(.main)
|
|
|
|
AsyncFunction("saveImageToPhotos") { (url: URL, _: String, promise: Promise) in
|
|
saveImageToPhotoLibrary(url: url, promise: promise)
|
|
}
|
|
|
|
View(OrcaMobileWebShellView.self) {
|
|
Events("onLoadState", "onBridgeMessage", "onExternalNavigation", "onBackEdgeSwipe")
|
|
|
|
Prop("generationDirectory") { (view: OrcaMobileWebShellView, value: String) in
|
|
view.setGenerationDirectory(value)
|
|
}
|
|
|
|
Prop("sessionId") { (view: OrcaMobileWebShellView, value: String) in
|
|
view.setSessionId(value)
|
|
}
|
|
|
|
Prop("bridgeEnabled") { (view: OrcaMobileWebShellView, value: Bool) in
|
|
view.setBridgeEnabled(value)
|
|
}
|
|
|
|
Prop("backEdgeSwipe") { (view: OrcaMobileWebShellView, value: Bool) in
|
|
view.setBackEdgeSwipe(value)
|
|
}
|
|
|
|
AsyncFunction("postBridgeMessage") {
|
|
(view: OrcaMobileWebShellView, json: String, promise: Promise) in
|
|
try view.postBridgeMessage(json, promise: promise)
|
|
}
|
|
|
|
OnViewDidUpdateProps { (view: OrcaMobileWebShellView) in
|
|
view.propsDidUpdate()
|
|
}
|
|
}
|
|
}
|
|
}
|