objc2_ui_kit/generated/
UISearchController.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uisearchcontrollerscopebaractivation?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct UISearchControllerScopeBarActivation(pub NSInteger);
15impl UISearchControllerScopeBarActivation {
16    /// System-defined automatic showing and hiding of the scope bar
17    #[doc(alias = "UISearchControllerScopeBarActivationAutomatic")]
18    pub const Automatic: Self = Self(0);
19    /// Showing and hiding the scope bar will be controlled by client code through the `showsScopeBar` API on the UISearchController's `searchBar`
20    #[doc(alias = "UISearchControllerScopeBarActivationManual")]
21    pub const Manual: Self = Self(1);
22    /// The search controller shows the scope bar when typing begins in the search field, and hides it when search is cancelled
23    #[doc(alias = "UISearchControllerScopeBarActivationOnTextEntry")]
24    pub const OnTextEntry: Self = Self(2);
25    /// The search controller shows the scope bar when search becomes active, and hides it when search is cancelled
26    #[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    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uisearchcontrollerdelegate?language=objc)
40    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    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uisearchresultsupdating?language=objc)
103    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    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uisearchcontroller?language=objc)
130    #[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        /// This is a [weak property][objc2::topics::weak_property].
234        /// Setter for [`searchResultsUpdater`][Self::searchResultsUpdater].
235        #[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        /// Setter for [`isActive`][Self::isActive].
247        #[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        /// This is a [weak property][objc2::topics::weak_property].
258        /// Setter for [`delegate`][Self::delegate].
259        #[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        /// Setter for [`dimsBackgroundDuringPresentation`][Self::dimsBackgroundDuringPresentation].
272        #[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        /// Setter for [`obscuresBackgroundDuringPresentation`][Self::obscuresBackgroundDuringPresentation].
285        #[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        /// Setter for [`hidesNavigationBarDuringPresentation`][Self::hidesNavigationBarDuringPresentation].
297        #[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        /// Setter for [`automaticallyShowsSearchResultsController`][Self::automaticallyShowsSearchResultsController].
323        #[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        /// Setter for [`showsSearchResultsController`][Self::showsSearchResultsController].
335        #[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        /// Setter for [`automaticallyShowsCancelButton`][Self::automaticallyShowsCancelButton].
344        #[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        /// Setter for [`automaticallyShowsScopeBar`][Self::automaticallyShowsScopeBar].
357        #[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        /// Controls if and when the UISearchController shows and hides the scope bar
363        /// However, UISearchBar will not show the scope bar if `scopeButtonTitles` contains fewer than two titles
364        /// Defaults to `UISearchControllerScopeBarActivationAutomatic`
365        /// `UISearchControllerScopeBarActivationAutomatic` is equivalent to earlier `automaticallyShowsScopeBar == YES`
366        /// `UISearchControllerScopeBarActivationManual` is equivalent to earlier `automaticallyShowsScopeBar == NO`
367        /// Similar to the behavior of `automaticallyShowsScopeBar`, setting the `showsScopeBar` property on the `searchController`'s `searchBar`
368        /// will change `scopeBarActivation` to `UISearchControllerScopeBarActivationManual`
369        #[unsafe(method(scopeBarActivation))]
370        #[unsafe(method_family = none)]
371        pub unsafe fn scopeBarActivation(&self) -> UISearchControllerScopeBarActivation;
372
373        /// Setter for [`scopeBarActivation`][Self::scopeBarActivation].
374        #[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        /// List of search hint objects to be displayed under keyboard on tvOS,
383        /// as a menu under the search field when the search bar is placed inline on iOS 16,
384        /// or as a list in front of the searchResultsController when the search bar is stacked.
385        /// Assigning with new array immediately updates the list on screen.
386        /// searchSuggestions is set to nil when user interaction selects a suggestion,
387        /// or when the user otherwise interacts with search (e.g., typing in the search field, choosing a different search scope, canceling search)
388        /// after dismissing the menu by tapping outside
389        #[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        /// Setter for [`searchSuggestions`][Self::searchSuggestions].
397        #[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        /// Default NO. When YES, the UISearchController will not create its internal child view controller
405        /// for presenting the list of search suggestions when the searchBarPlacement is stacked.
406        /// This property is intended to be set at the time that the search controller is initialized.
407        /// If set after that point, the internal view controller will not be destroyed, but its view will be hidden and remain so.
408        #[unsafe(method(ignoresSearchSuggestionsForSearchBarPlacementStacked))]
409        #[unsafe(method_family = none)]
410        pub unsafe fn ignoresSearchSuggestionsForSearchBarPlacementStacked(&self) -> bool;
411
412        /// Setter for [`ignoresSearchSuggestionsForSearchBarPlacementStacked`][Self::ignoresSearchSuggestionsForSearchBarPlacementStacked].
413        #[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        /// Setter for [`searchControllerObservedScrollView`][Self::searchControllerObservedScrollView].
428        #[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/// Methods declared on superclass `NSObject`.
439#[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}