Skip to content

Commit ddd918d

Browse files
committed
followup changes
1 parent d425c50 commit ddd918d

File tree

12 files changed

+60
-22
lines changed

12 files changed

+60
-22
lines changed

packages/react-native/Libraries/AppDelegate/RCTDefaultReactNativeFactoryDelegate.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
#import <UIKit/UIKit.h>
8+
#import <React/RCTUIKit.h> // [macOS]
99
#import "RCTReactNativeFactory.h"
1010

1111
NS_ASSUME_NONNULL_BEGIN
@@ -15,7 +15,11 @@ NS_ASSUME_NONNULL_BEGIN
1515
* Contains default implementation of RCTReactNativeFactoryDelegate methods.
1616
*/
1717

18+
#if !TARGET_OS_OSX // [macOS]
1819
@interface RCTDefaultReactNativeFactoryDelegate : UIResponder <RCTReactNativeFactoryDelegate>
20+
#else // [macOS
21+
@interface RCTDefaultReactNativeFactoryDelegate : NSResponder <RCTReactNativeFactoryDelegate>
22+
#endif // macOS]
1923
@end
2024

2125
NS_ASSUME_NONNULL_END

packages/react-native/Libraries/AppDelegate/RCTDefaultReactNativeFactoryDelegate.mm

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ - (RCTBridge *)createBridgeWithDelegate:(id<RCTBridgeDelegate>)delegate launchOp
3333
return [[RCTBridge alloc] initWithDelegate:delegate launchOptions:launchOptions];
3434
}
3535

36-
- (void)setRootView:(UIView *)rootView toRootViewController:(UIViewController *)rootViewController
36+
- (void)setRootView:(RCTPlatformView *)rootView toRootViewController:(RCTPlatformViewController *)rootViewController
3737
{
3838
rootViewController.view = rootView;
3939
}
@@ -43,14 +43,18 @@ - (void)customizeRootView:(RCTRootView *)rootView
4343
// Override point for customization after application launch.
4444
}
4545

46-
- (UIView *)createRootViewWithBridge:(RCTBridge *)bridge
46+
- (RCTPlatformView *)createRootViewWithBridge:(RCTBridge *)bridge
4747
moduleName:(NSString *)moduleName
4848
initProps:(NSDictionary *)initProps
4949
{
5050
BOOL enableFabric = self.fabricEnabled;
51-
UIView *rootView = RCTAppSetupDefaultRootView(bridge, moduleName, initProps, enableFabric);
51+
RCTUIView *rootView = RCTAppSetupDefaultRootView(bridge, moduleName, initProps, enableFabric);
5252

53+
#if !TARGET_OS_OSX // [macOS]
5354
rootView.backgroundColor = [UIColor systemBackgroundColor];
55+
#else // [macOS
56+
rootView.backgroundColor = [NSColor windowBackgroundColor];
57+
#endif // macOS]
5458

5559
return rootView;
5660
}

packages/react-native/Libraries/AppDelegate/RCTReactNativeFactory.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#import <React/RCTBridgeDelegate.h>
99
#import <React/RCTConvert.h>
10-
#import <UIKit/UIKit.h>
10+
#import <React/RCTUIKit.h> // [macOS]
1111
#import "RCTArchConfiguratorProtocol.h"
1212
#import "RCTDependencyProvider.h"
1313
#import "RCTRootViewFactory.h"
@@ -66,9 +66,9 @@ NS_ASSUME_NONNULL_BEGIN
6666
*
6767
* @returns: a UIView properly configured with a bridge for React Native.
6868
*/
69-
- (UIView *)createRootViewWithBridge:(RCTBridge *)bridge
70-
moduleName:(NSString *)moduleName
71-
initProps:(NSDictionary *)initProps;
69+
- (RCTPlatformView *)createRootViewWithBridge:(RCTBridge *)bridge
70+
moduleName:(NSString *)moduleName
71+
initProps:(NSDictionary *)initProps;
7272

7373
/// This method returns a map of Component Descriptors and Components classes that needs to be registered in the
7474
/// new renderer. The Component Descriptor is a string which represent the name used in JS to refer to the native

packages/react-native/Libraries/AppDelegate/RCTReactNativeFactory.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,15 @@ - (RCTRootViewFactory *)createRCTRootViewFactory
190190
turboModuleEnabled:self.turboModuleEnabled
191191
bridgelessEnabled:self.bridgelessEnabled];
192192

