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
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UINavigationItemLargeTitleDisplayMode(pub NSInteger);
impl UINavigationItemLargeTitleDisplayMode {
    #[doc(alias = "UINavigationItemLargeTitleDisplayModeAutomatic")]
    pub const Automatic: Self = Self(0);
    #[doc(alias = "UINavigationItemLargeTitleDisplayModeAlways")]
    pub const Always: Self = Self(1);
    #[doc(alias = "UINavigationItemLargeTitleDisplayModeNever")]
    pub const Never: Self = Self(2);
    #[doc(alias = "UINavigationItemLargeTitleDisplayModeInline")]
    pub const Inline: Self = Self(3);
}

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

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

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UINavigationItemBackButtonDisplayMode(pub NSInteger);
impl UINavigationItemBackButtonDisplayMode {
    #[doc(alias = "UINavigationItemBackButtonDisplayModeDefault")]
    pub const Default: Self = Self(0);
    #[doc(alias = "UINavigationItemBackButtonDisplayModeGeneric")]
    pub const Generic: Self = Self(1);
    #[doc(alias = "UINavigationItemBackButtonDisplayModeMinimal")]
    pub const Minimal: Self = Self(2);
}

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

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

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UINavigationItemSearchBarPlacement(pub NSInteger);
impl UINavigationItemSearchBarPlacement {
    #[doc(alias = "UINavigationItemSearchBarPlacementAutomatic")]
    pub const Automatic: Self = Self(0);
    #[doc(alias = "UINavigationItemSearchBarPlacementInline")]
    pub const Inline: Self = Self(1);
    #[doc(alias = "UINavigationItemSearchBarPlacementStacked")]
    pub const Stacked: Self = Self(2);
}

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

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

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UINavigationItemStyle(pub NSInteger);
impl UINavigationItemStyle {
    #[doc(alias = "UINavigationItemStyleNavigator")]
    pub const Navigator: Self = Self(0);
    #[doc(alias = "UINavigationItemStyleBrowser")]
    pub const Browser: Self = Self(1);
    #[doc(alias = "UINavigationItemStyleEditor")]
    pub const Editor: Self = Self(2);
}

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

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

extern_protocol!(
    pub unsafe trait UINavigationItemRenameDelegate:
        NSObjectProtocol + IsMainThreadOnly
    {
        #[method(navigationItem:didEndRenamingWithTitle:)]
        unsafe fn navigationItem_didEndRenamingWithTitle(
            &self,
            navigation_item: &UINavigationItem,
            title: &NSString,
        );

        #[optional]
        #[method(navigationItemShouldBeginRenaming:)]
        unsafe fn navigationItemShouldBeginRenaming(
            &self,
            navigation_item: &UINavigationItem,
        ) -> bool;

        #[optional]
        #[method_id(@__retain_semantics Other navigationItem:willBeginRenamingWithSuggestedTitle:selectedRange:)]
        unsafe fn navigationItem_willBeginRenamingWithSuggestedTitle_selectedRange(
            &self,
            navigation_item: &UINavigationItem,
            title: &NSString,
            selected_range: NonNull<NSRange>,
        ) -> Retained<NSString>;

        #[optional]
        #[method(navigationItem:shouldEndRenamingWithTitle:)]
        unsafe fn navigationItem_shouldEndRenamingWithTitle(
            &self,
            navigation_item: &UINavigationItem,
            title: &NSString,
        ) -> bool;
    }

    unsafe impl ProtocolType for dyn UINavigationItemRenameDelegate {}
);

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct UINavigationItem;

    unsafe impl ClassType for UINavigationItem {
        type Super = NSObject;
        type Mutability = MainThreadOnly;
    }
);

unsafe impl NSCoding for UINavigationItem {}

unsafe impl NSObjectProtocol for UINavigationItem {}

