Give the id to AvatarData to be able to compute initial properly.
This commit is contained in:
parent
b439109d05
commit
443076f636
19 changed files with 76 additions and 61 deletions
|
|
@ -67,7 +67,8 @@ class MessagesPresenter @Inject constructor(
|
|||
LaunchedEffect(syncUpdateFlow) {
|
||||
roomAvatar.value =
|
||||
AvatarData(
|
||||
name = room.bestName,
|
||||
id = room.roomId.value,
|
||||
name = room.name,
|
||||
url = room.avatarUrl,
|
||||
size = AvatarSize.SMALL
|
||||
)
|
||||
|
|
|
|||
|
|
@ -21,18 +21,7 @@
|
|||
|
||||
package io.element.android.features.messages
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.imePadding
|
||||
import androidx.compose.foundation.layout.navigationBarsPadding
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.statusBars
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.wrapContentHeight
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material.ModalBottomSheetValue
|
||||
import androidx.compose.material.icons.Icons
|
||||
|
|
@ -68,11 +57,7 @@ import io.element.android.libraries.designsystem.components.avatar.Avatar
|
|||
import io.element.android.libraries.designsystem.components.avatar.AvatarData
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreviewDark
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreviewLight
|
||||
import io.element.android.libraries.designsystem.theme.components.Icon
|
||||
import io.element.android.libraries.designsystem.theme.components.IconButton
|
||||
import io.element.android.libraries.designsystem.theme.components.Scaffold
|
||||
import io.element.android.libraries.designsystem.theme.components.Text
|
||||
import io.element.android.libraries.designsystem.theme.components.TopAppBar
|
||||
import io.element.android.libraries.designsystem.theme.components.*
|
||||
import io.element.android.libraries.designsystem.utils.LogCompositions
|
||||
import io.element.android.libraries.matrix.core.RoomId
|
||||
import io.element.android.libraries.textcomposer.MessageComposerMode
|
||||
|
|
@ -223,9 +208,9 @@ fun MessagesViewDarkPreview() = ElementPreviewDark { ContentToPreview() }
|
|||
private fun ContentToPreview() {
|
||||
MessagesView(
|
||||
MessagesState(
|
||||
roomId = RoomId(""),
|
||||
roomId = RoomId("!id"),
|
||||
roomName = "Room name",
|
||||
roomAvatar = AvatarData("Room name"),
|
||||
roomAvatar = AvatarData("!id", "Room name"),
|
||||
composerState = aMessageComposerState().copy(
|
||||
text = StableCharSequence("Hello"),
|
||||
isFullScreen = false,
|
||||
|
|
|
|||
|
|
@ -156,7 +156,8 @@ class TimelineItemsFactory @Inject constructor(
|
|||
val senderDisplayName = room.userDisplayName(currentSender).getOrNull()
|
||||
val senderAvatarUrl = room.userAvatarUrl(currentSender).getOrNull()
|
||||
val senderAvatarData = AvatarData(
|
||||
name = senderDisplayName ?: currentSender,
|
||||
id = currentSender,
|
||||
name = senderDisplayName,
|
||||
url = senderAvatarUrl,
|
||||
size = AvatarSize.SMALL
|
||||
)
|
||||
|
|
|
|||
|
|
@ -418,8 +418,8 @@ internal fun createMessageEvent(
|
|||
): TimelineItem.MessageEvent {
|
||||
return TimelineItem.MessageEvent(
|
||||
id = EventId(Math.random().toString()),
|
||||
senderId = "senderId",
|
||||
senderAvatar = AvatarData("sender"),
|
||||
senderId = "@senderId",
|
||||
senderAvatar = AvatarData("@senderId", "sender"),
|
||||
content = content,
|
||||
reactionsState = TimelineItemReactions(
|
||||
persistentListOf(
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ private fun aMessageEvent(
|
|||
id = AN_EVENT_ID,
|
||||
senderId = A_USER_ID.value,
|
||||
senderDisplayName = A_USER_NAME,
|
||||
senderAvatar = AvatarData(),
|
||||
senderAvatar = AvatarData(A_USER_ID.value, A_USER_NAME),
|
||||
content = content,
|
||||
sentTime = "",
|
||||
isMine = isMine,
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ private fun aMessageEvent(
|
|||
id = AN_EVENT_ID,
|
||||
senderId = A_USER_ID.value,
|
||||
senderDisplayName = A_USER_NAME,
|
||||
senderAvatar = AvatarData(),
|
||||
senderAvatar = AvatarData(A_USER_ID.value, A_USER_NAME),
|
||||
content = content,
|
||||
sentTime = "",
|
||||
isMine = isMine,
|
||||
|
|
|
|||
|
|
@ -20,12 +20,16 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import io.element.android.features.logout.LogoutPreferenceView
|
||||
import io.element.android.features.preferences.user.UserPreferences
|
||||
import io.element.android.features.rageshake.preferences.RageshakePreferencesView
|
||||
import io.element.android.libraries.architecture.Async
|
||||
import io.element.android.libraries.designsystem.components.preferences.PreferenceView
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreviewDark
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreviewLight
|
||||
import io.element.android.libraries.matrix.ui.components.MatrixUserPreviewParameterProvider
|
||||
import io.element.android.libraries.matrix.ui.model.MatrixUser
|
||||
import io.element.android.libraries.ui.strings.R as StringR
|
||||
|
||||
@Composable
|
||||
|
|
@ -55,13 +59,15 @@ fun PreferencesRootView(
|
|||
|
||||
@Preview
|
||||
@Composable
|
||||
fun PreferencesRootViewLightPreview() = ElementPreviewLight { ContentToPreview() }
|
||||
fun PreferencesRootViewLightPreview(@PreviewParameter(MatrixUserPreviewParameterProvider::class) matrixUser: MatrixUser) =
|
||||
ElementPreviewLight { ContentToPreview(matrixUser) }
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun PreferencesRootViewDarkPreview() = ElementPreviewDark { ContentToPreview() }
|
||||
fun PreferencesRootViewDarkPreview(@PreviewParameter(MatrixUserPreviewParameterProvider::class) matrixUser: MatrixUser) =
|
||||
ElementPreviewDark { ContentToPreview(matrixUser) }
|
||||
|
||||
@Composable
|
||||
private fun ContentToPreview() {
|
||||
PreferencesRootView(aPreferencesRootState())
|
||||
private fun ContentToPreview(matrixUser: MatrixUser) {
|
||||
PreferencesRootView(aPreferencesRootState().copy(myUser = Async.Success(matrixUser)))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,15 +16,8 @@
|
|||
|
||||
package io.element.android.features.roomlist
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import io.element.android.features.roomlist.model.RoomListEvents
|
||||
import io.element.android.features.roomlist.model.RoomListRoomSummary
|
||||
import io.element.android.features.roomlist.model.RoomListRoomSummaryPlaceholders
|
||||
|
|
@ -107,7 +100,8 @@ class RoomListPresenter @Inject constructor(
|
|||
val userDisplayName = client.loadUserDisplayName().getOrNull()
|
||||
val avatarData =
|
||||
AvatarData(
|
||||
name = userDisplayName ?: client.userId().value,
|
||||
id = client.userId().value,
|
||||
name = userDisplayName,
|
||||
url = userAvatarUrl,
|
||||
size = AvatarSize.SMALL
|
||||
)
|
||||
|
|
@ -136,6 +130,7 @@ class RoomListPresenter @Inject constructor(
|
|||
is RoomSummary.Empty -> RoomListRoomSummaryPlaceholders.create(roomSummary.identifier)
|
||||
is RoomSummary.Filled -> {
|
||||
val avatarData = AvatarData(
|
||||
id = roomSummary.identifier(),
|
||||
name = roomSummary.details.name,
|
||||
url = roomSummary.details.avatarURLString
|
||||
)
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ fun RoomListViewDarkPreview() = ElementPreviewDark { ContentToPreview() }
|
|||
private fun ContentToPreview() {
|
||||
RoomListView(
|
||||
aRoomListState().copy(
|
||||
matrixUser = MatrixUser(id = UserId("@id"), username = "User#1", avatarData = AvatarData("U")),
|
||||
matrixUser = MatrixUser(id = UserId("@id"), username = "User#1", avatarData = AvatarData("@id", "U")),
|
||||
roomList = stubbedRoomSummaries(),
|
||||
filter = "filter",
|
||||
)
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ fun DefaultRoomListTopBarDarkPreview() = ElementPreviewDark { DefaultRoomListTop
|
|||
@Composable
|
||||
private fun DefaultRoomListTopBarPreview() {
|
||||
DefaultRoomListTopBar(
|
||||
matrixUser = MatrixUser(UserId("id"), "Alice", AvatarData("Alice")),
|
||||
matrixUser = MatrixUser(UserId("@id"), "Alice", AvatarData("@id", "Alice")),
|
||||
scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior(rememberTopAppBarState()),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,6 @@ data class RoomListRoomSummary(
|
|||
val hasUnread: Boolean = false,
|
||||
val timestamp: String? = null,
|
||||
val lastMessage: CharSequence? = null,
|
||||
val avatarData: AvatarData = AvatarData(),
|
||||
val avatarData: AvatarData = AvatarData(id, name),
|
||||
val isPlaceholder: Boolean = false,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ object RoomListRoomSummaryPlaceholders {
|
|||
name = "Short name",
|
||||
timestamp = "hh:mm",
|
||||
lastMessage = "Last message for placeholder",
|
||||
avatarData = AvatarData("S")
|
||||
avatarData = AvatarData(id, "S")
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ internal fun stubbedRoomSummaries(): ImmutableList<RoomListRoomSummary> {
|
|||
hasUnread = true,
|
||||
timestamp = "14:18",
|
||||
lastMessage = "A very very very very long message which suites on two lines",
|
||||
avatarData = AvatarData("R"),
|
||||
avatarData = AvatarData("!id", "R"),
|
||||
id = "roomId"
|
||||
),
|
||||
RoomListRoomSummary(
|
||||
|
|
@ -35,7 +35,7 @@ internal fun stubbedRoomSummaries(): ImmutableList<RoomListRoomSummary> {
|
|||
hasUnread = false,
|
||||
timestamp = "14:16",
|
||||
lastMessage = "A short message",
|
||||
avatarData = AvatarData("Z"),
|
||||
avatarData = AvatarData("!id", "Z"),
|
||||
id = "roomId2"
|
||||
),
|
||||
RoomListRoomSummaryPlaceholders.create("roomId2")
|
||||
|
|
|
|||
|
|
@ -217,6 +217,6 @@ private val aRoomListRoomSummary = RoomListRoomSummary(
|
|||
hasUnread = true,
|
||||
timestamp = A_FORMATTED_DATE,
|
||||
lastMessage = A_MESSAGE,
|
||||
avatarData = AvatarData(name = A_ROOM_NAME),
|
||||
avatarData = AvatarData(id = A_ROOM_ID.value, name = A_ROOM_NAME),
|
||||
isPlaceholder = false,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue