Animate various room list components

This commit is contained in:
Stefan Ceriu
2023-01-04 13:23:59 +02:00
committed by Stefan Ceriu
parent 9926cd363c
commit 1b83d77c78
@@ -48,16 +48,18 @@ struct HomeScreenRoomCell: View {
.foregroundColor(.element.primaryContent) .foregroundColor(.element.primaryContent)
.lineLimit(1) .lineLimit(1)
if let lastMessage = room.lastMessage { if let lastMessage = room.lastMessage, !String(lastMessage.characters).isEmpty {
Text(lastMessage) Text(lastMessage)
.font(lastMessageFont) .font(lastMessageFont)
.foregroundColor(lastMessageForegroundColor) .foregroundColor(lastMessageForegroundColor)
.lineLimit(2) .lineLimit(2)
.multilineTextAlignment(.leading) .multilineTextAlignment(.leading)
.padding(.top, 2) .padding(.top, 2)
.animation(nil, value: UUID()) // Text animations look ugly .id(lastMessage)
.transition(.opacity.animation(.elementDefault))
} }
} }
.animation(.elementDefault, value: room)
Spacer() Spacer()
@@ -66,6 +68,8 @@ struct HomeScreenRoomCell: View {
Text(timestamp) Text(timestamp)
.font(.element.caption1) .font(.element.caption1)
.foregroundColor(.element.secondaryContent) .foregroundColor(.element.secondaryContent)
.id(timestamp)
.transition(.opacity.animation(.elementDefault))
} }
if room.hasUnreads { if room.hasUnreads {
@@ -73,8 +77,10 @@ struct HomeScreenRoomCell: View {
.frame(width: 12, height: 12) .frame(width: 12, height: 12)
.foregroundColor(.element.primaryContent) .foregroundColor(.element.primaryContent)
.clipShape(Circle()) .clipShape(Circle())
.transition(.opacity.animation(.elementDefault))
} }
} }
.animation(.elementDefault, value: room)
} }
} }
.frame(minHeight: 64.0) .frame(minHeight: 64.0)