react-native-macos 0.68.51 → 0.68.53

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.
@@ -16,6 +16,6 @@
16
16
  exports.version = {
17
17
  major: 0,
18
18
  minor: 68,
19
- patch: 51,
19
+ patch: 53,
20
20
  prerelease: null,
21
21
  };
@@ -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)
@@ -63,6 +63,7 @@ NSString *const RCTTextAttributesTagAttributeName = @"RCTTextAttributesTagAttrib
63
63
  _fontStyle = textAttributes->_fontStyle ?: _fontStyle;
64
64
  _fontVariant = textAttributes->_fontVariant ?: _fontVariant;
65
65
  _allowFontScaling = textAttributes->_allowFontScaling || _allowFontScaling; // *
66
+ _dynamicTypeRamp = textAttributes->_dynamicTypeRamp != RCTDynamicTypeRampUndefined ? textAttributes->_dynamicTypeRamp : _dynamicTypeRamp; // TODO(macOS GH#774)
66
67
  _letterSpacing = !isnan(textAttributes->_letterSpacing) ? textAttributes->_letterSpacing : _letterSpacing;
67
68
  _fontSmoothing = textAttributes->_fontSmoothing != RCTFontSmoothingAuto ? textAttributes->_fontSmoothing : _fontSmoothing; // TODO(OSS Candidate ISS#2710739)
68
69
 
@@ -223,6 +224,13 @@ NSString *const RCTTextAttributesTagAttributeName = @"RCTTextAttributesTagAttrib
223
224
 
224
225
  if (fontScalingEnabled) {
225
226
  CGFloat fontSizeMultiplier = !isnan(_fontSizeMultiplier) ? _fontSizeMultiplier : 1.0;
227
+ #if !TARGET_OS_OSX // [TODO(macOS GH#774)
228
+ if (_dynamicTypeRamp != RCTDynamicTypeRampUndefined) {
229
+ UIFontMetrics *fontMetrics = RCTUIFontMetricsForDynamicTypeRamp(_dynamicTypeRamp);
230
+ CGFloat baseSize = RCTUIBaseSizeForDynamicTypeRamp(_dynamicTypeRamp);
231
+ fontSizeMultiplier = [fontMetrics scaledValueForValue:baseSize] / baseSize;
232
+ }
233
+ #endif // ]TODO(macOS GH#774)
226
234
  CGFloat maxFontSizeMultiplier = !isnan(_maxFontSizeMultiplier) ? _maxFontSizeMultiplier : 0.0;
227
235
  return maxFontSizeMultiplier >= 1.0 ? fminf(maxFontSizeMultiplier, fontSizeMultiplier) : fontSizeMultiplier;
228
236
  } else {
@@ -321,6 +329,7 @@ static NSString *capitalizeText(NSString *text)
321
329
  RCTTextAttributesCompareObjects(_fontStyle) &&
322
330
  RCTTextAttributesCompareObjects(_fontVariant) &&
323
331
  RCTTextAttributesCompareOthers(_allowFontScaling) &&
332
+ RCTTextAttributesCompareOthers(_dynamicTypeRamp) && // TODO(macOS GH#774)
324
333
  RCTTextAttributesCompareFloats(_letterSpacing) &&
325
334
  RCTTextAttributesCompareOthers(_fontSmoothing) && // TODO(OSS Candidate ISS#2710739)
326
335
  // 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)
@@ -34,6 +34,7 @@ export const NativeText: HostComponent<NativeTextProps> =
34
34
  numberOfLines: true,
35
35
  ellipsizeMode: true,
36
36
  allowFontScaling: true,
37
+ dynamicTypeRamp: true,
37
38
  maxFontSizeMultiplier: true,
38
39
  disabled: true,
39
40
  selectable: true,
@@ -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
  *
@@ -27,7 +27,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
27
27
  __rnVersion = @{
28
28
  RCTVersionMajor: @(0),
29
29
  RCTVersionMinor: @(68),
30
- RCTVersionPatch: @(51),
30
+ RCTVersionPatch: @(53),
31
31
  RCTVersionPrerelease: [NSNull null],
32
32
  };
33
33
  });
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.68.51
1
+ VERSION_NAME=0.68.53
2
2
  GROUP=com.facebook.react
3
3
 
4
4
  POM_NAME=ReactNative
@@ -21,6 +21,6 @@ public class ReactNativeVersion {
21
21
  public static final Map<String, Object> VERSION = MapBuilder.<String, Object>of(
22
22
  "major", 0,
23
23
  "minor", 68,
24
- "patch", 51,
24
+ "patch", 53,
25
25
  "prerelease", null);
26
26
  }
@@ -21,7 +21,7 @@ namespace facebook::react {
21
21
  constexpr struct {
22
22
  int32_t Major = 0;
23
23
  int32_t Minor = 68;
24
- int32_t Patch = 51;
24
+ int32_t Patch = 53;
25
25
  std::string_view Prerelease = "";
26
26
  } ReactNativeVersion;
27
27
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-macos",
3
- "version": "0.68.51",
3
+ "version": "0.68.53",
4
4
  "bin": "./cli.js",
5
5
  "description": "React Native for macOS",
6
6
  "license": "MIT",
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "react": "17.0.2",
15
- "react-native-macos": "0.68.51"
15
+ "react-native-macos": "0.68.53"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@babel/core": "^7.12.9",