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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe 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 unsafe fn updateSearchResultsForSearchController(
108 &self,
109 search_controller: &UISearchController,
110 );
111
112 #[cfg(all(
113 feature = "UIResponder",
114 feature = "UISearchSuggestion",
115 feature = "UIViewController"
116 ))]
117 #[optional]
118 #[unsafe(method(updateSearchResultsForSearchController:selectingSearchSuggestion:))]
119 #[unsafe(method_family = none)]
120 unsafe fn updateSearchResultsForSearchController_selectingSearchSuggestion(
121 &self,
122 search_controller: &UISearchController,
123 search_suggestion: &ProtocolObject<dyn UISearchSuggestion>,
124 );
125 }
126);
127
128extern_class!(
129 #[unsafe(super(UIViewController, UIResponder, NSObject))]
131 #[thread_kind = MainThreadOnly]
132 #[derive(Debug, PartialEq, Eq, Hash)]
133 #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
134 pub struct UISearchController;
135);
136
137#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
138extern_conformance!(
139 unsafe impl NSCoding for UISearchController {}
140);
141
142#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
143extern_conformance!(
144 unsafe impl NSObjectProtocol for UISearchController {}
145);
146
147#[cfg(all(
148 feature = "UIAppearance",
149 feature = "UIResponder",
150 feature = "UIViewController"
151))]
152extern_conformance!(
153 unsafe impl UIAppearanceContainer for UISearchController {}
154);
155
156#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
157extern_conformance!(
158 unsafe impl UIContentContainer for UISearchController {}
159);
160
161#[cfg(all(
162 feature = "UIFocus",
163 feature = "UIResponder",
164 feature = "UIViewController"
165))]
166extern_conformance!(
167 unsafe impl UIFocusEnvironment for UISearchController {}
168);
169
170#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
171extern_conformance!(
172 unsafe impl UIResponderStandardEditActions for UISearchController {}
173);
174
175#[cfg(all(
176 feature = "UIResponder",
177 feature = "UITraitCollection",
178 feature = "UIViewController"
179))]
180extern_conformance!(
181 unsafe impl UITraitEnvironment for UISearchController {}
182);
183
184#[cfg(all(
185 feature = "UIResponder",
186 feature = "UIViewController",
187 feature = "UIViewControllerTransitioning"
188))]
189extern_conformance!(
190 unsafe impl UIViewControllerAnimatedTransitioning for UISearchController {}
191);
192
193#[cfg(all(
194 feature = "UIResponder",
195 feature = "UIViewController",
196 feature = "UIViewControllerTransitioning"
197))]
198extern_conformance!(
199 unsafe impl UIViewControllerTransitioningDelegate for UISearchController {}
200);
201
202#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
203impl UISearchController {
204 extern_methods!(
205 #[unsafe(method(initWithSearchResultsController:))]
206 #[unsafe(method_family = init)]
207 pub unsafe fn initWithSearchResultsController(
208 this: Allocated<Self>,
209 search_results_controller: Option<&UIViewController>,
210 ) -> Retained<Self>;
211
212 #[unsafe(method(initWithNibName:bundle:))]
213 #[unsafe(method_family = init)]
214 pub unsafe fn initWithNibName_bundle(
215 this: Allocated<Self>,
216 nib_name_or_nil: Option<&NSString>,
217 nib_bundle_or_nil: Option<&NSBundle>,
218 ) -> Retained<Self>;
219
220 #[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 unsafe fn searchResultsUpdater(
230 &self,
231 ) -> Option<Retained<ProtocolObject<dyn UISearchResultsUpdating>>>;
232
233 #[unsafe(method(setSearchResultsUpdater:))]
236 #[unsafe(method_family = none)]
237 pub unsafe fn setSearchResultsUpdater(
238 &self,
239 search_results_updater: Option<&ProtocolObject<dyn UISearchResultsUpdating>>,
240 );
241
242 #[unsafe(method(isActive))]
243 #[unsafe(method_family = none)]
244 pub unsafe fn isActive(&self) -> bool;
245
246 #[unsafe(method(setActive:))]
248 #[unsafe(method_family = none)]
249 pub unsafe fn setActive(&self, active: bool);
250
251 #[unsafe(method(delegate))]
252 #[unsafe(method_family = none)]
253 pub unsafe fn delegate(
254 &self,
255 ) -> Option<Retained<ProtocolObject<dyn UISearchControllerDelegate>>>;
256
257 #[unsafe(method(setDelegate:))]
260 #[unsafe(method_family = none)]
261 pub unsafe 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 unsafe fn dimsBackgroundDuringPresentation(&self) -> bool;
270
271 #[deprecated]
273 #[unsafe(method(setDimsBackgroundDuringPresentation:))]
274 #[unsafe(method_family = none)]
275 pub unsafe fn setDimsBackgroundDuringPresentation(
276 &self,
277 dims_background_during_presentation: bool,
278 );
279
280 #[unsafe(method(obscuresBackgroundDuringPresentation))]
281 #[unsafe(method_family = none)]
282 pub unsafe fn obscuresBackgroundDuringPresentation(&self) -> bool;
283
284 #[unsafe(method(setObscuresBackgroundDuringPresentation:))]
286 #[unsafe(method_family = none)]
287 pub unsafe fn setObscuresBackgroundDuringPresentation(
288 &self,
289 obscures_background_during_presentation: bool,
290 );
291
292 #[unsafe(method(hidesNavigationBarDuringPresentation))]
293 #[unsafe(method_family = none)]
294 pub unsafe fn hidesNavigationBarDuringPresentation(&self) -> bool;
295
296 #[unsafe(method(setHidesNavigationBarDuringPresentation:))]
298 #[unsafe(method_family = none)]
299 pub unsafe fn setHidesNavigationBarDuringPresentation(
300 &self,
301 hides_navigation_bar_during_presentation: bool,
302 );
303
304 #[unsafe(method(searchResultsController))]
305 #[unsafe(method_family = none)]
306 pub unsafe fn searchResultsController(&self) -> Option<Retained<UIViewController>>;
307
308 #[cfg(all(feature = "UISearchBar", feature = "UIView"))]
309 #[unsafe(method(searchBar))]
310 #[unsafe(method_family = none)]
311 pub unsafe fn searchBar(&self) -> Retained<UISearchBar>;
312
313 #[cfg(feature = "UINavigationItem")]
314 #[unsafe(method(searchBarPlacement))]
315 #[unsafe(method_family = none)]
316 pub unsafe fn searchBarPlacement(&self) -> UINavigationItemSearchBarPlacement;
317
318 #[unsafe(method(automaticallyShowsSearchResultsController))]
319 #[unsafe(method_family = none)]
320 pub unsafe fn automaticallyShowsSearchResultsController(&self) -> bool;
321
322 #[unsafe(method(setAutomaticallyShowsSearchResultsController:))]
324 #[unsafe(method_family = none)]
325 pub unsafe fn setAutomaticallyShowsSearchResultsController(
326 &self,
327 automatically_shows_search_results_controller: bool,
328 );
329
330 #[unsafe(method(showsSearchResultsController))]
331 #[unsafe(method_family = none)]
332 pub unsafe fn showsSearchResultsController(&self) -> bool;
333
334 #[unsafe(method(setShowsSearchResultsController:))]
336 #[unsafe(method_family = none)]
337 pub unsafe fn setShowsSearchResultsController(&self, shows_search_results_controller: bool);
338
339 #[unsafe(method(automaticallyShowsCancelButton))]
340 #[unsafe(method_family = none)]
341 pub unsafe fn automaticallyShowsCancelButton(&self) -> bool;
342
343 #[unsafe(method(setAutomaticallyShowsCancelButton:))]
345 #[unsafe(method_family = none)]
346 pub unsafe fn setAutomaticallyShowsCancelButton(
347 &self,
348 automatically_shows_cancel_button: bool,
349 );
350
351 #[deprecated = "Use scopeBarActivation instead"]
352 #[unsafe(method(automaticallyShowsScopeBar))]
353 #[unsafe(method_family = none)]
354 pub unsafe fn automaticallyShowsScopeBar(&self) -> bool;
355
356 #[deprecated = "Use scopeBarActivation instead"]
358 #[unsafe(method(setAutomaticallyShowsScopeBar:))]
359 #[unsafe(method_family = none)]
360 pub unsafe fn setAutomaticallyShowsScopeBar(&self, automatically_shows_scope_bar: bool);
361
362 #[unsafe(method(scopeBarActivation))]
370 #[unsafe(method_family = none)]
371 pub unsafe fn scopeBarActivation(&self) -> UISearchControllerScopeBarActivation;
372
373 #[unsafe(method(setScopeBarActivation:))]
375 #[unsafe(method_family = none)]
376 pub unsafe fn setScopeBarActivation(
377 &self,
378 scope_bar_activation: UISearchControllerScopeBarActivation,
379 );
380
381 #[cfg(feature = "UISearchSuggestion")]
382 #[unsafe(method(searchSuggestions))]
390 #[unsafe(method_family = none)]
391 pub unsafe fn searchSuggestions(
392 &self,
393 ) -> Option<Retained<NSArray<ProtocolObject<dyn UISearchSuggestion>>>>;
394
395 #[cfg(feature = "UISearchSuggestion")]
396 #[unsafe(method(setSearchSuggestions:))]
398 #[unsafe(method_family = none)]
399 pub unsafe fn setSearchSuggestions(
400 &self,
401 search_suggestions: Option<&NSArray<ProtocolObject<dyn UISearchSuggestion>>>,
402 );
403
404 #[unsafe(method(ignoresSearchSuggestionsForSearchBarPlacementStacked))]
409 #[unsafe(method_family = none)]
410 pub unsafe fn ignoresSearchSuggestionsForSearchBarPlacementStacked(&self) -> bool;
411
412 #[unsafe(method(setIgnoresSearchSuggestionsForSearchBarPlacementStacked:))]
414 #[unsafe(method_family = none)]
415 pub unsafe fn setIgnoresSearchSuggestionsForSearchBarPlacementStacked(
416 &self,
417 ignores_search_suggestions_for_search_bar_placement_stacked: bool,
418 );
419
420 #[cfg(all(feature = "UIScrollView", feature = "UIView"))]
421 #[deprecated = "Use -[UIViewController setContentScrollView:forEdge:] on the searchResultsController instead."]
422 #[unsafe(method(searchControllerObservedScrollView))]
423 #[unsafe(method_family = none)]
424 pub unsafe fn searchControllerObservedScrollView(&self) -> Option<Retained<UIScrollView>>;
425
426 #[cfg(all(feature = "UIScrollView", feature = "UIView"))]
427 #[deprecated = "Use -[UIViewController setContentScrollView:forEdge:] on the searchResultsController instead."]
429 #[unsafe(method(setSearchControllerObservedScrollView:))]
430 #[unsafe(method_family = none)]
431 pub unsafe fn setSearchControllerObservedScrollView(
432 &self,
433 search_controller_observed_scroll_view: Option<&UIScrollView>,
434 );
435 );
436}
437
438#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
440impl UISearchController {
441 extern_methods!(
442 #[unsafe(method(init))]
443 #[unsafe(method_family = init)]
444 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
445
446 #[unsafe(method(new))]
447 #[unsafe(method_family = new)]
448 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
449 );
450}