mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Tweaks discovered when using Compound overrides. (#4456)
- Fixes a bug where gradients wouldn't use the latest tokens after first use. - Makes the bloom aware of colour overrides (and discovers a bug with dark mode). - Decouples HomeScreenCell from the HomeScreenViewModel.Context (so it can be previewed with colour overrides).
This commit is contained in:
@@ -14,8 +14,9 @@ struct HomeScreenRoomCell: View {
|
||||
@Environment(\.redactionReasons) private var redactionReasons
|
||||
|
||||
let room: HomeScreenRoom
|
||||
let context: HomeScreenViewModel.Context
|
||||
let isSelected: Bool
|
||||
let mediaProvider: MediaProviderProtocol!
|
||||
let action: (HomeScreenViewAction) -> Void
|
||||
|
||||
private let verticalInsets = 12.0
|
||||
private let horizontalInsets = 16.0
|
||||
@@ -23,7 +24,7 @@ struct HomeScreenRoomCell: View {
|
||||
var body: some View {
|
||||
Button {
|
||||
if let roomID = room.roomID {
|
||||
context.send(viewAction: .selectRoom(roomIdentifier: roomID))
|
||||
action(.selectRoom(roomIdentifier: roomID))
|
||||
}
|
||||
} label: {
|
||||
HStack(spacing: 16.0) {
|
||||
@@ -51,7 +52,7 @@ struct HomeScreenRoomCell: View {
|
||||
if dynamicTypeSize < .accessibility3 {
|
||||
RoomAvatarImage(avatar: room.avatar,
|
||||
avatarSize: .room(on: .chats),
|
||||
mediaProvider: context.mediaProvider)
|
||||
mediaProvider: mediaProvider)
|
||||
.dynamicTypeSize(dynamicTypeSize < .accessibility1 ? dynamicTypeSize : .accessibility1)
|
||||
.accessibilityHidden(true)
|
||||
}
|
||||
@@ -167,27 +168,25 @@ private extension View {
|
||||
|
||||
struct HomeScreenRoomCell_Previews: PreviewProvider, TestablePreview {
|
||||
static let summaryProviderGeneric = RoomSummaryProviderMock(.init(state: .loaded(.mockRooms)))
|
||||
static let viewModelGeneric = makeViewModel(roomSummaryProvider: summaryProviderGeneric)
|
||||
static let genericRooms = summaryProviderGeneric.roomListPublisher.value.compactMap(mockRoom)
|
||||
|
||||
static let summaryProviderForNotificationsState = RoomSummaryProviderMock(.init(state: .loaded(.mockRoomsWithNotificationsState)))
|
||||
static let viewModelForNotificationsState = makeViewModel(roomSummaryProvider: summaryProviderForNotificationsState)
|
||||
static let notificationsStateRooms = summaryProviderForNotificationsState.roomListPublisher.value.compactMap(mockRoom)
|
||||
|
||||
static var previews: some View {
|
||||
VStack(spacing: 0) {
|
||||
ForEach(genericRooms) { room in
|
||||
HomeScreenRoomCell(room: room, context: viewModelGeneric.context, isSelected: false)
|
||||
HomeScreenRoomCell(room: room, isSelected: false, mediaProvider: MediaProviderMock(configuration: .init())) { _ in }
|
||||
}
|
||||
|
||||
HomeScreenRoomCell(room: .placeholder(), context: viewModelGeneric.context, isSelected: false)
|
||||
HomeScreenRoomCell(room: .placeholder(), isSelected: false, mediaProvider: MediaProviderMock(configuration: .init())) { _ in }
|
||||
.redacted(reason: .placeholder)
|
||||
}
|
||||
.previewDisplayName("Generic")
|
||||
|
||||
VStack(spacing: 0) {
|
||||
ForEach(notificationsStateRooms) { room in
|
||||
HomeScreenRoomCell(room: room, context: viewModelForNotificationsState.context, isSelected: false)
|
||||
HomeScreenRoomCell(room: room, isSelected: false, mediaProvider: MediaProviderMock(configuration: .init())) { _ in }
|
||||
}
|
||||
}
|
||||
.previewLayout(.sizeThatFits)
|
||||
|
||||
Reference in New Issue
Block a user