1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12extern_class!(
13 #[unsafe(super(NSObject))]
17 #[derive(Debug, PartialEq, Eq, Hash)]
18 pub struct UITraitCollection;
19);
20
21unsafe impl Send for UITraitCollection {}
22
23unsafe impl Sync for UITraitCollection {}
24
25extern_conformance!(
26 unsafe impl NSCoding for UITraitCollection {}
27);
28
29extern_conformance!(
30 unsafe impl NSCopying for UITraitCollection {}
31);
32
33unsafe impl CopyingHelper for UITraitCollection {
34 type Result = Self;
35}
36
37extern_conformance!(
38 unsafe impl NSObjectProtocol for UITraitCollection {}
39);
40
41extern_conformance!(
42 unsafe impl NSSecureCoding for UITraitCollection {}
43);
44
45impl UITraitCollection {
46 extern_methods!(
47 #[unsafe(method(init))]
48 #[unsafe(method_family = init)]
49 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
50
51 #[unsafe(method(initWithCoder:))]
52 #[unsafe(method_family = init)]
53 pub unsafe fn initWithCoder(
54 this: Allocated<Self>,
55 coder: &NSCoder,
56 ) -> Option<Retained<Self>>;
57
58 #[deprecated = "Compare values for specific traits in the trait collections instead"]
59 #[unsafe(method(containsTraitsInCollection:))]
60 #[unsafe(method_family = none)]
61 pub unsafe fn containsTraitsInCollection(
62 &self,
63 r#trait: Option<&UITraitCollection>,
64 ) -> bool;
65
66 #[deprecated = "Use +[UITraitCollection traitCollectionWithTraits:] and -[UITraitCollection traitCollectionByModifyingTraits:] to create and modify trait collections"]
67 #[unsafe(method(traitCollectionWithTraitsFromCollections:))]
68 #[unsafe(method_family = none)]
69 pub unsafe fn traitCollectionWithTraitsFromCollections(
70 trait_collections: &NSArray<UITraitCollection>,
71 ) -> Retained<UITraitCollection>;
72
73 #[cfg(feature = "UIDevice")]
74 #[unsafe(method(traitCollectionWithUserInterfaceIdiom:))]
75 #[unsafe(method_family = none)]
76 pub unsafe fn traitCollectionWithUserInterfaceIdiom(
77 idiom: UIUserInterfaceIdiom,
78 ) -> Retained<UITraitCollection>;
79
80 #[cfg(feature = "UIDevice")]
81 #[unsafe(method(userInterfaceIdiom))]
82 #[unsafe(method_family = none)]
83 pub unsafe fn userInterfaceIdiom(&self) -> UIUserInterfaceIdiom;
84
85 #[cfg(feature = "UIInterface")]
86 #[unsafe(method(traitCollectionWithUserInterfaceStyle:))]
87 #[unsafe(method_family = none)]
88 pub unsafe fn traitCollectionWithUserInterfaceStyle(
89 user_interface_style: UIUserInterfaceStyle,
90 ) -> Retained<UITraitCollection>;
91
92 #[cfg(feature = "UIInterface")]
93 #[unsafe(method(userInterfaceStyle))]
94 #[unsafe(method_family = none)]
95 pub unsafe fn userInterfaceStyle(&self) -> UIUserInterfaceStyle;
96
97 #[cfg(feature = "UIInterface")]
98 #[unsafe(method(traitCollectionWithLayoutDirection:))]
99 #[unsafe(method_family = none)]
100 pub unsafe fn traitCollectionWithLayoutDirection(
101 layout_direction: UITraitEnvironmentLayoutDirection,
102 ) -> Retained<UITraitCollection>;
103
104 #[cfg(feature = "UIInterface")]
105 #[unsafe(method(layoutDirection))]
106 #[unsafe(method_family = none)]
107 pub unsafe fn layoutDirection(&self) -> UITraitEnvironmentLayoutDirection;
108
109 #[cfg(feature = "objc2-core-foundation")]
110 #[unsafe(method(traitCollectionWithDisplayScale:))]
111 #[unsafe(method_family = none)]
112 pub unsafe fn traitCollectionWithDisplayScale(
113 scale: CGFloat,
114 ) -> Retained<UITraitCollection>;
115
116 #[cfg(feature = "objc2-core-foundation")]
117 #[unsafe(method(displayScale))]
118 #[unsafe(method_family = none)]
119 pub unsafe fn displayScale(&self) -> CGFloat;
120
121 #[cfg(feature = "UIInterface")]
122 #[unsafe(method(traitCollectionWithHorizontalSizeClass:))]
123 #[unsafe(method_family = none)]
124 pub unsafe fn traitCollectionWithHorizontalSizeClass(
125 horizontal_size_class: UIUserInterfaceSizeClass,
126 ) -> Retained<UITraitCollection>;
127
128 #[cfg(feature = "UIInterface")]
129 #[unsafe(method(horizontalSizeClass))]
130 #[unsafe(method_family = none)]
131 pub unsafe fn horizontalSizeClass(&self) -> UIUserInterfaceSizeClass;
132
133 #[cfg(feature = "UIInterface")]
134 #[unsafe(method(traitCollectionWithVerticalSizeClass:))]
135 #[unsafe(method_family = none)]
136 pub unsafe fn traitCollectionWithVerticalSizeClass(
137 vertical_size_class: UIUserInterfaceSizeClass,
138 ) -> Retained<UITraitCollection>;
139
140 #[cfg(feature = "UIInterface")]
141 #[unsafe(method(verticalSizeClass))]
142 #[unsafe(method_family = none)]
143 pub unsafe fn verticalSizeClass(&self) -> UIUserInterfaceSizeClass;
144
145 #[cfg(feature = "UITouch")]
146 #[unsafe(method(traitCollectionWithForceTouchCapability:))]
147 #[unsafe(method_family = none)]
148 pub unsafe fn traitCollectionWithForceTouchCapability(
149 capability: UIForceTouchCapability,
150 ) -> Retained<UITraitCollection>;
151
152 #[cfg(feature = "UITouch")]
153 #[unsafe(method(forceTouchCapability))]
154 #[unsafe(method_family = none)]
155 pub fn forceTouchCapability(&self) -> UIForceTouchCapability;
156
157 #[cfg(feature = "UIContentSizeCategory")]
158 #[unsafe(method(traitCollectionWithPreferredContentSizeCategory:))]
159 #[unsafe(method_family = none)]
160 pub unsafe fn traitCollectionWithPreferredContentSizeCategory(
161 preferred_content_size_category: &UIContentSizeCategory,
162 ) -> Retained<UITraitCollection>;
163
164 #[cfg(feature = "UIContentSizeCategory")]
165 #[unsafe(method(preferredContentSizeCategory))]
166 #[unsafe(method_family = none)]
167 pub unsafe fn preferredContentSizeCategory(&self) -> Retained<UIContentSizeCategory>;
168
169 #[cfg(feature = "UIInterface")]
170 #[unsafe(method(traitCollectionWithDisplayGamut:))]
171 #[unsafe(method_family = none)]
172 pub unsafe fn traitCollectionWithDisplayGamut(
173 display_gamut: UIDisplayGamut,
174 ) -> Retained<UITraitCollection>;
175
176 #[cfg(feature = "UIInterface")]
177 #[unsafe(method(displayGamut))]
178 #[unsafe(method_family = none)]
179 pub unsafe fn displayGamut(&self) -> UIDisplayGamut;
180
181 #[cfg(feature = "UIInterface")]
182 #[unsafe(method(traitCollectionWithAccessibilityContrast:))]
183 #[unsafe(method_family = none)]
184 pub unsafe fn traitCollectionWithAccessibilityContrast(
185 accessibility_contrast: UIAccessibilityContrast,
186 ) -> Retained<UITraitCollection>;
187
188 #[cfg(feature = "UIInterface")]
189 #[unsafe(method(accessibilityContrast))]
190 #[unsafe(method_family = none)]
191 pub unsafe fn accessibilityContrast(&self) -> UIAccessibilityContrast;
192
193 #[cfg(feature = "UIInterface")]
194 #[unsafe(method(traitCollectionWithUserInterfaceLevel:))]
195 #[unsafe(method_family = none)]
196 pub unsafe fn traitCollectionWithUserInterfaceLevel(
197 user_interface_level: UIUserInterfaceLevel,
198 ) -> Retained<UITraitCollection>;
199
200 #[cfg(feature = "UIInterface")]
201 #[unsafe(method(userInterfaceLevel))]
202 #[unsafe(method_family = none)]
203 pub unsafe fn userInterfaceLevel(&self) -> UIUserInterfaceLevel;
204
205 #[cfg(feature = "UIInterface")]
206 #[unsafe(method(traitCollectionWithLegibilityWeight:))]
207 #[unsafe(method_family = none)]
208 pub unsafe fn traitCollectionWithLegibilityWeight(
209 legibility_weight: UILegibilityWeight,
210 ) -> Retained<UITraitCollection>;
211
212 #[cfg(feature = "UIInterface")]
213 #[unsafe(method(legibilityWeight))]
214 #[unsafe(method_family = none)]
215 pub unsafe fn legibilityWeight(&self) -> UILegibilityWeight;
216
217 #[cfg(feature = "UIInterface")]
218 #[unsafe(method(traitCollectionWithActiveAppearance:))]
219 #[unsafe(method_family = none)]
220 pub unsafe fn traitCollectionWithActiveAppearance(
221 user_interface_active_appearance: UIUserInterfaceActiveAppearance,
222 ) -> Retained<UITraitCollection>;
223
224 #[cfg(feature = "UIInterface")]
225 #[unsafe(method(activeAppearance))]
226 #[unsafe(method_family = none)]
227 pub unsafe fn activeAppearance(&self) -> UIUserInterfaceActiveAppearance;
228
229 #[cfg(feature = "UIInterface")]
230 #[unsafe(method(traitCollectionWithToolbarItemPresentationSize:))]
231 #[unsafe(method_family = none)]
232 pub unsafe fn traitCollectionWithToolbarItemPresentationSize(
233 toolbar_item_presentation_size: UINSToolbarItemPresentationSize,
234 ) -> Retained<UITraitCollection>;
235
236 #[cfg(feature = "UIInterface")]
237 #[unsafe(method(toolbarItemPresentationSize))]
238 #[unsafe(method_family = none)]
239 pub unsafe fn toolbarItemPresentationSize(&self) -> UINSToolbarItemPresentationSize;
240
241 #[cfg(feature = "UIInterface")]
242 #[unsafe(method(traitCollectionWithImageDynamicRange:))]
244 #[unsafe(method_family = none)]
245 pub unsafe fn traitCollectionWithImageDynamicRange(
246 image_dynamic_range: UIImageDynamicRange,
247 ) -> Retained<UITraitCollection>;
248
249 #[cfg(feature = "UIInterface")]
250 #[unsafe(method(imageDynamicRange))]
252 #[unsafe(method_family = none)]
253 pub unsafe fn imageDynamicRange(&self) -> UIImageDynamicRange;
254
255 #[unsafe(method(traitCollectionWithTypesettingLanguage:))]
256 #[unsafe(method_family = none)]
257 pub unsafe fn traitCollectionWithTypesettingLanguage(
258 language: &NSString,
259 ) -> Retained<UITraitCollection>;
260
261 #[unsafe(method(typesettingLanguage))]
262 #[unsafe(method_family = none)]
263 pub unsafe fn typesettingLanguage(&self) -> Retained<NSString>;
264
265 #[cfg(feature = "UISceneDefinitions")]
266 #[unsafe(method(traitCollectionWithSceneCaptureState:))]
268 #[unsafe(method_family = none)]
269 pub unsafe fn traitCollectionWithSceneCaptureState(
270 scene_capture_state: UISceneCaptureState,
271 ) -> Retained<UITraitCollection>;
272
273 #[cfg(feature = "UISceneDefinitions")]
274 #[unsafe(method(sceneCaptureState))]
276 #[unsafe(method_family = none)]
277 pub unsafe fn sceneCaptureState(&self) -> UISceneCaptureState;
278
279 #[cfg(feature = "UITraitListEnvironment")]
280 #[unsafe(method(traitCollectionWithListEnvironment:))]
282 #[unsafe(method_family = none)]
283 pub unsafe fn traitCollectionWithListEnvironment(
284 list_environment: UIListEnvironment,
285 ) -> Retained<UITraitCollection>;
286
287 #[cfg(feature = "UITraitListEnvironment")]
288 #[unsafe(method(listEnvironment))]
290 #[unsafe(method_family = none)]
291 pub unsafe fn listEnvironment(&self) -> UIListEnvironment;
292 );
293}
294
295impl UITraitCollection {
297 extern_methods!(
298 #[unsafe(method(new))]
299 #[unsafe(method_family = new)]
300 pub unsafe fn new() -> Retained<Self>;
301 );
302}
303
304extern_protocol!(
305 pub unsafe trait UIMutableTraits: NSObjectProtocol + MainThreadOnly {
307 #[cfg(all(feature = "UITrait", feature = "objc2-core-foundation"))]
308 #[unsafe(method(setCGFloatValue:forTrait:))]
309 #[unsafe(method_family = none)]
310 unsafe fn setCGFloatValue_forTrait(&self, value: CGFloat, r#trait: &UICGFloatTrait);
311
312 #[cfg(all(feature = "UITrait", feature = "objc2-core-foundation"))]
313 #[unsafe(method(valueForCGFloatTrait:))]
314 #[unsafe(method_family = none)]
315 unsafe fn valueForCGFloatTrait(&self, r#trait: &UICGFloatTrait) -> CGFloat;
316
317 #[cfg(feature = "UITrait")]
318 #[unsafe(method(setNSIntegerValue:forTrait:))]
319 #[unsafe(method_family = none)]
320 unsafe fn setNSIntegerValue_forTrait(&self, value: NSInteger, r#trait: &UINSIntegerTrait);
321
322 #[cfg(feature = "UITrait")]
323 #[unsafe(method(valueForNSIntegerTrait:))]
324 #[unsafe(method_family = none)]
325 unsafe fn valueForNSIntegerTrait(&self, r#trait: &UINSIntegerTrait) -> NSInteger;
326
327 #[cfg(feature = "UITrait")]
328 #[unsafe(method(setObject:forTrait:))]
329 #[unsafe(method_family = none)]
330 unsafe fn setObject_forTrait(
331 &self,
332 object: Option<&ProtocolObject<dyn NSObjectProtocol>>,
333 r#trait: &UIObjectTrait,
334 );
335
336 #[cfg(feature = "UITrait")]
337 #[unsafe(method(objectForTrait:))]
338 #[unsafe(method_family = none)]
339 unsafe fn objectForTrait(
340 &self,
341 r#trait: &UIObjectTrait,
342 ) -> Option<Retained<ProtocolObject<dyn NSObjectProtocol>>>;
343
344 #[cfg(feature = "UIDevice")]
345 #[unsafe(method(userInterfaceIdiom))]
346 #[unsafe(method_family = none)]
347 unsafe fn userInterfaceIdiom(&self) -> UIUserInterfaceIdiom;
348
349 #[cfg(feature = "UIDevice")]
350 #[unsafe(method(setUserInterfaceIdiom:))]
352 #[unsafe(method_family = none)]
353 unsafe fn setUserInterfaceIdiom(&self, user_interface_idiom: UIUserInterfaceIdiom);
354
355 #[cfg(feature = "UIInterface")]
356 #[unsafe(method(userInterfaceStyle))]
357 #[unsafe(method_family = none)]
358 unsafe fn userInterfaceStyle(&self) -> UIUserInterfaceStyle;
359
360 #[cfg(feature = "UIInterface")]
361 #[unsafe(method(setUserInterfaceStyle:))]
363 #[unsafe(method_family = none)]
364 unsafe fn setUserInterfaceStyle(&self, user_interface_style: UIUserInterfaceStyle);
365
366 #[cfg(feature = "UIInterface")]
367 #[unsafe(method(layoutDirection))]
368 #[unsafe(method_family = none)]
369 unsafe fn layoutDirection(&self) -> UITraitEnvironmentLayoutDirection;
370
371 #[cfg(feature = "UIInterface")]
372 #[unsafe(method(setLayoutDirection:))]
374 #[unsafe(method_family = none)]
375 unsafe fn setLayoutDirection(&self, layout_direction: UITraitEnvironmentLayoutDirection);
376
377 #[cfg(feature = "objc2-core-foundation")]
378 #[unsafe(method(displayScale))]
379 #[unsafe(method_family = none)]
380 unsafe fn displayScale(&self) -> CGFloat;
381
382 #[cfg(feature = "objc2-core-foundation")]
383 #[unsafe(method(setDisplayScale:))]
385 #[unsafe(method_family = none)]
386 unsafe fn setDisplayScale(&self, display_scale: CGFloat);
387
388 #[cfg(feature = "UIInterface")]
389 #[unsafe(method(horizontalSizeClass))]
390 #[unsafe(method_family = none)]
391 unsafe fn horizontalSizeClass(&self) -> UIUserInterfaceSizeClass;
392
393 #[cfg(feature = "UIInterface")]
394 #[unsafe(method(setHorizontalSizeClass:))]
396 #[unsafe(method_family = none)]
397 unsafe fn setHorizontalSizeClass(&self, horizontal_size_class: UIUserInterfaceSizeClass);
398
399 #[cfg(feature = "UIInterface")]
400 #[unsafe(method(verticalSizeClass))]
401 #[unsafe(method_family = none)]
402 unsafe fn verticalSizeClass(&self) -> UIUserInterfaceSizeClass;
403
404 #[cfg(feature = "UIInterface")]
405 #[unsafe(method(setVerticalSizeClass:))]
407 #[unsafe(method_family = none)]
408 unsafe fn setVerticalSizeClass(&self, vertical_size_class: UIUserInterfaceSizeClass);
409
410 #[cfg(feature = "UITouch")]
411 #[unsafe(method(forceTouchCapability))]
412 #[unsafe(method_family = none)]
413 unsafe fn forceTouchCapability(&self) -> UIForceTouchCapability;
414
415 #[cfg(feature = "UITouch")]
416 #[unsafe(method(setForceTouchCapability:))]
418 #[unsafe(method_family = none)]
419 unsafe fn setForceTouchCapability(&self, force_touch_capability: UIForceTouchCapability);
420
421 #[cfg(feature = "UIContentSizeCategory")]
422 #[unsafe(method(preferredContentSizeCategory))]
423 #[unsafe(method_family = none)]
424 unsafe fn preferredContentSizeCategory(&self) -> Retained<UIContentSizeCategory>;
425
426 #[cfg(feature = "UIContentSizeCategory")]
427 #[unsafe(method(setPreferredContentSizeCategory:))]
429 #[unsafe(method_family = none)]
430 unsafe fn setPreferredContentSizeCategory(
431 &self,
432 preferred_content_size_category: &UIContentSizeCategory,
433 );
434
435 #[cfg(feature = "UIInterface")]
436 #[unsafe(method(displayGamut))]
437 #[unsafe(method_family = none)]
438 unsafe fn displayGamut(&self) -> UIDisplayGamut;
439
440 #[cfg(feature = "UIInterface")]
441 #[unsafe(method(setDisplayGamut:))]
443 #[unsafe(method_family = none)]
444 unsafe fn setDisplayGamut(&self, display_gamut: UIDisplayGamut);
445
446 #[cfg(feature = "UIInterface")]
447 #[unsafe(method(accessibilityContrast))]
448 #[unsafe(method_family = none)]
449 unsafe fn accessibilityContrast(&self) -> UIAccessibilityContrast;
450
451 #[cfg(feature = "UIInterface")]
452 #[unsafe(method(setAccessibilityContrast:))]
454 #[unsafe(method_family = none)]
455 unsafe fn setAccessibilityContrast(&self, accessibility_contrast: UIAccessibilityContrast);
456
457 #[cfg(feature = "UIInterface")]
458 #[unsafe(method(userInterfaceLevel))]
459 #[unsafe(method_family = none)]
460 unsafe fn userInterfaceLevel(&self) -> UIUserInterfaceLevel;
461
462 #[cfg(feature = "UIInterface")]
463 #[unsafe(method(setUserInterfaceLevel:))]
465 #[unsafe(method_family = none)]
466 unsafe fn setUserInterfaceLevel(&self, user_interface_level: UIUserInterfaceLevel);
467
468 #[cfg(feature = "UIInterface")]
469 #[unsafe(method(legibilityWeight))]
470 #[unsafe(method_family = none)]
471 unsafe fn legibilityWeight(&self) -> UILegibilityWeight;
472
473 #[cfg(feature = "UIInterface")]
474 #[unsafe(method(setLegibilityWeight:))]
476 #[unsafe(method_family = none)]
477 unsafe fn setLegibilityWeight(&self, legibility_weight: UILegibilityWeight);
478
479 #[cfg(feature = "UIInterface")]
480 #[unsafe(method(activeAppearance))]
481 #[unsafe(method_family = none)]
482 unsafe fn activeAppearance(&self) -> UIUserInterfaceActiveAppearance;
483
484 #[cfg(feature = "UIInterface")]
485 #[unsafe(method(setActiveAppearance:))]
487 #[unsafe(method_family = none)]
488 unsafe fn setActiveAppearance(&self, active_appearance: UIUserInterfaceActiveAppearance);
489
490 #[cfg(feature = "UIInterface")]
491 #[unsafe(method(toolbarItemPresentationSize))]
492 #[unsafe(method_family = none)]
493 unsafe fn toolbarItemPresentationSize(&self) -> UINSToolbarItemPresentationSize;
494
495 #[cfg(feature = "UIInterface")]
496 #[unsafe(method(setToolbarItemPresentationSize:))]
498 #[unsafe(method_family = none)]
499 unsafe fn setToolbarItemPresentationSize(
500 &self,
501 toolbar_item_presentation_size: UINSToolbarItemPresentationSize,
502 );
503
504 #[cfg(feature = "UIInterface")]
505 #[unsafe(method(imageDynamicRange))]
506 #[unsafe(method_family = none)]
507 unsafe fn imageDynamicRange(&self) -> UIImageDynamicRange;
508
509 #[cfg(feature = "UIInterface")]
510 #[unsafe(method(setImageDynamicRange:))]
512 #[unsafe(method_family = none)]
513 unsafe fn setImageDynamicRange(&self, image_dynamic_range: UIImageDynamicRange);
514
515 #[cfg(feature = "UISceneDefinitions")]
516 #[unsafe(method(sceneCaptureState))]
517 #[unsafe(method_family = none)]
518 unsafe fn sceneCaptureState(&self) -> UISceneCaptureState;
519
520 #[cfg(feature = "UISceneDefinitions")]
521 #[unsafe(method(setSceneCaptureState:))]
523 #[unsafe(method_family = none)]
524 unsafe fn setSceneCaptureState(&self, scene_capture_state: UISceneCaptureState);
525
526 #[unsafe(method(typesettingLanguage))]
527 #[unsafe(method_family = none)]
528 unsafe fn typesettingLanguage(&self) -> Retained<NSString>;
529
530 #[unsafe(method(setTypesettingLanguage:))]
532 #[unsafe(method_family = none)]
533 unsafe fn setTypesettingLanguage(&self, typesetting_language: &NSString);
534
535 #[cfg(feature = "UITraitListEnvironment")]
536 #[unsafe(method(listEnvironment))]
537 #[unsafe(method_family = none)]
538 unsafe fn listEnvironment(&self) -> UIListEnvironment;
539
540 #[cfg(feature = "UITraitListEnvironment")]
541 #[unsafe(method(setListEnvironment:))]
543 #[unsafe(method_family = none)]
544 unsafe fn setListEnvironment(&self, list_environment: UIListEnvironment);
545 }
546);
547
548#[cfg(feature = "block2")]
550pub type UITraitMutations =
551 *mut block2::DynBlock<dyn Fn(NonNull<ProtocolObject<dyn UIMutableTraits>>)>;
552
553impl UITraitCollection {
554 extern_methods!(
555 #[cfg(feature = "block2")]
556 #[unsafe(method(traitCollectionWithTraits:))]
557 #[unsafe(method_family = none)]
558 pub unsafe fn traitCollectionWithTraits(
559 mutations: UITraitMutations,
560 ) -> Retained<UITraitCollection>;
561
562 #[cfg(feature = "block2")]
563 #[unsafe(method(traitCollectionByModifyingTraits:))]
564 #[unsafe(method_family = none)]
565 pub unsafe fn traitCollectionByModifyingTraits(
566 &self,
567 mutations: UITraitMutations,
568 ) -> Retained<UITraitCollection>;
569
570 #[cfg(all(feature = "UITrait", feature = "objc2-core-foundation"))]
571 #[unsafe(method(traitCollectionWithCGFloatValue:forTrait:))]
572 #[unsafe(method_family = none)]
573 pub unsafe fn traitCollectionWithCGFloatValue_forTrait(
574 value: CGFloat,
575 r#trait: &UICGFloatTrait,
576 ) -> Retained<UITraitCollection>;
577
578 #[cfg(all(feature = "UITrait", feature = "objc2-core-foundation"))]
579 #[unsafe(method(traitCollectionByReplacingCGFloatValue:forTrait:))]
580 #[unsafe(method_family = none)]
581 pub unsafe fn traitCollectionByReplacingCGFloatValue_forTrait(
582 &self,
583 value: CGFloat,
584 r#trait: &UICGFloatTrait,
585 ) -> Retained<UITraitCollection>;
586
587 #[cfg(all(feature = "UITrait", feature = "objc2-core-foundation"))]
588 #[unsafe(method(valueForCGFloatTrait:))]
589 #[unsafe(method_family = none)]
590 pub unsafe fn valueForCGFloatTrait(&self, r#trait: &UICGFloatTrait) -> CGFloat;
591
592 #[cfg(feature = "UITrait")]
593 #[unsafe(method(traitCollectionWithNSIntegerValue:forTrait:))]
594 #[unsafe(method_family = none)]
595 pub unsafe fn traitCollectionWithNSIntegerValue_forTrait(
596 value: NSInteger,
597 r#trait: &UINSIntegerTrait,
598 ) -> Retained<UITraitCollection>;
599
600 #[cfg(feature = "UITrait")]
601 #[unsafe(method(traitCollectionByReplacingNSIntegerValue:forTrait:))]
602 #[unsafe(method_family = none)]
603 pub unsafe fn traitCollectionByReplacingNSIntegerValue_forTrait(
604 &self,
605 value: NSInteger,
606 r#trait: &UINSIntegerTrait,
607 ) -> Retained<UITraitCollection>;
608
609 #[cfg(feature = "UITrait")]
610 #[unsafe(method(valueForNSIntegerTrait:))]
611 #[unsafe(method_family = none)]
612 pub unsafe fn valueForNSIntegerTrait(&self, r#trait: &UINSIntegerTrait) -> NSInteger;
613
614 #[cfg(feature = "UITrait")]
615 #[unsafe(method(traitCollectionWithObject:forTrait:))]
616 #[unsafe(method_family = none)]
617 pub unsafe fn traitCollectionWithObject_forTrait(
618 object: Option<&ProtocolObject<dyn NSObjectProtocol>>,
619 r#trait: &UIObjectTrait,
620 ) -> Retained<UITraitCollection>;
621
622 #[cfg(feature = "UITrait")]
623 #[unsafe(method(traitCollectionByReplacingObject:forTrait:))]
624 #[unsafe(method_family = none)]
625 pub unsafe fn traitCollectionByReplacingObject_forTrait(
626 &self,
627 object: Option<&ProtocolObject<dyn NSObjectProtocol>>,
628 r#trait: &UIObjectTrait,
629 ) -> Retained<UITraitCollection>;
630
631 #[cfg(feature = "UITrait")]
632 #[unsafe(method(objectForTrait:))]
633 #[unsafe(method_family = none)]
634 pub unsafe fn objectForTrait(
635 &self,
636 r#trait: &UIObjectTrait,
637 ) -> Option<Retained<ProtocolObject<dyn NSObjectProtocol>>>;
638 );
639}
640
641extern_protocol!(
642 pub unsafe trait UITraitEnvironment: NSObjectProtocol + MainThreadOnly {
646 #[unsafe(method(traitCollection))]
647 #[unsafe(method_family = none)]
648 fn traitCollection(&self) -> Retained<UITraitCollection>;
649
650 #[deprecated = "Use the trait change registration APIs declared in the UITraitChangeObservable protocol"]
652 #[unsafe(method(traitCollectionDidChange:))]
653 #[unsafe(method_family = none)]
654 unsafe fn traitCollectionDidChange(
655 &self,
656 previous_trait_collection: Option<&UITraitCollection>,
657 );
658 }
659);
660
661extern_protocol!(
662 pub unsafe trait UITraitChangeRegistration:
664 NSObjectProtocol + NSCopying + MainThreadOnly
665 {
666 }
667);
668
669#[cfg(feature = "block2")]
671pub type UITraitChangeHandler = *mut block2::DynBlock<
672 dyn Fn(NonNull<ProtocolObject<dyn UITraitEnvironment>>, NonNull<UITraitCollection>),
673>;
674
675extern_protocol!(
676 pub unsafe trait UITraitOverrides: UIMutableTraits + MainThreadOnly {
678 #[cfg(feature = "UITrait")]
679 #[unsafe(method(containsTrait:))]
680 #[unsafe(method_family = none)]
681 unsafe fn containsTrait(&self, r#trait: &UITrait) -> bool;
682
683 #[cfg(feature = "UITrait")]
684 #[unsafe(method(removeTrait:))]
685 #[unsafe(method_family = none)]
686 unsafe fn removeTrait(&self, r#trait: &UITrait);
687 }
688);
689
690extern_protocol!(
691 pub unsafe trait UITraitChangeObservable: MainThreadOnly {
693 #[unsafe(method(unregisterForTraitChanges:))]
694 #[unsafe(method_family = none)]
695 unsafe fn unregisterForTraitChanges(
696 &self,
697 registration: &ProtocolObject<dyn UITraitChangeRegistration>,
698 );
699 }
700);
701
702impl UITraitCollection {
704 extern_methods!(
705 #[unsafe(method(currentTraitCollection))]
706 #[unsafe(method_family = none)]
707 pub unsafe fn currentTraitCollection() -> Retained<UITraitCollection>;
708
709 #[unsafe(method(setCurrentTraitCollection:))]
711 #[unsafe(method_family = none)]
712 pub unsafe fn setCurrentTraitCollection(current_trait_collection: &UITraitCollection);
713
714 #[cfg(feature = "block2")]
715 #[unsafe(method(performAsCurrentTraitCollection:))]
716 #[unsafe(method_family = none)]
717 pub unsafe fn performAsCurrentTraitCollection(
718 &self,
719 actions: &block2::DynBlock<dyn Fn() + '_>,
720 );
721 );
722}
723
724impl UITraitCollection {
726 extern_methods!(
727 #[unsafe(method(hasDifferentColorAppearanceComparedToTraitCollection:))]
728 #[unsafe(method_family = none)]
729 pub unsafe fn hasDifferentColorAppearanceComparedToTraitCollection(
730 &self,
731 trait_collection: Option<&UITraitCollection>,
732 ) -> bool;
733 );
734}
735
736impl UITraitCollection {
738 extern_methods!(
739 #[cfg(feature = "UIImageConfiguration")]
740 #[unsafe(method(imageConfiguration))]
741 #[unsafe(method_family = none)]
742 pub unsafe fn imageConfiguration(&self) -> Retained<UIImageConfiguration>;
743 );
744}