1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct UISearchControllerScopeBarActivation(pub NSInteger);
15impl UISearchControllerScopeBarActivation {
16 #[doc(alias = "UISearchControllerScopeBarActivationAutomatic")]
18 pub const Automatic: Self = Self(0);
19 #[doc(alias = "UISearchControllerScopeBarActivationManual")]
21 pub const Manual: Self = Self(1);
22 #[doc(alias = "UISearchControllerScopeBarActivationOnTextEntry")]
24 pub const OnTextEntry: Self = Self(2);
25 #[doc(alias = "UISearchControllerScopeBarActivationOnSearchActivation")]
27 pub const OnSearchActivation: Self = Self(3);
28}
29
30unsafe impl Encode for UISearchControllerScopeBarActivation {
31 const ENCODING: Encoding = NSInteger::ENCODING;
32}
33
34unsafe impl RefEncode for UISearchControllerScopeBarActivation {
35 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
36}
37
38extern_protocol!(
39 pub unsafe trait UISearchControllerDelegate: NSObjectProtocol + MainThreadOnly {
41 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
42 #[optional]
43 #[unsafe(method(willPresentSearchController:))]
44 #[unsafe(method_family = none)]
45 fn willPresentSearchController(&self, search_controller: &UISearchController);
46
47 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
48 #[optional]
49 #[unsafe(method(didPresentSearchController:))]
50 #[unsafe(method_family = none)]
51 fn didPresentSearchController(&self, search_controller: &UISearchController);
52
53 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
54 #[optional]
55 #[unsafe(method(willDismissSearchController:))]
56 #[unsafe(method_family = none)]
57 fn willDismissSearchController(&self, search_controller: &UISearchController);
58
59 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
60 #[optional]
61 #[unsafe(method(didDismissSearchController:))]
62 #[unsafe(method_family = none)]
63 fn didDismissSearchController(&self, search_controller: &UISearchController);
64
65 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
66 #[optional]
67 #[unsafe(method(presentSearchController:))]
68 #[unsafe(method_family = none)]
69 fn presentSearchController(&self, search_controller: &UISearchController);
70
71 #[cfg(all(
72 feature = "UINavigationItem",
73 feature = "UIResponder",
74 feature = "UIViewController"
75 ))]
76 #[optional]
77 #[unsafe(method(searchController:willChangeToSearchBarPlacement:))]
78 #[unsafe(method_family = none)]
79 fn searchController_willChangeToSearchBarPlacement(
80 &self,
81 search_controller: &UISearchController,
82 new_placement: UINavigationItemSearchBarPlacement,
83 );
84
85 #[cfg(all(
86 feature = "UINavigationItem",
87 feature = "UIResponder",
88 feature = "UIViewController"
89 ))]
90 #[optional]
91 #[unsafe(method(searchController:didChangeFromSearchBarPlacement:))]
92 #[unsafe(method_family = none)]
93 fn searchController_didChangeFromSearchBarPlacement(
94 &self,
95 search_controller: &UISearchController,
96 previous_placement: UINavigationItemSearchBarPlacement,
97 );
98 }
99);
100
101extern_protocol!(
102 pub unsafe trait UISearchResultsUpdating: NSObjectProtocol + MainThreadOnly {
104 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
105 #[unsafe(method(updateSearchResultsForSearchController:))]
106 #[unsafe(method_family = none)]
107 fn updateSearchResultsForSearchController(&self, search_controller: &UISearchController);
108
109 #[cfg(all(
110 feature = "UIResponder",
111 feature = "UISearchSuggestion",
112 feature = "UIViewController"
113 ))]
114 #[optional]
115 #[unsafe(method(updateSearchResultsForSearchController:selectingSearchSuggestion:))]
116 #[unsafe(method_family = none)]
117 fn updateSearchResultsForSearchController_selectingSearchSuggestion(
118 &self,
119 search_controller: &UISearchController,
120 search_suggestion: &ProtocolObject<dyn UISearchSuggestion>,
121 );
122 }
123);
124
125extern_class!(
126 #[unsafe(super(UIViewController, UIResponder, NSObject))]
128 #[thread_kind = MainThreadOnly]
129 #[derive(Debug, PartialEq, Eq, Hash)]
130 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
131 pub struct UISearchController;
132);
133
134#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
135extern_conformance!(
136 unsafe impl NSCoding for UISearchController {}
137);
138
139#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
140extern_conformance!(
141 unsafe impl NSObjectProtocol for UISearchController {}
142);
143
144#[cfg(all(
145 feature = "UIAppearance",
146 feature = "UIResponder",
147 feature = "UIViewController"
148))]
149extern_conformance!(
150 unsafe impl UIAppearanceContainer for UISearchController {}
151);
152
153#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
154extern_conformance!(
155 unsafe impl UIContentContainer for UISearchController {}
156);
157
158#[cfg(all(
159 feature = "UIFocus",
160 feature = "UIResponder",
161 feature = "UIViewController"
162))]
163extern_conformance!(
164 unsafe impl UIFocusEnvironment for UISearchController {}
165);
166
167#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
168extern_conformance!(
169 unsafe impl UIResponderStandardEditActions for UISearchController {}
170);
171
172#[cfg(all(
173 feature = "UIResponder",
174 feature = "UITraitCollection",
175 feature = "UIViewController"
176))]
177extern_conformance!(
178 unsafe impl UITraitEnvironment for UISearchController {}
179);
180
181#[cfg(all(
182 feature = "UIResponder",
183 feature = "UIViewController",
184 feature = "UIViewControllerTransitioning"
185))]
186extern_conformance!(
187 unsafe impl UIViewControllerAnimatedTransitioning for UISearchController {}
188);
189
190#[cfg(all(
191 feature = "UIResponder",
192 feature = "UIViewController",
193 feature = "UIViewControllerTransitioning"
194))]
195extern_conformance!(
196 unsafe impl UIViewControllerTransitioningDelegate for UISearchController {}
197);
198
199#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
200impl UISearchController {
201 extern_methods!(
202 #[unsafe(method(initWithSearchResultsController:))]
203 #[unsafe(method_family = init)]
204 pub fn initWithSearchResultsController(
205 this: Allocated<Self>,
206 search_results_controller: Option<&UIViewController>,
207 ) -> Retained<Self>;
208
209 #[unsafe(method(initWithNibName:bundle:))]
210 #[unsafe(method_family = init)]
211 pub fn initWithNibName_bundle(
212 this: Allocated<Self>,
213 nib_name_or_nil: Option<&NSString>,
214 nib_bundle_or_nil: Option<&NSBundle>,
215 ) -> Retained<Self>;
216
217 #[unsafe(method(initWithCoder:))]
221 #[unsafe(method_family = init)]
222 pub unsafe fn initWithCoder(
223 this: Allocated<Self>,
224 coder: &NSCoder,
225 ) -> Option<Retained<Self>>;
226
227 #[unsafe(method(searchResultsUpdater))]
228 #[unsafe(method_family = none)]
229 pub fn searchResultsUpdater(
230 &self,
231 ) -> Option<Retained<ProtocolObject<dyn UISearchResultsUpdating>>>;
232
233 #[unsafe(method(setSearchResultsUpdater:))]
237 #[unsafe(method_family = none)]
238 pub fn setSearchResultsUpdater(
239 &self,
240 search_results_updater: Option<&ProtocolObject<dyn UISearchResultsUpdating>>,
241 );
242
243 #[unsafe(method(isActive))]
244 #[unsafe(method_family = none)]
245 pub fn isActive(&self) -> bool;
246
247 #[unsafe(method(setActive:))]
249 #[unsafe(method_family = none)]
250 pub fn setActive(&self, active: bool);
251
252 #[unsafe(method(delegate))]
253 #[unsafe(method_family = none)]
254 pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn UISearchControllerDelegate>>>;
255
256 #[unsafe(method(setDelegate:))]
260 #[unsafe(method_family = none)]
261 pub fn setDelegate(
262 &self,
263 delegate: Option<&ProtocolObject<dyn UISearchControllerDelegate>>,
264 );
265
266 #[deprecated]
267 #[unsafe(method(dimsBackgroundDuringPresentation))]
268 #[unsafe(method_family = none)]
269 pub fn dimsBackgroundDuringPresentation(&self) -> bool;
270
271 #[deprecated]
273 #[unsafe(method(setDimsBackgroundDuringPresentation:))]
274 #[unsafe(method_family = none)]
275 pub fn setDimsBackgroundDuringPresentation(
276 &self,
277 dims_background_during_presentation: bool,
278 );
279
280 #[unsafe(method(obscuresBackgroundDuringPresentation))]
281 #[unsafe(method_family = none)]
282 pub fn obscuresBackgroundDuringPresentation(&self) -> bool;
283
284 #[unsafe(method(setObscuresBackgroundDuringPresentation:))]
286 #[unsafe(method_family = none)]
287 pub fn setObscuresBackgroundDuringPresentation(
288 &self,
289 obscures_background_during_presentation: bool,
290 );
291
292 #[unsafe(method(hidesNavigationBarDuringPresentation))]
295 #[unsafe(method_family = none)]
296 pub fn hidesNavigationBarDuringPresentation(&self) -> bool;
297
298 #[unsafe(method(setHidesNavigationBarDuringPresentation:))]
300 #[unsafe(method_family = none)]
301 pub fn setHidesNavigationBarDuringPresentation(
302 &self,
303 hides_navigation_bar_during_presentation: bool,
304 );
305
306 #[unsafe(method(searchResultsController))]
307 #[unsafe(method_family = none)]
308 pub fn searchResultsController(&self) -> Option<Retained<UIViewController>>;
309
310 #[cfg(all(feature = "UISearchBar", feature = "UIView"))]
311 #[unsafe(method(searchBar))]
312 #[unsafe(method_family = none)]
313 pub fn searchBar(&self) -> Retained<UISearchBar>;
314
315 #[cfg(feature = "UINavigationItem")]
316 #[unsafe(method(searchBarPlacement))]
317 #[unsafe(method_family = none)]
318 pub fn searchBarPlacement(&self) -> UINavigationItemSearchBarPlacement;
319
320 #[unsafe(method(automaticallyShowsSearchResultsController))]
321 #[unsafe(method_family = none)]
322 pub fn automaticallyShowsSearchResultsController(&self) -> bool;
323
324 #[unsafe(method(setAutomaticallyShowsSearchResultsController:))]
326 #[unsafe(method_family = none)]
327 pub fn setAutomaticallyShowsSearchResultsController(
328 &self,
329 automatically_shows_search_results_controller: bool,
330 );
331
332 #[unsafe(method(showsSearchResultsController))]
333 #[unsafe(method_family = none)]
334 pub fn showsSearchResultsController(&self) -> bool;
335
336 #[unsafe(method(setShowsSearchResultsController:))]
338 #[unsafe(method_family = none)]
339 pub fn setShowsSearchResultsController(&self, shows_search_results_controller: bool);
340
341 #[unsafe(method(automaticallyShowsCancelButton))]
342 #[unsafe(method_family = none)]
343 pub fn automaticallyShowsCancelButton(&self) -> bool;
344
345 #[unsafe(method(setAutomaticallyShowsCancelButton:))]
347 #[unsafe(method_family = none)]
348 pub fn setAutomaticallyShowsCancelButton(&self, automatically_shows_cancel_button: bool);
349
350 #[deprecated = "Use scopeBarActivation instead"]
351 #[unsafe(method(automaticallyShowsScopeBar))]
352 #[unsafe(method_family = none)]
353 pub fn automaticallyShowsScopeBar(&self) -> bool;
354
355 #[deprecated = "Use scopeBarActivation instead"]
357 #[unsafe(method(setAutomaticallyShowsScopeBar:))]
358 #[unsafe(method_family = none)]
359 pub fn setAutomaticallyShowsScopeBar(&self, automatically_shows_scope_bar: bool);
360
361 #[unsafe(method(scopeBarActivation))]
369 #[unsafe(method_family = none)]
370 pub fn scopeBarActivation(&self) -> UISearchControllerScopeBarActivation;
371
372 #[unsafe(method(setScopeBarActivation:))]
374 #[unsafe(method_family = none)]
375 pub fn setScopeBarActivation(
376 &self,
377 scope_bar_activation: UISearchControllerScopeBarActivation,
378 );
379
380 #[cfg(feature = "UISearchSuggestion")]
381 #[unsafe(method(searchSuggestions))]
389 #[unsafe(method_family = none)]
390 pub fn searchSuggestions(
391 &self,
392 ) -> Option<Retained<NSArray<ProtocolObject<dyn UISearchSuggestion>>>>;
393
394 #[cfg(feature = "UISearchSuggestion")]
395 #[unsafe(method(setSearchSuggestions:))]
399 #[unsafe(method_family = none)]
400 pub fn setSearchSuggestions(
401 &self,
402 search_suggestions: Option<&NSArray<ProtocolObject<dyn UISearchSuggestion>>>,
403 );
404
405 #[unsafe(method(ignoresSearchSuggestionsForSearchBarPlacementStacked))]
410 #[unsafe(method_family = none)]
411 pub fn ignoresSearchSuggestionsForSearchBarPlacementStacked(&self) -> bool;
412
413 #[unsafe(method(setIgnoresSearchSuggestionsForSearchBarPlacementStacked:))]
415 #[unsafe(method_family = none)]
416 pub fn setIgnoresSearchSuggestionsForSearchBarPlacementStacked(
417 &self,
418 ignores_search_suggestions_for_search_bar_placement_stacked: bool,
419 );
420
421 #[cfg(all(feature = "UIScrollView", feature = "UIView"))]
422 #[deprecated = "Use -[UIViewController setContentScrollView:forEdge:] on the searchResultsController instead."]
423 #[unsafe(method(searchControllerObservedScrollView))]
424 #[unsafe(method_family = none)]
425 pub fn searchControllerObservedScrollView(&self) -> Option<Retained<UIScrollView>>;
426
427 #[cfg(all(feature = "UIScrollView", feature = "UIView"))]
428 #[deprecated = "Use -[UIViewController setContentScrollView:forEdge:] on the searchResultsController instead."]
430 #[unsafe(method(setSearchControllerObservedScrollView:))]
431 #[unsafe(method_family = none)]
432 pub fn setSearchControllerObservedScrollView(
433 &self,
434 search_controller_observed_scroll_view: Option<&UIScrollView>,
435 );
436 );
437}
438
439#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
441impl UISearchController {
442 extern_methods!(
443 #[unsafe(method(init))]
444 #[unsafe(method_family = init)]
445 pub fn init(this: Allocated<Self>) -> Retained<Self>;
446
447 #[unsafe(method(new))]
448 #[unsafe(method_family = new)]
449 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
450 );
451}