File tree Expand file tree Collapse file tree 7 files changed +125
-0
lines changed
src/desktopMain/kotlin/dev/icerock/moko/permissions/compose
src/desktopMain/kotlin/dev/icerock/moko/permissions Expand file tree Collapse file tree 7 files changed +125
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,17 @@ android {
1818 }
1919}
2020
21+ kotlin {
22+ jvm(" desktop" )
23+
24+ sourceSets {
25+ val commonMain by getting
26+ val desktopMain by getting {
27+ dependsOn(commonMain)
28+ }
29+ }
30+ }
31+
2132dependencies {
2233 commonMainApi(projects.permissions)
2334 commonMainApi(compose.runtime)
Original file line number Diff line number Diff line change 1+ package dev.icerock.moko.permissions.compose
2+
3+ import androidx.compose.runtime.Composable
4+ import androidx.compose.runtime.LaunchedEffect
5+ import dev.icerock.moko.permissions.PermissionsController
6+
7+ @Composable
8+ @Suppress(" FunctionNaming" )
9+ actual fun BindEffect (permissionsController : PermissionsController ) {
10+ LaunchedEffect (permissionsController) {
11+ permissionsController.bind()
12+ }
13+ }
Original file line number Diff line number Diff line change 1+ package dev.icerock.moko.permissions.compose
2+
3+ import androidx.compose.runtime.Composable
4+ import androidx.compose.runtime.remember
5+ import dev.icerock.moko.permissions.PermissionsController
6+ import dev.icerock.moko.permissions.PermissionsControllerImpl
7+
8+ @Composable
9+ actual fun rememberPermissionsControllerFactory (): PermissionsControllerFactory {
10+ return remember {
11+ PermissionsControllerFactory {
12+ PermissionsControllerImpl ()
13+ }
14+ }
15+ }
Original file line number Diff line number Diff line change @@ -14,6 +14,17 @@ android {
1414 namespace = " dev.icerock.moko.permissions.test"
1515}
1616
17+ kotlin {
18+ jvm(" desktop" )
19+
20+ sourceSets {
21+ val commonMain by getting
22+ val desktopMain by getting {
23+ dependsOn(commonMain)
24+ }
25+ }
26+ }
27+
1728dependencies {
1829 commonMainImplementation(libs.coroutines)
1930
Original file line number Diff line number Diff line change @@ -13,6 +13,17 @@ android {
1313 namespace = " dev.icerock.moko.permissions"
1414}
1515
16+ kotlin {
17+ jvm(" desktop" )
18+
19+ sourceSets {
20+ val commonMain by getting
21+ val desktopMain by getting {
22+ dependsOn(commonMain)
23+ }
24+ }
25+ }
26+
1627dependencies {
1728 commonMainImplementation(libs.coroutines)
1829 androidMainImplementation(libs.activity)
Original file line number Diff line number Diff line change 1+ package dev.icerock.moko.permissions
2+
3+ actual interface PermissionsController {
4+ /* *
5+ * Check is permission already granted and if not - request permission from user.
6+ *
7+ * @param permission what permission we want to provide
8+ *
9+ * @throws DeniedException if user decline request, but we can retry (only on Android)
10+ * @throws DeniedAlwaysException if user decline request and we can't show request again
11+ * (we should send user to settings)
12+ * @throws RequestCanceledException if user cancel request without response (only on Android)
13+ */
14+ actual suspend fun providePermission (permission : Permission )
15+
16+ /* *
17+ * @return true if permission already granted. In all other cases - false.
18+ */
19+ actual suspend fun isPermissionGranted (permission : Permission ): Boolean
20+
21+ /* *
22+ * Returns current state of permission. Can be suspended because on
23+ * Android detection of `Denied`/`NotDetermined` requires a bound FragmentManager.
24+ *
25+ * @param permission state of what permission we want
26+ *
27+ * @return current state. On Android can't be `DeniedAlways` (except push notifications).
28+ * On iOS can't be `Denied`.
29+ * @see PermissionState for a detailed description.
30+ */
31+ actual suspend fun getPermissionState (permission : Permission ): PermissionState
32+
33+ /* *
34+ * Open system UI of application settings to change permissions state
35+ */
36+ actual fun openAppSettings ()
37+
38+ fun bind ()
39+ }
Original file line number Diff line number Diff line change 1+ package dev.icerock.moko.permissions
2+
3+ class PermissionsControllerImpl : PermissionsController {
4+ override suspend fun providePermission (permission : Permission ) {
5+ // TODO("Not yet implemented")
6+ }
7+
8+ override suspend fun isPermissionGranted (permission : Permission ): Boolean {
9+ return true
10+ // TODO("Not yet implemented")
11+ }
12+
13+ override suspend fun getPermissionState (permission : Permission ): PermissionState {
14+ return PermissionState .Granted
15+ // TODO("Not yet implemented")
16+ }
17+
18+ override fun openAppSettings () {
19+ // TODO("Not yet implemented")
20+ }
21+
22+ override fun bind () {
23+ // TODO("Not yet implemented")
24+ }
25+ }
You can’t perform that action at this time.
0 commit comments