objc2_ui_kit/generated/
UIBarButtonItemBadge.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
10extern_class!(
11    /// A badge to be rendered on a bar button item.
12    ///
13    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uibarbuttonitembadge?language=objc)
14    #[unsafe(super(NSObject))]
15    #[thread_kind = MainThreadOnly]
16    #[derive(Debug, PartialEq, Eq, Hash)]
17    pub struct UIBarButtonItemBadge;
18);
19
20extern_conformance!(
21    unsafe impl NSCoding for UIBarButtonItemBadge {}
22);
23
24extern_conformance!(
25    unsafe impl NSCopying for UIBarButtonItemBadge {}
26);
27
28unsafe impl CopyingHelper for UIBarButtonItemBadge {
29    type Result = Self;
30}
31
32extern_conformance!(
33    unsafe impl NSObjectProtocol for UIBarButtonItemBadge {}
34);
35
36extern_conformance!(
37    unsafe impl NSSecureCoding for UIBarButtonItemBadge {}
38);
39
40impl UIBarButtonItemBadge {
41    extern_methods!(
42        /// Creates a badge with the specified `count`.
43        ///
44        /// The count is localized when shown, and will update
45        /// when the app’s locale changes.
46        #[unsafe(method(badgeWithCount:))]
47        #[unsafe(method_family = none)]
48        pub fn badgeWithCount(count: NSUInteger, mtm: MainThreadMarker) -> Retained<Self>;
49
50        /// Creates a badge with the specified `string`.
51        #[unsafe(method(badgeWithString:))]
52        #[unsafe(method_family = none)]
53        pub fn badgeWithString(string_value: &NSString, mtm: MainThreadMarker) -> Retained<Self>;
54
55        /// Creates a badge that's empty, and just renders the badge background
56        /// with no content.
57        #[unsafe(method(indicatorBadge))]
58        #[unsafe(method_family = none)]
59        pub fn indicatorBadge(mtm: MainThreadMarker) -> Retained<Self>;
60
61        #[unsafe(method(init))]
62        #[unsafe(method_family = init)]
63        pub fn init(this: Allocated<Self>) -> Retained<Self>;
64
65        #[unsafe(method(stringValue))]
66        #[unsafe(method_family = none)]
67        pub fn stringValue(&self) -> Option<Retained<NSString>>;
68
69        #[cfg(feature = "UIColor")]
70        /// The badge's background color. A `nil` value will be treated as an indication to use the system default.
71        #[unsafe(method(backgroundColor))]
72        #[unsafe(method_family = none)]
73        pub fn backgroundColor(&self) -> Option<Retained<UIColor>>;
74
75        #[cfg(feature = "UIColor")]
76        /// Setter for [`backgroundColor`][Self::backgroundColor].
77        #[unsafe(method(setBackgroundColor:))]
78        #[unsafe(method_family = none)]
79        pub fn setBackgroundColor(&self, background_color: Option<&UIColor>);
80
81        #[cfg(feature = "UIColor")]
82        /// The badge's foreground color. A `nil` value will be treated as an indication to use the system default.
83        #[unsafe(method(foregroundColor))]
84        #[unsafe(method_family = none)]
85        pub fn foregroundColor(&self) -> Option<Retained<UIColor>>;
86
87        #[cfg(feature = "UIColor")]
88        /// Setter for [`foregroundColor`][Self::foregroundColor].
89        #[unsafe(method(setForegroundColor:))]
90        #[unsafe(method_family = none)]
91        pub fn setForegroundColor(&self, foreground_color: Option<&UIColor>);
92
93        #[cfg(feature = "UIFont")]
94        /// The font to use for the badge. A `nil` value will be treated as an indication to use the system default.
95        #[unsafe(method(font))]
96        #[unsafe(method_family = none)]
97        pub fn font(&self) -> Option<Retained<UIFont>>;
98
99        #[cfg(feature = "UIFont")]
100        /// Setter for [`font`][Self::font].
101        #[unsafe(method(setFont:))]
102        #[unsafe(method_family = none)]
103        pub fn setFont(&self, font: Option<&UIFont>);
104    );
105}
106
107/// Methods declared on superclass `NSObject`.
108impl UIBarButtonItemBadge {
109    extern_methods!(
110        #[unsafe(method(new))]
111        #[unsafe(method_family = new)]
112        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
113    );
114}
115
116/// Badging.
117#[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem"))]
118impl UIBarButtonItem {
119    extern_methods!(
120        /// Sets a badge on the bar button item. Currently only supported in navigation bars.
121        #[unsafe(method(badge))]
122        #[unsafe(method_family = none)]
123        pub fn badge(&self) -> Option<Retained<UIBarButtonItemBadge>>;
124
125        /// Setter for [`badge`][Self::badge].
126        #[unsafe(method(setBadge:))]
127        #[unsafe(method_family = none)]
128        pub fn setBadge(&self, badge: Option<&UIBarButtonItemBadge>);
129    );
130}