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" } } } 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..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 @@ -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 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