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
//! 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::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitabbaritemstateappearance?language=objc)
    #[unsafe(super(NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct UITabBarItemStateAppearance;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for UITabBarItemStateAppearance {}
);

impl UITabBarItemStateAppearance {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

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

        /// Text attributes to be used for rendering title text. If the font or color are unspecified, appropriate defaults are supplied.
        #[unsafe(method(titleTextAttributes))]
        #[unsafe(method_family = none)]
        pub fn titleTextAttributes(
            &self,
        ) -> Retained<NSDictionary<NSAttributedStringKey, AnyObject>>;

        /// Setter for [`titleTextAttributes`][Self::titleTextAttributes].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `title_text_attributes` generic should be of the correct type.
        #[unsafe(method(setTitleTextAttributes:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTitleTextAttributes(
            &self,
            title_text_attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
        );

        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
        /// An offset to apply to the UITabBarItem's title position
        #[unsafe(method(titlePositionAdjustment))]
        #[unsafe(method_family = none)]
        pub fn titlePositionAdjustment(&self) -> UIOffset;

        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
        /// Setter for [`titlePositionAdjustment`][Self::titlePositionAdjustment].
        #[unsafe(method(setTitlePositionAdjustment:))]
        #[unsafe(method_family = none)]
        pub fn setTitlePositionAdjustment(&self, title_position_adjustment: UIOffset);

        #[cfg(feature = "UIColor")]
        /// The color to use for item icons. If not specified, a suitable color will be derived.
        #[unsafe(method(iconColor))]
        #[unsafe(method_family = none)]
        pub fn iconColor(&self) -> Option<Retained<UIColor>>;

        #[cfg(feature = "UIColor")]
        /// Setter for [`iconColor`][Self::iconColor].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setIconColor:))]
        #[unsafe(method_family = none)]
        pub fn setIconColor(&self, icon_color: Option<&UIColor>);

        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
        /// An offset to apply to the badge's position
        #[unsafe(method(badgePositionAdjustment))]
        #[unsafe(method_family = none)]
        pub fn badgePositionAdjustment(&self) -> UIOffset;

        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
        /// Setter for [`badgePositionAdjustment`][Self::badgePositionAdjustment].
        #[unsafe(method(setBadgePositionAdjustment:))]
        #[unsafe(method_family = none)]
        pub fn setBadgePositionAdjustment(&self, badge_position_adjustment: UIOffset);

        #[cfg(feature = "UIColor")]
        /// The color to use for the badge background
        #[unsafe(method(badgeBackgroundColor))]
        #[unsafe(method_family = none)]
        pub fn badgeBackgroundColor(&self) -> Option<Retained<UIColor>>;

        #[cfg(feature = "UIColor")]
        /// Setter for [`badgeBackgroundColor`][Self::badgeBackgroundColor].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setBadgeBackgroundColor:))]
        #[unsafe(method_family = none)]
        pub fn setBadgeBackgroundColor(&self, badge_background_color: Option<&UIColor>);

        /// Text attributes to be used for rendering badge text. If the font and color are unspecified, appropriate defaults are supplied.
        #[unsafe(method(badgeTextAttributes))]
        #[unsafe(method_family = none)]
        pub fn badgeTextAttributes(
            &self,
        ) -> Retained<NSDictionary<NSAttributedStringKey, AnyObject>>;

        /// Setter for [`badgeTextAttributes`][Self::badgeTextAttributes].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `badge_text_attributes` generic should be of the correct type.
        #[unsafe(method(setBadgeTextAttributes:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setBadgeTextAttributes(
            &self,
            badge_text_attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
        );

        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
        /// An offset to apply to the badge's title position
        #[unsafe(method(badgeTitlePositionAdjustment))]
        #[unsafe(method_family = none)]
        pub fn badgeTitlePositionAdjustment(&self) -> UIOffset;

        #[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
        /// Setter for [`badgeTitlePositionAdjustment`][Self::badgeTitlePositionAdjustment].
        #[unsafe(method(setBadgeTitlePositionAdjustment:))]
        #[unsafe(method_family = none)]
        pub fn setBadgeTitlePositionAdjustment(&self, badge_title_position_adjustment: UIOffset);
    );
}

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitabbaritemappearancestyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UITabBarItemAppearanceStyle(pub NSInteger);
impl UITabBarItemAppearanceStyle {
    #[doc(alias = "UITabBarItemAppearanceStyleStacked")]
    pub const Stacked: Self = Self(0);
    #[doc(alias = "UITabBarItemAppearanceStyleInline")]
    pub const Inline: Self = Self(1);
    #[doc(alias = "UITabBarItemAppearanceStyleCompactInline")]
    pub const CompactInline: Self = Self(2);
}

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

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

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitabbaritemappearance?language=objc)
    #[unsafe(super(NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct UITabBarItemAppearance;
);

