fixed search

This commit is contained in:
Mauro Romito
2025-09-15 10:33:11 +02:00
committed by Stefan Ceriu
parent dbe5bb35b4
commit ea4c003741
4 changed files with 47 additions and 22 deletions

View File

@@ -9491,7 +9491,7 @@
repositoryURL = "https://github.com/element-hq/compound-ios";
requirement = {
kind = revision;
revision = 07563f32203a0a8c3a660cc9fc7cd59cdebcc34f;
revision = 92f99140d925e77f01f5ef72c1aeffe0b0e3d96a;
};
};
F76A08D0EA29A07A54F4EB4D /* XCRemoteSwiftPackageReference "swift-collections" */ = {

View File

@@ -15,7 +15,7 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/element-hq/compound-ios",
"state" : {
"revision" : "07563f32203a0a8c3a660cc9fc7cd59cdebcc34f"
"revision" : "92f99140d925e77f01f5ef72c1aeffe0b0e3d96a"
}
},
{
@@ -311,8 +311,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/siteline/SwiftUI-Introspect",
"state" : {
"revision" : "807f73ce09a9b9723f12385e592b4e0aaebd3336",
"version" : "1.3.0"
"revision" : "712db7f70540eb0d09d72a7a34c6fa6092c9a142",
"version" : "26.0.0-rc.1"
}
},
{

View File

@@ -7,7 +7,7 @@
import GameController
import SwiftUI
import SwiftUIIntrospect
@_spi(Advanced) import SwiftUIIntrospect
// MARK: - Search Controller Extensions
@@ -52,24 +52,49 @@ private struct SearchControllerModifier: ViewModifier {
/// is `false`, checking if this value is `false` is pretty much meaningless.
@State private var isSearching = false
@ViewBuilder
func body(content: Content) -> some View {
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
let text: Text? = if let placeholder {
Text(placeholder)
} else {
nil
}
if #available(iOS 26, *) {
content
.searchable(text: $searchQuery, placement: .navigationBarDrawer(displayMode: .always), prompt: text)
.interactiveDismissDisabled(!searchQuery.isEmpty && disablesInteractiveDismiss)
.introspect(.navigationStack, on: .supportedVersions, scope: .ancestor) { navigationController in
// Uses the navigation stack as .searchField is unreliable when pushing the second search bar, during the create rooms flow.
guard let searchController = navigationController.navigationBar.topItem?.searchController else { return }
searchController.automaticallyShowsCancelButton = showsCancelButton
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
}
}
}
}
}

View File

@@ -72,7 +72,7 @@ packages:
# path: ../matrix-rust-sdk
Compound:
url: https://github.com/element-hq/compound-ios
revision: 07563f32203a0a8c3a660cc9fc7cd59cdebcc34f
revision: 92f99140d925e77f01f5ef72c1aeffe0b0e3d96a
# path: ../compound-ios
AnalyticsEvents:
url: https://github.com/matrix-org/matrix-analytics-events