diff --git a/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageViewer.ios.kt b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageViewer.ios.kt index 1f40b9740a..c42b994987 100755 --- a/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageViewer.ios.kt +++ b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/ImageViewer.ios.kt @@ -52,22 +52,23 @@ fun getDependencies(ioScope: CoroutineScope, toastState: MutableState + withContext(Dispatchers.Main) { + val window = UIApplication.sharedApplication.windows.last() as? UIWindow + val currentViewController = window?.rootViewController + val activityViewController = UIActivityViewController( + activityItems = listOf( + UIImage.imageWithContentsOfFile(imageUrl), + picture.description + ), + applicationActivities = null + ) + currentViewController?.presentViewController( + viewControllerToPresent = activityViewController, + animated = true, + completion = null, + ) + } } } } diff --git a/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt index b84d46d13c..732c467613 100644 --- a/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt +++ b/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/storage/IosImageStorage.ios.kt @@ -119,6 +119,21 @@ class IosImageStorage( } }.readData() } + + suspend fun getNSURLToShare(picture: PictureData): NSURL = withContext(Dispatchers.IO) { + when (picture) { + is PictureData.Camera -> { + picture.jpgFile + } + + is PictureData.Resource -> { + NSURL( + fileURLWithPath = NSBundle.mainBundle.resourcePath + "/" + picture.resource, + isDirectory = false + ) + } + } + } } @OptIn(ExperimentalForeignApi::class)