Add support for quick room search through the Cmd+K shortcut (#2363)

This commit is contained in:
Stefan Ceriu
2024-01-29 14:55:11 +02:00
committed by GitHub
parent c442afa5f6
commit 197b088662
28 changed files with 796 additions and 61 deletions
@@ -35,6 +35,7 @@ enum HomeScreenCoordinatorAction {
case presentSecureBackupSettings
case presentStartChatScreen
case presentInvitesScreen
case presentGlobalSearch
case logout
}
@@ -82,6 +83,8 @@ final class HomeScreenCoordinator: CoordinatorProtocol {
actionsSubject.send(.presentStartChatScreen)
case .presentInvitesScreen:
actionsSubject.send(.presentInvitesScreen)
case .presentGlobalSearch:
actionsSubject.send(.presentGlobalSearch)
}
}
.store(in: &cancellables)
@@ -28,6 +28,7 @@ enum HomeScreenViewModelAction {
case presentFeedbackScreen
case presentStartChatScreen
case presentInvitesScreen
case presentGlobalSearch
case logout
}
@@ -49,6 +50,7 @@ enum HomeScreenViewAction {
case skipRecoveryKeyConfirmation
case updateVisibleItemRange(range: Range<Int>, isScrolling: Bool)
case selectInvites
case globalSearch
}
enum HomeScreenRoomListMode: CustomStringConvertible {
@@ -141,6 +141,8 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
actionsSubject.send(.presentStartChatScreen)
case .selectInvites:
actionsSubject.send(.presentInvitesScreen)
case .globalSearch:
actionsSubject.send(.presentGlobalSearch)
}
}
@@ -94,6 +94,12 @@ struct HomeScreenContent: View {
.onChange(of: context.viewState.visibleRooms) { _ in
updateVisibleRange()
}
.background(
Button("", action: {
context.send(viewAction: .globalSearch)
})
.keyboardShortcut(KeyEquivalent("k"), modifiers: [.command])
)
.scrollDismissesKeyboard(.immediately)
.scrollDisabled(context.viewState.roomListMode == .skeletons)
.scrollBounceBehavior(context.viewState.roomListMode == .empty ? .basedOnSize : .automatic)