From c54471b5e0e4a1f9727cb5da4c6d5f7228075eb8 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 26 Jan 2023 16:32:10 +0100 Subject: [PATCH] Add some aliases and fixes placeholder color. --- .../roomlist/components/RoomSummaryRow.kt | 31 ++++++++++++++----- .../designsystem/theme/ColorAliases.kt | 29 +++++++++++++++++ 2 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ColorAliases.kt diff --git a/features/roomlist/src/main/kotlin/io/element/android/features/roomlist/components/RoomSummaryRow.kt b/features/roomlist/src/main/kotlin/io/element/android/features/roomlist/components/RoomSummaryRow.kt index 05494f95c3..9693d17a26 100644 --- a/features/roomlist/src/main/kotlin/io/element/android/features/roomlist/components/RoomSummaryRow.kt +++ b/features/roomlist/src/main/kotlin/io/element/android/features/roomlist/components/RoomSummaryRow.kt @@ -54,6 +54,11 @@ import com.google.accompanist.placeholder.material.placeholder import io.element.android.features.roomlist.model.RoomListRoomSummary import io.element.android.libraries.designsystem.components.avatar.Avatar import io.element.android.libraries.designsystem.theme.ElementTheme +import io.element.android.libraries.designsystem.theme.roomListPlaceHolder +import io.element.android.libraries.designsystem.theme.roomListRoomMessage +import io.element.android.libraries.designsystem.theme.roomListRoomMessageDate +import io.element.android.libraries.designsystem.theme.roomListRoomName +import io.element.android.libraries.designsystem.theme.roomListUnreadIndicator private val minHeight = 72.dp @@ -95,7 +100,11 @@ internal fun DefaultRoomSummaryRow( ) { Avatar( room.avatarData, - modifier = Modifier.placeholder(room.isPlaceholder, shape = CircleShape) + modifier = Modifier.placeholder( + visible = room.isPlaceholder, + shape = CircleShape, + color = ElementTheme.colors.roomListPlaceHolder, + ) ) Column( modifier = Modifier @@ -105,19 +114,27 @@ internal fun DefaultRoomSummaryRow( ) { // Name Text( - modifier = Modifier - .placeholder(room.isPlaceholder, shape = TextPlaceholderShape), + modifier = Modifier.placeholder( + visible = room.isPlaceholder, + shape = TextPlaceholderShape, + color = ElementTheme.colors.roomListPlaceHolder, + ), fontSize = 16.sp, fontWeight = FontWeight.SemiBold, text = room.name, + color = ElementTheme.colors.roomListRoomName, maxLines = 1, overflow = TextOverflow.Ellipsis ) // Last Message Text( - modifier = Modifier.placeholder(room.isPlaceholder, shape = TextPlaceholderShape), + modifier = Modifier.placeholder( + visible = room.isPlaceholder, + shape = TextPlaceholderShape, + color = ElementTheme.colors.roomListPlaceHolder, + ), text = room.lastMessage?.toString().orEmpty(), - color = ElementTheme.colors.secondary, + color = ElementTheme.colors.roomListRoomMessage, fontSize = 14.sp, maxLines = 1, overflow = TextOverflow.Ellipsis @@ -132,11 +149,11 @@ internal fun DefaultRoomSummaryRow( modifier = Modifier.placeholder(room.isPlaceholder, shape = TextPlaceholderShape), fontSize = 12.sp, text = room.timestamp ?: "", - color = ElementTheme.colors.secondary, + color = ElementTheme.colors.roomListRoomMessageDate, ) Spacer(Modifier.size(4.dp)) val unreadIndicatorColor = - if (room.hasUnread) ElementTheme.colors.primary else Color.Transparent + if (room.hasUnread) ElementTheme.colors.roomListUnreadIndicator else Color.Transparent Box( modifier = Modifier .size(12.dp) diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ColorAliases.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ColorAliases.kt new file mode 100644 index 0000000000..1325211232 --- /dev/null +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/ColorAliases.kt @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2023 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.element.android.libraries.designsystem.theme + +import io.element.android.libraries.designsystem.SystemGrey4Dark +import io.element.android.libraries.designsystem.SystemGrey6Light + +/** + * Room list + */ +val ElementColors.roomListRoomName get() = primary +val ElementColors.roomListRoomMessage get() = secondary +val ElementColors.roomListRoomMessageDate get() = secondary +val ElementColors.roomListUnreadIndicator get() = primary +val ElementColors.roomListPlaceHolder get() = if (isLight) SystemGrey6Light else SystemGrey4Dark