react-native-tinyui 1.1.0 → 2.0.0

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.
Files changed (44) hide show
  1. package/README.md +43 -7
  2. package/ios/Core/Tinyui.mm +18 -0
  3. package/ios/LiquidGlassText/TinyuiLiquidGlassTextProvider.swift +0 -1
  4. package/ios/Menu/TinyuiMenuView.mm +15 -0
  5. package/ios/SFSymbol/TinyuiSFSymbolEffects.swift +184 -0
  6. package/ios/SFSymbol/TinyuiSFSymbolImage.swift +103 -0
  7. package/ios/SFSymbol/TinyuiSFSymbolProvider.swift +135 -0
  8. package/ios/SFSymbol/TinyuiSFSymbolShadowNode.mm +4 -2
  9. package/ios/SFSymbol/TinyuiSFSymbolView.mm +14 -122
  10. package/ios/TipKit/TinyuiTipsRuntime.swift +14 -0
  11. package/lib/module/NativeTinyui.js.map +1 -1
  12. package/lib/module/SFSymbol/index.js +0 -4
  13. package/lib/module/SFSymbol/index.js.map +1 -1
  14. package/lib/module/SFSymbol/options.js +0 -2
  15. package/lib/module/SFSymbol/options.js.map +1 -1
  16. package/lib/module/TipKit/index.js +9 -0
  17. package/lib/module/TipKit/index.js.map +1 -1
  18. package/lib/module/index.js.map +1 -1
  19. package/lib/typescript/src/LiquidGlassText/types.d.ts +1 -1
  20. package/lib/typescript/src/LiquidGlassText/types.d.ts.map +1 -1
  21. package/lib/typescript/src/NativeTinyui.d.ts +1 -0
  22. package/lib/typescript/src/NativeTinyui.d.ts.map +1 -1
  23. package/lib/typescript/src/SFSymbol/index.d.ts +1 -1
  24. package/lib/typescript/src/SFSymbol/index.d.ts.map +1 -1
  25. package/lib/typescript/src/SFSymbol/options.d.ts +0 -2
  26. package/lib/typescript/src/SFSymbol/options.d.ts.map +1 -1
  27. package/lib/typescript/src/SFSymbol/types.d.ts +1 -5
  28. package/lib/typescript/src/SFSymbol/types.d.ts.map +1 -1
  29. package/lib/typescript/src/TipKit/index.d.ts +6 -0
  30. package/lib/typescript/src/TipKit/index.d.ts.map +1 -1
  31. package/lib/typescript/src/index.d.ts +1 -1
  32. package/lib/typescript/src/index.d.ts.map +1 -1
  33. package/package.json +1 -1
  34. package/src/LiquidGlassText/types.ts +1 -1
  35. package/src/NativeTinyui.ts +1 -0
  36. package/src/SFSymbol/index.tsx +0 -5
  37. package/src/SFSymbol/options.ts +0 -2
  38. package/src/SFSymbol/types.ts +1 -18
  39. package/src/TipKit/index.ts +10 -0
  40. package/src/index.tsx +0 -1
  41. package/ios/SFSymbol/TinyuiSFSymbolEffects.h +0 -9
  42. package/ios/SFSymbol/TinyuiSFSymbolEffects.mm +0 -180
  43. package/ios/SFSymbol/TinyuiSFSymbolImage.h +0 -8
  44. package/ios/SFSymbol/TinyuiSFSymbolImage.mm +0 -141