193-
configuration.createRootViewWithBridge = ^UIView *(RCTBridge *bridge, NSString *moduleName, NSDictionary *initProps) {
193+
configuration.createRootViewWithBridge = ^RCTPlatformView *(RCTBridge *bridge, NSString *moduleName, NSDictionary *initProps) {
194194
return [weakSelf.delegate createRootViewWithBridge:bridge moduleName:moduleName initProps:initProps];
195195
};
196196

197197
configuration.createBridgeWithDelegate = ^RCTBridge *(id<RCTBridgeDelegate> delegate, NSDictionary *launchOptions) {
198198
return [weakSelf.delegate createBridgeWithDelegate:delegate launchOptions:launchOptions];
199199
};
200200

201-
configuration.customizeRootView = ^(UIView *_Nonnull rootView) {
201+
configuration.customizeRootView = ^(RCTPlatformView *_Nonnull rootView) {
202202
[weakSelf.delegate customizeRootView:(RCTRootView *)rootView];
203203
};
204204

packages/react-native/Libraries/Image/RCTImageView.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ - (void)imageLoaderLoadedImage:(UIImage *)loadedImage
512512
}
513513
} else {
514514
if (strongSelf->_onLoad) {
515-
RCTImageSource *sourceLoaded = [source imageSourceWithSize:image.size scale:image.scale];
515+
RCTImageSource *sourceLoaded = [source imageSourceWithSize:image.size scale:UIImageGetScale(image)]; // [macOS]
516516
strongSelf->_onLoad(onLoadParamsForSource(sourceLoaded));
517517
}
518518
if (strongSelf->_onLoadEnd) {

packages/react-native/React/Base/RCTUIKit.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ NS_ASSUME_NONNULL_BEGIN
140140
// UIFontDescriptor.h/NSFontDescriptor.h
141141
#define UIFontDescriptorFamilyAttribute NSFontFamilyAttribute;
142142
#define UIFontDescriptorNameAttribute NSFontNameAttribute;
143-
#define UIFontDescriptorFaceAttribute NSFontFaceAttribute;
143+
#define UIFontDescriptorFaceAttribute NSFontFaceAttribute;
144144
#define UIFontDescriptorSizeAttribute NSFontSizeAttribute
145145

146146
#define UIFontDescriptorTraitsAttribute NSFontTraitsAttribute
@@ -161,6 +161,13 @@ NS_ASSUME_NONNULL_BEGIN
161161
#define UIFontWeightHeavy NSFontWeightHeavy
162162
#define UIFontWeightBlack NSFontWeightBlack
163163

164+
#define UIFontDescriptorSystemDesign NSFontDescriptorSystemDesign
165+
#define UIFontDescriptorSystemDesignDefault NSFontDescriptorSystemDesignDefault
166+
#define UIFontDescriptorSystemDesignSerif NSFontDescriptorSystemDesignSerif
167+
#define UIFontDescriptorSystemDesignRounded NSFontDescriptorSystemDesignRounded
168+
#define UIFontDescriptorSystemDesignMonospaced NSFontDescriptorSystemDesignMonospaced
169+
170+
164171
// RCTActivityIndicatorView.h
165172
#define UIActivityIndicatorView NSProgressIndicator
166173

@@ -473,6 +480,8 @@ CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *path);
473480
@property (nonatomic, assign) BOOL enableFocusRing;
474481
@property (nonatomic, assign, getter=isScrollEnabled) BOOL scrollEnabled;
475482

483+
- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated;
484+
476485
@end
477486

478487
@interface RCTClipView : NSClipView

packages/react-native/React/Base/macOS/RCTUIKit.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,18 @@ - (void)setContentOffset:(CGPoint)contentOffset
617617
[self.documentView scrollPoint:contentOffset];
618618
}
619619

620+
- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated
621+
{
622+
if (animated) {
623+
[NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
624+
context.duration = 0.3; // Set the duration of the animation
625+
[self.documentView.animator scrollPoint:contentOffset];
626+
} completionHandler:nil];
627+
} else {
628+
[self.documentView scrollPoint:contentOffset];
629+
}
630+
}
631+
620632
- (UIEdgeInsets)contentInset
621633
{
622634
return super.contentInsets;

packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
/**
1111
* UIView class for root <ModalHostView> component.
1212
*/
13-
@interface RCTModalHostViewComponentView : RCTViewComponentView <UIAdaptivePresentationControllerDelegate>
14-
13+
@interface RCTModalHostViewComponentView : RCTViewComponentView
1514
#if !TARGET_OS_OSX // [macOS]
15+
<UIAdaptivePresentationControllerDelegate>
16+
1617
/**
1718
* Subclasses may override this method and present the modal on different view controller.
1819
* Default implementation presents the modal on `[self reactViewController]`.

packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTEnhancedScrollView.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ - (void)scrollViewWillEndDragging:(RCTUIScrollView *)scrollView
300300
}
301301
}
302302

303-
- (void)scrollViewDidZoom:(__unused UIScrollView *)scrollView
303+
- (void)scrollViewDidZoom:(__unused RCTUIScrollView *)scrollView // [macOS]
304304
{
305305
[self centerContentIfNeeded];
306306
}
@@ -313,4 +313,4 @@ - (BOOL)isHorizontal:(RCTUIScrollView *)scrollView // [macOS]
313313
scrollView.contentSize.width > self.frame.size.width;
314314
}
315315

316-
@end
316+
@end

packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,15 @@ - (void)_updateTitle
158158

159159
#pragma mark - Attaching & Detaching
160160

161+
#if !TARGET_OS_OSX // [macOS]
161162
- (void)didMoveToSuperview
162163
{
163164
[super didMoveToSuperview];
165+
#else // macOS]
166+
- (void)viewDidMoveToSuperview
167+
{
168+
[super viewDidMoveToSuperview];
169+
#endif // macOS]
164170
if (self.superview) {
165171
[self _attach];
166172
} else {
@@ -240,4 +246,4 @@ - (NSString *)componentViewName_DO_NOT_USE_THIS_IS_BROKEN
240246
Class<RCTComponentViewProtocol> RCTPullToRefreshViewCls(void)
241247
{
242248
return RCTPullToRefreshViewComponentView.class;
243-
}
249+
}

0 commit comments

Comments
 (0)