extern_conformance!(
    unsafe impl NSCoding for UITabBarItemAppearance {}
);

extern_conformance!(
    unsafe impl NSCopying for UITabBarItemAppearance {}
);

unsafe impl CopyingHelper for UITabBarItemAppearance {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for UITabBarItemAppearance {}
);

extern_conformance!(
    unsafe impl NSSecureCoding for UITabBarItemAppearance {}
);

impl UITabBarItemAppearance {
    extern_methods!(
        /// Construct an appearance with default values for the stacked layout.
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        /// Construct an appearance with default values for the given layout.
        #[unsafe(method(initWithStyle:))]
        #[unsafe(method_family = init)]
        pub fn initWithStyle(
            this: Allocated<Self>,
            style: UITabBarItemAppearanceStyle,
        ) -> Retained<Self>;

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

        #[unsafe(method(copy))]
        #[unsafe(method_family = copy)]
        pub fn copy(&self) -> Retained<Self>;

        /// Reset this appearance to that of the given layout.
        #[unsafe(method(configureWithDefaultForStyle:))]
        #[unsafe(method_family = none)]
        pub fn configureWithDefaultForStyle(&self, style: UITabBarItemAppearanceStyle);

        /// The appearance when the tab bar item is in the normal state
        #[unsafe(method(normal))]
        #[unsafe(method_family = none)]
        pub fn normal(&self) -> Retained<UITabBarItemStateAppearance>;

        /// The appearance when the tab bar item is in the selected state
        #[unsafe(method(selected))]
        #[unsafe(method_family = none)]
        pub fn selected(&self) -> Retained<UITabBarItemStateAppearance>;

        /// The appearance when the tab bar item is in the disabled state
        #[unsafe(method(disabled))]
        #[unsafe(method_family = none)]
        pub fn disabled(&self) -> Retained<UITabBarItemStateAppearance>;

        /// The appearance when the tab bar item is in the focused state
        #[unsafe(method(focused))]
        #[unsafe(method_family = none)]
        pub fn focused(&self) -> Retained<UITabBarItemStateAppearance>;
    );
}

/// Methods declared on superclass `NSObject`.
impl UITabBarItemAppearance {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}

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

#[cfg(feature = "UIBarAppearance")]
extern_conformance!(
    unsafe impl NSCoding for UITabBarAppearance {}
);

#[cfg(feature = "UIBarAppearance")]
extern_conformance!(
    unsafe impl NSCopying for UITabBarAppearance {}
);

#[cfg(feature = "UIBarAppearance")]
unsafe impl CopyingHelper for UITabBarAppearance {
    type Result = Self;
}

#[cfg(feature = "UIBarAppearance")]
extern_conformance!(
    unsafe impl NSObjectProtocol for UITabBarAppearance {}
);

#[cfg(feature = "UIBarAppearance")]
extern_conformance!(
    unsafe impl NSSecureCoding for UITabBarAppearance {}
);