@@ -1,180 +0,0 @@
1
- #if TINYUI_FEATURE_SF_SYMBOL
2
-
3
- #import "TinyuiSFSymbolEffects.h"
4
- #include <cmath>
5
-
6
- // Keep the concrete receiver types so the compiler checks every Symbols API.
7
- #define TINYUI_LAYER_SCOPE(effect) \
8
- if ([scope isEqual:@"byLayer"]) effect = [effect effectWithByLayer]; \
9
- if ([scope isEqual:@"wholeSymbol"]) effect = [effect effectWithWholeSymbol];
10
-
11
- NSSymbolEffect *TinyuiSFSymbolEffect(NSDictionary *configuration)
12
- {
13
- NSString *type = configuration[@"type"];
14
- NSString *scope = configuration[@"scope"];
15
- NSString *direction = configuration[@"direction"];
16
- if ([type isEqual:@"pulse"]) {
17
- NSSymbolPulseEffect *effect = NSSymbolPulseEffect.effect;
18
- TINYUI_LAYER_SCOPE(effect);
19
- return effect;
20
- }
21
- if ([type isEqual:@"bounce"]) {
22
- NSSymbolBounceEffect *effect = NSSymbolBounceEffect.effect;
23
- if ([direction isEqual:@"up"]) effect = NSSymbolBounceEffect.bounceUpEffect;
24
- if ([direction isEqual:@"down"]) effect = NSSymbolBounceEffect.bounceDownEffect;
25
- TINYUI_LAYER_SCOPE(effect);
26
- return effect;
27
- }
28
- if ([type isEqual:@"scale"]) {
29
- NSSymbolScaleEffect *effect = NSSymbolScaleEffect.effect;
30
- if ([direction isEqual:@"up"]) effect = NSSymbolScaleEffect.scaleUpEffect;
31
- if ([direction isEqual:@"down"]) effect = NSSymbolScaleEffect.scaleDownEffect;
32
- TINYUI_LAYER_SCOPE(effect);
33
- return effect;
34
- }
35
- if ([type isEqual:@"appear"]) {
36
- NSSymbolAppearEffect *effect = NSSymbolAppearEffect.effect;
37
- if ([direction isEqual:@"up"]) effect = NSSymbolAppearEffect.appearUpEffect;
38
- if ([direction isEqual:@"down"]) effect = NSSymbolAppearEffect.appearDownEffect;
39
- TINYUI_LAYER_SCOPE(effect);
40
- return effect;
41
- }
42
- if ([type isEqual:@"disappear"]) {
43
- NSSymbolDisappearEffect *effect = NSSymbolDisappearEffect.effect;
44
- if ([direction isEqual:@"up"]) effect = NSSymbolDisappearEffect.disappearUpEffect;
45
- if ([direction isEqual:@"down"]) effect = NSSymbolDisappearEffect.disappearDownEffect;
46
- TINYUI_LAYER_SCOPE(effect);
47
- return effect;
48
- }
49
- if ([type isEqual:@"variableColor"]) {
50
- NSSymbolVariableColorEffect *effect = NSSymbolVariableColorEffect.effect;
51
- if ([configuration[@"iteration"] isEqual:@"iterative"]) effect = [effect effectWithIterative];
52
- if ([configuration[@"iteration"] isEqual:@"cumulative"]) effect = [effect effectWithCumulative];
53
- if ([configuration[@"reversing"] isKindOfClass:NSNumber.class]) {
54
- effect = [configuration[@"reversing"] boolValue]
55
- ? [effect effectWithReversing] : [effect effectWithNonReversing];
56
- }
57
- if ([configuration[@"inactiveLayers"] isEqual:@"hide"]) effect = [effect effectWithHideInactiveLayers];
58
- if ([configuration[@"inactiveLayers"] isEqual:@"dim"]) effect = [effect effectWithDimInactiveLayers];
59
- return effect;
60
- }
61
- if (@available(iOS 18.0, *)) {
62
- if ([type isEqual:@"wiggle"]) {
63
- NSSymbolWiggleEffect *effect = NSSymbolWiggleEffect.effect;
64
- if ([direction isEqual:@"up"]) effect = NSSymbolWiggleEffect.wiggleUpEffect;
65
- if ([direction isEqual:@"down"]) effect = NSSymbolWiggleEffect.wiggleDownEffect;
66
- if ([direction isEqual:@"left"]) effect = NSSymbolWiggleEffect.wiggleLeftEffect;
67
- if ([direction isEqual:@"right"]) effect = NSSymbolWiggleEffect.wiggleRightEffect;
68
- if ([direction isEqual:@"forward"]) effect = NSSymbolWiggleEffect.wiggleForwardEffect;
69
- if ([direction isEqual:@"backward"]) effect = NSSymbolWiggleEffect.wiggleBackwardEffect;
70
- if ([direction isEqual:@"clockwise"]) effect = NSSymbolWiggleEffect.wiggleClockwiseEffect;
71
- if ([direction isEqual:@"counterClockwise"]) effect = NSSymbolWiggleEffect.wiggleCounterClockwiseEffect;
72
- id angle = configuration[@"angle"];
73
- if ([angle isKindOfClass:NSNumber.class] && std::isfinite([angle doubleValue])) {
74
- effect = [NSSymbolWiggleEffect wiggleCustomAngleEffect:[angle doubleValue]];
75
- }
76
- TINYUI_LAYER_SCOPE(effect);
77
- return effect;
78
- }
79
- if ([type isEqual:@"rotate"]) {
80
- NSSymbolRotateEffect *effect = NSSymbolRotateEffect.effect;
81
- if ([direction isEqual:@"clockwise"]) effect = NSSymbolRotateEffect.rotateClockwiseEffect;
82
- if ([direction isEqual:@"counterClockwise"]) effect = NSSymbolRotateEffect.rotateCounterClockwiseEffect;
83
- TINYUI_LAYER_SCOPE(effect);
84
- return effect;
85
- }
86
- if ([type isEqual:@"breathe"]) {
87
- NSSymbolBreatheEffect *effect = NSSymbolBreatheEffect.effect;
88
- if ([configuration[@"style"] isEqual:@"plain"]) effect = NSSymbolBreatheEffect.breathePlainEffect;
89
- if ([configuration[@"style"] isEqual:@"pulse"]) effect = NSSymbolBreatheEffect.breathePulseEffect;
90
- TINYUI_LAYER_SCOPE(effect);
91
- return effect;
92
- }
93
- }
94
- if (@available(iOS 26.0, *)) {
95
- if ([type isEqual:@"drawOn"]) {
96
- NSSymbolDrawOnEffect *effect = NSSymbolDrawOnEffect.effect;
97
- TINYUI_LAYER_SCOPE(effect);
98
- if ([scope isEqual:@"individually"]) effect = [effect effectWithIndividually];
99
- return effect;
100
- }
101
- if ([type isEqual:@"drawOff"]) {
102
- NSSymbolDrawOffEffect *effect = NSSymbolDrawOffEffect.effect;
103
- TINYUI_LAYER_SCOPE(effect);
104
- if ([scope isEqual:@"individually"]) effect = [effect effectWithIndividually];
105
- if ([configuration[@"reversed"] isKindOfClass:NSNumber.class]) {
106
- effect = [configuration[@"reversed"] boolValue]
107
- ? [effect effectWithReversed] : [effect effectWithNonReversed];
108
- }
109
- return effect;
110
- }
111
- }
112
- return nil;
113
- }
114
-
115
- #undef TINYUI_LAYER_SCOPE
116
-
117
- NSSymbolEffectOptions *TinyuiSFSymbolOptions(NSDictionary *configuration)
118
- {
119
- NSSymbolEffectOptions *options = NSSymbolEffectOptions.options;
120
- if (![configuration isKindOfClass:NSDictionary.class]) return options;
121
- id speedValue = configuration[@"speed"];
122
- double speed = [speedValue isKindOfClass:NSNumber.class] ? [speedValue doubleValue] : 1;
123
- if (std::isfinite(speed) && speed > 0) options = [options optionsWithSpeed:speed];
124
- id repeat = configuration[@"repeat"];
125
- if ([repeat isEqual:@NO]) return [options optionsWithNonRepeating];
126
- BOOL countProvided = [repeat isKindOfClass:NSNumber.class];
127
- // JS validates safe integers; cap the conversion at the native integer range.
128
- NSInteger count = countProvided ? (NSInteger)fmin([repeat doubleValue], (double)NSIntegerMax / 2) : 1;
129
- count = MAX(1, count);
130
- id behaviorValue = configuration[@"repeatBehavior"];
131
- NSString *behavior = [behaviorValue isKindOfClass:NSString.class] ? behaviorValue : nil;
132
- id delayValue = configuration[@"repeatDelay"];
133
- BOOL hasDelay = [delayValue isKindOfClass:NSNumber.class];
134
- double delay = hasDelay ? [delayValue doubleValue] : 0;
135
- if (!std::isfinite(delay) || delay < 0) delay = 0;
136
- BOOL forever = [repeat isEqual:@"forever"] || behavior != nil || hasDelay;
137
-
138
- if (@available(iOS 18.0, *)) {
139
- NSSymbolEffectOptionsRepeatBehavior *repetition = nil;
140
- if ([behavior isEqual:@"continuous"]) {
141
- repetition = NSSymbolEffectOptionsRepeatBehavior.behaviorContinuous;
142
- } else if (countProvided) {
143
- repetition = hasDelay
144
- ? [NSSymbolEffectOptionsRepeatBehavior behaviorPeriodicWithCount:count delay:delay]
145
- : [NSSymbolEffectOptionsRepeatBehavior behaviorPeriodicWithCount:count];
146
- } else if (forever) {
147
- repetition = hasDelay
148
- ? [NSSymbolEffectOptionsRepeatBehavior behaviorPeriodicWithDelay:delay]
149
- : NSSymbolEffectOptionsRepeatBehavior.behaviorPeriodic;
150
- }
151
- if (repetition != nil) options = [options optionsWithRepeatBehavior:repetition];
152
- } else {
153
- if (countProvided) options = [options optionsWithRepeatCount:count];
154
- else if (forever) options = [options optionsWithRepeating];
155
- }
156
- return options;
157
- }
158
-
159
- NSSymbolContentTransition *TinyuiSFSymbolTransition(NSDictionary *configuration)
160
- {
161
- NSString *type = configuration[@"type"];
162
- if ([type isEqual:@"automatic"]) return NSSymbolAutomaticContentTransition.transition;
163
- if (![type isEqual:@"replace"] && ![type isEqual:@"magicReplace"]) return nil;
164
-
165
- NSSymbolReplaceContentTransition *transition = NSSymbolReplaceContentTransition.transition;
166
- NSString *direction = configuration[@"direction"];
167
- if ([direction isEqual:@"downUp"]) transition = NSSymbolReplaceContentTransition.replaceDownUpTransition;
168
- if ([direction isEqual:@"upUp"]) transition = NSSymbolReplaceContentTransition.replaceUpUpTransition;
169
- if ([direction isEqual:@"offUp"]) transition = NSSymbolReplaceContentTransition.replaceOffUpTransition;
170
- if ([configuration[@"scope"] isEqual:@"byLayer"]) transition = [transition transitionWithByLayer];
171
- if ([configuration[@"scope"] isEqual:@"wholeSymbol"]) transition = [transition transitionWithWholeSymbol];
172
- if (@available(iOS 18.0, *)) {
173
- if ([type isEqual:@"magicReplace"]) {
174
- return [NSSymbolReplaceContentTransition magicTransitionWithFallback:transition];
175
- }
176
- }
177
- return transition;
178
- }
179
-
180
- #endif
@@ -1,8 +0,0 @@
1
- #pragma once
2
-
3
- #import <UIKit/UIKit.h>
4
-
5
- NS_ASSUME_NONNULL_BEGIN
6
- // Shared by Fabric measurement and the mounted view so their metrics match.
7
- UIImage * _Nullable TinyuiSFSymbolImage(NSDictionary *configuration, BOOL includeColors);
8
- NS_ASSUME_NONNULL_END
@@ -1,141 +0,0 @@
1
- #if TINYUI_FEATURE_SF_SYMBOL
2
-
3
- #import "TinyuiSFSymbolImage.h"
4
- #import <React/RCTConvert.h>
5
- #include <cmath>
6
-
7
- static UIImageSymbolWeight symbolWeight(NSString *value)
8
- {
9
- NSDictionary *weights = @{
10
- @"ultraLight": @(UIImageSymbolWeightUltraLight), @"thin": @(UIImageSymbolWeightThin),
11
- @"light": @(UIImageSymbolWeightLight), @"regular": @(UIImageSymbolWeightRegular),
12
- @"medium": @(UIImageSymbolWeightMedium), @"semibold": @(UIImageSymbolWeightSemibold),
13
- @"bold": @(UIImageSymbolWeightBold), @"heavy": @(UIImageSymbolWeightHeavy),
14
- @"black": @(UIImageSymbolWeightBlack),
15
- };
16
- return (UIImageSymbolWeight)[weights[value ?: @""] integerValue];
17
- }
18
-
19
- static UIImageSymbolScale symbolScale(NSString *value)
20
- {
21
- if ([value isEqual:@"small"]) return UIImageSymbolScaleSmall;
22
- if ([value isEqual:@"medium"]) return UIImageSymbolScaleMedium;
23
- if ([value isEqual:@"large"]) return UIImageSymbolScaleLarge;
24
- if ([value isEqual:@"unspecified"]) return UIImageSymbolScaleUnspecified;
25
- return UIImageSymbolScaleDefault;
26
- }
27
-
28
- static UIFontTextStyle textStyle(NSString *value)
29
- {
30
- return @{
31
- @"extraLargeTitle": UIFontTextStyleExtraLargeTitle,
32
- @"extraLargeTitle2": UIFontTextStyleExtraLargeTitle2,
33
- @"largeTitle": UIFontTextStyleLargeTitle, @"title1": UIFontTextStyleTitle1,
34
- @"title2": UIFontTextStyleTitle2, @"title3": UIFontTextStyleTitle3,
35
- @"headline": UIFontTextStyleHeadline, @"subheadline": UIFontTextStyleSubheadline,
36
- @"body": UIFontTextStyleBody, @"callout": UIFontTextStyleCallout,
37
- @"footnote": UIFontTextStyleFootnote, @"caption1": UIFontTextStyleCaption1,
38
- @"caption2": UIFontTextStyleCaption2,
39
- }[value ?: @""];
40
- }
41
-
42
- UIImage *TinyuiSFSymbolImage(NSDictionary *configuration, BOOL includeColors)
43
- {
44
- if (![configuration isKindOfClass:NSDictionary.class]) return nil;
45
- NSString *name = configuration[@"name"];
46
- if (![name isKindOfClass:NSString.class] || name.length == 0) return nil;
47
-
48
- CGFloat size = [configuration[@"size"] doubleValue];
49
- if (!std::isfinite(size) || size <= 0) size = 17;
50
- UIImageSymbolWeight weight = symbolWeight(configuration[@"weight"]);
51
- UIImageSymbolScale scale = symbolScale(configuration[@"scale"]);
52
- UIFontTextStyle style = textStyle(configuration[@"textStyle"]);
53
- if (style != nil) {
54
- // RN supplies the scale explicitly; use unscaled metrics here to avoid
55
- // applying Dynamic Type twice and to keep Yoga and UIKit in agreement.
56
- UITraitCollection *traits = [UITraitCollection
57
- traitCollectionWithPreferredContentSizeCategory:UIContentSizeCategoryLarge];
58
- UIFont *font = [UIFont preferredFontForTextStyle:style compatibleWithTraitCollection:traits];
59
- size = font.pointSize;
60
- if (weight == UIImageSymbolWeightUnspecified) {
61
- NSNumber *fontWeight = font.fontDescriptor.fontAttributes[UIFontDescriptorTraitsAttribute][UIFontWeightTrait];
62
- weight = UIImageSymbolWeightForFontWeight(fontWeight.doubleValue);
63
- }
64
- }
65
- double fontScale = [configuration[@"fontScale"] doubleValue];
66
- if (std::isfinite(fontScale) && fontScale > 0) size *= fontScale;
67
-
68
- UIImageSymbolConfiguration *symbol = [UIImageSymbolConfiguration
69
- configurationWithPointSize:size weight:weight scale:scale];
70
- NSString *family = configuration[@"fontFamily"];
71
- if ([family isKindOfClass:NSString.class] && family.length > 0) {
72
- UIFont *font = [UIFont fontWithName:family size:size];
73
- if (font != nil) {
74
- symbol = [UIImageSymbolConfiguration configurationWithFont:font scale:scale];
75
- if (weight != UIImageSymbolWeightUnspecified) {
76
- symbol = [symbol configurationByApplyingConfiguration:
77
- [UIImageSymbolConfiguration configurationWithWeight:weight]];
78
- }
79
- }
80
- }
81
-
82
- if (includeColors) {
83
- NSString *mode = configuration[@"renderingMode"];
84
- UIColor *color = [RCTConvert UIColor:configuration[@"color"]] ?: UIColor.labelColor;
85
- UIImageSymbolConfiguration *colors = nil;
86
- if ([mode isEqual:@"monochrome"]) {
87
- colors = UIImageSymbolConfiguration.configurationPreferringMonochrome;
88
- } else if ([mode isEqual:@"multicolor"]) {
89
- colors = UIImageSymbolConfiguration.configurationPreferringMulticolor;
90
- } else if ([mode isEqual:@"hierarchical"]) {
91
- colors = [UIImageSymbolConfiguration configurationWithHierarchicalColor:color];
92
- } else if ([mode isEqual:@"palette"]) {
93
- NSMutableArray<UIColor *> *palette = [NSMutableArray array];
94
- id values = configuration[@"paletteColors"];
95
- if ([values isKindOfClass:NSArray.class]) {
96
- for (id value in values) {
97
- UIColor *paletteColor = [RCTConvert UIColor:value];
98
- if (paletteColor != nil && palette.count < 3) [palette addObject:paletteColor];
99
- }
100
- }
101
- if (palette.count == 0) [palette addObject:color];
102
- colors = [UIImageSymbolConfiguration configurationWithPaletteColors:palette];
103
- }
104
- if (colors != nil) symbol = [symbol configurationByApplyingConfiguration:colors];
105
- }
106
-
107
- if (@available(iOS 26.0, *)) {
108
- NSString *variableMode = configuration[@"variableValueMode"];
109
- UIImageSymbolVariableValueMode variable = UIImageSymbolVariableValueModeAutomatic;
110
- if ([variableMode isEqual:@"color"]) variable = UIImageSymbolVariableValueModeColor;
111
- if ([variableMode isEqual:@"draw"]) variable = UIImageSymbolVariableValueModeDraw;
112
- symbol = [symbol configurationByApplyingConfiguration:
113
- [UIImageSymbolConfiguration configurationWithVariableValueMode:variable]];
114
-
115
- NSString *colorMode = configuration[@"colorRenderingMode"];
116
- UIImageSymbolColorRenderingMode rendering = UIImageSymbolColorRenderingModeAutomatic;
117
- if ([colorMode isEqual:@"flat"]) rendering = UIImageSymbolColorRenderingModeFlat;
118
- if ([colorMode isEqual:@"gradient"]) rendering = UIImageSymbolColorRenderingModeGradient;
119
- symbol = [symbol configurationByApplyingConfiguration:
120
- [UIImageSymbolConfiguration configurationWithColorRenderingMode:rendering]];
121
- }
122
-
123
- BOOL asset = [configuration[@"source"] isEqual:@"asset"];
124
- id variableValue = configuration[@"variableValue"];
125
- UIImage *image;
126
- if ([variableValue isKindOfClass:NSNumber.class]) {
127
- double value = [variableValue doubleValue];
128
- value = std::isfinite(value) ? fmin(1, fmax(0, value)) : 0;
129
- image = asset
130
- ? [UIImage imageNamed:name inBundle:NSBundle.mainBundle variableValue:value withConfiguration:symbol]
131
- : [UIImage systemImageNamed:name variableValue:value withConfiguration:symbol];
132
- } else {
133
- image = asset
134
- ? [UIImage imageNamed:name inBundle:NSBundle.mainBundle withConfiguration:symbol]
135
- : [UIImage systemImageNamed:name withConfiguration:symbol];
136
- }
137
- // Symbol content transitions are undefined for ordinary bitmap assets.
138
- return image.isSymbolImage ? image : nil;
139
- }
140
-
141
- #endif