mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
Public room search tweaks (#2750)
- Remove the "Join" button. - Hide the extra bottom separator. - Show an empty search result. - Fix a bug where we would paginate and search simultaneously.
This commit is contained in:
parent
7b2168a540
commit
aaa8af2996
@ -93,6 +93,10 @@ class RoomDirectorySearchScreenViewModel: RoomDirectorySearchScreenViewModelType
|
||||
title: L10n.screenRoomDirectorySearchLoadingError,
|
||||
iconName: "xmark"))
|
||||
}
|
||||
|
||||
// Add a small delay to allow the rooms to be published,
|
||||
// otherwise you see the No Results text briefly.
|
||||
try? await Task.sleep(for: .milliseconds(50))
|
||||
state.isLoading = false
|
||||
}
|
||||
}
|
||||
|
@ -37,17 +37,10 @@ struct RoomDirectorySearchCell: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
if result.canBeJoined {
|
||||
ListRow(label: .avatar(title: result.name ?? result.alias ?? result.id,
|
||||
description: description,
|
||||
icon: avatar),
|
||||
details: .label(title: L10n.actionJoin, icon: EmptyView()),
|
||||
kind: .navigationLink(action: joinAction))
|
||||
} else {
|
||||
ListRow(label: .avatar(title: result.name ?? result.alias ?? result.id,
|
||||
description: description,
|
||||
icon: avatar), kind: .label)
|
||||
}
|
||||
ListRow(label: .avatar(title: result.name ?? result.alias ?? result.id,
|
||||
description: description,
|
||||
icon: avatar),
|
||||
kind: result.canBeJoined ? .navigationLink(action: joinAction) : .label)
|
||||
}
|
||||
|
||||
private var avatar: some View {
|
||||
@ -70,7 +63,7 @@ struct RoomDirectorySearchCell_Previews: PreviewProvider, TestablePreview {
|
||||
name: "Test title",
|
||||
topic: "test description",
|
||||
avatarURL: nil,
|
||||
canBeJoined: false),
|
||||
canBeJoined: true),
|
||||
imageProvider: MockMediaProvider()) { }
|
||||
|
||||
RoomDirectorySearchCell(result: .init(id: "!test_id_2:matrix.org",
|
||||
@ -78,7 +71,7 @@ struct RoomDirectorySearchCell_Previews: PreviewProvider, TestablePreview {
|
||||
name: nil,
|
||||
topic: "test description",
|
||||
avatarURL: nil,
|
||||
canBeJoined: false),
|
||||
canBeJoined: true),
|
||||
imageProvider: MockMediaProvider()) { }
|
||||
|
||||
RoomDirectorySearchCell(result: .init(id: "!test_id_3:example.com",
|
||||
@ -86,7 +79,7 @@ struct RoomDirectorySearchCell_Previews: PreviewProvider, TestablePreview {
|
||||
name: "Test title no topic",
|
||||
topic: nil,
|
||||
avatarURL: nil,
|
||||
canBeJoined: false),
|
||||
canBeJoined: true),
|
||||
imageProvider: MockMediaProvider()) { }
|
||||
|
||||
RoomDirectorySearchCell(result: .init(id: "!test_id_4:example.com",
|
||||
@ -94,7 +87,7 @@ struct RoomDirectorySearchCell_Previews: PreviewProvider, TestablePreview {
|
||||
name: nil,
|
||||
topic: nil,
|
||||
avatarURL: nil,
|
||||
canBeJoined: false),
|
||||
canBeJoined: true),
|
||||
imageProvider: MockMediaProvider()) { }
|
||||
|
||||
RoomDirectorySearchCell(result: .init(id: "!test_id_5:example.com",
|
||||
@ -129,5 +122,6 @@ struct RoomDirectorySearchCell_Previews: PreviewProvider, TestablePreview {
|
||||
canBeJoined: false),
|
||||
imageProvider: MockMediaProvider()) { }
|
||||
}
|
||||
.compoundList()
|
||||
}
|
||||
}
|
||||
|
@ -34,13 +34,22 @@ struct RoomDirectorySearchScreen: View {
|
||||
if context.viewState.isLoading {
|
||||
ProgressView()
|
||||
.frame(maxWidth: .infinity)
|
||||
} else if context.viewState.rooms.isEmpty {
|
||||
Text(L10n.commonNoResults)
|
||||
.font(.compound.bodyLG)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
.frame(maxWidth: .infinity)
|
||||
.accessibilityIdentifier(A11yIdentifiers.startChatScreen.searchNoResults)
|
||||
} else {
|
||||
// This needs to be in the else as when you start a search, the results are cleared making the footer visible.
|
||||
// We only want to trigger the pagination when the state is not loading.
|
||||
emptyRectangle
|
||||
.onAppear {
|
||||
context.send(viewAction: .reachedBottom)
|
||||
}
|
||||
}
|
||||
|
||||
emptyRectangle
|
||||
.onAppear {
|
||||
context.send(viewAction: .reachedBottom)
|
||||
}
|
||||
}
|
||||
.listRowSeparator(.hidden)
|
||||
}
|
||||
}
|
||||
.listStyle(.plain)
|
||||
@ -70,7 +79,7 @@ struct RoomDirectorySearchScreen: View {
|
||||
|
||||
// MARK: - Previews
|
||||
|
||||
struct RoomDirectorySearchScreenScreen_Previews: PreviewProvider, TestablePreview {
|
||||
struct RoomDirectorySearchScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel: RoomDirectorySearchScreenViewModel = {
|
||||
let results = [RoomDirectorySearchResult(id: "test_1",
|
||||
alias: "#test_1:example.com",
|
||||
|
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchCell-iPad-en-GB.1.png
(Stored with Git LFS)
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchCell-iPad-en-GB.1.png
(Stored with Git LFS)
Binary file not shown.
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchCell-iPad-pseudo.1.png
(Stored with Git LFS)
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchCell-iPad-pseudo.1.png
(Stored with Git LFS)
Binary file not shown.
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchCell-iPhone-15-en-GB.1.png
(Stored with Git LFS)
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchCell-iPhone-15-en-GB.1.png
(Stored with Git LFS)
Binary file not shown.
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchCell-iPhone-15-pseudo.1.png
(Stored with Git LFS)
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchCell-iPhone-15-pseudo.1.png
(Stored with Git LFS)
Binary file not shown.
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchScreen-iPad-en-GB.1.png
(Stored with Git LFS)
Normal file
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchScreen-iPad-en-GB.1.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchScreen-iPad-pseudo.1.png
(Stored with Git LFS)
Normal file
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchScreen-iPad-pseudo.1.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchScreen-iPhone-15-en-GB.1.png
(Stored with Git LFS)
Normal file
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchScreen-iPhone-15-en-GB.1.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchScreen-iPhone-15-pseudo.1.png
(Stored with Git LFS)
Normal file
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchScreen-iPhone-15-pseudo.1.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchScreenScreen-iPad-en-GB.1.png
(Stored with Git LFS)
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchScreenScreen-iPad-en-GB.1.png
(Stored with Git LFS)
Binary file not shown.
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchScreenScreen-iPad-pseudo.1.png
(Stored with Git LFS)
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchScreenScreen-iPad-pseudo.1.png
(Stored with Git LFS)
Binary file not shown.
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchScreenScreen-iPhone-15-en-GB.1.png
(Stored with Git LFS)
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchScreenScreen-iPhone-15-en-GB.1.png
(Stored with Git LFS)
Binary file not shown.
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchScreenScreen-iPhone-15-pseudo.1.png
(Stored with Git LFS)
BIN
PreviewTests/__Snapshots__/PreviewTests/test_roomDirectorySearchScreenScreen-iPhone-15-pseudo.1.png
(Stored with Git LFS)
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user