#[cfg(feature = "UIBarAppearance")]
impl UITabBarAppearance {
    extern_methods!(
        /// The appearance for the stacked tab bar item layout
        #[unsafe(method(stackedLayoutAppearance))]
        #[unsafe(method_family = none)]
        pub fn stackedLayoutAppearance(&self) -> Retained<UITabBarItemAppearance>;

        /// Setter for [`stackedLayoutAppearance`][Self::stackedLayoutAppearance].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setStackedLayoutAppearance:))]
        #[unsafe(method_family = none)]
        pub fn setStackedLayoutAppearance(
            &self,
            stacked_layout_appearance: &UITabBarItemAppearance,
        );

        /// The appearance for the inline tab bar item layout
        #[unsafe(method(inlineLayoutAppearance))]
        #[unsafe(method_family = none)]
        pub fn inlineLayoutAppearance(&self) -> Retained<UITabBarItemAppearance>;

        /// Setter for [`inlineLayoutAppearance`][Self::inlineLayoutAppearance].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setInlineLayoutAppearance:))]
        #[unsafe(method_family = none)]
        pub fn setInlineLayoutAppearance(&self, inline_layout_appearance: &UITabBarItemAppearance);

        /// The appearance for the compact inline tab bar item layout
        #[unsafe(method(compactInlineLayoutAppearance))]
        #[unsafe(method_family = none)]
        pub fn compactInlineLayoutAppearance(&self) -> Retained<UITabBarItemAppearance>;

        /// Setter for [`compactInlineLayoutAppearance`][Self::compactInlineLayoutAppearance].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setCompactInlineLayoutAppearance:))]
        #[unsafe(method_family = none)]
        pub fn setCompactInlineLayoutAppearance(
            &self,
            compact_inline_layout_appearance: &UITabBarItemAppearance,
        );

        #[cfg(feature = "UIColor")]
        /// A color to use for the selectionIndicator, its specific behavior depends on the value of selectionIndicatorImage. If selectionIndicatorImage is nil, then the selectionIndicatorTintColor is used to color the UITabBar's default selection indicator; a nil or clearColor selectionIndicatorTintColor will result in no indicator. If selectionIndicatorImage is a template image, then the selectionIndicatorTintColor is used to tint the image; a nil or clearColor selectionIndicatorTintColor will also result in no indicator. If the selectionIndicatorImage is not a template image, then it will be rendered without respect to the value of selectionIndicatorTintColor.
        #[unsafe(method(selectionIndicatorTintColor))]
        #[unsafe(method_family = none)]
        pub fn selectionIndicatorTintColor(&self) -> Option<Retained<UIColor>>;

        #[cfg(feature = "UIColor")]
        /// Setter for [`selectionIndicatorTintColor`][Self::selectionIndicatorTintColor].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setSelectionIndicatorTintColor:))]
        #[unsafe(method_family = none)]
        pub fn setSelectionIndicatorTintColor(
            &self,
            selection_indicator_tint_color: Option<&UIColor>,
        );

        #[cfg(feature = "UIImage")]
        /// An image that is rendered behind the selected UITabBarItem and above the tab bar's background. Modified by selectionIndicatorTintColor when appropriate.
        #[unsafe(method(selectionIndicatorImage))]
        #[unsafe(method_family = none)]
        pub fn selectionIndicatorImage(&self) -> Option<Retained<UIImage>>;

        #[cfg(feature = "UIImage")]
        /// Setter for [`selectionIndicatorImage`][Self::selectionIndicatorImage].
        #[unsafe(method(setSelectionIndicatorImage:))]
        #[unsafe(method_family = none)]
        pub fn setSelectionIndicatorImage(&self, selection_indicator_image: Option<&UIImage>);

        #[cfg(feature = "UITabBar")]
        /// Determines how items in the tab bar lay out in the stacked item layout
        #[unsafe(method(stackedItemPositioning))]
        #[unsafe(method_family = none)]
        pub fn stackedItemPositioning(&self) -> UITabBarItemPositioning;

        #[cfg(feature = "UITabBar")]
        /// Setter for [`stackedItemPositioning`][Self::stackedItemPositioning].
        #[unsafe(method(setStackedItemPositioning:))]
        #[unsafe(method_family = none)]
        pub fn setStackedItemPositioning(&self, stacked_item_positioning: UITabBarItemPositioning);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(stackedItemWidth))]
        #[unsafe(method_family = none)]
        pub fn stackedItemWidth(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`stackedItemWidth`][Self::stackedItemWidth].
        #[unsafe(method(setStackedItemWidth:))]
        #[unsafe(method_family = none)]
        pub fn setStackedItemWidth(&self, stacked_item_width: CGFloat);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(stackedItemSpacing))]
        #[unsafe(method_family = none)]
        pub fn stackedItemSpacing(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`stackedItemSpacing`][Self::stackedItemSpacing].
        #[unsafe(method(setStackedItemSpacing:))]
        #[unsafe(method_family = none)]
        pub fn setStackedItemSpacing(&self, stacked_item_spacing: CGFloat);
    );
}

/// Methods declared on superclass `UIBarAppearance`.
#[cfg(feature = "UIBarAppearance")]
impl UITabBarAppearance {
    extern_methods!(
        /// Constructs a new bar appearance, configured with default values and targeting the device idiom.
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[cfg(feature = "UIDevice")]
        /// Constructs a new bar appearance, targeting the passed-in idiom as a hint. Not all platforms support all available idioms. See the idiom property to determine the resolved idiom.
        #[unsafe(method(initWithIdiom:))]
        #[unsafe(method_family = init)]
        pub fn initWithIdiom(this: Allocated<Self>, idiom: UIUserInterfaceIdiom) -> Retained<Self>;

        /// Constructs a new bar appearance, copying all relevant properties from the given appearance object. This initializer is useful for migrating configuration between UIBarAppearance subclasses. For example, you can initialize a UINavigationBarAppearance with a UIToolbarAppearance instance, and shared attributes will be identical between the two.
        #[unsafe(method(initWithBarAppearance:))]
        #[unsafe(method_family = init)]
        pub fn initWithBarAppearance(
            this: Allocated<Self>,
            bar_appearance: &UIBarAppearance,
        ) -> Retained<Self>;

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

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "UIBarAppearance")]
impl UITabBarAppearance {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}