From 54c85f92ca019efa83fd760dd8aaa9c1aa6cee00 Mon Sep 17 00:00:00 2001 From: Aleksey Mikhailov Date: Mon, 2 Mar 2020 16:39:22 +0700 Subject: [PATCH 1/3] add ability to pass lazy getter of UIViewController --- .../media/picker/MediaPickerController.kt | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/media/src/iosMain/kotlin/dev/icerock/moko/media/picker/MediaPickerController.kt b/media/src/iosMain/kotlin/dev/icerock/moko/media/picker/MediaPickerController.kt index a25793d..2d7bdb1 100755 --- a/media/src/iosMain/kotlin/dev/icerock/moko/media/picker/MediaPickerController.kt +++ b/media/src/iosMain/kotlin/dev/icerock/moko/media/picker/MediaPickerController.kt @@ -19,15 +19,33 @@ import platform.CoreServices.kUTTypeMovie import platform.CoreServices.kUTTypeVideo import platform.Foundation.CFBridgingRelease import platform.Foundation.NSURL -import platform.UIKit.* +import platform.UIKit.UIImage +import platform.UIKit.UIImagePickerController +import platform.UIKit.UIImagePickerControllerDelegateProtocol +import platform.UIKit.UIImagePickerControllerEditedImage +import platform.UIKit.UIImagePickerControllerImageURL +import platform.UIKit.UIImagePickerControllerMediaType +import platform.UIKit.UIImagePickerControllerMediaURL +import platform.UIKit.UIImagePickerControllerOriginalImage +import platform.UIKit.UIImagePickerControllerSourceType +import platform.UIKit.UINavigationControllerDelegateProtocol +import platform.UIKit.UIViewController import platform.darwin.NSObject import kotlin.coroutines.Continuation import kotlin.coroutines.suspendCoroutine actual class MediaPickerController( - val permissionsController: PermissionsController, - val viewController: UIViewController + private val permissionsController: PermissionsController, + private val getViewController: () -> UIViewController ) { + constructor( + permissionsController: PermissionsController, + viewController: UIViewController + ) : this( + permissionsController = permissionsController, + getViewController = { viewController } + ) + actual suspend fun pickImage(source: MediaSource): Bitmap { source.requiredPermissions().forEach { permission -> permissionsController.providePermission(permission) @@ -41,7 +59,7 @@ actual class MediaPickerController( controller.sourceType = source.toSourceType() controller.mediaTypes = listOf(kImageType) controller.delegate = delegatePtr - viewController.presentViewController(controller, animated = true, completion = null) + getViewController().presentViewController(controller, animated = true, completion = null) } delegatePtr = null @@ -153,7 +171,7 @@ actual class MediaPickerController( UIImagePickerControllerSourceType.UIImagePickerControllerSourceTypePhotoLibrary controller.mediaTypes = listOf(kImageType, kVideoType, kMovieType) controller.delegate = delegatePtr - viewController.presentViewController(controller, animated = true, completion = null) + getViewController().presentViewController(controller, animated = true, completion = null) } delegatePtr = null From da6872ac6509cf02cc1d46bcf4afc6da8eb6981d Mon Sep 17 00:00:00 2001 From: Aleksey Mikhailov Date: Mon, 2 Mar 2020 16:39:28 +0700 Subject: [PATCH 2/3] up version --- README.md | 3 ++- buildSrc/src/main/kotlin/Versions.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d1ac94b..252dc40 100755 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ TODO - 0.1.0 - kotlin 1.3.61 - 0.2.0 + - 0.3.0 ## Installation root build.gradle @@ -41,7 +42,7 @@ allprojects { project build.gradle ```groovy dependencies { - commonMainApi("dev.icerock.moko:media:0.2.0") + commonMainApi("dev.icerock.moko:media:0.3.0") } ``` diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index a2e5637..150d10b 100755 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -21,7 +21,7 @@ object Versions { object MultiPlatform { const val coroutines = "1.3.3" const val mokoPermissions = "0.3.0" - const val mokoMedia = "0.2.0" + const val mokoMedia = "0.3.0" } } } From 0b1c658a7fc728f6e1d00e759f70c67067899b2b Mon Sep 17 00:00:00 2001 From: Aleksey Mikhailov Date: Mon, 2 Mar 2020 16:43:07 +0700 Subject: [PATCH 3/3] revert permissionsController visibility changes --- .../dev/icerock/moko/media/picker/MediaPickerController.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media/src/iosMain/kotlin/dev/icerock/moko/media/picker/MediaPickerController.kt b/media/src/iosMain/kotlin/dev/icerock/moko/media/picker/MediaPickerController.kt index 2d7bdb1..ad3747b 100755 --- a/media/src/iosMain/kotlin/dev/icerock/moko/media/picker/MediaPickerController.kt +++ b/media/src/iosMain/kotlin/dev/icerock/moko/media/picker/MediaPickerController.kt @@ -35,7 +35,7 @@ import kotlin.coroutines.Continuation import kotlin.coroutines.suspendCoroutine actual class MediaPickerController( - private val permissionsController: PermissionsController, + val permissionsController: PermissionsController, private val getViewController: () -> UIViewController ) { constructor(