Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class ObjectTypeFragment : BaseComposeFragment() {
isPinned = menuState.isPinned,
canDelete = menuState.canDelete,
isDescriptionFeatured = menuState.isDescriptionFeatured,
canEditDetails = menuState.canEditDetails,
onEvent = vm::onMenuEvent
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ fun ObjectTypeMenu(
isPinned: Boolean,
canDelete: Boolean,
isDescriptionFeatured: Boolean,
canEditDetails: Boolean,
onEvent: (ObjectTypeMenuEvent) -> Unit
) {
val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
Expand Down Expand Up @@ -84,24 +85,26 @@ fun ObjectTypeMenu(
onClick = { onEvent(ObjectTypeMenuEvent.OnIconClick) }
)

Divider(paddingStart = 20.dp, paddingEnd = 20.dp)

// Description cell
MenuCell(
iconRes = R.drawable.ic_obj_settings_description_24,
title = stringResource(R.string.description),
trailingContent = {
Text(
text = if (isDescriptionFeatured)
stringResource(R.string.modal_hide)
else
stringResource(R.string.show),
style = PreviewTitle1Regular,
color = colorResource(R.color.text_secondary)
)
},
onClick = { onEvent(ObjectTypeMenuEvent.OnDescriptionClick) }
)
if (canEditDetails) {
Divider(paddingStart = 20.dp, paddingEnd = 20.dp)

// Description cell
MenuCell(
iconRes = R.drawable.ic_obj_settings_description_24,
title = stringResource(R.string.description),
trailingContent = {
Text(
text = if (isDescriptionFeatured)
stringResource(R.string.modal_hide)
else
stringResource(R.string.show),
style = PreviewTitle1Regular,
color = colorResource(R.color.text_secondary)
)
},
onClick = { onEvent(ObjectTypeMenuEvent.OnDescriptionClick) }
)
}

// Divider before bottom section
Box(
Expand Down Expand Up @@ -223,6 +226,7 @@ fun ObjectTypeMenuPreview() {
isPinned = false,
canDelete = true,
isDescriptionFeatured = false,
canEditDetails = true,
onEvent = {}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ data class UiObjectTypeMenuState(
val isPinned: Boolean = false,
val canDelete: Boolean = true,
val icon: ObjectIcon = ObjectIcon.None,
val isDescriptionFeatured: Boolean = false
val isDescriptionFeatured: Boolean = false,
val canEditDetails: Boolean = true
) {
companion object {
val Hidden = UiObjectTypeMenuState(isVisible = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,8 @@ class ObjectTypeViewModel(
icon = uiIconState.value.icon,
isPinned = pinnedWidgetBlockId.value != null,
canDelete = _objectTypePermissionsState.value?.canDelete ?: false,
isDescriptionFeatured = _isDescriptionFeatured.value
isDescriptionFeatured = _isDescriptionFeatured.value,
canEditDetails = _objectTypePermissionsState.value?.canEditDetails ?: false
)
}
}
Expand Down Expand Up @@ -793,7 +794,7 @@ class ObjectTypeViewModel(

uiDescriptionState.value = UiDescriptionState(
description = descriptionText,
isVisible = isDescriptionFeatured,
isVisible = isDescriptionFeatured && objectPermissions.canEditDetails,
isEditable = objectPermissions.canEditDetails
)
}
Expand Down