From 1b83d77c7819c43a473e28176601f2e2c33ef85b Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Wed, 4 Jan 2023 13:23:59 +0200 Subject: [PATCH] Animate various room list components --- .../Screens/HomeScreen/View/HomeScreenRoomCell.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift index d9bbe6512..b3bec4450 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenRoomCell.swift @@ -48,16 +48,18 @@ struct HomeScreenRoomCell: View { .foregroundColor(.element.primaryContent) .lineLimit(1) - if let lastMessage = room.lastMessage { + if let lastMessage = room.lastMessage, !String(lastMessage.characters).isEmpty { Text(lastMessage) .font(lastMessageFont) .foregroundColor(lastMessageForegroundColor) .lineLimit(2) .multilineTextAlignment(.leading) .padding(.top, 2) - .animation(nil, value: UUID()) // Text animations look ugly + .id(lastMessage) + .transition(.opacity.animation(.elementDefault)) } } + .animation(.elementDefault, value: room) Spacer() @@ -66,6 +68,8 @@ struct HomeScreenRoomCell: View { Text(timestamp) .font(.element.caption1) .foregroundColor(.element.secondaryContent) + .id(timestamp) + .transition(.opacity.animation(.elementDefault)) } if room.hasUnreads { @@ -73,8 +77,10 @@ struct HomeScreenRoomCell: View { .frame(width: 12, height: 12) .foregroundColor(.element.primaryContent) .clipShape(Circle()) + .transition(.opacity.animation(.elementDefault)) } } + .animation(.elementDefault, value: room) } } .frame(minHeight: 64.0)