extern_methods!(
    unsafe impl UINavigationItem {
        #[method_id(@__retain_semantics Init initWithTitle:)]
        pub unsafe fn initWithTitle(this: Allocated<Self>, title: &NSString) -> Retained<Self>;

        #[method_id(@__retain_semantics Init initWithCoder:)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;

        #[method_id(@__retain_semantics Other title)]
        pub unsafe fn title(&self) -> Option<Retained<NSString>>;

        #[method(setTitle:)]
        pub unsafe fn setTitle(&self, title: Option<&NSString>);

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[method_id(@__retain_semantics Other titleView)]
        pub unsafe fn titleView(&self) -> Option<Retained<UIView>>;

        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
        #[method(setTitleView:)]
        pub unsafe fn setTitleView(&self, title_view: Option<&UIView>);

        #[method_id(@__retain_semantics Other prompt)]
        pub unsafe fn prompt(&self) -> Option<Retained<NSString>>;

        #[method(setPrompt:)]
        pub unsafe fn setPrompt(&self, prompt: Option<&NSString>);

        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
        #[method_id(@__retain_semantics Other backBarButtonItem)]
        pub unsafe fn backBarButtonItem(&self) -> Option<Retained<UIBarButtonItem>>;

        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
        #[method(setBackBarButtonItem:)]
        pub unsafe fn setBackBarButtonItem(&self, back_bar_button_item: Option<&UIBarButtonItem>);

        #[method_id(@__retain_semantics Other backButtonTitle)]
        pub unsafe fn backButtonTitle(&self) -> Option<Retained<NSString>>;

        #[method(setBackButtonTitle:)]
        pub unsafe fn setBackButtonTitle(&self, back_button_title: Option<&NSString>);

        #[method(hidesBackButton)]
        pub unsafe fn hidesBackButton(&self) -> bool;

        #[method(setHidesBackButton:)]
        pub unsafe fn setHidesBackButton(&self, hides_back_button: bool);

        #[method(setHidesBackButton:animated:)]
        pub unsafe fn setHidesBackButton_animated(&self, hides_back_button: bool, animated: bool);

        #[method(backButtonDisplayMode)]
        pub unsafe fn backButtonDisplayMode(&self) -> UINavigationItemBackButtonDisplayMode;

        #[method(setBackButtonDisplayMode:)]
        pub unsafe fn setBackButtonDisplayMode(
            &self,
            back_button_display_mode: UINavigationItemBackButtonDisplayMode,
        );

        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
        #[method_id(@__retain_semantics Other backAction)]
        pub unsafe fn backAction(&self) -> Option<Retained<UIAction>>;

        #[cfg(all(feature = "UIAction", feature = "UIMenuElement"))]
        #[method(setBackAction:)]
        pub unsafe fn setBackAction(&self, back_action: Option<&UIAction>);

        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement", feature = "block2"))]
        #[method(titleMenuProvider)]
        pub unsafe fn titleMenuProvider(
            &self,
        ) -> *mut block2::Block<dyn Fn(NonNull<NSArray<UIMenuElement>>) -> *mut UIMenu>;

        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement", feature = "block2"))]
        #[method(setTitleMenuProvider:)]
        pub unsafe fn setTitleMenuProvider(
            &self,
            title_menu_provider: Option<
                &block2::Block<dyn Fn(NonNull<NSArray<UIMenuElement>>) -> *mut UIMenu>,
            >,
        );

        #[method_id(@__retain_semantics Other renameDelegate)]
        pub unsafe fn renameDelegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn UINavigationItemRenameDelegate>>>;

        #[method(setRenameDelegate:)]
        pub unsafe fn setRenameDelegate(
            &self,
            rename_delegate: Option<&ProtocolObject<dyn UINavigationItemRenameDelegate>>,
        );

        #[cfg(feature = "UIDocumentProperties")]
        #[method_id(@__retain_semantics Other documentProperties)]
        pub unsafe fn documentProperties(&self) -> Option<Retained<UIDocumentProperties>>;

        #[cfg(feature = "UIDocumentProperties")]
        #[method(setDocumentProperties:)]
        pub unsafe fn setDocumentProperties(
            &self,
            document_properties: Option<&UIDocumentProperties>,
        );

        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
        #[method_id(@__retain_semantics Other leftBarButtonItems)]
        pub unsafe fn leftBarButtonItems(&self) -> Option<Retained<NSArray<UIBarButtonItem>>>;

        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
        #[method(setLeftBarButtonItems:)]
        pub unsafe fn setLeftBarButtonItems(
            &self,
            left_bar_button_items: Option<&NSArray<UIBarButtonItem>>,
        );

        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
        #[method_id(@__retain_semantics Other rightBarButtonItems)]
        pub unsafe fn rightBarButtonItems(&self) -> Option<Retained<NSArray<UIBarButtonItem>>>;

        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
        #[method(setRightBarButtonItems:)]
        pub unsafe fn setRightBarButtonItems(
            &self,
            right_bar_button_items: Option<&NSArray<UIBarButtonItem>>,
        );

        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
        #[method(setLeftBarButtonItems:animated:)]
        pub unsafe fn setLeftBarButtonItems_animated(
            &self,
            items: Option<&NSArray<UIBarButtonItem>>,
            animated: bool,
        );

        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
        #[method(setRightBarButtonItems:animated:)]
        pub unsafe fn setRightBarButtonItems_animated(
            &self,
            items: Option<&NSArray<UIBarButtonItem>>,
            animated: bool,
        );

        #[method(leftItemsSupplementBackButton)]
        pub unsafe fn leftItemsSupplementBackButton(&self) -> bool;

        #[method(setLeftItemsSupplementBackButton:)]
        pub unsafe fn setLeftItemsSupplementBackButton(
            &self,
            left_items_supplement_back_button: bool,
        );

        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
        #[method_id(@__retain_semantics Other leftBarButtonItem)]
        pub unsafe fn leftBarButtonItem(&self) -> Option<Retained<UIBarButtonItem>>;

        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
        #[method(setLeftBarButtonItem:)]
        pub unsafe fn setLeftBarButtonItem(&self, left_bar_button_item: Option<&UIBarButtonItem>);

        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
        #[method_id(@__retain_semantics Other rightBarButtonItem)]
        pub unsafe fn rightBarButtonItem(&self) -> Option<Retained<UIBarButtonItem>>;

        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
        #[method(setRightBarButtonItem:)]
        pub unsafe fn setRightBarButtonItem(&self, right_bar_button_item: Option<&UIBarButtonItem>);

        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
        #[method(setLeftBarButtonItem:animated:)]
        pub unsafe fn setLeftBarButtonItem_animated(
            &self,
            item: Option<&UIBarButtonItem>,
            animated: bool,
        );

        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
        #[method(setRightBarButtonItem:animated:)]
        pub unsafe fn setRightBarButtonItem_animated(
            &self,
            item: Option<&UIBarButtonItem>,
            animated: bool,
        );

        #[method_id(@__retain_semantics Other customizationIdentifier)]
        pub unsafe fn customizationIdentifier(&self) -> Option<Retained<NSString>>;

        #[method(setCustomizationIdentifier:)]
        pub unsafe fn setCustomizationIdentifier(
            &self,
            customization_identifier: Option<&NSString>,
        );

        #[cfg(feature = "UIBarButtonItemGroup")]
        #[method_id(@__retain_semantics Other leadingItemGroups)]
        pub unsafe fn leadingItemGroups(&self) -> Retained<NSArray<UIBarButtonItemGroup>>;

        #[cfg(feature = "UIBarButtonItemGroup")]
        #[method(setLeadingItemGroups:)]
        pub unsafe fn setLeadingItemGroups(
            &self,
            leading_item_groups: &NSArray<UIBarButtonItemGroup>,
        );

        #[cfg(feature = "UIBarButtonItemGroup")]
        #[method_id(@__retain_semantics Other centerItemGroups)]
        pub unsafe fn centerItemGroups(&self) -> Retained<NSArray<UIBarButtonItemGroup>>;

        #[cfg(feature = "UIBarButtonItemGroup")]
        #[method(setCenterItemGroups:)]
        pub unsafe fn setCenterItemGroups(
            &self,
            center_item_groups: &NSArray<UIBarButtonItemGroup>,
        );

        #[cfg(feature = "UIBarButtonItemGroup")]
        #[method_id(@__retain_semantics Other trailingItemGroups)]
        pub unsafe fn trailingItemGroups(&self) -> Retained<NSArray<UIBarButtonItemGroup>>;

        #[cfg(feature = "UIBarButtonItemGroup")]
        #[method(setTrailingItemGroups:)]
        pub unsafe fn setTrailingItemGroups(
            &self,
            trailing_item_groups: &NSArray<UIBarButtonItemGroup>,
        );

        #[cfg(feature = "UIBarButtonItemGroup")]
        #[method_id(@__retain_semantics Other pinnedTrailingGroup)]
        pub unsafe fn pinnedTrailingGroup(&self) -> Option<Retained<UIBarButtonItemGroup>>;

        #[cfg(feature = "UIBarButtonItemGroup")]
        #[method(setPinnedTrailingGroup:)]
        pub unsafe fn setPinnedTrailingGroup(
            &self,
            pinned_trailing_group: Option<&UIBarButtonItemGroup>,
        );

        #[cfg(all(feature = "UIDeferredMenuElement", feature = "UIMenuElement"))]
        #[method_id(@__retain_semantics Other additionalOverflowItems)]
        pub unsafe fn additionalOverflowItems(&self) -> Option<Retained<UIDeferredMenuElement>>;

        #[cfg(all(feature = "UIDeferredMenuElement", feature = "UIMenuElement"))]
        #[method(setAdditionalOverflowItems:)]
        pub unsafe fn setAdditionalOverflowItems(
            &self,
            additional_overflow_items: Option<&UIDeferredMenuElement>,
        );

        #[cfg(feature = "UIPopoverPresentationControllerSourceItem")]
        #[method_id(@__retain_semantics Other overflowPresentationSource)]
        pub unsafe fn overflowPresentationSource(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn UIPopoverPresentationControllerSourceItem>>>;

        #[method(largeTitleDisplayMode)]
        pub unsafe fn largeTitleDisplayMode(&self) -> UINavigationItemLargeTitleDisplayMode;

        #[method(setLargeTitleDisplayMode:)]
        pub unsafe fn setLargeTitleDisplayMode(
            &self,
            large_title_display_mode: UINavigationItemLargeTitleDisplayMode,
        );

        #[method(style)]
        pub unsafe fn style(&self) -> UINavigationItemStyle;

        #[method(setStyle:)]
        pub unsafe fn setStyle(&self, style: UINavigationItemStyle);

        #[cfg(all(
            feature = "UIResponder",
            feature = "UISearchController",
            feature = "UIViewController"
        ))]
        #[method_id(@__retain_semantics Other searchController)]
        pub unsafe fn searchController(&self) -> Option<Retained<UISearchController>>;

        #[cfg(all(
            feature = "UIResponder",
            feature = "UISearchController",
            feature = "UIViewController"
        ))]
        #[method(setSearchController:)]
        pub unsafe fn setSearchController(&self, search_controller: Option<&UISearchController>);

        #[method(hidesSearchBarWhenScrolling)]
        pub unsafe fn hidesSearchBarWhenScrolling(&self) -> bool;

        #[method(setHidesSearchBarWhenScrolling:)]
        pub unsafe fn setHidesSearchBarWhenScrolling(&self, hides_search_bar_when_scrolling: bool);

        #[method(preferredSearchBarPlacement)]
        pub unsafe fn preferredSearchBarPlacement(&self) -> UINavigationItemSearchBarPlacement;

        #[method(setPreferredSearchBarPlacement:)]
        pub unsafe fn setPreferredSearchBarPlacement(
            &self,
            preferred_search_bar_placement: UINavigationItemSearchBarPlacement,
        );

        #[method(searchBarPlacement)]
        pub unsafe fn searchBarPlacement(&self) -> UINavigationItemSearchBarPlacement;

        #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
        #[method_id(@__retain_semantics Other standardAppearance)]
        pub unsafe fn standardAppearance(&self) -> Option<Retained<UINavigationBarAppearance>>;

        #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
        #[method(setStandardAppearance:)]
        pub unsafe fn setStandardAppearance(
            &self,
            standard_appearance: Option<&UINavigationBarAppearance>,
        );

        #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
        #[method_id(@__retain_semantics Other compactAppearance)]
        pub unsafe fn compactAppearance(&self) -> Option<Retained<UINavigationBarAppearance>>;

        #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
        #[method(setCompactAppearance:)]
        pub unsafe fn setCompactAppearance(
            &self,
            compact_appearance: Option<&UINavigationBarAppearance>,
        );

        #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
        #[method_id(@__retain_semantics Other scrollEdgeAppearance)]
        pub unsafe fn scrollEdgeAppearance(&self) -> Option<Retained<UINavigationBarAppearance>>;

        #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
        #[method(setScrollEdgeAppearance:)]
        pub unsafe fn setScrollEdgeAppearance(
            &self,
            scroll_edge_appearance: Option<&UINavigationBarAppearance>,
        );

        #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
        #[method_id(@__retain_semantics Other compactScrollEdgeAppearance)]
        pub unsafe fn compactScrollEdgeAppearance(
            &self,
        ) -> Option<Retained<UINavigationBarAppearance>>;

        #[cfg(all(feature = "UIBarAppearance", feature = "UINavigationBarAppearance"))]
        #[method(setCompactScrollEdgeAppearance:)]
        pub unsafe fn setCompactScrollEdgeAppearance(
            &self,
            compact_scroll_edge_appearance: Option<&UINavigationBarAppearance>,
        );
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl UINavigationItem {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    }
);