Skip to content

Commit

Permalink
Merge pull request #63 from team-haribo/feature/62-get-permission
Browse files Browse the repository at this point in the history
🔀 :: (#62) - get permission
  • Loading branch information
diejdkll authored Feb 24, 2024
2 parents bee5ec2 + a7989a7 commit 28dd5da
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion feature/main/src/main/java/com/goms/main/MainScreen.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.goms.main

import android.util.Log
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 @@ -14,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 @@ -80,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 28dd5da

Please sign in to comment.