mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Searching disables the filters (#2530)
This commit is contained in:
@@ -37,21 +37,21 @@ struct RoomListFilterView_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
private struct FilterToggleStyle: ToggleStyle {
|
||||
private func strokeColor(isOn: Bool) -> Color {
|
||||
isOn ? .compound.bgSubtleSecondary : .compound.borderInteractiveSecondary
|
||||
isOn ? .compound.bgActionPrimaryRest : .compound.borderInteractiveSecondary
|
||||
}
|
||||
|
||||
private func backgroundColor(isOn: Bool) -> Color {
|
||||
isOn ? .compound.bgSubtleSecondary : .compound.bgCanvasDefault
|
||||
isOn ? .compound.bgActionPrimaryRest : .compound.bgCanvasDefault
|
||||
}
|
||||
|
||||
private func foregroundColor(isOn: Bool) -> Color {
|
||||
isOn ? .compound.textPrimary : .compound.textSecondary
|
||||
isOn ? .compound.textOnSolidPrimary : .compound.textPrimary
|
||||
}
|
||||
|
||||
func makeBody(configuration: Configuration) -> some View {
|
||||
let shape = RoundedRectangle(cornerRadius: 20)
|
||||
configuration.label
|
||||
.font(.compound.bodyLGSemibold)
|
||||
.font(.compound.bodyLG)
|
||||
.foregroundColor(foregroundColor(isOn: configuration.isOn))
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.vertical, 8)
|
||||
|
||||
@@ -53,7 +53,7 @@ struct HomeScreenContent: View {
|
||||
.layoutPriority(1)
|
||||
}
|
||||
case .rooms:
|
||||
if context.viewState.shouldShowFilters {
|
||||
if context.viewState.areFiltersEnabled {
|
||||
// Showing empty views in pinned headers makes the room list spasm when reaching the top
|
||||
LazyVStack(spacing: 0, pinnedViews: [.sectionHeaders]) {
|
||||
Section {
|
||||
@@ -68,6 +68,7 @@ struct HomeScreenContent: View {
|
||||
.readFrame($topSectionFrame)
|
||||
}
|
||||
}
|
||||
.isSearching($context.isSearchFieldFocused)
|
||||
.searchable(text: $context.searchQuery)
|
||||
.compoundSearchField()
|
||||
.disableAutocorrection(true)
|
||||
@@ -76,6 +77,7 @@ struct HomeScreenContent: View {
|
||||
|
||||
LazyVStack(spacing: 0) {
|
||||
HomeScreenRoomList(context: context)
|
||||
.isSearching($context.isSearchFieldFocused)
|
||||
}
|
||||
.searchable(text: $context.searchQuery)
|
||||
.compoundSearchField()
|
||||
|
||||
@@ -17,17 +17,9 @@
|
||||
import SwiftUI
|
||||
|
||||
struct HomeScreenRoomList: View {
|
||||
@Environment(\.isSearching) var isSearchFieldFocused
|
||||
|
||||
@ObservedObject var context: HomeScreenViewModel.Context
|
||||
|
||||
var body: some View {
|
||||
filteredContent
|
||||
.onChange(of: isSearchFieldFocused) { context.isSearchFieldFocused = $0 }
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var filteredContent: some View {
|
||||
// Hide the room list when the search bar is focused but the query is empty
|
||||
// This works hand in hand with the room list service layer filtering and
|
||||
// avoids glitches when focusing the search bar
|
||||
|
||||
Reference in New Issue
Block a user