objc2-ui-kit 0.3.2

Bindings to the UIKit framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uisearchcontrollerscopebaractivation?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UISearchControllerScopeBarActivation(pub NSInteger);
impl UISearchControllerScopeBarActivation {
    /// System-defined automatic showing and hiding of the scope bar
    #[doc(alias = "UISearchControllerScopeBarActivationAutomatic")]
    pub const Automatic: Self = Self(0);
    /// Showing and hiding the scope bar will be controlled by client code through the `showsScopeBar` API on the UISearchController's `searchBar`
    #[doc(alias = "UISearchControllerScopeBarActivationManual")]
    pub const Manual: Self = Self(1);
    /// The search controller shows the scope bar when typing begins in the search field, and hides it when search is cancelled
    #[doc(alias = "UISearchControllerScopeBarActivationOnTextEntry")]
    pub const OnTextEntry: Self = Self(2);
    /// The search controller shows the scope bar when search becomes active, and hides it when search is cancelled
    #[doc(alias = "UISearchControllerScopeBarActivationOnSearchActivation")]
    pub const OnSearchActivation: Self = Self(3);
}

unsafe impl Encode for UISearchControllerScopeBarActivation {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for UISearchControllerScopeBarActivation {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uisearchcontrollerdelegate?language=objc)
    pub unsafe trait UISearchControllerDelegate: NSObjectProtocol + MainThreadOnly {
        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[optional]
        #[unsafe(method(willPresentSearchController:))]
        #[unsafe(method_family = none)]
        fn willPresentSearchController(&self, search_controller: &UISearchController);

        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[optional]
        #[unsafe(method(didPresentSearchController:))]
        #[unsafe(method_family = none)]
        fn didPresentSearchController(&self, search_controller: &UISearchController);

        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[optional]
        #[unsafe(method(willDismissSearchController:))]
        #[unsafe(method_family = none)]
        fn willDismissSearchController(&self, search_controller: &UISearchController);

        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[optional]
        #[unsafe(method(didDismissSearchController:))]
        #[unsafe(method_family = none)]
        fn didDismissSearchController(&self, search_controller: &UISearchController);

        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[optional]
        #[unsafe(method(presentSearchController:))]
        #[unsafe(method_family = none)]
        fn presentSearchController(&self, search_controller: &UISearchController);

        #[cfg(all(
            feature = "UINavigationItem",
            feature = "UIResponder",
            feature = "UIViewController"
        ))]
        #[optional]
        #[unsafe(method(searchController:willChangeToSearchBarPlacement:))]
        #[unsafe(method_family = none)]
        fn searchController_willChangeToSearchBarPlacement(
            &self,
            search_controller: &UISearchController,
            new_placement: UINavigationItemSearchBarPlacement,
        );

        #[cfg(all(
            feature = "UINavigationItem",
            feature = "UIResponder",
            feature = "UIViewController"
        ))]
        #[optional]
        #[unsafe(method(searchController:didChangeFromSearchBarPlacement:))]
        #[unsafe(method_family = none)]
        fn searchController_didChangeFromSearchBarPlacement(
            &self,
            search_controller: &UISearchController,
            previous_placement: UINavigationItemSearchBarPlacement,
        );
    }
);

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uisearchresultsupdating?language=objc)
    pub unsafe trait UISearchResultsUpdating: NSObjectProtocol + MainThreadOnly {
        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[unsafe(method(updateSearchResultsForSearchController:))]
        #[unsafe(method_family = none)]
        fn updateSearchResultsForSearchController(&self, search_controller: &UISearchController);

        #[cfg(all(
            feature = "UIResponder",
            feature = "UISearchSuggestion",
            feature = "UIViewController"
        ))]
        #[optional]
        #[unsafe(method(updateSearchResultsForSearchController:selectingSearchSuggestion:))]
        #[unsafe(method_family = none)]
        fn updateSearchResultsForSearchController_selectingSearchSuggestion(
            &self,
            search_controller: &UISearchController,
            search_suggestion: &ProtocolObject<dyn UISearchSuggestion>,
        );
    }
);

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uisearchcontroller?language=objc)
    #[unsafe(super(UIViewController, UIResponder, NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
    pub struct UISearchController;
);

