Add a search bar to the space filters screen
This commit is contained in:
committed by
Stefan Ceriu
parent
fdcf14f282
commit
15ff4e497b
@@ -15,9 +15,22 @@ enum ChatsSpaceFiltersScreenViewModelAction {
|
||||
struct ChatsSpaceFiltersScreenViewState: BindableState {
|
||||
var filters = [SpaceServiceFilter]()
|
||||
var bindings: ChatsSpaceFiltersScreenViewStateBindings
|
||||
|
||||
var visibleFilters: [SpaceServiceFilter] {
|
||||
if bindings.searchQuery.isEmpty {
|
||||
return filters
|
||||
}
|
||||
|
||||
return filters.filter { filter in
|
||||
filter.room.name.localizedStandardContains(bindings.searchQuery) ||
|
||||
(filter.room.canonicalAlias ?? "").localizedStandardContains(bindings.searchQuery)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ChatsSpaceFiltersScreenViewStateBindings { }
|
||||
struct ChatsSpaceFiltersScreenViewStateBindings {
|
||||
var searchQuery = ""
|
||||
}
|
||||
|
||||
enum ChatsSpaceFiltersScreenViewAction: CustomStringConvertible {
|
||||
case confirm(SpaceServiceFilter)
|
||||
|
||||
@@ -15,13 +15,16 @@ struct ChatsSpaceFiltersScreen: View {
|
||||
NavigationStack {
|
||||
ScrollView {
|
||||
LazyVStack(spacing: 0) {
|
||||
ForEach(context.viewState.filters) { filter in
|
||||
ForEach(context.viewState.visibleFilters) { filter in
|
||||
ChatsSpaceFilterCell(filter: filter,
|
||||
mediaProvider: context.mediaProvider) { filter in
|
||||
context.send(viewAction: .confirm(filter))
|
||||
}
|
||||
}
|
||||
}
|
||||
.searchable(text: $context.searchQuery, placement: .navigationBarDrawer)
|
||||
.focusSearchIfHardwareKeyboardAvailable()
|
||||
.compoundSearchField()
|
||||
}
|
||||
.toolbar { toolbar }
|
||||
.navigationTitle(L10n.screenRoomlistYourSpaces)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e28fb24e8a9087f8e951ed8c18ab9048cfacd72fcb2c328ddf3e46169306a1b6
|
||||
size 100972
|
||||
oid sha256:fae14c3a25602d5220c0e36439b408999fda970f1e27cbf1b4a6ff57ecac5b6e
|
||||
size 100370
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e28fb24e8a9087f8e951ed8c18ab9048cfacd72fcb2c328ddf3e46169306a1b6
|
||||
size 100972
|
||||
oid sha256:a250e7aedfcca3264b58fc4227d680d23ba37cbbe4dbfbbbbef09e36bf136f23
|
||||
size 101326
|
||||
|
||||
Reference in New Issue
Block a user