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"))]
138unsafe impl NSCoding for UISearchController {}
139
140#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
141unsafe impl NSObjectProtocol for UISearchController {}
142
143#[cfg(all(
144    feature = "UIAppearance",
145    feature = "UIResponder",
146    feature = "UIViewController"
147))]
148unsafe impl UIAppearanceContainer for UISearchController {}
149
150#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
151unsafe impl UIContentContainer for UISearchController {}
152
153#[cfg(all(
154    feature = "UIFocus",
155    feature = "UIResponder",
156    feature = "UIViewController"
157))]
158unsafe impl UIFocusEnvironment for UISearchController {}
159
160#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
161unsafe impl UIResponderStandardEditActions for UISearchController {}
162
163#[cfg(all(
164    feature = "UIResponder",
165    feature = "UITraitCollection",
166    feature = "UIViewController"
167))]
168unsafe impl UITraitEnvironment for UISearchController {}
169
170#[cfg(all(
171    feature = "UIResponder",
172    feature = "UIViewController",
173    feature = "UIViewControllerTransitioning"
174))]
175unsafe impl UIViewControllerAnimatedTransitioning for UISearchController {}
176
177#[cfg(all(
178    feature = "UIResponder",
179    feature = "UIViewController",
180    feature = "UIViewControllerTransitioning"
181))]
182unsafe impl UIViewControllerTransitioningDelegate for UISearchController {}
183
184#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
185impl UISearchController {
186    extern_methods!(
187        #[unsafe(method(initWithSearchResultsController:))]
188        #[unsafe(method_family = init)]
189        pub unsafe fn initWithSearchResultsController(
190            this: Allocated<Self>,
191            search_results_controller: Option<&UIViewController>,
192        ) -> Retained<Self>;
193
194        #[unsafe(method(initWithNibName:bundle:))]
195        #[unsafe(method_family = init)]
196        pub unsafe fn initWithNibName_bundle(
197            this: Allocated<Self>,
198            nib_name_or_nil: Option<&NSString>,
199            nib_bundle_or_nil: Option<&NSBundle>,
200        ) -> Retained<Self>;
201
202        #[unsafe(method(initWithCoder:))]
203        #[unsafe(method_family = init)]
204        pub unsafe fn initWithCoder(
205            this: Allocated<Self>,
206            coder: &NSCoder,
207        ) -> Option<Retained<Self>>;
208
209        #[unsafe(method(searchResultsUpdater))]
210        #[unsafe(method_family = none)]
211        pub unsafe fn searchResultsUpdater(
212            &self,
213        ) -> Option<Retained<ProtocolObject<dyn UISearchResultsUpdating>>>;
214
215        /// This is a [weak property][objc2::topics::weak_property].
216        /// Setter for [`searchResultsUpdater`][Self::searchResultsUpdater].
217        #[unsafe(method(setSearchResultsUpdater:))]
218        #[unsafe(method_family = none)]
219        pub unsafe fn setSearchResultsUpdater(
220            &self,
221            search_results_updater: Option<&ProtocolObject<dyn UISearchResultsUpdating>>,
222        );
223
224        #[unsafe(method(isActive))]
225        #[unsafe(method_family = none)]
226        pub unsafe fn isActive(&self) -> bool;
227
228        /// Setter for [`isActive`][Self::isActive].
229        #[unsafe(method(setActive:))]
230        #[unsafe(method_family = none)]
231        pub unsafe fn setActive(&self, active: bool);
232
233        #[unsafe(method(delegate))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn delegate(
236            &self,
237        ) -> Option<Retained<ProtocolObject<dyn UISearchControllerDelegate>>>;
238
239        /// This is a [weak property][objc2::topics::weak_property].
240        /// Setter for [`delegate`][Self::delegate].
241        #[unsafe(method(setDelegate:))]
242        #[unsafe(method_family = none)]
243        pub unsafe fn setDelegate(
244            &self,
245            delegate: Option<&ProtocolObject<dyn UISearchControllerDelegate>>,
246        );
247
248        #[deprecated]
249        #[unsafe(method(dimsBackgroundDuringPresentation))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn dimsBackgroundDuringPresentation(&self) -> bool;
252
253        /// Setter for [`dimsBackgroundDuringPresentation`][Self::dimsBackgroundDuringPresentation].
254        #[deprecated]
255        #[unsafe(method(setDimsBackgroundDuringPresentation:))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn setDimsBackgroundDuringPresentation(
258            &self,
259            dims_background_during_presentation: bool,
260        );
261
262        #[unsafe(method(obscuresBackgroundDuringPresentation))]
263        #[unsafe(method_family = none)]
264        pub unsafe fn obscuresBackgroundDuringPresentation(&self) -> bool;
265
266        /// Setter for [`obscuresBackgroundDuringPresentation`][Self::obscuresBackgroundDuringPresentation].
267        #[unsafe(method(setObscuresBackgroundDuringPresentation:))]
268        #[unsafe(method_family = none)]
269        pub unsafe fn setObscuresBackgroundDuringPresentation(
270            &self,
271            obscures_background_during_presentation: bool,
272        );
273
274        #[unsafe(method(hidesNavigationBarDuringPresentation))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn hidesNavigationBarDuringPresentation(&self) -> bool;
277
278        /// Setter for [`hidesNavigationBarDuringPresentation`][Self::hidesNavigationBarDuringPresentation].
279        #[unsafe(method(setHidesNavigationBarDuringPresentation:))]
280        #[unsafe(method_family = none)]
281        pub unsafe fn setHidesNavigationBarDuringPresentation(
282            &self,
283            hides_navigation_bar_during_presentation: bool,
284        );
285
286        #[unsafe(method(searchResultsController))]
287        #[unsafe(method_family = none)]
288        pub unsafe fn searchResultsController(&self) -> Option<Retained<UIViewController>>;
289
290        #[cfg(all(feature = "UISearchBar", feature = "UIView"))]
291        #[unsafe(method(searchBar))]
292        #[unsafe(method_family = none)]
293        pub unsafe fn searchBar(&self) -> Retained<UISearchBar>;
294
295        #[cfg(feature = "UINavigationItem")]
296        #[unsafe(method(searchBarPlacement))]
297        #[unsafe(method_family = none)]
298        pub unsafe fn searchBarPlacement(&self) -> UINavigationItemSearchBarPlacement;
299
300        #[unsafe(method(automaticallyShowsSearchResultsController))]
301        #[unsafe(method_family = none)]
302        pub unsafe fn automaticallyShowsSearchResultsController(&self) -> bool;
303
304        /// Setter for [`automaticallyShowsSearchResultsController`][Self::automaticallyShowsSearchResultsController].
305        #[unsafe(method(setAutomaticallyShowsSearchResultsController:))]
306        #[unsafe(method_family = none)]
307        pub unsafe fn setAutomaticallyShowsSearchResultsController(
308            &self,
309            automatically_shows_search_results_controller: bool,
310        );
311
312        #[unsafe(method(showsSearchResultsController))]
313        #[unsafe(method_family = none)]
314        pub unsafe fn showsSearchResultsController(&self) -> bool;
315
316        /// Setter for [`showsSearchResultsController`][Self::showsSearchResultsController].
317        #[unsafe(method(setShowsSearchResultsController:))]
318        #[unsafe(method_family = none)]
319        pub unsafe fn setShowsSearchResultsController(&self, shows_search_results_controller: bool);
320
321        #[unsafe(method(automaticallyShowsCancelButton))]
322        #[unsafe(method_family = none)]
323        pub unsafe fn automaticallyShowsCancelButton(&self) -> bool;
324
325        /// Setter for [`automaticallyShowsCancelButton`][Self::automaticallyShowsCancelButton].
326        #[unsafe(method(setAutomaticallyShowsCancelButton:))]
327        #[unsafe(method_family = none)]
328        pub unsafe fn setAutomaticallyShowsCancelButton(
329            &self,
330            automatically_shows_cancel_button: bool,
331        );
332
333        #[deprecated = "Use scopeBarActivation instead"]
334        #[unsafe(method(automaticallyShowsScopeBar))]
335        #[unsafe(method_family = none)]
336        pub unsafe fn automaticallyShowsScopeBar(&self) -> bool;
337
338        /// Setter for [`automaticallyShowsScopeBar`][Self::automaticallyShowsScopeBar].
339        #[deprecated = "Use scopeBarActivation instead"]
340        #[unsafe(method(setAutomaticallyShowsScopeBar:))]
341        #[unsafe(method_family = none)]
342        pub unsafe fn setAutomaticallyShowsScopeBar(&self, automatically_shows_scope_bar: bool);
343
344        /// Controls if and when the UISearchController shows and hides the scope bar
345        /// However, UISearchBar will not show the scope bar if `scopeButtonTitles` contains fewer than two titles
346        /// Defaults to `UISearchControllerScopeBarActivationAutomatic`
347        /// `UISearchControllerScopeBarActivationAutomatic` is equivalent to earlier `automaticallyShowsScopeBar == YES`
348        /// `UISearchControllerScopeBarActivationManual` is equivalent to earlier `automaticallyShowsScopeBar == NO`
349        /// Similar to the behavior of `automaticallyShowsScopeBar`, setting the `showsScopeBar` property on the `searchController`'s `searchBar`
350        /// will change `scopeBarActivation` to `UISearchControllerScopeBarActivationManual`
351        #[unsafe(method(scopeBarActivation))]
352        #[unsafe(method_family = none)]
353        pub unsafe fn scopeBarActivation(&self) -> UISearchControllerScopeBarActivation;
354
355        /// Setter for [`scopeBarActivation`][Self::scopeBarActivation].
356        #[unsafe(method(setScopeBarActivation:))]
357        #[unsafe(method_family = none)]
358        pub unsafe fn setScopeBarActivation(
359            &self,
360            scope_bar_activation: UISearchControllerScopeBarActivation,
361        );
362
363        #[cfg(feature = "UISearchSuggestion")]
364        /// List of search hint objects to be displayed under keyboard on tvOS,
365        /// as a menu under the search field when the search bar is placed inline on iOS 16,
366        /// or as a list in front of the searchResultsController when the search bar is stacked.
367        /// Assigning with new array immediately updates the list on screen.
368        /// searchSuggestions is set to nil when user interaction selects a suggestion,
369        /// or when the user otherwise interacts with search (e.g., typing in the search field, choosing a different search scope, canceling search)
370        /// after dismissing the menu by tapping outside
371        #[unsafe(method(searchSuggestions))]
372        #[unsafe(method_family = none)]
373        pub unsafe fn searchSuggestions(
374            &self,
375        ) -> Option<Retained<NSArray<ProtocolObject<dyn UISearchSuggestion>>>>;
376
377        #[cfg(feature = "UISearchSuggestion")]
378        /// Setter for [`searchSuggestions`][Self::searchSuggestions].
379        #[unsafe(method(setSearchSuggestions:))]
380        #[unsafe(method_family = none)]
381        pub unsafe fn setSearchSuggestions(
382            &self,
383            search_suggestions: Option<&NSArray<ProtocolObject<dyn UISearchSuggestion>>>,
384        );
385
386        /// Default NO. When YES, the UISearchController will not create its internal child view controller
387        /// for presenting the list of search suggestions when the searchBarPlacement is stacked.
388        /// This property is intended to be set at the time that the search controller is initialized.
389        /// If set after that point, the internal view controller will not be destroyed, but its view will be hidden and remain so.
390        #[unsafe(method(ignoresSearchSuggestionsForSearchBarPlacementStacked))]
391        #[unsafe(method_family = none)]
392        pub unsafe fn ignoresSearchSuggestionsForSearchBarPlacementStacked(&self) -> bool;
393
394        /// Setter for [`ignoresSearchSuggestionsForSearchBarPlacementStacked`][Self::ignoresSearchSuggestionsForSearchBarPlacementStacked].
395        #[unsafe(method(setIgnoresSearchSuggestionsForSearchBarPlacementStacked:))]
396        #[unsafe(method_family = none)]
397        pub unsafe fn setIgnoresSearchSuggestionsForSearchBarPlacementStacked(
398            &self,
399            ignores_search_suggestions_for_search_bar_placement_stacked: bool,
400        );
401
402        #[cfg(all(feature = "UIScrollView", feature = "UIView"))]
403        #[deprecated = "Use -[UIViewController setContentScrollView:forEdge:] on the searchResultsController instead."]
404        #[unsafe(method(searchControllerObservedScrollView))]
405        #[unsafe(method_family = none)]
406        pub unsafe fn searchControllerObservedScrollView(&self) -> Option<Retained<UIScrollView>>;
407
408        #[cfg(all(feature = "UIScrollView", feature = "UIView"))]
409        /// Setter for [`searchControllerObservedScrollView`][Self::searchControllerObservedScrollView].
410        #[deprecated = "Use -[UIViewController setContentScrollView:forEdge:] on the searchResultsController instead."]
411        #[unsafe(method(setSearchControllerObservedScrollView:))]
412        #[unsafe(method_family = none)]
413        pub unsafe fn setSearchControllerObservedScrollView(
414            &self,
415            search_controller_observed_scroll_view: Option<&UIScrollView>,
416        );
417    );
418}
419
420/// Methods declared on superclass `NSObject`.
421#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
422impl UISearchController {
423    extern_methods!(
424        #[unsafe(method(init))]
425        #[unsafe(method_family = init)]
426        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
427
428        #[unsafe(method(new))]
429        #[unsafe(method_family = new)]
430        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
431    );
432}