#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
extern_conformance!(
    unsafe impl NSCoding for UISearchController {}
);

#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
extern_conformance!(
    unsafe impl NSObjectProtocol for UISearchController {}
);

#[cfg(all(
    feature = "UIAppearance",
    feature = "UIResponder",
    feature = "UIViewController"
))]
extern_conformance!(
    unsafe impl UIAppearanceContainer for UISearchController {}
);

#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
extern_conformance!(
    unsafe impl UIContentContainer for UISearchController {}
);

#[cfg(all(
    feature = "UIFocus",
    feature = "UIResponder",
    feature = "UIViewController"
))]
extern_conformance!(
    unsafe impl UIFocusEnvironment for UISearchController {}
);

#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
extern_conformance!(
    unsafe impl UIResponderStandardEditActions for UISearchController {}
);

#[cfg(all(
    feature = "UIResponder",
    feature = "UITraitCollection",
    feature = "UIViewController"
))]
extern_conformance!(
    unsafe impl UITraitEnvironment for UISearchController {}
);

#[cfg(all(
    feature = "UIResponder",
    feature = "UIViewController",
    feature = "UIViewControllerTransitioning"
))]
extern_conformance!(
    unsafe impl UIViewControllerAnimatedTransitioning for UISearchController {}
);

#[cfg(all(
    feature = "UIResponder",
    feature = "UIViewController",
    feature = "UIViewControllerTransitioning"
))]
extern_conformance!(
    unsafe impl UIViewControllerTransitioningDelegate for UISearchController {}
);

