react-native-macos 0.0.0-d8612d037 → 0.0.0-d869ab1cf
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/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Image/RCTImageView.mm +14 -10
- 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/TextNativeComponent.js +1 -0
- package/Libraries/Text/TextProps.js +17 -0
- package/React/Base/RCTUtils.m +6 -3
- package/React/Base/RCTVersion.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/cxxreact/ReactNativeVersion.h +1 -1
- package/package.json +1 -1
- package/template/Gemfile.lock +1 -1
- package/template/package.json +1 -1
|
@@ -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
|
|
@@ -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 = RCTUIBaseSizeForDynamicTypeRamp(_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
|
+
RCTDynamicTypeRampSubhead,
|
|
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 RCTUIBaseSizeForDynamicTypeRamp(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
|
+
@"subhead": @(RCTDynamicTypeRampSubhead),
|
|
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
|
+
@(RCTDynamicTypeRampSubhead): 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 RCTUIBaseSizeForDynamicTypeRamp(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
|
+
@(RCTDynamicTypeRampSubhead): @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)
|
|
@@ -186,6 +186,23 @@ export type TextProps = $ReadOnly<{|
|
|
|
186
186
|
*/
|
|
187
187
|
adjustsFontSizeToFit?: ?boolean,
|
|
188
188
|
|
|
189
|
+
/**
|
|
190
|
+
* The Dynamic Text scale ramp to apply to this element on iOS.
|
|
191
|
+
*/
|
|
192
|
+
dynamicTypeRamp?: ?(
|
|
193
|
+
| 'caption2'
|
|
194
|
+
| 'caption1'
|
|
195
|
+
| 'footnote'
|
|
196
|
+
| 'subhead'
|
|
197
|
+
| 'callout'
|
|
198
|
+
| 'body'
|
|
199
|
+
| 'headline'
|
|
200
|
+
| 'title3'
|
|
201
|
+
| 'title2'
|
|
202
|
+
| 'title1'
|
|
203
|
+
| 'largeTitle'
|
|
204
|
+
),
|
|
205
|
+
|
|
189
206
|
/**
|
|
190
207
|
* Smallest possible scale a font can reach.
|
|
191
208
|
*
|
package/React/Base/RCTUtils.m
CHANGED
|
@@ -905,9 +905,12 @@ UIImage *__nullable RCTImageFromLocalAssetURL(NSURL *imageURL)
|
|
|
905
905
|
}
|
|
906
906
|
#if !TARGET_OS_OSX // TODO(macOS GH#774)
|
|
907
907
|
image = [UIImage imageWithContentsOfFile:filePath];
|
|
908
|
-
#else // TODO(macOS GH#774)
|
|
909
|
-
|
|
910
|
-
|
|
908
|
+
#else // [TODO(macOS GH#774)
|
|
909
|
+
// macOS keeps file handles in open state for lifetime of image if "initWithContentsOfFile:" is used with path inside app bundle
|
|
910
|
+
// Workaround is to load file in data and then convert data to image
|
|
911
|
+
NSData *data = [NSData dataWithContentsOfFile:filePath];
|
|
912
|
+
image = [[NSImage alloc] initWithData:data];
|
|
913
|
+
#endif // ]TODO(macOS GH#774)
|
|
911
914
|
}
|
|
912
915
|
}
|
|
913
916
|
|
package/React/Base/RCTVersion.m
CHANGED
package/package.json
CHANGED
package/template/Gemfile.lock
CHANGED