Skip to content

Commit

Permalink
fix: update image selector dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Balcan committed Jan 24, 2025
1 parent 757199b commit e173a5c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement.spacedBy
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.CameraAlt
import androidx.compose.material.icons.outlined.Collections
import androidx.compose.material.icons.outlined.Image
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import org.dhis2.form.R
import org.hisp.dhis.mobile.ui.designsystem.component.BottomSheetShell
import org.hisp.dhis.mobile.ui.designsystem.theme.Spacing
import org.hisp.dhis.mobile.ui.designsystem.component.ButtonCarousel
import org.hisp.dhis.mobile.ui.designsystem.component.CarouselButtonData
import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor
import org.hisp.dhis.mobile.ui.designsystem.theme.TextColor

@Composable
internal fun ImagePickerOptionsDialog(
title: String,
showImageOptions: Boolean,
onDismiss: () -> Unit,
onTakePicture: (Context) -> Unit,
Expand All @@ -35,44 +35,49 @@ internal fun ImagePickerOptionsDialog(
exit = slideOutVertically() + fadeOut(),
) {
BottomSheetShell(
title = stringResource(R.string.select_option),
title = title,
icon = {
Icon(Icons.Outlined.Image, contentDescription = null, tint = SurfaceColor.Primary)
},
onDismiss = onDismiss,
content = {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(
horizontal = Spacing.Spacing16,
vertical = Spacing.Spacing24,
),
verticalArrangement = spacedBy(Spacing.Spacing16),
) {
val context = LocalContext.current
Box(
modifier = Modifier
.fillMaxWidth()
.clickable {
buttonBlock = {
val context = LocalContext.current
ButtonCarousel(
carouselButtonList = listOf(
CarouselButtonData(
onClick = {
onDismiss()
onTakePicture(context)
},
contentAlignment = Alignment.CenterStart,
) {
Text(stringResource(R.string.take_photo))
}

Box(
modifier = Modifier
.fillMaxWidth()
.clickable {
enabled = true,
text = stringResource(R.string.take_photo),
icon = {
Icon(
Icons.Outlined.CameraAlt,
contentDescription = null,
tint = TextColor.OnSurface,
)
},
),
CarouselButtonData(
onClick = {
onDismiss()
onSelectFromGallery()
onTakePicture(context)
},
contentAlignment = Alignment.CenterStart,
) {
Text(stringResource(R.string.from_gallery))
}
}
enabled = true,
text = stringResource(R.string.from_gallery_v2),
icon = {
Icon(
Icons.Outlined.Collections,
contentDescription = null,
tint = TextColor.OnSurface,
)
},
),
),
)
},
content = null,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ internal fun ProvideInputImage(
)

ImagePickerOptionsDialog(
title = fieldUiModel.label,
showImageOptions = showImageOptions,
onDismiss = { showImageOptions = false },
onTakePicture = { context ->
Expand Down
2 changes: 1 addition & 1 deletion form/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<string name="copied_text">Copied</string>
<string name="empty_description">No info for this field</string>
<string name="take_photo">Take Photo</string>
<string name="from_gallery">Choose from gallery</string>
<string name="from_gallery_v2">From gallery</string>
<string name="warning_error_on_complete_title">Check this!</string>
<string name="action_do_not_show_again">Do not show again</string>
<string name="validation_error_message">the provided value is not allowed for this field</string>
Expand Down

0 comments on commit e173a5c

Please sign in to comment.