#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
impl UISearchController {
    extern_methods!(
        #[unsafe(method(initWithSearchResultsController:))]
        #[unsafe(method_family = init)]
        pub fn initWithSearchResultsController(
            this: Allocated<Self>,
            search_results_controller: Option<&UIViewController>,
        ) -> Retained<Self>;

        #[unsafe(method(initWithNibName:bundle:))]
        #[unsafe(method_family = init)]
        pub fn initWithNibName_bundle(
            this: Allocated<Self>,
            nib_name_or_nil: Option<&NSString>,
            nib_bundle_or_nil: Option<&NSBundle>,
        ) -> Retained<Self>;

        /// # Safety
        ///
        /// `coder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;

        #[unsafe(method(searchResultsUpdater))]
        #[unsafe(method_family = none)]
        pub fn searchResultsUpdater(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn UISearchResultsUpdating>>>;

        /// Setter for [`searchResultsUpdater`][Self::searchResultsUpdater].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setSearchResultsUpdater:))]
        #[unsafe(method_family = none)]
        pub fn setSearchResultsUpdater(
            &self,
            search_results_updater: Option<&ProtocolObject<dyn UISearchResultsUpdating>>,
        );

        #[unsafe(method(isActive))]
        #[unsafe(method_family = none)]
        pub fn isActive(&self) -> bool;

        /// Setter for [`isActive`][Self::isActive].
        #[unsafe(method(setActive:))]
        #[unsafe(method_family = none)]
        pub fn setActive(&self, active: bool);

        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn UISearchControllerDelegate>>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn UISearchControllerDelegate>>,
        );

        #[deprecated]
        #[unsafe(method(dimsBackgroundDuringPresentation))]
        #[unsafe(method_family = none)]
        pub fn dimsBackgroundDuringPresentation(&self) -> bool;

        /// Setter for [`dimsBackgroundDuringPresentation`][Self::dimsBackgroundDuringPresentation].
        #[deprecated]
        #[unsafe(method(setDimsBackgroundDuringPresentation:))]
        #[unsafe(method_family = none)]
        pub fn setDimsBackgroundDuringPresentation(
            &self,
            dims_background_during_presentation: bool,
        );

        #[unsafe(method(obscuresBackgroundDuringPresentation))]
        #[unsafe(method_family = none)]
        pub fn obscuresBackgroundDuringPresentation(&self) -> bool;

        /// Setter for [`obscuresBackgroundDuringPresentation`][Self::obscuresBackgroundDuringPresentation].
        #[unsafe(method(setObscuresBackgroundDuringPresentation:))]
        #[unsafe(method_family = none)]
        pub fn setObscuresBackgroundDuringPresentation(
            &self,
            obscures_background_during_presentation: bool,
        );

        /// Default is `YES` for apps linked before iOS 26.0, other than on MacCatalyst, where the default is `NO`.
        /// On iOS 26.0 for apps linked on iOS 26.0 and later, the value is determined by context unless directly set through the API. The default remains `NO` on MacCatalyst.
        #[unsafe(method(hidesNavigationBarDuringPresentation))]
        #[unsafe(method_family = none)]
        pub fn hidesNavigationBarDuringPresentation(&self) -> bool;

        /// Setter for [`hidesNavigationBarDuringPresentation`][Self::hidesNavigationBarDuringPresentation].
        #[unsafe(method(setHidesNavigationBarDuringPresentation:))]
        #[unsafe(method_family = none)]
        pub fn setHidesNavigationBarDuringPresentation(
            &self,
            hides_navigation_bar_during_presentation: bool,
        );

        #[unsafe(method(searchResultsController))]
        #[unsafe(method_family = none)]
        pub fn searchResultsController(&self) -> Option<Retained<UIViewController>>;

        #[cfg(all(feature = "UISearchBar", feature = "UIView"))]
        #[unsafe(method(searchBar))]
        #[unsafe(method_family = none)]
        pub fn searchBar(&self) -> Retained<UISearchBar>;

        #[cfg(feature = "UINavigationItem")]
        #[unsafe(method(searchBarPlacement))]
        #[unsafe(method_family = none)]
        pub fn searchBarPlacement(&self) -> UINavigationItemSearchBarPlacement;

        #[unsafe(method(automaticallyShowsSearchResultsController))]
        #[unsafe(method_family = none)]
        pub fn automaticallyShowsSearchResultsController(&self) -> bool;

        /// Setter for [`automaticallyShowsSearchResultsController`][Self::automaticallyShowsSearchResultsController].
        #[unsafe(method(setAutomaticallyShowsSearchResultsController:))]
        #[unsafe(method_family = none)]
        pub fn setAutomaticallyShowsSearchResultsController(
            &self,
            automatically_shows_search_results_controller: bool,
        );

        #[unsafe(method(showsSearchResultsController))]
        #[unsafe(method_family = none)]
        pub fn showsSearchResultsController(&self) -> bool;

        /// Setter for [`showsSearchResultsController`][Self::showsSearchResultsController].
        #[unsafe(method(setShowsSearchResultsController:))]
        #[unsafe(method_family = none)]
        pub fn setShowsSearchResultsController(&self, shows_search_results_controller: bool);

        #[unsafe(method(automaticallyShowsCancelButton))]
        #[unsafe(method_family = none)]
        pub fn automaticallyShowsCancelButton(&self) -> bool;

        /// Setter for [`automaticallyShowsCancelButton`][Self::automaticallyShowsCancelButton].
        #[unsafe(method(setAutomaticallyShowsCancelButton:))]
        #[unsafe(method_family = none)]
        pub fn setAutomaticallyShowsCancelButton(&self, automatically_shows_cancel_button: bool);

        #[deprecated = "Use scopeBarActivation instead"]
        #[unsafe(method(automaticallyShowsScopeBar))]
        #[unsafe(method_family = none)]
        pub fn automaticallyShowsScopeBar(&self) -> bool;

        /// Setter for [`automaticallyShowsScopeBar`][Self::automaticallyShowsScopeBar].
        #[deprecated = "Use scopeBarActivation instead"]
        #[unsafe(method(setAutomaticallyShowsScopeBar:))]
        #[unsafe(method_family = none)]
        pub fn setAutomaticallyShowsScopeBar(&self, automatically_shows_scope_bar: bool);

        /// Controls if and when the UISearchController shows and hides the scope bar
        /// However, UISearchBar will not show the scope bar if `scopeButtonTitles` contains fewer than two titles
        /// Defaults to `UISearchControllerScopeBarActivationAutomatic`
        /// `UISearchControllerScopeBarActivationAutomatic` is equivalent to earlier `automaticallyShowsScopeBar == YES`
        /// `UISearchControllerScopeBarActivationManual` is equivalent to earlier `automaticallyShowsScopeBar == NO`
        /// Similar to the behavior of `automaticallyShowsScopeBar`, setting the `showsScopeBar` property on the `searchController`'s `searchBar`
        /// will change `scopeBarActivation` to `UISearchControllerScopeBarActivationManual`
        #[unsafe(method(scopeBarActivation))]
        #[unsafe(method_family = none)]
        pub fn scopeBarActivation(&self) -> UISearchControllerScopeBarActivation;

        /// Setter for [`scopeBarActivation`][Self::scopeBarActivation].
        #[unsafe(method(setScopeBarActivation:))]
        #[unsafe(method_family = none)]
        pub fn setScopeBarActivation(
            &self,
            scope_bar_activation: UISearchControllerScopeBarActivation,
        );

        #[cfg(feature = "UISearchSuggestion")]
        /// List of search hint objects to be displayed under keyboard on tvOS,
        /// as a menu under the search field when the search bar is placed inline on iOS 16,
        /// or as a list in front of the searchResultsController when the search bar is stacked.
        /// Assigning with new array immediately updates the list on screen.
        /// searchSuggestions is set to nil when user interaction selects a suggestion,
        /// or when the user otherwise interacts with search (e.g., typing in the search field, choosing a different search scope, canceling search)
        /// after dismissing the menu by tapping outside
        #[unsafe(method(searchSuggestions))]
        #[unsafe(method_family = none)]
        pub fn searchSuggestions(
            &self,
        ) -> Option<Retained<NSArray<ProtocolObject<dyn UISearchSuggestion>>>>;

        #[cfg(feature = "UISearchSuggestion")]
        /// Setter for [`searchSuggestions`][Self::searchSuggestions].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setSearchSuggestions:))]
        #[unsafe(method_family = none)]
        pub fn setSearchSuggestions(
            &self,
            search_suggestions: Option<&NSArray<ProtocolObject<dyn UISearchSuggestion>>>,
        );

        /// Default NO. When YES, the UISearchController will not create its internal child view controller
        /// for presenting the list of search suggestions when the searchBarPlacement is stacked.
        /// This property is intended to be set at the time that the search controller is initialized.
        /// If set after that point, the internal view controller will not be destroyed, but its view will be hidden and remain so.
        #[unsafe(method(ignoresSearchSuggestionsForSearchBarPlacementStacked))]
        #[unsafe(method_family = none)]
        pub fn ignoresSearchSuggestionsForSearchBarPlacementStacked(&self) -> bool;

        /// Setter for [`ignoresSearchSuggestionsForSearchBarPlacementStacked`][Self::ignoresSearchSuggestionsForSearchBarPlacementStacked].
        #[unsafe(method(setIgnoresSearchSuggestionsForSearchBarPlacementStacked:))]
        #[unsafe(method_family = none)]
        pub fn setIgnoresSearchSuggestionsForSearchBarPlacementStacked(
            &self,
            ignores_search_suggestions_for_search_bar_placement_stacked: bool,
        );

        #[cfg(all(feature = "UIScrollView", feature = "UIView"))]
        #[deprecated = "Use -[UIViewController setContentScrollView:forEdge:] on the searchResultsController instead."]
        #[unsafe(method(searchControllerObservedScrollView))]
        #[unsafe(method_family = none)]
        pub fn searchControllerObservedScrollView(&self) -> Option<Retained<UIScrollView>>;

        #[cfg(all(feature = "UIScrollView", feature = "UIView"))]
        /// Setter for [`searchControllerObservedScrollView`][Self::searchControllerObservedScrollView].
        #[deprecated = "Use -[UIViewController setContentScrollView:forEdge:] on the searchResultsController instead."]
        #[unsafe(method(setSearchControllerObservedScrollView:))]
        #[unsafe(method_family = none)]
        pub fn setSearchControllerObservedScrollView(
            &self,
            search_controller_observed_scroll_view: Option<&UIScrollView>,
        );
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
impl UISearchController {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}