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:
Doug 2024-04-29 10:01:48 +01:00 committed by GitHub
parent 7b2168a540
commit aaa8af2996
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 48 additions and 41 deletions

View File

@ -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
}
}

View File

@ -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()
}
}

View File

@ -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",

Binary file not shown.