Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement onAllPermissionsGranted for rememberCallPermissionsState #1045

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ public final class io/getstream/video/android/compose/lifecycle/MediaPiPLifecycl
}

public final class io/getstream/video/android/compose/permission/CallPermissionsKt {
public static final fun LaunchCallPermissions (Lio/getstream/video/android/core/Call;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;II)V
public static final fun rememberCallPermissionsState (Lio/getstream/video/android/core/Call;Ljava/util/List;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;II)Lio/getstream/video/android/compose/permission/VideoPermissionsState;
public static final fun LaunchCallPermissions (Lio/getstream/video/android/core/Call;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;II)V
public static final fun rememberCallPermissionsState (Lio/getstream/video/android/core/Call;Ljava/util/List;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;II)Lio/getstream/video/android/compose/permission/VideoPermissionsState;
}

public final class io/getstream/video/android/compose/permission/ComposableSingletons$LaunchPermissionRequestKt {
Expand Down Expand Up @@ -929,7 +929,7 @@ public final class io/getstream/video/android/compose/ui/components/call/activec
}

public final class io/getstream/video/android/compose/ui/components/call/activecall/CallContentKt {
public static final fun CallContent (Lio/getstream/video/android/core/Call;Landroidx/compose/ui/Modifier;Lio/getstream/video/android/compose/ui/components/call/renderer/LayoutType;ZLio/getstream/video/android/compose/permission/VideoPermissionsState;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;Lio/getstream/video/android/compose/ui/components/call/renderer/VideoRendererStyle;Lkotlin/jvm/functions/Function6;Lkotlin/jvm/functions/Function5;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;ZLkotlin/jvm/functions/Function3;ZLandroidx/compose/runtime/Composer;III)V
public static final fun CallContent (Lio/getstream/video/android/core/Call;Landroidx/compose/ui/Modifier;Lio/getstream/video/android/compose/ui/components/call/renderer/LayoutType;Lio/getstream/video/android/compose/permission/VideoPermissionsState;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function3;Lio/getstream/video/android/compose/ui/components/call/renderer/VideoRendererStyle;Lkotlin/jvm/functions/Function6;Lkotlin/jvm/functions/Function5;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;ZLkotlin/jvm/functions/Function3;ZLandroidx/compose/runtime/Composer;III)V
}

public final class io/getstream/video/android/compose/ui/components/call/activecall/ComposableSingletons$AudioCallContentKt {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public fun rememberCallPermissionsState(
)
},
onPermissionsResult: ((Map<String, Boolean>) -> Unit)? = null,
onAllPermissionsGranted: (suspend () -> Unit)? = null,
): VideoPermissionsState {
if (LocalInspectionMode.current) return fakeVideoPermissionsState

Expand All @@ -70,6 +71,14 @@ public fun rememberCallPermissionsState(
}
}
}

val allPermissionsGranted = permissionState.allPermissionsGranted
LaunchedEffect(key1 = allPermissionsGranted) {
if (allPermissionsGranted) {
onAllPermissionsGranted?.invoke()
}
}

return remember(call, permissions) {
object : VideoPermissionsState {
override val allPermissionsGranted: Boolean
Expand All @@ -94,8 +103,13 @@ public fun rememberCallPermissionsState(
public fun LaunchCallPermissions(
call: Call,
onPermissionsResult: ((Map<String, Boolean>) -> Unit)? = null,
onAllPermissionsGranted: (suspend () -> Unit)? = null,
) {
val callPermissionsState =
rememberCallPermissionsState(call = call, onPermissionsResult = onPermissionsResult)
rememberCallPermissionsState(
call = call,
onPermissionsResult = onPermissionsResult,
onAllPermissionsGranted = onAllPermissionsGranted,
)
LaunchedEffect(key1 = call) { callPermissionsState.launchPermissionRequest() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ public fun CallContent(
call: Call,
modifier: Modifier = Modifier,
layout: LayoutType = LayoutType.DYNAMIC,
isShowingOverlayAppBar: Boolean = false,
permissions: VideoPermissionsState = rememberCallPermissionsState(call = call),
onBackPressed: () -> Unit = {},
onCallAction: (CallAction) -> Unit = { DefaultOnCallActionHandler.onCallAction(call, it) },
Expand Down
Loading