fixed search

This commit is contained in:
Mauro Romito
2025-09-15 10:33:11 +02:00
committed by Stefan Ceriu
parent 78c3ea9696
commit 699a42be95
4 changed files with 47 additions and 22 deletions
+1 -1
View File
@@ -9491,7 +9491,7 @@
repositoryURL = "https://github.com/element-hq/compound-ios"; repositoryURL = "https://github.com/element-hq/compound-ios";
requirement = { requirement = {
kind = revision; kind = revision;
revision = 07563f32203a0a8c3a660cc9fc7cd59cdebcc34f; revision = 92f99140d925e77f01f5ef72c1aeffe0b0e3d96a;
}; };
}; };
F76A08D0EA29A07A54F4EB4D /* XCRemoteSwiftPackageReference "swift-collections" */ = { F76A08D0EA29A07A54F4EB4D /* XCRemoteSwiftPackageReference "swift-collections" */ = {
@@ -15,7 +15,7 @@
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "https://github.com/element-hq/compound-ios", "location" : "https://github.com/element-hq/compound-ios",
"state" : { "state" : {
"revision" : "07563f32203a0a8c3a660cc9fc7cd59cdebcc34f" "revision" : "92f99140d925e77f01f5ef72c1aeffe0b0e3d96a"
} }
}, },
{ {
@@ -311,8 +311,8 @@
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "https://github.com/siteline/SwiftUI-Introspect", "location" : "https://github.com/siteline/SwiftUI-Introspect",
"state" : { "state" : {
"revision" : "807f73ce09a9b9723f12385e592b4e0aaebd3336", "revision" : "712db7f70540eb0d09d72a7a34c6fa6092c9a142",
"version" : "1.3.0" "version" : "26.0.0-rc.1"
} }
}, },
{ {
+42 -17
View File
@@ -7,7 +7,7 @@
import GameController import GameController
import SwiftUI import SwiftUI
import SwiftUIIntrospect @_spi(Advanced) import SwiftUIIntrospect
// MARK: - Search Controller Extensions // MARK: - Search Controller Extensions
@@ -52,24 +52,49 @@ private struct SearchControllerModifier: ViewModifier {
/// is `false`, checking if this value is `false` is pretty much meaningless. /// is `false`, checking if this value is `false` is pretty much meaningless.
@State private var isSearching = false @State private var isSearching = false
@ViewBuilder
func body(content: Content) -> some View { func body(content: Content) -> some View {
content let text: Text? = if let placeholder {
.interactiveDismissDisabled(!searchQuery.isEmpty && disablesInteractiveDismiss) Text(placeholder)
.background { } else {
SearchController(searchQuery: $searchQuery, nil
placeholder: placeholder, }
hidesNavigationBar: hidesNavigationBar,
showsCancelButton: showsCancelButton, if #available(iOS 26, *) {
hidesSearchBarWhenScrolling: false, content
accessibilityFocusOnStart: accessibilityFocusOnStart, .searchable(text: $searchQuery, placement: .navigationBarDrawer(displayMode: .always), prompt: text)
isSearching: $isSearching) .interactiveDismissDisabled(!searchQuery.isEmpty && disablesInteractiveDismiss)
} .introspect(.navigationStack, on: .supportedVersions, scope: .ancestor) { navigationController in
.onDisappear { // Uses the navigation stack as .searchField is unreliable when pushing the second search bar, during the create rooms flow.
// Dismiss search when the view disappears to tidy up appearance when popping back to the view. guard let searchController = navigationController.navigationBar.topItem?.searchController else { return }
if isSearching { searchController.automaticallyShowsCancelButton = showsCancelButton
isSearching = false searchController.hidesNavigationBarDuringPresentation = hidesNavigationBar
} }
} .onDisappear {
// Dismiss search when the view disappears to tidy up appearance when popping back to the view.
if isSearching {
isSearching = false
}
}
} else {
content
.interactiveDismissDisabled(!searchQuery.isEmpty && disablesInteractiveDismiss)
.background {
SearchController(searchQuery: $searchQuery,
placeholder: placeholder,
hidesNavigationBar: hidesNavigationBar,
showsCancelButton: showsCancelButton,
hidesSearchBarWhenScrolling: false,
accessibilityFocusOnStart: accessibilityFocusOnStart,
isSearching: $isSearching)
}
.onDisappear {
// Dismiss search when the view disappears to tidy up appearance when popping back to the view.
if isSearching {
isSearching = false
}
}
}
} }
} }
+1 -1
View File
@@ -72,7 +72,7 @@ packages:
# path: ../matrix-rust-sdk # path: ../matrix-rust-sdk
Compound: Compound:
url: https://github.com/element-hq/compound-ios url: https://github.com/element-hq/compound-ios
revision: 07563f32203a0a8c3a660cc9fc7cd59cdebcc34f revision: 92f99140d925e77f01f5ef72c1aeffe0b0e3d96a
# path: ../compound-ios # path: ../compound-ios
AnalyticsEvents: AnalyticsEvents:
url: https://github.com/matrix-org/matrix-analytics-events url: https://github.com/matrix-org/matrix-analytics-events