Skip to content

Commit

Permalink
Added permissionDeniedContent usage example in sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
onseok committed Dec 17, 2023
1 parent 0356f9d commit 92dd283
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
package com.preat.peekaboo.common

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Button
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.SnackbarHost
import androidx.compose.material.SnackbarHostState
Expand All @@ -32,11 +35,13 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.preat.peekaboo.common.component.CircularButton
import com.preat.peekaboo.common.component.InstagramCameraButton
import com.preat.peekaboo.common.icon.IconCached
import com.preat.peekaboo.common.icon.IconClose
import com.preat.peekaboo.common.icon.IconWarning
import com.preat.peekaboo.common.style.PeekabooTheme
import com.preat.peekaboo.image.picker.SelectionMode
import com.preat.peekaboo.image.picker.rememberImagePickerLauncher
Expand Down Expand Up @@ -131,6 +136,28 @@ fun App() {
}
showCamera = false
},
permissionDeniedContent = {
Column(
modifier =
Modifier
.fillMaxSize()
.background(color = MaterialTheme.colors.background),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
) {
Icon(
imageVector = IconWarning,
contentDescription = "Warning Icon",
tint = MaterialTheme.colors.onBackground,
)
Spacer(modifier = Modifier.height(16.dp))
Text(
text = "Please grant the camera permission!",
color = MaterialTheme.colors.onBackground,
textAlign = TextAlign.Center,
)
}
},
)
}
IconButton(
Expand All @@ -150,15 +177,18 @@ fun App() {
}
}
} else {
LazyRow(horizontalArrangement = Arrangement.spacedBy(4.dp)) {
LazyRow(
horizontalArrangement = Arrangement.spacedBy(8.dp),
contentPadding = PaddingValues(horizontal = 8.dp),
) {
items(images) { image ->
Image(
bitmap = image,
contentDescription = "Selected Image",
modifier =
Modifier
.size(100.dp)
.clip(CircleShape),
.size(200.dp)
.clip(shape = RoundedCornerShape(12.dp)),
contentScale = ContentScale.Crop,
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.preat.peekaboo.common.icon

import androidx.compose.material.icons.materialIcon
import androidx.compose.material.icons.materialPath

internal val IconWarning =
materialIcon(name = "Filled.Warning") {
materialPath {
moveTo(1.0f, 21.0f)
horizontalLineToRelative(22.0f)
lineTo(12.0f, 2.0f)
lineTo(1.0f, 21.0f)
close()
moveTo(13.0f, 18.0f)
horizontalLineToRelative(-2.0f)
verticalLineToRelative(-2.0f)
horizontalLineToRelative(2.0f)
verticalLineToRelative(2.0f)
close()
moveTo(13.0f, 14.0f)
horizontalLineToRelative(-2.0f)
verticalLineToRelative(-4.0f)
horizontalLineToRelative(2.0f)
verticalLineToRelative(4.0f)
close()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ object PeekabooColors {
val uiLightBlack = Color(25, 25, 28).copy(alpha = 0.7f)
val darkBackground = Color(0xFF19191C)
val darkOnBackground = Color(0xFFFFFFFF)
val primary = Color(0xFFE0E0E0)
val onPrimary = Color(0xFF000000)
val darkPrimary = Color(0xFF424242)
val darkOnPrimary = Color(0xFFFFFFFF)
}

@Suppress("FunctionName")
Expand All @@ -25,11 +29,15 @@ fun PeekabooTheme(content: @Composable () -> Unit) {
MaterialTheme.colors.copy(
background = PeekabooColors.darkBackground,
onBackground = PeekabooColors.darkOnBackground,
primary = PeekabooColors.darkPrimary,
onPrimary = PeekabooColors.darkOnPrimary,
)
} else {
MaterialTheme.colors.copy(
background = PeekabooColors.background,
onBackground = PeekabooColors.onBackground,
primary = PeekabooColors.primary,
onPrimary = PeekabooColors.onPrimary,
)
}

Expand Down

0 comments on commit 92dd283

Please sign in to comment.