Ukryj galerie wedlug ustawien

This commit is contained in:
admin
2026-06-30 21:52:29 +02:00
parent 2531ff2b9f
commit 18baec5020
4 changed files with 10 additions and 4 deletions
@@ -40,6 +40,7 @@ data class DriverAppSettingsDto(
val selectedDate: String,
val maxPastDays: Int,
val autoRefreshSeconds: Int,
val allowGalleryUploads: Boolean?,
)
data class DriverSessionDto(
@@ -603,7 +603,7 @@ private fun DetailScreen(
item {
Text("Zdjecia ladunku", style = MaterialTheme.typography.titleLarge, fontWeight = FontWeight.Bold)
Spacer(Modifier.height(12.dp))
PhotoGrid(route.photos, state.imageAuthHeader, onPhoto, onCamera = {
PhotoGrid(route.photos, state.imageAuthHeader, state.allowGalleryUploads, onPhoto, onCamera = {
val newUri = createCameraUri(context)
cameraUri = newUri
if (ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
@@ -637,6 +637,7 @@ private fun ManifestSection(route: DriverRouteDto) {
private fun PhotoGrid(
photos: List<RoutePhotoDto>,
imageAuthHeader: String?,
allowGalleryUploads: Boolean,
onPhoto: (RoutePhotoDto) -> Unit,
onCamera: () -> Unit,
onGallery: () -> Unit,
@@ -648,7 +649,9 @@ private fun PhotoGrid(
horizontalArrangement = Arrangement.spacedBy(12.dp),
) {
item { ActionTile("Aparat", Icons.Outlined.CameraAlt, onCamera) }
item { ActionTile("Galeria", Icons.Outlined.AddPhotoAlternate, onGallery) }
if (allowGalleryUploads) {
item { ActionTile("Galeria", Icons.Outlined.AddPhotoAlternate, onGallery) }
}
items(photos, key = { it.id }) { photo ->
AsyncImage(
model = imageRequest(photo.url, imageAuthHeader),
@@ -29,6 +29,7 @@ data class DriverUiState(
val minRouteDate: String = LocalDate.now().minusDays(7).toString(),
val maxRouteDate: String = LocalDate.now().plusDays(1).toString(),
val autoRefreshSeconds: Int = 60,
val allowGalleryUploads: Boolean = true,
val selectedRoute: DriverRouteDto? = null,
val selectedPhoto: RoutePhotoDto? = null,
val imageAuthHeader: String? = null,
@@ -91,6 +92,7 @@ class DriverViewModel(application: Application) : AndroidViewModel(application)
minRouteDate = settings?.minDate ?: it.minRouteDate,
maxRouteDate = settings?.maxDate ?: it.maxRouteDate,
autoRefreshSeconds = settings?.autoRefreshSeconds ?: it.autoRefreshSeconds,
allowGalleryUploads = settings?.allowGalleryUploads ?: it.allowGalleryUploads,
imageAuthHeader = repository.imageAuthHeader(),
error = null,
)