Skip to content

Commit

Permalink
Merge pull request #4 from icerockdev/develop
Browse files Browse the repository at this point in the history
Release 0.3.0
  • Loading branch information
Alex009 authored Mar 2, 2020
2 parents e1d7d33 + 0b1c658 commit fb408b8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ TODO
- 0.1.0
- kotlin 1.3.61
- 0.2.0
- 0.3.0

## Installation
root build.gradle
Expand All @@ -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")
}
```

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit fb408b8

Please sign in to comment.