Update icon and text when a room is a favorite.

This commit is contained in:
Benoit Marty
2026-01-27 14:55:50 +01:00
parent fd9cc15763
commit 020484f605
3 changed files with 15 additions and 5 deletions

View File

@@ -131,16 +131,21 @@ private fun RoomListModalBottomSheetContent(
style = ListItemStyle.Primary,
)
}
val (textResId, icon) = if (contextMenu.isFavorite) {
CommonStrings.common_favourited to CompoundIcons.FavouriteSolid()
} else {
CommonStrings.common_favourite to CompoundIcons.Favourite()
}
ListItem(
headlineContent = {
Text(
text = stringResource(id = CommonStrings.common_favourite),
text = stringResource(id = textResId),
style = MaterialTheme.typography.bodyLarge,
)
},
leadingContent = ListItemContent.Icon(
iconSource = IconSource.Vector(
CompoundIcons.Favourite(),
icon,
)
),
trailingContent = ListItemContent.Switch(

View File

@@ -15,7 +15,7 @@ open class RoomListStateContextMenuShownProvider : PreviewParameterProvider<Room
override val values: Sequence<RoomListState.ContextMenu.Shown>
get() = sequenceOf(
aContextMenuShown(hasNewContent = true),
aContextMenuShown(isDm = true),
aContextMenuShown(isDm = true, isFavorite = true),
aContextMenuShown(roomName = null)
)
}

View File

@@ -589,9 +589,14 @@ private fun FavoriteItem(
isFavorite: Boolean,
onFavoriteChanges: (Boolean) -> Unit,
) {
val (textResId, icon) = if (isFavorite) {
CommonStrings.common_favourited to CompoundIcons.FavouriteSolid()
} else {
CommonStrings.common_favourite to CompoundIcons.Favourite()
}
PreferenceSwitch(
icon = CompoundIcons.Favourite(),
title = stringResource(id = CommonStrings.common_favourite),
icon = icon,
title = stringResource(id = textResId),
isChecked = isFavorite,
onCheckedChange = onFavoriteChanges
)