forked from microsoft/react-native-macos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRCTUIKit.h
More file actions
677 lines (523 loc) · 19.9 KB
/
RCTUIKit.h
File metadata and controls
677 lines (523 loc) · 19.9 KB
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
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// [macOS]
#include <TargetConditionals.h>
#include <React/RCTAssert.h>
#if !TARGET_OS_OSX
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
//
// functionally equivalent types
//
UIKIT_STATIC_INLINE CGFloat UIImageGetScale(UIImage *image)
{
return image.scale;
}
UIKIT_STATIC_INLINE CGImageRef UIImageGetCGImageRef(UIImage *image)
{
return image.CGImage;
}
UIKIT_STATIC_INLINE UIImage *UIImageWithContentsOfFile(NSString *filePath)
{
return [UIImage imageWithContentsOfFile:filePath];
}
UIKIT_STATIC_INLINE UIImage *UIImageWithData(NSData *imageData)
{
return [UIImage imageWithData:imageData];
}
UIKIT_STATIC_INLINE UIBezierPath *UIBezierPathWithRoundedRect(CGRect rect, CGFloat cornerRadius)
{
return [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:cornerRadius];
}
UIKIT_STATIC_INLINE void UIBezierPathAppendPath(UIBezierPath *path, UIBezierPath *appendPath)
{
[path appendPath:appendPath];
}
UIKIT_STATIC_INLINE CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *path)
{
return [path CGPath];
}
//
// substantially different types
//
// UIView
#define RCTPlatformView UIView
#define RCTUIView UIView
#define RCTUIScrollView UIScrollView
#define RCTUIPanGestureRecognizer UIPanGestureRecognizer
UIKIT_STATIC_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView *view, CGPoint point, __unused UIEvent *__nullable event)
{
return [view hitTest:point withEvent:event];
}
UIKIT_STATIC_INLINE BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view)
{
return view.clipsToBounds;
}
UIKIT_STATIC_INLINE void RCTUIViewSetContentModeRedraw(UIView *view)
{
view.contentMode = UIViewContentModeRedraw;
}
UIKIT_STATIC_INLINE BOOL RCTUIViewIsDescendantOfView(RCTPlatformView *view, RCTPlatformView *parent)
{
return [view isDescendantOfView:parent];
}
UIKIT_STATIC_INLINE NSValue *NSValueWithCGRect(CGRect rect)
{
return [NSValue valueWithCGRect:rect];
}
UIKIT_STATIC_INLINE NSValue *NSValueWithCGSize(CGSize size)
{
return [NSValue valueWithCGSize:size];
}
UIKIT_STATIC_INLINE CGRect CGRectValue(NSValue *value)
{
return [value CGRectValue];
}
//
// semantically equivalent types
//
#define RCTUIColor UIColor
UIKIT_STATIC_INLINE UIFont *UIFontWithSize(UIFont *font, CGFloat pointSize)
{
return [font fontWithSize:pointSize];
}
UIKIT_STATIC_INLINE CGFloat UIFontLineHeight(UIFont *font)
{
return [font lineHeight];
}
NS_ASSUME_NONNULL_END
#else // TARGET_OS_OSX [
#import <AppKit/AppKit.h>
#import <React/RCTComponent.h>
NS_ASSUME_NONNULL_BEGIN
//
// semantically equivalent constants
//
// UIApplication.h/NSApplication.h
#define UIApplicationDidBecomeActiveNotification NSApplicationDidBecomeActiveNotification
#define UIApplicationDidEnterBackgroundNotification NSApplicationDidHideNotification
#define UIApplicationDidFinishLaunchingNotification NSApplicationDidFinishLaunchingNotification
#define UIApplicationWillResignActiveNotification NSApplicationWillResignActiveNotification
#define UIApplicationWillEnterForegroundNotification NSApplicationWillUnhideNotification
// UIFontDescriptor.h/NSFontDescriptor.h
#define UIFontDescriptorFamilyAttribute NSFontFamilyAttribute;
#define UIFontDescriptorNameAttribute NSFontNameAttribute;
#define UIFontDescriptorFaceAttribute NSFontFaceAttribute;
#define UIFontDescriptorSizeAttribute NSFontSizeAttribute
#define UIFontDescriptorTraitsAttribute NSFontTraitsAttribute
#define UIFontDescriptorFeatureSettingsAttribute NSFontFeatureSettingsAttribute
#define UIFontSymbolicTrait NSFontSymbolicTrait
#define UIFontWeightTrait NSFontWeightTrait
#define UIFontFeatureTypeIdentifierKey NSFontFeatureTypeIdentifierKey
#define UIFontFeatureSelectorIdentifierKey NSFontFeatureSelectorIdentifierKey
#define UIFontWeightUltraLight NSFontWeightUltraLight
#define UIFontWeightThin NSFontWeightThin
#define UIFontWeightLight NSFontWeightLight
#define UIFontWeightRegular NSFontWeightRegular
#define UIFontWeightMedium NSFontWeightMedium
#define UIFontWeightSemibold NSFontWeightSemibold
#define UIFontWeightBold NSFontWeightBold
#define UIFontWeightHeavy NSFontWeightHeavy
#define UIFontWeightBlack NSFontWeightBlack
#define UIFontDescriptorSystemDesign NSFontDescriptorSystemDesign
#define UIFontDescriptorSystemDesignDefault NSFontDescriptorSystemDesignDefault
#define UIFontDescriptorSystemDesignSerif NSFontDescriptorSystemDesignSerif
#define UIFontDescriptorSystemDesignRounded NSFontDescriptorSystemDesignRounded
#define UIFontDescriptorSystemDesignMonospaced NSFontDescriptorSystemDesignMonospaced
// RCTActivityIndicatorView.h
#define UIActivityIndicatorView NSProgressIndicator
// UIGeometry.h/NSGeometry.h
#define UIEdgeInsetsZero NSEdgeInsetsZero
// UIView.h/NSLayoutConstraint.h
#define UIViewNoIntrinsicMetric -1
// NSViewNoIntrinsicMetric is defined to -1 but is only available on macOS 10.11 and higher. On previous versions it was NSViewNoInstrinsicMetric (misspelled) and also defined to -1.
// UIInterface.h/NSUserInterfaceLayout.h
#define UIUserInterfaceLayoutDirection NSUserInterfaceLayoutDirection
//
// semantically equivalent enums
//
// UIGestureRecognizer.h/NSGestureRecognizer.h
enum
{
UIGestureRecognizerStatePossible = NSGestureRecognizerStatePossible,
UIGestureRecognizerStateBegan = NSGestureRecognizerStateBegan,
UIGestureRecognizerStateChanged = NSGestureRecognizerStateChanged,
UIGestureRecognizerStateEnded = NSGestureRecognizerStateEnded,
UIGestureRecognizerStateCancelled = NSGestureRecognizerStateCancelled,
UIGestureRecognizerStateFailed = NSGestureRecognizerStateFailed,
UIGestureRecognizerStateRecognized = NSGestureRecognizerStateRecognized,
};
// UIFontDescriptor.h/NSFontDescriptor.h
enum
{
UIFontDescriptorTraitItalic = NSFontItalicTrait,
UIFontDescriptorTraitBold = NSFontBoldTrait,
UIFontDescriptorTraitCondensed = NSFontCondensedTrait,
};
// UIView.h/NSView.h
enum : NSUInteger
{
UIViewAutoresizingNone = NSViewNotSizable,
UIViewAutoresizingFlexibleLeftMargin = NSViewMinXMargin,
UIViewAutoresizingFlexibleWidth = NSViewWidthSizable,
UIViewAutoresizingFlexibleRightMargin = NSViewMaxXMargin,
UIViewAutoresizingFlexibleTopMargin = NSViewMinYMargin,
UIViewAutoresizingFlexibleHeight = NSViewHeightSizable,
UIViewAutoresizingFlexibleBottomMargin = NSViewMaxYMargin,
};
// UIView/NSView.h
typedef NS_ENUM(NSInteger, UIViewContentMode) {
UIViewContentModeScaleAspectFill = NSViewLayerContentsPlacementScaleProportionallyToFill,
UIViewContentModeScaleAspectFit = NSViewLayerContentsPlacementScaleProportionallyToFit,
UIViewContentModeScaleToFill = NSViewLayerContentsPlacementScaleAxesIndependently,
UIViewContentModeCenter = NSViewLayerContentsPlacementCenter,
UIViewContentModeTopLeft = NSViewLayerContentsPlacementTopLeft,
};
// UIInterface.h/NSUserInterfaceLayout.h
enum : NSInteger
{
UIUserInterfaceLayoutDirectionLeftToRight = NSUserInterfaceLayoutDirectionLeftToRight,
UIUserInterfaceLayoutDirectionRightToLeft = NSUserInterfaceLayoutDirectionRightToLeft,
};
// RCTActivityIndicatorView.h
typedef NS_ENUM(NSInteger, UIActivityIndicatorViewStyle) {
UIActivityIndicatorViewStyleLarge,
UIActivityIndicatorViewStyleMedium,
};
//
// semantically equivalent functions
//
// UIGeometry.h/NSGeometry.h
NS_INLINE CGRect UIEdgeInsetsInsetRect(CGRect rect, NSEdgeInsets insets)
{
rect.origin.x += insets.left;
rect.origin.y += insets.top;
rect.size.width -= (insets.left + insets.right);
rect.size.height -= (insets.top + insets.bottom);
return rect;
}
NS_INLINE BOOL UIEdgeInsetsEqualToEdgeInsets(NSEdgeInsets insets1, NSEdgeInsets insets2)
{
return NSEdgeInsetsEqual(insets1, insets2);
}
NS_INLINE NSString *NSStringFromCGSize(CGSize size)
{
return NSStringFromSize(NSSizeFromCGSize(size));
}
NS_INLINE NSString *NSStringFromCGRect(CGRect rect)
{
return NSStringFromRect(NSRectFromCGRect(rect));
}
#ifdef __cplusplus
extern "C" {
#endif
// UIGraphics.h
CGContextRef UIGraphicsGetCurrentContext(void);
CGImageRef UIImageGetCGImageRef(NSImage *image);
#ifdef __cplusplus
}
#endif // __cpusplus
//
// semantically equivalent types
//
// UIAccessibility.h/NSAccessibility.h
@compatibility_alias UIAccessibilityCustomAction NSAccessibilityCustomAction;
// UIColor.h/NSColor.h
#define RCTUIColor NSColor
// UIFont.h/NSFont.h
// Both NSFont and UIFont are toll-free bridged to CTFontRef so we'll assume they're semantically equivalent
@compatibility_alias UIFont NSFont;
// UIViewController.h/NSViewController.h
@compatibility_alias UIViewController NSViewController;
NS_INLINE NSFont *UIFontWithSize(NSFont *font, CGFloat pointSize)
{
return [NSFont fontWithDescriptor:font.fontDescriptor size:pointSize];
}
NS_INLINE CGFloat UIFontLineHeight(NSFont *font)
{
return ceilf(font.ascender + ABS(font.descender) + font.leading);
}
// UIFontDescriptor.h/NSFontDescriptor.h
// Both NSFontDescriptor and UIFontDescriptor are toll-free bridged to CTFontDescriptorRef so we'll assume they're semantically equivalent
@compatibility_alias UIFontDescriptor NSFontDescriptor;
typedef NSFontSymbolicTraits UIFontDescriptorSymbolicTraits;
typedef NSFontWeight UIFontWeight;
// UIGeometry.h/NSGeometry.h
typedef NSEdgeInsets UIEdgeInsets;
NS_INLINE NSEdgeInsets UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat bottom, CGFloat right)
{
return NSEdgeInsetsMake(top, left, bottom, right);
}
//
// functionally equivalent types
//
// These types have the same purpose but may differ semantically. Use with care!
#define UIEvent NSEvent
#define UITouchType NSTouchType
#define UIEventButtonMask NSEventButtonMask
#define UIKeyModifierFlags NSEventModifierFlags
// UIGestureRecognizer
#define UIGestureRecognizer NSGestureRecognizer
#define UIGestureRecognizerDelegate NSGestureRecognizerDelegate
#define RCTUIPanGestureRecognizer NSPanGestureRecognizer
// UIApplication
#define UIApplication NSApplication
// UIImage
@compatibility_alias UIImage NSImage;
typedef NS_ENUM(NSInteger, UIImageRenderingMode) {
UIImageRenderingModeAlwaysOriginal,
UIImageRenderingModeAlwaysTemplate,
};
#ifdef __cplusplus
extern "C"
#endif
CGFloat UIImageGetScale(NSImage *image);
CGImageRef UIImageGetCGImageRef(NSImage *image);
NS_INLINE UIImage *UIImageWithContentsOfFile(NSString *filePath)
{
return [[NSImage alloc] initWithContentsOfFile:filePath];
}
NS_INLINE UIImage *UIImageWithData(NSData *imageData)
{
return [[NSImage alloc] initWithData:imageData];
}
NSData *UIImagePNGRepresentation(NSImage *image);
NSData *UIImageJPEGRepresentation(NSImage *image, CGFloat compressionQuality);
// UIBezierPath
@compatibility_alias UIBezierPath NSBezierPath;
UIBezierPath *UIBezierPathWithRoundedRect(CGRect rect, CGFloat cornerRadius);
void UIBezierPathAppendPath(UIBezierPath *path, UIBezierPath *appendPath);
CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *path);
//
// substantially different types
//
// UIView
#define RCTPlatformView NSView
@interface RCTUIView : RCTPlatformView
@property (nonatomic, readonly) BOOL canBecomeFirstResponder;
- (BOOL)becomeFirstResponder;
@property(nonatomic, readonly) BOOL isFirstResponder;
@property (nonatomic, getter=isUserInteractionEnabled) BOOL userInteractionEnabled;
- (NSView *)hitTest:(CGPoint)point withEvent:(UIEvent *_Nullable)event;
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event;
- (void)insertSubview:(NSView *)view atIndex:(NSInteger)index;
- (void)didMoveToWindow;
- (void)setNeedsLayout;
- (void)layoutIfNeeded;
- (void)layoutSubviews;
- (void)setNeedsDisplay;
// Methods related to mouse events
- (BOOL)hasMouseHoverEvent;
- (NSDictionary*)locationInfoFromDraggingLocation:(NSPoint)locationInWindow;
- (NSDictionary*)locationInfoFromEvent:(NSEvent*)event;
- (void)sendMouseEventWithBlock:(RCTDirectEventBlock)block
locationInfo:(NSDictionary*)locationInfo
modifierFlags:(NSEventModifierFlags)modifierFlags
additionalData:(NSDictionary* __nullable)additionalData;
// FUTURE: When Xcode 14 is no longer supported (CI is building with Xcode 15), we can remove this override since it's now declared on NSView
@property BOOL clipsToBounds;
@property (nonatomic, copy) NSColor *backgroundColor;
@property (nonatomic) CGAffineTransform transform;
/**
* Specifies whether the view should receive the mouse down event when the
* containing window is in the background.
*/
@property (nonatomic, assign) BOOL acceptsFirstMouse;
@property (nonatomic, assign) BOOL mouseDownCanMoveWindow;
/**
* Specifies whether the view participates in the key view loop as user tabs through different controls
* This is equivalent to acceptsFirstResponder on mac OS.
*/
@property (nonatomic, assign) BOOL focusable;
/**
* Specifies whether focus ring should be drawn when the view has the first responder status.
*/
@property (nonatomic, assign) BOOL enableFocusRing;
// Mouse events
@property (nonatomic, copy) RCTDirectEventBlock onMouseEnter;
@property (nonatomic, copy) RCTDirectEventBlock onMouseLeave;
@property (nonatomic, copy) RCTDirectEventBlock onDragEnter;
@property (nonatomic, copy) RCTDirectEventBlock onDragLeave;
@property (nonatomic, copy) RCTDirectEventBlock onDrop;
@property (nonatomic, copy) RCTBubblingEventBlock onResponderGrant;
@property (nonatomic, copy) RCTBubblingEventBlock onResponderMove;
@property (nonatomic, copy) RCTBubblingEventBlock onResponderRelease;
@property (nonatomic, copy) RCTBubblingEventBlock onResponderTerminate;
@property (nonatomic, copy) RCTBubblingEventBlock onResponderTerminationRequest;
@property (nonatomic, copy) RCTBubblingEventBlock onStartShouldSetResponder;
@end
// UIScrollView
@interface RCTUIScrollView : NSScrollView
// UIScrollView properties missing in NSScrollView
@property (nonatomic, assign) CGPoint contentOffset;
@property (nonatomic, assign) UIEdgeInsets contentInset;
@property (nonatomic, assign) CGSize contentSize;
@property (nonatomic, assign) BOOL showsHorizontalScrollIndicator;
@property (nonatomic, assign) BOOL showsVerticalScrollIndicator;
@property (nonatomic, assign) UIEdgeInsets scrollIndicatorInsets;
@property(nonatomic, assign) CGFloat minimumZoomScale;
@property(nonatomic, assign) CGFloat maximumZoomScale;
@property (nonatomic, assign) CGFloat zoomScale;
@property (nonatomic, assign) BOOL alwaysBounceHorizontal;
@property (nonatomic, assign) BOOL alwaysBounceVertical;
// macOS specific properties
@property (nonatomic, assign) BOOL enableFocusRing;
@property (nonatomic, assign, getter=isScrollEnabled) BOOL scrollEnabled;
- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated;
@end
@interface RCTClipView : NSClipView
@property (nonatomic, assign) BOOL constrainScrolling;
@end
NS_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView *view, CGPoint point, __unused UIEvent *__nullable event)
{
// [macOS IMPORTANT -- point is in local coordinate space, but OSX expects super coordinate space for hitTest:
NSView *superview = [view superview];
NSPoint pointInSuperview = superview != nil ? [view convertPoint:point toView:superview] : point;
return [view hitTest:pointInSuperview];
}
BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view);
NS_INLINE void RCTUIViewSetContentModeRedraw(RCTPlatformView *view)
{
view.layerContentsRedrawPolicy = NSViewLayerContentsRedrawDuringViewResize;
}
NS_INLINE BOOL RCTUIViewIsDescendantOfView(RCTPlatformView *view, RCTPlatformView *parent)
{
return [view isDescendantOf:parent];
}
NS_INLINE NSValue *NSValueWithCGRect(CGRect rect)
{
return [NSValue valueWithBytes:&rect objCType:@encode(CGRect)];
}
NS_INLINE NSValue *NSValueWithCGSize(CGSize size)
{
return [NSValue valueWithBytes:&size objCType:@encode(CGSize)];
}
NS_INLINE CGRect CGRectValue(NSValue *value)
{
CGRect rect = CGRectZero;
[value getValue:&rect];
return rect;
}
NS_ASSUME_NONNULL_END
#endif // ] TARGET_OS_OSX
#if !TARGET_OS_OSX
typedef UIApplication RCTUIApplication;
typedef UIWindow RCTPlatformWindow;
typedef UIViewController RCTPlatformViewController;
#else
typedef NSApplication RCTUIApplication;
typedef NSWindow RCTPlatformWindow;
typedef NSViewController RCTPlatformViewController;
#endif
//
// fabric component types
//
// RCTUISlider
#if !TARGET_OS_OSX
typedef UISlider RCTUISlider;
#else
@protocol RCTUISliderDelegate;
@interface RCTUISlider : NSSlider
NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, weak) id<RCTUISliderDelegate> delegate;
@property (nonatomic, readonly) BOOL pressed;
@property (nonatomic, assign) float value;
@property (nonatomic, assign) float minimumValue;
@property (nonatomic, assign) float maximumValue;
@property (nonatomic, strong) NSColor *minimumTrackTintColor;
@property (nonatomic, strong) NSColor *maximumTrackTintColor;
- (void)setValue:(float)value animated:(BOOL)animated;
NS_ASSUME_NONNULL_END
@end
#endif
#if TARGET_OS_OSX // [macOS
@protocol RCTUISliderDelegate <NSObject>
@optional
NS_ASSUME_NONNULL_BEGIN
- (void)slider:(RCTUISlider *)slider didPress:(BOOL)press;
NS_ASSUME_NONNULL_END
@end
#endif // macOS]
// RCTUILabel
#if !TARGET_OS_OSX
typedef UILabel RCTUILabel;
#else
@interface RCTUILabel : NSTextField
NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, copy) NSString* _Nullable text;
@property(nonatomic, assign) NSInteger numberOfLines;
@property(nonatomic, assign) NSTextAlignment textAlignment;
NS_ASSUME_NONNULL_END
@end
#endif
// RCTUISwitch
#if !TARGET_OS_OSX
typedef UISwitch RCTUISwitch;
#else
@interface RCTUISwitch : NSSwitch
NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, getter=isOn) BOOL on;
- (void)setOn:(BOOL)on animated:(BOOL)animated;
NS_ASSUME_NONNULL_END
@end
#endif
// RCTUIActivityIndicatorView
#if !TARGET_OS_OSX
typedef UIActivityIndicatorView RCTUIActivityIndicatorView;
#else
@interface RCTUIActivityIndicatorView : NSProgressIndicator
NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) UIActivityIndicatorViewStyle activityIndicatorViewStyle;
@property (nonatomic, assign) BOOL hidesWhenStopped;
@property (nullable, readwrite, nonatomic, strong) RCTUIColor *color;
@property (nonatomic, readonly, getter=isAnimating) BOOL animating;
- (void)startAnimating;
- (void)stopAnimating;
NS_ASSUME_NONNULL_END
@end
#endif
// RCTUITouch
#if !TARGET_OS_OSX
typedef UITouch RCTUITouch;
#else
@interface RCTUITouch : NSEvent
@end
#endif
// RCTUIImageView
#if !TARGET_OS_OSX
typedef UIImageView RCTUIImageView;
#else
@interface RCTUIImageView : NSImageView
NS_ASSUME_NONNULL_BEGIN
// FUTURE: When Xcode 14 is no longer supported (CI is building with Xcode 15), we can remove this override since it's now declared on NSView
@property (assign) BOOL clipsToBounds;
@property (nonatomic, strong) RCTUIColor *tintColor;
@property (nonatomic, assign) UIViewContentMode contentMode;
NS_ASSUME_NONNULL_END
@end
#endif
#if !TARGET_OS_OSX
typedef UIGraphicsImageRendererContext RCTUIGraphicsImageRendererContext;
typedef UIGraphicsImageDrawingActions RCTUIGraphicsImageDrawingActions;
typedef UIGraphicsImageRendererFormat RCTUIGraphicsImageRendererFormat;
typedef UIGraphicsImageRenderer RCTUIGraphicsImageRenderer;
#else
NS_ASSUME_NONNULL_BEGIN
typedef NSGraphicsContext RCTUIGraphicsImageRendererContext;
typedef void (^RCTUIGraphicsImageDrawingActions)(RCTUIGraphicsImageRendererContext *rendererContext);
@interface RCTUIGraphicsImageRendererFormat : NSObject
+ (instancetype)defaultFormat;
@property (nonatomic) CGFloat scale;
@property (nonatomic) BOOL opaque;
@end
@interface RCTUIGraphicsImageRenderer : NSObject
- (instancetype)initWithSize:(CGSize)size;
- (instancetype)initWithSize:(CGSize)size format:(RCTUIGraphicsImageRendererFormat *)format;
- (NSImage *)imageWithActions:(NS_NOESCAPE RCTUIGraphicsImageDrawingActions)actions;
@end
NS_ASSUME_NONNULL_END
#endif