Skip to content

Commit

Permalink
✨ :: Ger permission to main
Browse files Browse the repository at this point in the history
  • Loading branch information
diejdkll committed Feb 23, 2024
1 parent 14db2ff commit a7989a7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions feature/main/src/main/java/com/goms/main/MainScreen.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.goms.main

import android.Manifest
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand All @@ -13,6 +16,9 @@ import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -79,6 +85,24 @@ fun MainScreen(
onQrcodeClick: () -> Unit,
mainCallBack: () -> Unit
) {
var isPermissionRequest by rememberSaveable { mutableStateOf(false) }

val permissionLauncher = rememberLauncherForActivityResult(
contract = ActivityResultContracts.RequestMultiplePermissions()
) { isGrantedMap: Map<String, Boolean> -> }

if (!isPermissionRequest) {
LaunchedEffect(true) {
permissionLauncher.launch(
arrayOf(
Manifest.permission.CAMERA,
Manifest.permission.POST_NOTIFICATIONS
)
)
isPermissionRequest = true
}
}

LaunchedEffect(true) {
mainCallBack()
}
Expand Down

0 comments on commit a7989a7

Please sign in to comment.