react-native-macos 0.0.0-bb8a035db → 0.0.0-bc0c2c4d1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
- package/Libraries/Components/TextInput/TextInput.js +7 -0
- package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Image/RCTImageView.mm +14 -10
- package/Libraries/Lists/VirtualizedList.js +13 -1
- package/Libraries/Text/BaseText/RCTBaseTextViewManager.m +1 -0
- package/Libraries/Text/RCTTextAttributes.h +2 -0
- package/Libraries/Text/RCTTextAttributes.m +9 -0
- package/Libraries/Text/Text/RCTDynamicTypeRamp.h +40 -0
- package/Libraries/Text/Text/RCTDynamicTypeRamp.m +77 -0
- package/Libraries/Text/Text/RCTTextView.m +118 -47
- package/Libraries/Text/Text.js +0 -8
- package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.h +5 -0
- package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputView.m +55 -5
- package/Libraries/Text/TextInput/Multiline/RCTMultilineTextInputViewManager.m +2 -0
- package/Libraries/Text/TextInput/Multiline/RCTUITextView.h +1 -1
- package/Libraries/Text/TextInput/RCTBaseTextInputView.m +1 -1
- package/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +0 -1
- package/Libraries/Text/TextNativeComponent.js +2 -0
- package/Libraries/Text/TextProps.js +29 -0
- package/React/Base/RCTAssert.h +4 -3
- package/React/Base/RCTAssert.m +11 -2
- package/React/Base/RCTBridge.m +1 -1
- package/React/Base/RCTConstants.h +6 -0
- package/React/Base/RCTConstants.m +15 -0
- package/React/Base/RCTConvert.m +1 -1
- package/React/Base/RCTUIKit.h +8 -13
- package/React/Base/RCTVersion.m +1 -1
- package/React/Base/macOS/RCTUIKit.m +33 -0
- package/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm +6 -2
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTPullToRefreshViewComponentView.mm +1 -1
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +17 -3
- package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +8 -1
- package/React/Fabric/Mounting/RCTMountingManager.h +1 -1
- package/React/Fabric/Mounting/RCTMountingManager.mm +3 -3
- package/React/Fabric/RCTConversions.h +9 -1
- package/React/Fabric/RCTLocalizationProvider.mm +10 -4
- package/React/Fabric/RCTScheduler.h +5 -0
- package/React/Fabric/RCTScheduler.mm +10 -0
- package/React/Fabric/RCTSurfacePresenter.h +2 -0
- package/React/Fabric/RCTSurfacePresenter.mm +12 -11
- package/React/Fabric/RCTSurfaceTouchHandler.mm +0 -1
- package/React/React-RCTFabric.podspec +1 -1
- package/React/Views/RCTView.m +6 -1
- package/React/Views/RCTViewManager.m +1 -1
- package/React/Views/ScrollView/RCTScrollView.m +1 -1
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactCommon/React-Fabric.podspec +1 -1
- package/ReactCommon/React-rncore.podspec +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/ReactCommon/react/renderer/core/EventDispatcher.cpp +21 -0
- package/ReactCommon/react/renderer/core/EventDispatcher.h +15 -0
- package/ReactCommon/react/renderer/core/EventListener.cpp +39 -0
- package/ReactCommon/react/renderer/core/EventListener.h +44 -0
- package/ReactCommon/react/renderer/graphics/React-graphics.podspec +1 -1
- package/ReactCommon/react/renderer/scheduler/Scheduler.cpp +14 -0
- package/ReactCommon/react/renderer/scheduler/Scheduler.h +6 -0
- package/ReactCommon/react/utils/ManagedObjectWrapper.h +1 -1
- package/ReactCommon/react/utils/ManagedObjectWrapper.mm +1 -3
- package/package.json +1 -1
- package/template/Gemfile.lock +3 -3
- package/template/package.json +1 -1
|
@@ -130,6 +130,7 @@ const RCTTextInputViewConfig = {
|
|
|
130
130
|
blurOnSubmit: true,
|
|
131
131
|
mostRecentEventCount: true,
|
|
132
132
|
scrollEnabled: true,
|
|
133
|
+
hideVerticalScrollIndicator: true,
|
|
133
134
|
selectionColor: {process: require('../../StyleSheet/processColor')},
|
|
134
135
|
contextMenuHidden: true,
|
|
135
136
|
secureTextEntry: true,
|
|
@@ -331,6 +331,13 @@ type IOSProps = $ReadOnly<{|
|
|
|
331
331
|
scrollEnabled?: ?boolean,
|
|
332
332
|
|
|
333
333
|
// [TODO(macOS GH#774)
|
|
334
|
+
/**
|
|
335
|
+
* If `true`, hide vertical scrollbar on the underlying multiline scrollview
|
|
336
|
+
* The default value is `false`.
|
|
337
|
+
* @platform macos
|
|
338
|
+
*/
|
|
339
|
+
hideVerticalScrollIndicator?: ?boolean,
|
|
340
|
+
|
|
334
341
|
/**
|
|
335
342
|
* If `false`, disables grammar-check.
|
|
336
343
|
* @platform macos
|
|
@@ -128,6 +128,8 @@ static NSDictionary *onLoadParamsForSource(RCTImageSource *source)
|
|
|
128
128
|
// Whether the latest change of props requires the image to be reloaded
|
|
129
129
|
BOOL _needsReload;
|
|
130
130
|
|
|
131
|
+
UIImage *_image; // TODO(macOS GH#774)
|
|
132
|
+
|
|
131
133
|
RCTUIImageViewAnimated *_imageView;
|
|
132
134
|
|
|
133
135
|
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
@@ -199,10 +201,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
|
|
199
201
|
if (_renderingMode != image.renderingMode) {
|
|
200
202
|
image = [image imageWithRenderingMode:_renderingMode];
|
|
201
203
|
}
|
|
202
|
-
#else // [TODO(macOS GH#774)
|
|
203
|
-
if ((_renderingMode == UIImageRenderingModeAlwaysTemplate) != [image isTemplate]) {
|
|
204
|
-
[image setTemplate:(_renderingMode == UIImageRenderingModeAlwaysTemplate)];
|
|
205
|
-
}
|
|
206
204
|
#endif // ]TODO(macOS GH#774)
|
|
207
205
|
|
|
208
206
|
if (_resizeMode == RCTResizeModeRepeat) {
|
|
@@ -211,6 +209,10 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
|
|
211
209
|
#else // [TODO(macOS GH#774)
|
|
212
210
|
image.capInsets = _capInsets;
|
|
213
211
|
image.resizingMode = NSImageResizingModeTile;
|
|
212
|
+
} else if (_resizeMode == RCTResizeModeCover) {
|
|
213
|
+
if (!NSEqualSizes(self.bounds.size, NSZeroSize)) {
|
|
214
|
+
image = RCTFillImagePreservingAspectRatio(image, self.bounds.size, self.window.backingScaleFactor ?: 1.0);
|
|
215
|
+
}
|
|
214
216
|
#endif // ]TODO(macOS GH#774)
|
|
215
217
|
} else if (!UIEdgeInsetsEqualToEdgeInsets(UIEdgeInsetsZero, _capInsets)) {
|
|
216
218
|
// Applying capInsets of 0 will switch the "resizingMode" of the image to "tile" which is undesired
|
|
@@ -222,6 +224,12 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
|
|
222
224
|
#endif // ]TODO(macOS GH#774)
|
|
223
225
|
}
|
|
224
226
|
|
|
227
|
+
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
228
|
+
if ((_renderingMode == UIImageRenderingModeAlwaysTemplate) != [image isTemplate]) {
|
|
229
|
+
[image setTemplate:(_renderingMode == UIImageRenderingModeAlwaysTemplate)];
|
|
230
|
+
}
|
|
231
|
+
#endif // ]TODO(macOS GH#774)
|
|
232
|
+
|
|
225
233
|
// Apply trilinear filtering to smooth out mis-sized images
|
|
226
234
|
_imageView.layer.minificationFilter = kCAFilterTrilinear;
|
|
227
235
|
_imageView.layer.magnificationFilter = kCAFilterTrilinear;
|
|
@@ -233,17 +241,13 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
|
|
233
241
|
{
|
|
234
242
|
image = image ?: _defaultImage;
|
|
235
243
|
if (image != self.image) {
|
|
236
|
-
|
|
237
|
-
if (image && _resizeMode == RCTResizeModeCover && !NSEqualSizes(self.bounds.size, NSZeroSize)) {
|
|
238
|
-
image = RCTFillImagePreservingAspectRatio(image, self.bounds.size, self.window.backingScaleFactor ?: 1.0);
|
|
239
|
-
}
|
|
240
|
-
#endif // ]TODO(macOS GH#774)
|
|
244
|
+
_image = image; // TODO(macOS GH#774)
|
|
241
245
|
[self updateWithImage:image];
|
|
242
246
|
}
|
|
243
247
|
}
|
|
244
248
|
|
|
245
249
|
- (UIImage *)image {
|
|
246
|
-
return _imageView.image;
|
|
250
|
+
return _image ?: _imageView.image; // TODO(macOS GH#774)
|
|
247
251
|
}
|
|
248
252
|
|
|
249
253
|
- (void)setBlurRadius:(CGFloat)blurRadius
|
|
@@ -1334,9 +1334,21 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
1334
1334
|
this.props.onPreferredScrollerStyleDidChange;
|
|
1335
1335
|
const invertedDidChange = this.props.onInvertedDidChange;
|
|
1336
1336
|
|
|
1337
|
+
const isFirstRowSelected = this.state.selectedRowIndex === this.state.first;
|
|
1338
|
+
const isLastRowSelected = this.state.selectedRowIndex === this.state.last;
|
|
1339
|
+
|
|
1340
|
+
// Don't pass in ArrowUp/ArrowDown at the top/bottom of the list so that keyboard event can bubble
|
|
1341
|
+
let _validKeysDown = ['Home', 'End'];
|
|
1342
|
+
if (!isFirstRowSelected) {
|
|
1343
|
+
_validKeysDown.push('ArrowUp');
|
|
1344
|
+
}
|
|
1345
|
+
if (!isLastRowSelected) {
|
|
1346
|
+
_validKeysDown.push('ArrowDown');
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1337
1349
|
const keyboardNavigationProps = {
|
|
1338
1350
|
focusable: true,
|
|
1339
|
-
validKeysDown:
|
|
1351
|
+
validKeysDown: _validKeysDown,
|
|
1340
1352
|
onKeyDown: this._handleKeyDown,
|
|
1341
1353
|
};
|
|
1342
1354
|
// ]TODO(macOS GH#774)
|
|
@@ -36,6 +36,7 @@ RCT_REMAP_SHADOW_PROPERTY(fontWeight, textAttributes.fontWeight, NSString)
|
|
|
36
36
|
RCT_REMAP_SHADOW_PROPERTY(fontStyle, textAttributes.fontStyle, NSString)
|
|
37
37
|
RCT_REMAP_SHADOW_PROPERTY(fontVariant, textAttributes.fontVariant, NSArray)
|
|
38
38
|
RCT_REMAP_SHADOW_PROPERTY(allowFontScaling, textAttributes.allowFontScaling, BOOL)
|
|
39
|
+
RCT_REMAP_SHADOW_PROPERTY(dynamicTypeRamp, textAttributes.dynamicTypeRamp, RCTDynamicTypeRamp) // TODO(macOS GH#774)
|
|
39
40
|
RCT_REMAP_SHADOW_PROPERTY(maxFontSizeMultiplier, textAttributes.maxFontSizeMultiplier, CGFloat)
|
|
40
41
|
RCT_REMAP_SHADOW_PROPERTY(letterSpacing, textAttributes.letterSpacing, CGFloat)
|
|
41
42
|
RCT_REMAP_SHADOW_PROPERTY(apple_fontSmoothing, textAttributes.fontSmoothing, RCTFontSmoothing) // TODO(OSS Candidate ISS#2710739)
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
#import <React/RCTUIKit.h> // TODO(macOS GH#774)
|
|
9
9
|
|
|
10
10
|
#import <React/RCTTextDecorationLineType.h>
|
|
11
|
+
#import <React/RCTDynamicTypeRamp.h> // TODO(macOS GH#774)
|
|
11
12
|
#import <React/RCTFontSmoothing.h> // TODO(OSS Candidate ISS#2710739)
|
|
12
13
|
|
|
13
14
|
#import "RCTTextTransform.h"
|
|
@@ -38,6 +39,7 @@ extern NSString *const RCTTextAttributesTagAttributeName;
|
|
|
38
39
|
@property (nonatomic, copy, nullable) NSString *fontStyle;
|
|
39
40
|
@property (nonatomic, copy, nullable) NSArray<NSString *> *fontVariant;
|
|
40
41
|
@property (nonatomic, assign) BOOL allowFontScaling;
|
|
42
|
+
@property (nonatomic, assign) RCTDynamicTypeRamp dynamicTypeRamp; // TODO(macOS GH#774)
|
|
41
43
|
@property (nonatomic, assign) CGFloat letterSpacing;
|
|
42
44
|
@property (nonatomic, assign) RCTFontSmoothing fontSmoothing; // TODO(OSS Candidate ISS#2710739)
|
|
43
45
|
@property (class, nonatomic, assign) RCTFontSmoothing fontSmoothingDefault; // TODO(OSS Candidate ISS#2710739)
|
|
@@ -70,6 +70,7 @@ NSString *const RCTTextAttributesTagAttributeName = @"RCTTextAttributesTagAttrib
|
|
|
70
70
|
_fontStyle = textAttributes->_fontStyle ?: _fontStyle;
|
|
71
71
|
_fontVariant = textAttributes->_fontVariant ?: _fontVariant;
|
|
72
72
|
_allowFontScaling = textAttributes->_allowFontScaling || _allowFontScaling; // *
|
|
73
|
+
_dynamicTypeRamp = textAttributes->_dynamicTypeRamp != RCTDynamicTypeRampUndefined ? textAttributes->_dynamicTypeRamp : _dynamicTypeRamp; // TODO(macOS GH#774)
|
|
73
74
|
_letterSpacing = !isnan(textAttributes->_letterSpacing) ? textAttributes->_letterSpacing : _letterSpacing;
|
|
74
75
|
_fontSmoothing = textAttributes->_fontSmoothing != RCTFontSmoothingAuto ? textAttributes->_fontSmoothing : _fontSmoothing; // TODO(OSS Candidate ISS#2710739)
|
|
75
76
|
|
|
@@ -230,6 +231,13 @@ NSString *const RCTTextAttributesTagAttributeName = @"RCTTextAttributesTagAttrib
|
|
|
230
231
|
|
|
231
232
|
if (fontScalingEnabled) {
|
|
232
233
|
CGFloat fontSizeMultiplier = !isnan(_fontSizeMultiplier) ? _fontSizeMultiplier : 1.0;
|
|
234
|
+
#if !TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
235
|
+
if (_dynamicTypeRamp != RCTDynamicTypeRampUndefined) {
|
|
236
|
+
UIFontMetrics *fontMetrics = RCTUIFontMetricsForDynamicTypeRamp(_dynamicTypeRamp);
|
|
237
|
+
CGFloat baseSize = RCTBaseSizeForDynamicTypeRamp(_dynamicTypeRamp);
|
|
238
|
+
fontSizeMultiplier = [fontMetrics scaledValueForValue:baseSize] / baseSize;
|
|
239
|
+
}
|
|
240
|
+
#endif // ]TODO(macOS GH#774)
|
|
233
241
|
CGFloat maxFontSizeMultiplier = !isnan(_maxFontSizeMultiplier) ? _maxFontSizeMultiplier : 0.0;
|
|
234
242
|
return maxFontSizeMultiplier >= 1.0 ? fminf(maxFontSizeMultiplier, fontSizeMultiplier) : fontSizeMultiplier;
|
|
235
243
|
} else {
|
|
@@ -328,6 +336,7 @@ static NSString *capitalizeText(NSString *text)
|
|
|
328
336
|
RCTTextAttributesCompareObjects(_fontStyle) &&
|
|
329
337
|
RCTTextAttributesCompareObjects(_fontVariant) &&
|
|
330
338
|
RCTTextAttributesCompareOthers(_allowFontScaling) &&
|
|
339
|
+
RCTTextAttributesCompareOthers(_dynamicTypeRamp) && // TODO(macOS GH#774)
|
|
331
340
|
RCTTextAttributesCompareFloats(_letterSpacing) &&
|
|
332
341
|
RCTTextAttributesCompareOthers(_fontSmoothing) && // TODO(OSS Candidate ISS#2710739)
|
|
333
342
|
// Paragraph Styles
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// TODO(macOS GH#774)
|
|
9
|
+
|
|
10
|
+
#import <Foundation/Foundation.h>
|
|
11
|
+
|
|
12
|
+
#import <React/RCTConvert.h>
|
|
13
|
+
|
|
14
|
+
typedef NS_ENUM(NSInteger, RCTDynamicTypeRamp) {
|
|
15
|
+
RCTDynamicTypeRampUndefined,
|
|
16
|
+
RCTDynamicTypeRampCaption2,
|
|
17
|
+
RCTDynamicTypeRampCaption1,
|
|
18
|
+
RCTDynamicTypeRampFootnote,
|
|
19
|
+
RCTDynamicTypeRampSubheadline,
|
|
20
|
+
RCTDynamicTypeRampCallout,
|
|
21
|
+
RCTDynamicTypeRampBody,
|
|
22
|
+
RCTDynamicTypeRampHeadline,
|
|
23
|
+
RCTDynamicTypeRampTitle3,
|
|
24
|
+
RCTDynamicTypeRampTitle2,
|
|
25
|
+
RCTDynamicTypeRampTitle1,
|
|
26
|
+
RCTDynamicTypeRampLargeTitle
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
@interface RCTConvert (DynamicTypeRamp)
|
|
30
|
+
|
|
31
|
+
+ (RCTDynamicTypeRamp)RCTDynamicTypeRamp:(nullable id)json;
|
|
32
|
+
|
|
33
|
+
@end
|
|
34
|
+
|
|
35
|
+
#if !TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
36
|
+
/// Generates a `UIFontMetrics` instance representing a particular Dynamic Type ramp.
|
|
37
|
+
UIFontMetrics * _Nonnull RCTUIFontMetricsForDynamicTypeRamp(RCTDynamicTypeRamp dynamicTypeRamp);
|
|
38
|
+
/// The "reference" size for a particular font scale ramp, equal to a text element's size under default text size settings.
|
|
39
|
+
CGFloat RCTBaseSizeForDynamicTypeRamp(RCTDynamicTypeRamp dynamicTypeRamp);
|
|
40
|
+
#endif // ]TODO(macOS GH#774)
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// TODO(macOS GH#774)
|
|
9
|
+
|
|
10
|
+
#import <React/RCTDynamicTypeRamp.h>
|
|
11
|
+
|
|
12
|
+
@implementation RCTConvert (DynamicTypeRamp)
|
|
13
|
+
|
|
14
|
+
RCT_ENUM_CONVERTER(RCTDynamicTypeRamp, (@{
|
|
15
|
+
@"caption2": @(RCTDynamicTypeRampCaption2),
|
|
16
|
+
@"caption1": @(RCTDynamicTypeRampCaption1),
|
|
17
|
+
@"footnote": @(RCTDynamicTypeRampFootnote),
|
|
18
|
+
@"subheadline": @(RCTDynamicTypeRampSubheadline),
|
|
19
|
+
@"callout": @(RCTDynamicTypeRampCallout),
|
|
20
|
+
@"body": @(RCTDynamicTypeRampBody),
|
|
21
|
+
@"headline": @(RCTDynamicTypeRampHeadline),
|
|
22
|
+
@"title3": @(RCTDynamicTypeRampTitle3),
|
|
23
|
+
@"title2": @(RCTDynamicTypeRampTitle2),
|
|
24
|
+
@"title1": @(RCTDynamicTypeRampTitle1),
|
|
25
|
+
@"largeTitle": @(RCTDynamicTypeRampLargeTitle),
|
|
26
|
+
}), RCTDynamicTypeRampUndefined, integerValue)
|
|
27
|
+
|
|
28
|
+
@end
|
|
29
|
+
|
|
30
|
+
#if !TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
31
|
+
UIFontMetrics *RCTUIFontMetricsForDynamicTypeRamp(RCTDynamicTypeRamp dynamicTypeRamp) {
|
|
32
|
+
static NSDictionary<NSNumber *, UIFontTextStyle> *mapping;
|
|
33
|
+
static dispatch_once_t onceToken;
|
|
34
|
+
dispatch_once(&onceToken, ^{
|
|
35
|
+
mapping = @{
|
|
36
|
+
@(RCTDynamicTypeRampCaption2): UIFontTextStyleCaption2,
|
|
37
|
+
@(RCTDynamicTypeRampCaption1): UIFontTextStyleCaption1,
|
|
38
|
+
@(RCTDynamicTypeRampFootnote): UIFontTextStyleFootnote,
|
|
39
|
+
@(RCTDynamicTypeRampSubheadline): UIFontTextStyleSubheadline,
|
|
40
|
+
@(RCTDynamicTypeRampCallout): UIFontTextStyleCallout,
|
|
41
|
+
@(RCTDynamicTypeRampBody): UIFontTextStyleBody,
|
|
42
|
+
@(RCTDynamicTypeRampHeadline): UIFontTextStyleHeadline,
|
|
43
|
+
@(RCTDynamicTypeRampTitle3): UIFontTextStyleTitle3,
|
|
44
|
+
@(RCTDynamicTypeRampTitle2): UIFontTextStyleTitle2,
|
|
45
|
+
@(RCTDynamicTypeRampTitle1): UIFontTextStyleTitle1,
|
|
46
|
+
@(RCTDynamicTypeRampLargeTitle): UIFontTextStyleLargeTitle,
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
id textStyle = mapping[@(dynamicTypeRamp)] ?: UIFontTextStyleBody; // Default to body if we don't recognize the specified ramp
|
|
51
|
+
return [UIFontMetrics metricsForTextStyle:textStyle];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
CGFloat RCTBaseSizeForDynamicTypeRamp(RCTDynamicTypeRamp dynamicTypeRamp) {
|
|
55
|
+
static NSDictionary<NSNumber *, NSNumber *> *mapping;
|
|
56
|
+
static dispatch_once_t onceToken;
|
|
57
|
+
dispatch_once(&onceToken, ^{
|
|
58
|
+
// Values taken from https://developer.apple.com/design/human-interface-guidelines/foundations/typography/
|
|
59
|
+
mapping = @{
|
|
60
|
+
@(RCTDynamicTypeRampCaption2): @11,
|
|
61
|
+
@(RCTDynamicTypeRampCaption1): @12,
|
|
62
|
+
@(RCTDynamicTypeRampFootnote): @13,
|
|
63
|
+
@(RCTDynamicTypeRampSubheadline): @15,
|
|
64
|
+
@(RCTDynamicTypeRampCallout): @16,
|
|
65
|
+
@(RCTDynamicTypeRampBody): @17,
|
|
66
|
+
@(RCTDynamicTypeRampHeadline): @17,
|
|
67
|
+
@(RCTDynamicTypeRampTitle3): @20,
|
|
68
|
+
@(RCTDynamicTypeRampTitle2): @22,
|
|
69
|
+
@(RCTDynamicTypeRampTitle1): @28,
|
|
70
|
+
@(RCTDynamicTypeRampLargeTitle): @34,
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
NSNumber *baseSize = mapping[@(dynamicTypeRamp)] ?: @17; // Default to body size if we don't recognize the specified ramp
|
|
75
|
+
return CGFLOAT_IS_DOUBLE ? [baseSize doubleValue] : [baseSize floatValue];
|
|
76
|
+
}
|
|
77
|
+
#endif // ]TODO(macOS GH#774)
|
|
@@ -22,6 +22,27 @@
|
|
|
22
22
|
|
|
23
23
|
#import <QuartzCore/QuartzCore.h> // TODO(macOS GH#774)
|
|
24
24
|
|
|
25
|
+
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
26
|
+
|
|
27
|
+
// We are managing the key view loop using the RCTTextView.
|
|
28
|
+
// Disable key view for backed NSTextView so we don't get double focus.
|
|
29
|
+
@interface RCTUnfocusableTextView : NSTextView
|
|
30
|
+
@end
|
|
31
|
+
|
|
32
|
+
@implementation RCTUnfocusableTextView
|
|
33
|
+
|
|
34
|
+
- (BOOL)canBecomeKeyView
|
|
35
|
+
{
|
|
36
|
+
return NO;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@end
|
|
40
|
+
|
|
41
|
+
@interface RCTTextView () <NSTextViewDelegate>
|
|
42
|
+
@end
|
|
43
|
+
|
|
44
|
+
#endif // ]TODO(macOS GH#774)
|
|
45
|
+
|
|
25
46
|
@implementation RCTTextView
|
|
26
47
|
{
|
|
27
48
|
CAShapeLayer *_highlightLayer;
|
|
@@ -29,6 +50,7 @@
|
|
|
29
50
|
UILongPressGestureRecognizer *_longPressGestureRecognizer;
|
|
30
51
|
#else // [TODO(macOS GH#774)
|
|
31
52
|
NSString * _accessibilityLabel;
|
|
53
|
+
NSTextView *_textView;
|
|
32
54
|
#endif // ]TODO(macOS GH#774)
|
|
33
55
|
|
|
34
56
|
RCTEventDispatcher *_eventDispatcher; // TODO(OSS Candidate ISS#2710739)
|
|
@@ -57,6 +79,18 @@
|
|
|
57
79
|
self.accessibilityRole = NSAccessibilityStaticTextRole;
|
|
58
80
|
// Fix blurry text on non-retina displays.
|
|
59
81
|
self.canDrawSubviewsIntoLayer = YES;
|
|
82
|
+
// The NSTextView is responsible for drawing text and managing selection.
|
|
83
|
+
_textView = [[RCTUnfocusableTextView alloc] initWithFrame:self.bounds];
|
|
84
|
+
_textView.delegate = self;
|
|
85
|
+
_textView.usesFontPanel = NO;
|
|
86
|
+
_textView.drawsBackground = NO;
|
|
87
|
+
_textView.linkTextAttributes = @{};
|
|
88
|
+
_textView.editable = NO;
|
|
89
|
+
_textView.selectable = NO;
|
|
90
|
+
_textView.verticallyResizable = NO;
|
|
91
|
+
_textView.layoutManager.usesFontLeading = NO;
|
|
92
|
+
_textStorage = _textView.textStorage;
|
|
93
|
+
[self addSubview:_textView];
|
|
60
94
|
#endif // ]TODO(macOS GH#774)
|
|
61
95
|
self.opaque = NO;
|
|
62
96
|
RCTUIViewSetContentModeRedraw(self); // TODO(macOS GH#774) and TODO(macOS ISS#3536887)
|
|
@@ -65,40 +99,7 @@
|
|
|
65
99
|
}
|
|
66
100
|
|
|
67
101
|
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
68
|
-
- (void)dealloc
|
|
69
|
-
{
|
|
70
|
-
[self removeAllTextStorageLayoutManagers];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
- (void)removeAllTextStorageLayoutManagers
|
|
74
|
-
{
|
|
75
|
-
// On macOS AppKit can throw an uncaught exception
|
|
76
|
-
// (-[NSConcretePointerArray pointerAtIndex:]: attempt to access pointer at index ...)
|
|
77
|
-
// during the dealloc of NSLayoutManager. The _textStorage and its
|
|
78
|
-
// associated NSLayoutManager dealloc later in an autorelease pool.
|
|
79
|
-
// Manually removing the layout managers from _textStorage prior to release
|
|
80
|
-
// works around this issue in AppKit.
|
|
81
|
-
NSArray<NSLayoutManager *> *managers = [[_textStorage layoutManagers] copy];
|
|
82
|
-
for (NSLayoutManager *manager in managers) {
|
|
83
|
-
[_textStorage removeLayoutManager:manager];
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
102
|
|
|
87
|
-
- (BOOL)canBecomeKeyView
|
|
88
|
-
{
|
|
89
|
-
// RCTText should not get any keyboard focus unless its `selectable` prop is true
|
|
90
|
-
return _selectable;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
- (void)drawFocusRingMask {
|
|
94
|
-
if ([self enableFocusRing]) {
|
|
95
|
-
NSRectFill([self bounds]);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
- (NSRect)focusRingMaskBounds {
|
|
100
|
-
return [self bounds];
|
|
101
|
-
}
|
|
102
103
|
#endif // ]TODO(macOS GH#774)
|
|
103
104
|
|
|
104
105
|
#if DEBUG // TODO(macOS GH#774) description is a debug-only feature
|
|
@@ -119,14 +120,19 @@
|
|
|
119
120
|
|
|
120
121
|
_selectable = selectable;
|
|
121
122
|
|
|
122
|
-
#if !TARGET_OS_OSX // TODO(macOS GH#774)
|
|
123
|
+
#if !TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
123
124
|
if (_selectable) {
|
|
124
125
|
[self enableContextMenu];
|
|
125
126
|
}
|
|
126
127
|
else {
|
|
127
128
|
[self disableContextMenu];
|
|
128
129
|
}
|
|
129
|
-
#
|
|
130
|
+
#else
|
|
131
|
+
_textView.selectable = _selectable;
|
|
132
|
+
if (_selectable) {
|
|
133
|
+
[self setFocusable:YES];
|
|
134
|
+
}
|
|
135
|
+
#endif // ]TODO(macOS GH#774)
|
|
130
136
|
}
|
|
131
137
|
|
|
132
138
|
#if !TARGET_OS_OSX // TODO(macOS GH#774)
|
|
@@ -149,13 +155,37 @@
|
|
|
149
155
|
contentFrame:(CGRect)contentFrame
|
|
150
156
|
descendantViews:(NSArray<RCTUIView *> *)descendantViews // TODO(macOS ISS#3536887)
|
|
151
157
|
{
|
|
152
|
-
|
|
153
|
-
|
|
158
|
+
// This lets the textView own its text storage on macOS
|
|
159
|
+
// We update and replace the text container `_textView.textStorage.attributedString` when text/layout changes
|
|
160
|
+
#if !TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
161
|
+
_textStorage = textStorage;
|
|
154
162
|
#endif // ]TODO(macOS GH#774)
|
|
155
163
|
|
|
156
|
-
_textStorage = textStorage;
|
|
157
164
|
_contentFrame = contentFrame;
|
|
158
165
|
|
|
166
|
+
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
167
|
+
NSLayoutManager *layoutManager = textStorage.layoutManagers.firstObject;
|
|
168
|
+
NSTextContainer *textContainer = layoutManager.textContainers.firstObject;
|
|
169
|
+
|
|
170
|
+
[_textView replaceTextContainer:textContainer];
|
|
171
|
+
|
|
172
|
+
// On macOS AppKit can throw an uncaught exception
|
|
173
|
+
// (-[NSConcretePointerArray pointerAtIndex:]: attempt to access pointer at index ...)
|
|
174
|
+
// during the dealloc of NSLayoutManager. The textStorage and its
|
|
175
|
+
// associated NSLayoutManager dealloc later in an autorelease pool.
|
|
176
|
+
// Manually removing the layout managers from textStorage prior to release
|
|
177
|
+
// works around this issue in AppKit.
|
|
178
|
+
NSArray<NSLayoutManager *> *managers = [[textStorage layoutManagers] copy];
|
|
179
|
+
for (NSLayoutManager *manager in managers) {
|
|
180
|
+
[textStorage removeLayoutManager:manager];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
_textView.minSize = contentFrame.size;
|
|
184
|
+
_textView.maxSize = contentFrame.size;
|
|
185
|
+
_textView.frame = contentFrame;
|
|
186
|
+
_textView.textStorage.attributedString = textStorage;
|
|
187
|
+
#endif // ]TODO(macOS GH#774)
|
|
188
|
+
|
|
159
189
|
// FIXME: Optimize this.
|
|
160
190
|
for (RCTUIView *view in _descendantViews) { // TODO(macOS ISS#3536887)
|
|
161
191
|
[view removeFromSuperview];
|
|
@@ -173,6 +203,13 @@
|
|
|
173
203
|
- (void)drawRect:(CGRect)rect
|
|
174
204
|
{
|
|
175
205
|
[super drawRect:rect];
|
|
206
|
+
|
|
207
|
+
// For iOS, UITextView api is not used for legacy performance reasons. A custom draw implementation is used instead.
|
|
208
|
+
// On desktop, we use NSTextView to access api's for arbitrary selection, custom cursors etc...
|
|
209
|
+
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
210
|
+
return;
|
|
211
|
+
#endif // ]TODO(macOS GH#774)
|
|
212
|
+
|
|
176
213
|
if (!_textStorage) {
|
|
177
214
|
return;
|
|
178
215
|
}
|
|
@@ -408,6 +445,39 @@
|
|
|
408
445
|
}
|
|
409
446
|
}
|
|
410
447
|
}
|
|
448
|
+
#endif // ]TODO(macOS GH#774)
|
|
449
|
+
|
|
450
|
+
#pragma mark - Selection
|
|
451
|
+
|
|
452
|
+
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
453
|
+
- (void)textDidEndEditing:(NSNotification *)notification
|
|
454
|
+
{
|
|
455
|
+
_textView.selectedRange = NSMakeRange(NSNotFound, 0);
|
|
456
|
+
}
|
|
457
|
+
#endif // ]TODO(macOS GH#774)
|
|
458
|
+
|
|
459
|
+
#pragma mark - Responder chain
|
|
460
|
+
|
|
461
|
+
#if !TARGET_OS_OSX // TODO(macOS GH#774)
|
|
462
|
+
- (BOOL)canBecomeFirstResponder
|
|
463
|
+
{
|
|
464
|
+
return _selectable;
|
|
465
|
+
}
|
|
466
|
+
#else
|
|
467
|
+
- (BOOL)canBecomeKeyView
|
|
468
|
+
{
|
|
469
|
+
return self.focusable;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
- (void)drawFocusRingMask {
|
|
473
|
+
if (self.focusable && self.enableFocusRing) {
|
|
474
|
+
NSRectFill([self bounds]);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
- (NSRect)focusRingMaskBounds {
|
|
479
|
+
return [self bounds];
|
|
480
|
+
}
|
|
411
481
|
|
|
412
482
|
- (BOOL)becomeFirstResponder
|
|
413
483
|
{
|
|
@@ -423,22 +493,19 @@
|
|
|
423
493
|
|
|
424
494
|
- (BOOL)resignFirstResponder
|
|
425
495
|
{
|
|
426
|
-
|
|
496
|
+
// Don't relinquish first responder while selecting text.
|
|
497
|
+
if (_selectable && NSRunLoop.currentRunLoop.currentMode == NSEventTrackingRunLoopMode) {
|
|
427
498
|
return NO;
|
|
428
499
|
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
[_eventDispatcher sendEvent:[RCTFocusChangeEvent blurEventWithReactTag:self.reactTag]];
|
|
432
|
-
|
|
433
|
-
return YES;
|
|
500
|
+
|
|
501
|
+
return [super resignFirstResponder];
|
|
434
502
|
}
|
|
435
503
|
|
|
436
|
-
#endif // ]TODO(macOS GH#774)
|
|
437
|
-
|
|
438
504
|
- (BOOL)canBecomeFirstResponder
|
|
439
505
|
{
|
|
440
|
-
return
|
|
506
|
+
return self.focusable;
|
|
441
507
|
}
|
|
508
|
+
#endif
|
|
442
509
|
|
|
443
510
|
#if !TARGET_OS_OSX // TODO(macOS GH#774)
|
|
444
511
|
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
|
|
@@ -451,6 +518,8 @@
|
|
|
451
518
|
}
|
|
452
519
|
#endif // TODO(macOS GH#774)
|
|
453
520
|
|
|
521
|
+
#pragma mark - Copy/Paste
|
|
522
|
+
|
|
454
523
|
- (void)copy:(id)sender
|
|
455
524
|
{
|
|
456
525
|
NSAttributedString *attributedText = _textStorage;
|
|
@@ -470,6 +539,8 @@
|
|
|
470
539
|
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
|
|
471
540
|
pasteboard.items = @[item];
|
|
472
541
|
#elif TARGET_OS_OSX // TODO(macOS GH#774)
|
|
542
|
+
[_textView copy:sender];
|
|
543
|
+
|
|
473
544
|
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
|
|
474
545
|
[pasteboard clearContents];
|
|
475
546
|
[pasteboard writeObjects:[NSArray arrayWithObjects:attributedText.string, rtf, nil]];
|
package/Libraries/Text/Text.js
CHANGED
|
@@ -42,12 +42,9 @@ const Text: React.AbstractComponent<
|
|
|
42
42
|
onResponderTerminationRequest,
|
|
43
43
|
onStartShouldSetResponder,
|
|
44
44
|
pressRetentionOffset,
|
|
45
|
-
suppressHighlighting,
|
|
46
45
|
...restProps
|
|
47
46
|
} = props;
|
|
48
47
|
|
|
49
|
-
const [isHighlighted, setHighlighted] = useState(false);
|
|
50
|
-
|
|
51
48
|
const isPressable =
|
|
52
49
|
(onPress != null ||
|
|
53
50
|
onLongPress != null ||
|
|
@@ -64,11 +61,9 @@ const Text: React.AbstractComponent<
|
|
|
64
61
|
onLongPress,
|
|
65
62
|
onPress,
|
|
66
63
|
onPressIn(event) {
|
|
67
|
-
setHighlighted(!suppressHighlighting);
|
|
68
64
|
onPressIn?.(event);
|
|
69
65
|
},
|
|
70
66
|
onPressOut(event) {
|
|
71
|
-
setHighlighted(false);
|
|
72
67
|
onPressOut?.(event);
|
|
73
68
|
},
|
|
74
69
|
onResponderTerminationRequest_DEPRECATED:
|
|
@@ -86,7 +81,6 @@ const Text: React.AbstractComponent<
|
|
|
86
81
|
onPressOut,
|
|
87
82
|
onResponderTerminationRequest,
|
|
88
83
|
onStartShouldSetResponder,
|
|
89
|
-
suppressHighlighting,
|
|
90
84
|
],
|
|
91
85
|
);
|
|
92
86
|
|
|
@@ -162,7 +156,6 @@ const Text: React.AbstractComponent<
|
|
|
162
156
|
<NativeVirtualText
|
|
163
157
|
{...restProps}
|
|
164
158
|
{...eventHandlersForText}
|
|
165
|
-
isHighlighted={isHighlighted}
|
|
166
159
|
isPressable={isPressable}
|
|
167
160
|
numberOfLines={numberOfLines}
|
|
168
161
|
selectionColor={selectionColor}
|
|
@@ -177,7 +170,6 @@ const Text: React.AbstractComponent<
|
|
|
177
170
|
accessible={accessible !== false}
|
|
178
171
|
allowFontScaling={allowFontScaling !== false}
|
|
179
172
|
ellipsizeMode={ellipsizeMode ?? 'tail'}
|
|
180
|
-
isHighlighted={isHighlighted}
|
|
181
173
|
numberOfLines={numberOfLines}
|
|
182
174
|
selectionColor={selectionColor}
|
|
183
175
|
style={style}
|
|
@@ -12,8 +12,13 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
12
12
|
@interface RCTMultilineTextInputView : RCTBaseTextInputView
|
|
13
13
|
|
|
14
14
|
#if TARGET_OS_OSX // [TODO(macOS GH#774)
|
|
15
|
+
|
|
16
|
+
@property (nonatomic, assign) BOOL scrollEnabled;
|
|
17
|
+
|
|
15
18
|
- (void)setReadablePasteBoardTypes:(NSArray<NSPasteboardType> *)readablePasteboardTypes;
|
|
19
|
+
@property (nonatomic, assign) BOOL hideVerticalScrollIndicator;
|
|
16
20
|
#endif // ]TODO(macOS GH#774)
|
|
21
|
+
|
|
17
22
|
@end
|
|
18
23
|
|
|
19
24
|
NS_ASSUME_NONNULL_END
|