react-native-linear-gradient-fabric 0.1.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.
- package/README.md +132 -0
- package/android/build.gradle +107 -0
- package/android/gradle.properties +4 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/lineargradientfabric/LinearGradientFabricPackage.kt +17 -0
- package/android/src/main/java/com/lineargradientfabric/LinearGradientView.kt +128 -0
- package/android/src/newarch/LinearGradientViewManager.kt +92 -0
- package/android/src/oldarch/LinearGradientViewManager.kt +82 -0
- package/ios/LinearGradientView.h +13 -0
- package/ios/LinearGradientView.m +145 -0
- package/ios/LinearGradientViewComponentView.h +13 -0
- package/ios/LinearGradientViewComponentView.mm +181 -0
- package/ios/LinearGradientViewManager.h +5 -0
- package/ios/LinearGradientViewManager.m +56 -0
- package/lib/commonjs/LinearGradientNativeComponent.js +10 -0
- package/lib/commonjs/LinearGradientNativeComponent.js.map +1 -0
- package/lib/commonjs/index.js +73 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/LinearGradientNativeComponent.js +3 -0
- package/lib/module/LinearGradientNativeComponent.js.map +1 -0
- package/lib/module/index.js +64 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/src/LinearGradientNativeComponent.d.ts +39 -0
- package/lib/typescript/src/LinearGradientNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +54 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +145 -0
- package/react-native-linear-gradient-fabric.podspec +20 -0
- package/src/LinearGradientNativeComponent.ts +43 -0
- package/src/index.tsx +128 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#import "LinearGradientView.h"
|
|
2
|
+
#import <QuartzCore/QuartzCore.h>
|
|
3
|
+
|
|
4
|
+
@implementation LinearGradientView {
|
|
5
|
+
CAGradientLayer *_gradientLayer;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
9
|
+
{
|
|
10
|
+
if (self = [super initWithFrame:frame]) {
|
|
11
|
+
_gradientLayer = [CAGradientLayer layer];
|
|
12
|
+
_gradientLayer.frame = self.bounds;
|
|
13
|
+
[self.layer insertSublayer:_gradientLayer atIndex:0];
|
|
14
|
+
|
|
15
|
+
// Set default values
|
|
16
|
+
_startPoint = CGPointMake(0.5, 0);
|
|
17
|
+
_endPoint = CGPointMake(0.5, 1);
|
|
18
|
+
_useAngle = NO;
|
|
19
|
+
_angle = 0;
|
|
20
|
+
_angleCenter = CGPointMake(0.5, 0.5);
|
|
21
|
+
}
|
|
22
|
+
return self;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
- (void)layoutSubviews
|
|
26
|
+
{
|
|
27
|
+
[super layoutSubviews];
|
|
28
|
+
_gradientLayer.frame = self.bounds;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
- (void)setColors:(NSArray<NSNumber *> *)colors
|
|
32
|
+
{
|
|
33
|
+
_colors = colors;
|
|
34
|
+
[self updateGradient];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
- (void)setLocations:(NSArray<NSNumber *> *)locations
|
|
38
|
+
{
|
|
39
|
+
_locations = locations;
|
|
40
|
+
[self updateGradient];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
- (void)setStartPoint:(CGPoint)startPoint
|
|
44
|
+
{
|
|
45
|
+
_startPoint = startPoint;
|
|
46
|
+
[self updateGradient];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
- (void)setEndPoint:(CGPoint)endPoint
|
|
50
|
+
{
|
|
51
|
+
_endPoint = endPoint;
|
|
52
|
+
[self updateGradient];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
- (void)setUseAngle:(BOOL)useAngle
|
|
56
|
+
{
|
|
57
|
+
_useAngle = useAngle;
|
|
58
|
+
[self updateGradient];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
- (void)setAngle:(CGFloat)angle
|
|
62
|
+
{
|
|
63
|
+
_angle = angle;
|
|
64
|
+
[self updateGradient];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
- (void)setAngleCenter:(CGPoint)angleCenter
|
|
68
|
+
{
|
|
69
|
+
_angleCenter = angleCenter;
|
|
70
|
+
[self updateGradient];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
- (void)updateGradient
|
|
74
|
+
{
|
|
75
|
+
if (!_colors || _colors.count == 0) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Convert colors from ARGB int to CGColor
|
|
80
|
+
NSMutableArray<id> *cgColors = [NSMutableArray arrayWithCapacity:_colors.count];
|
|
81
|
+
for (NSNumber *colorNumber in _colors) {
|
|
82
|
+
int colorInt = [colorNumber intValue];
|
|
83
|
+
UIColor *color = [self colorFromInt:colorInt];
|
|
84
|
+
[cgColors addObject:(id)color.CGColor];
|
|
85
|
+
}
|
|
86
|
+
_gradientLayer.colors = cgColors;
|
|
87
|
+
|
|
88
|
+
// Set locations if provided
|
|
89
|
+
if (_locations && _locations.count > 0) {
|
|
90
|
+
_gradientLayer.locations = _locations;
|
|
91
|
+
} else {
|
|
92
|
+
_gradientLayer.locations = nil;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Calculate start and end points
|
|
96
|
+
CGPoint startPoint, endPoint;
|
|
97
|
+
|
|
98
|
+
if (_useAngle) {
|
|
99
|
+
[self calculatePointsForAngle:_angle
|
|
100
|
+
centerX:_angleCenter.x
|
|
101
|
+
centerY:_angleCenter.y
|
|
102
|
+
startPoint:&startPoint
|
|
103
|
+
endPoint:&endPoint];
|
|
104
|
+
} else {
|
|
105
|
+
startPoint = _startPoint;
|
|
106
|
+
endPoint = _endPoint;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
_gradientLayer.startPoint = startPoint;
|
|
110
|
+
_gradientLayer.endPoint = endPoint;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
- (UIColor *)colorFromInt:(int)colorInt
|
|
114
|
+
{
|
|
115
|
+
// React Native processColor returns ARGB format on iOS
|
|
116
|
+
CGFloat alpha = ((colorInt >> 24) & 0xFF) / 255.0;
|
|
117
|
+
CGFloat red = ((colorInt >> 16) & 0xFF) / 255.0;
|
|
118
|
+
CGFloat green = ((colorInt >> 8) & 0xFF) / 255.0;
|
|
119
|
+
CGFloat blue = (colorInt & 0xFF) / 255.0;
|
|
120
|
+
|
|
121
|
+
return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
- (void)calculatePointsForAngle:(CGFloat)angle
|
|
125
|
+
centerX:(CGFloat)centerX
|
|
126
|
+
centerY:(CGFloat)centerY
|
|
127
|
+
startPoint:(CGPoint *)startPoint
|
|
128
|
+
endPoint:(CGPoint *)endPoint
|
|
129
|
+
{
|
|
130
|
+
// Convert angle from degrees to radians
|
|
131
|
+
// Angle 0 = up, 90 = right, 180 = down, 270 = left
|
|
132
|
+
CGFloat angleRad = (angle - 90) * M_PI / 180.0;
|
|
133
|
+
|
|
134
|
+
// Calculate the gradient direction vector
|
|
135
|
+
CGFloat dx = cos(angleRad);
|
|
136
|
+
CGFloat dy = sin(angleRad);
|
|
137
|
+
|
|
138
|
+
// Normalize to ensure the gradient covers the full view
|
|
139
|
+
CGFloat length = 0.5;
|
|
140
|
+
|
|
141
|
+
*startPoint = CGPointMake(centerX - dx * length, centerY - dy * length);
|
|
142
|
+
*endPoint = CGPointMake(centerX + dx * length, centerY + dy * length);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
|
+
#import <React/RCTViewComponentView.h>
|
|
3
|
+
#import <UIKit/UIKit.h>
|
|
4
|
+
|
|
5
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
6
|
+
|
|
7
|
+
@interface LinearGradientViewComponentView : RCTViewComponentView
|
|
8
|
+
|
|
9
|
+
@end
|
|
10
|
+
|
|
11
|
+
NS_ASSUME_NONNULL_END
|
|
12
|
+
|
|
13
|
+
#endif /* RCT_NEW_ARCH_ENABLED */
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
|
+
#import "LinearGradientViewComponentView.h"
|
|
3
|
+
|
|
4
|
+
#import <React/RCTConversions.h>
|
|
5
|
+
#import <React/RCTFabricComponentsPlugins.h>
|
|
6
|
+
#import <react/renderer/components/RNLinearGradientFabricSpec/ComponentDescriptors.h>
|
|
7
|
+
#import <react/renderer/components/RNLinearGradientFabricSpec/EventEmitters.h>
|
|
8
|
+
#import <react/renderer/components/RNLinearGradientFabricSpec/Props.h>
|
|
9
|
+
#import <react/renderer/components/RNLinearGradientFabricSpec/RCTComponentViewHelpers.h>
|
|
10
|
+
|
|
11
|
+
using namespace facebook::react;
|
|
12
|
+
|
|
13
|
+
@interface LinearGradientViewComponentView () <RCTLinearGradientViewViewProtocol>
|
|
14
|
+
@end
|
|
15
|
+
|
|
16
|
+
@implementation LinearGradientViewComponentView {
|
|
17
|
+
CAGradientLayer *_gradientLayer;
|
|
18
|
+
std::vector<int> _colors;
|
|
19
|
+
std::vector<Float> _locations;
|
|
20
|
+
Float _startPointX;
|
|
21
|
+
Float _startPointY;
|
|
22
|
+
Float _endPointX;
|
|
23
|
+
Float _endPointY;
|
|
24
|
+
BOOL _useAngle;
|
|
25
|
+
Float _angle;
|
|
26
|
+
Float _angleCenterX;
|
|
27
|
+
Float _angleCenterY;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
31
|
+
{
|
|
32
|
+
return concreteComponentDescriptorProvider<LinearGradientViewComponentDescriptor>();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
36
|
+
{
|
|
37
|
+
if (self = [super initWithFrame:frame]) {
|
|
38
|
+
static const auto defaultProps = std::make_shared<const LinearGradientViewProps>();
|
|
39
|
+
_props = defaultProps;
|
|
40
|
+
|
|
41
|
+
_gradientLayer = [CAGradientLayer layer];
|
|
42
|
+
_gradientLayer.frame = self.bounds;
|
|
43
|
+
[self.layer insertSublayer:_gradientLayer atIndex:0];
|
|
44
|
+
|
|
45
|
+
// Set default values
|
|
46
|
+
_startPointX = 0.5;
|
|
47
|
+
_startPointY = 0;
|
|
48
|
+
_endPointX = 0.5;
|
|
49
|
+
_endPointY = 1;
|
|
50
|
+
_useAngle = NO;
|
|
51
|
+
_angle = 0;
|
|
52
|
+
_angleCenterX = 0.5;
|
|
53
|
+
_angleCenterY = 0.5;
|
|
54
|
+
}
|
|
55
|
+
return self;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
- (void)layoutSubviews
|
|
59
|
+
{
|
|
60
|
+
[super layoutSubviews];
|
|
61
|
+
_gradientLayer.frame = self.bounds;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
|
65
|
+
{
|
|
66
|
+
const auto &newProps = *std::static_pointer_cast<const LinearGradientViewProps>(props);
|
|
67
|
+
|
|
68
|
+
// Update colors
|
|
69
|
+
_colors.clear();
|
|
70
|
+
for (const auto &color : newProps.colors) {
|
|
71
|
+
_colors.push_back(color);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Update locations
|
|
75
|
+
_locations.clear();
|
|
76
|
+
for (const auto &location : newProps.locations) {
|
|
77
|
+
_locations.push_back(location);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Update start point
|
|
81
|
+
_startPointX = newProps.startPoint.x;
|
|
82
|
+
_startPointY = newProps.startPoint.y;
|
|
83
|
+
|
|
84
|
+
// Update end point
|
|
85
|
+
_endPointX = newProps.endPoint.x;
|
|
86
|
+
_endPointY = newProps.endPoint.y;
|
|
87
|
+
|
|
88
|
+
// Update angle settings
|
|
89
|
+
_useAngle = newProps.useAngle;
|
|
90
|
+
_angle = newProps.angle;
|
|
91
|
+
_angleCenterX = newProps.angleCenter.x;
|
|
92
|
+
_angleCenterY = newProps.angleCenter.y;
|
|
93
|
+
|
|
94
|
+
[self updateGradient];
|
|
95
|
+
|
|
96
|
+
[super updateProps:props oldProps:oldProps];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
- (void)updateGradient
|
|
100
|
+
{
|
|
101
|
+
if (_colors.empty()) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Convert colors from ARGB int to CGColor
|
|
106
|
+
NSMutableArray<id> *cgColors = [NSMutableArray arrayWithCapacity:_colors.size()];
|
|
107
|
+
for (int colorInt : _colors) {
|
|
108
|
+
UIColor *color = [self colorFromInt:colorInt];
|
|
109
|
+
[cgColors addObject:(id)color.CGColor];
|
|
110
|
+
}
|
|
111
|
+
_gradientLayer.colors = cgColors;
|
|
112
|
+
|
|
113
|
+
// Set locations if provided
|
|
114
|
+
if (!_locations.empty()) {
|
|
115
|
+
NSMutableArray<NSNumber *> *locationsArray = [NSMutableArray arrayWithCapacity:_locations.size()];
|
|
116
|
+
for (Float location : _locations) {
|
|
117
|
+
[locationsArray addObject:@(location)];
|
|
118
|
+
}
|
|
119
|
+
_gradientLayer.locations = locationsArray;
|
|
120
|
+
} else {
|
|
121
|
+
_gradientLayer.locations = nil;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Calculate start and end points
|
|
125
|
+
CGPoint startPoint, endPoint;
|
|
126
|
+
|
|
127
|
+
if (_useAngle) {
|
|
128
|
+
[self calculatePointsForAngle:_angle
|
|
129
|
+
centerX:_angleCenterX
|
|
130
|
+
centerY:_angleCenterY
|
|
131
|
+
startPoint:&startPoint
|
|
132
|
+
endPoint:&endPoint];
|
|
133
|
+
} else {
|
|
134
|
+
startPoint = CGPointMake(_startPointX, _startPointY);
|
|
135
|
+
endPoint = CGPointMake(_endPointX, _endPointY);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
_gradientLayer.startPoint = startPoint;
|
|
139
|
+
_gradientLayer.endPoint = endPoint;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
- (UIColor *)colorFromInt:(int)colorInt
|
|
143
|
+
{
|
|
144
|
+
// React Native processColor returns ARGB format on iOS
|
|
145
|
+
CGFloat alpha = ((colorInt >> 24) & 0xFF) / 255.0;
|
|
146
|
+
CGFloat red = ((colorInt >> 16) & 0xFF) / 255.0;
|
|
147
|
+
CGFloat green = ((colorInt >> 8) & 0xFF) / 255.0;
|
|
148
|
+
CGFloat blue = (colorInt & 0xFF) / 255.0;
|
|
149
|
+
|
|
150
|
+
return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
- (void)calculatePointsForAngle:(Float)angle
|
|
154
|
+
centerX:(Float)centerX
|
|
155
|
+
centerY:(Float)centerY
|
|
156
|
+
startPoint:(CGPoint *)startPoint
|
|
157
|
+
endPoint:(CGPoint *)endPoint
|
|
158
|
+
{
|
|
159
|
+
// Convert angle from degrees to radians
|
|
160
|
+
// Angle 0 = up, 90 = right, 180 = down, 270 = left
|
|
161
|
+
CGFloat angleRad = (angle - 90) * M_PI / 180.0;
|
|
162
|
+
|
|
163
|
+
// Calculate the gradient direction vector
|
|
164
|
+
CGFloat dx = cos(angleRad);
|
|
165
|
+
CGFloat dy = sin(angleRad);
|
|
166
|
+
|
|
167
|
+
// Normalize to ensure the gradient covers the full view
|
|
168
|
+
CGFloat length = 0.5;
|
|
169
|
+
|
|
170
|
+
*startPoint = CGPointMake(centerX - dx * length, centerY - dy * length);
|
|
171
|
+
*endPoint = CGPointMake(centerX + dx * length, centerY + dy * length);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
@end
|
|
175
|
+
|
|
176
|
+
Class<RCTComponentViewProtocol> LinearGradientViewCls(void)
|
|
177
|
+
{
|
|
178
|
+
return LinearGradientViewComponentView.class;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
#endif /* RCT_NEW_ARCH_ENABLED */
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#import "LinearGradientViewManager.h"
|
|
2
|
+
#import "LinearGradientView.h"
|
|
3
|
+
#import <React/RCTBridge.h>
|
|
4
|
+
#import <React/RCTConvert.h>
|
|
5
|
+
|
|
6
|
+
@implementation LinearGradientViewManager
|
|
7
|
+
|
|
8
|
+
RCT_EXPORT_MODULE(LinearGradientView)
|
|
9
|
+
|
|
10
|
+
- (UIView *)view
|
|
11
|
+
{
|
|
12
|
+
return [[LinearGradientView alloc] init];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
RCT_EXPORT_VIEW_PROPERTY(colors, NSArray)
|
|
16
|
+
RCT_EXPORT_VIEW_PROPERTY(locations, NSArray)
|
|
17
|
+
RCT_CUSTOM_VIEW_PROPERTY(startPoint, NSDictionary, LinearGradientView)
|
|
18
|
+
{
|
|
19
|
+
if (json) {
|
|
20
|
+
NSDictionary *dict = [RCTConvert NSDictionary:json];
|
|
21
|
+
CGFloat x = [[dict objectForKey:@"x"] floatValue];
|
|
22
|
+
CGFloat y = [[dict objectForKey:@"y"] floatValue];
|
|
23
|
+
view.startPoint = CGPointMake(x, y);
|
|
24
|
+
} else {
|
|
25
|
+
view.startPoint = CGPointMake(0.5, 0);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
RCT_CUSTOM_VIEW_PROPERTY(endPoint, NSDictionary, LinearGradientView)
|
|
30
|
+
{
|
|
31
|
+
if (json) {
|
|
32
|
+
NSDictionary *dict = [RCTConvert NSDictionary:json];
|
|
33
|
+
CGFloat x = [[dict objectForKey:@"x"] floatValue];
|
|
34
|
+
CGFloat y = [[dict objectForKey:@"y"] floatValue];
|
|
35
|
+
view.endPoint = CGPointMake(x, y);
|
|
36
|
+
} else {
|
|
37
|
+
view.endPoint = CGPointMake(0.5, 1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
RCT_EXPORT_VIEW_PROPERTY(useAngle, BOOL)
|
|
42
|
+
RCT_EXPORT_VIEW_PROPERTY(angle, CGFloat)
|
|
43
|
+
|
|
44
|
+
RCT_CUSTOM_VIEW_PROPERTY(angleCenter, NSDictionary, LinearGradientView)
|
|
45
|
+
{
|
|
46
|
+
if (json) {
|
|
47
|
+
NSDictionary *dict = [RCTConvert NSDictionary:json];
|
|
48
|
+
CGFloat x = [[dict objectForKey:@"x"] floatValue];
|
|
49
|
+
CGFloat y = [[dict objectForKey:@"y"] floatValue];
|
|
50
|
+
view.angleCenter = CGPointMake(x, y);
|
|
51
|
+
} else {
|
|
52
|
+
view.angleCenter = CGPointMake(0.5, 0.5);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _codegenNativeComponent = _interopRequireDefault(require("react-native/Libraries/Utilities/codegenNativeComponent"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
var _default = exports.default = (0, _codegenNativeComponent.default)('LinearGradientView');
|
|
10
|
+
//# sourceMappingURL=LinearGradientNativeComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_codegenNativeComponent","_interopRequireDefault","require","e","__esModule","default","_default","exports","codegenNativeComponent"],"sourceRoot":"../../src","sources":["LinearGradientNativeComponent.ts"],"mappings":";;;;;;AACA,IAAAA,uBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA6F,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAuC9E,IAAAG,+BAAsB,EACnC,oBACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.LinearGradient = LinearGradient;
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _reactNative = require("react-native");
|
|
10
|
+
var _LinearGradientNativeComponent = _interopRequireDefault(require("./LinearGradientNativeComponent"));
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
13
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
14
|
+
const DEFAULT_START = {
|
|
15
|
+
x: 0.5,
|
|
16
|
+
y: 0
|
|
17
|
+
};
|
|
18
|
+
const DEFAULT_END = {
|
|
19
|
+
x: 0.5,
|
|
20
|
+
y: 1
|
|
21
|
+
};
|
|
22
|
+
const DEFAULT_ANGLE_CENTER = {
|
|
23
|
+
x: 0.5,
|
|
24
|
+
y: 0.5
|
|
25
|
+
};
|
|
26
|
+
function processColors(colors) {
|
|
27
|
+
return colors.map(color => {
|
|
28
|
+
const processed = (0, _reactNative.processColor)(color);
|
|
29
|
+
if (processed === null || processed === undefined) {
|
|
30
|
+
throw new Error(`Invalid color value: ${String(color)}`);
|
|
31
|
+
}
|
|
32
|
+
return typeof processed === 'number' ? processed : 0;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function validateLocations(locations, colorsLength) {
|
|
36
|
+
if (!locations) {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
if (locations.length !== colorsLength) {
|
|
40
|
+
console.warn(`LinearGradient: locations array length (${locations.length}) does not match colors array length (${colorsLength})`);
|
|
41
|
+
}
|
|
42
|
+
return locations;
|
|
43
|
+
}
|
|
44
|
+
function LinearGradient({
|
|
45
|
+
colors,
|
|
46
|
+
locations,
|
|
47
|
+
start = DEFAULT_START,
|
|
48
|
+
end = DEFAULT_END,
|
|
49
|
+
useAngle = false,
|
|
50
|
+
angle = 0,
|
|
51
|
+
angleCenter = DEFAULT_ANGLE_CENTER,
|
|
52
|
+
style,
|
|
53
|
+
children,
|
|
54
|
+
...rest
|
|
55
|
+
}) {
|
|
56
|
+
if (colors.length < 2) {
|
|
57
|
+
throw new Error('LinearGradient requires at least 2 colors');
|
|
58
|
+
}
|
|
59
|
+
const processedColors = React.useMemo(() => processColors(colors), [colors]);
|
|
60
|
+
const validatedLocations = React.useMemo(() => validateLocations(locations, colors.length), [locations, colors.length]);
|
|
61
|
+
return /*#__PURE__*/React.createElement(_LinearGradientNativeComponent.default, _extends({}, rest, {
|
|
62
|
+
style: _reactNative.StyleSheet.flatten(style),
|
|
63
|
+
colors: processedColors,
|
|
64
|
+
locations: validatedLocations,
|
|
65
|
+
startPoint: start,
|
|
66
|
+
endPoint: end,
|
|
67
|
+
useAngle: useAngle,
|
|
68
|
+
angle: angle,
|
|
69
|
+
angleCenter: angleCenter
|
|
70
|
+
}), children);
|
|
71
|
+
}
|
|
72
|
+
var _default = exports.default = LinearGradient;
|
|
73
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","_interopRequireWildcard","require","_reactNative","_LinearGradientNativeComponent","_interopRequireDefault","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_extends","assign","bind","arguments","length","apply","DEFAULT_START","x","y","DEFAULT_END","DEFAULT_ANGLE_CENTER","processColors","colors","map","color","processed","processColor","undefined","Error","String","validateLocations","locations","colorsLength","console","warn","LinearGradient","start","end","useAngle","angle","angleCenter","style","children","rest","processedColors","useMemo","validatedLocations","createElement","StyleSheet","flatten","startPoint","endPoint","_default","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["codegenNativeComponent"],"sourceRoot":"../../src","sources":["LinearGradientNativeComponent.ts"],"mappings":"AACA,OAAOA,sBAAsB,MAAM,yDAAyD;AAuC5F,eAAeA,sBAAsB,CACnC,oBACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { processColor, StyleSheet } from 'react-native';
|
|
4
|
+
import LinearGradientNativeComponent from './LinearGradientNativeComponent';
|
|
5
|
+
const DEFAULT_START = {
|
|
6
|
+
x: 0.5,
|
|
7
|
+
y: 0
|
|
8
|
+
};
|
|
9
|
+
const DEFAULT_END = {
|
|
10
|
+
x: 0.5,
|
|
11
|
+
y: 1
|
|
12
|
+
};
|
|
13
|
+
const DEFAULT_ANGLE_CENTER = {
|
|
14
|
+
x: 0.5,
|
|
15
|
+
y: 0.5
|
|
16
|
+
};
|
|
17
|
+
function processColors(colors) {
|
|
18
|
+
return colors.map(color => {
|
|
19
|
+
const processed = processColor(color);
|
|
20
|
+
if (processed === null || processed === undefined) {
|
|
21
|
+
throw new Error(`Invalid color value: ${String(color)}`);
|
|
22
|
+
}
|
|
23
|
+
return typeof processed === 'number' ? processed : 0;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function validateLocations(locations, colorsLength) {
|
|
27
|
+
if (!locations) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
if (locations.length !== colorsLength) {
|
|
31
|
+
console.warn(`LinearGradient: locations array length (${locations.length}) does not match colors array length (${colorsLength})`);
|
|
32
|
+
}
|
|
33
|
+
return locations;
|
|
34
|
+
}
|
|
35
|
+
export function LinearGradient({
|
|
36
|
+
colors,
|
|
37
|
+
locations,
|
|
38
|
+
start = DEFAULT_START,
|
|
39
|
+
end = DEFAULT_END,
|
|
40
|
+
useAngle = false,
|
|
41
|
+
angle = 0,
|
|
42
|
+
angleCenter = DEFAULT_ANGLE_CENTER,
|
|
43
|
+
style,
|
|
44
|
+
children,
|
|
45
|
+
...rest
|
|
46
|
+
}) {
|
|
47
|
+
if (colors.length < 2) {
|
|
48
|
+
throw new Error('LinearGradient requires at least 2 colors');
|
|
49
|
+
}
|
|
50
|
+
const processedColors = React.useMemo(() => processColors(colors), [colors]);
|
|
51
|
+
const validatedLocations = React.useMemo(() => validateLocations(locations, colors.length), [locations, colors.length]);
|
|
52
|
+
return /*#__PURE__*/React.createElement(LinearGradientNativeComponent, _extends({}, rest, {
|
|
53
|
+
style: StyleSheet.flatten(style),
|
|
54
|
+
colors: processedColors,
|
|
55
|
+
locations: validatedLocations,
|
|
56
|
+
startPoint: start,
|
|
57
|
+
endPoint: end,
|
|
58
|
+
useAngle: useAngle,
|
|
59
|
+
angle: angle,
|
|
60
|
+
angleCenter: angleCenter
|
|
61
|
+
}), children);
|
|
62
|
+
}
|
|
63
|
+
export default LinearGradient;
|
|
64
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","processColor","StyleSheet","LinearGradientNativeComponent","DEFAULT_START","x","y","DEFAULT_END","DEFAULT_ANGLE_CENTER","processColors","colors","map","color","processed","undefined","Error","String","validateLocations","locations","colorsLength","length","console","warn","LinearGradient","start","end","useAngle","angle","angleCenter","style","children","rest","processedColors","useMemo","validatedLocations","createElement","_extends","flatten","startPoint","endPoint"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,SAASC,YAAY,EAAEC,UAAU,QAAQ,cAAc;AAEvD,OAAOC,6BAA6B,MAAM,iCAAiC;AAqD3E,MAAMC,aAAoB,GAAG;EAAEC,CAAC,EAAE,GAAG;EAAEC,CAAC,EAAE;AAAE,CAAC;AAC7C,MAAMC,WAAkB,GAAG;EAAEF,CAAC,EAAE,GAAG;EAAEC,CAAC,EAAE;AAAE,CAAC;AAC3C,MAAME,oBAA2B,GAAG;EAAEH,CAAC,EAAE,GAAG;EAAEC,CAAC,EAAE;AAAI,CAAC;AAEtD,SAASG,aAAaA,CAACC,MAAoB,EAAY;EACrD,OAAOA,MAAM,CAACC,GAAG,CAAEC,KAAK,IAAK;IAC3B,MAAMC,SAAS,GAAGZ,YAAY,CAACW,KAAK,CAAC;IACrC,IAAIC,SAAS,KAAK,IAAI,IAAIA,SAAS,KAAKC,SAAS,EAAE;MACjD,MAAM,IAAIC,KAAK,CAAC,wBAAwBC,MAAM,CAACJ,KAAK,CAAC,EAAE,CAAC;IAC1D;IACA,OAAO,OAAOC,SAAS,KAAK,QAAQ,GAAGA,SAAS,GAAG,CAAC;EACtD,CAAC,CAAC;AACJ;AAEA,SAASI,iBAAiBA,CACxBC,SAA+B,EAC/BC,YAAoB,EACE;EACtB,IAAI,CAACD,SAAS,EAAE;IACd,OAAOJ,SAAS;EAClB;EAEA,IAAII,SAAS,CAACE,MAAM,KAAKD,YAAY,EAAE;IACrCE,OAAO,CAACC,IAAI,CACV,2CAA2CJ,SAAS,CAACE,MAAM,yCAAyCD,YAAY,GAClH,CAAC;EACH;EAEA,OAAOD,SAAS;AAClB;AAEA,OAAO,SAASK,cAAcA,CAAC;EAC7Bb,MAAM;EACNQ,SAAS;EACTM,KAAK,GAAGpB,aAAa;EACrBqB,GAAG,GAAGlB,WAAW;EACjBmB,QAAQ,GAAG,KAAK;EAChBC,KAAK,GAAG,CAAC;EACTC,WAAW,GAAGpB,oBAAoB;EAClCqB,KAAK;EACLC,QAAQ;EACR,GAAGC;AACgB,CAAC,EAAsB;EAC1C,IAAIrB,MAAM,CAACU,MAAM,GAAG,CAAC,EAAE;IACrB,MAAM,IAAIL,KAAK,CAAC,2CAA2C,CAAC;EAC9D;EAEA,MAAMiB,eAAe,GAAGhC,KAAK,CAACiC,OAAO,CAAC,MAAMxB,aAAa,CAACC,MAAM,CAAC,EAAE,CAACA,MAAM,CAAC,CAAC;EAC5E,MAAMwB,kBAAkB,GAAGlC,KAAK,CAACiC,OAAO,CACtC,MAAMhB,iBAAiB,CAACC,SAAS,EAAER,MAAM,CAACU,MAAM,CAAC,EACjD,CAACF,SAAS,EAAER,MAAM,CAACU,MAAM,CAC3B,CAAC;EAED,oBACEpB,KAAA,CAAAmC,aAAA,CAAChC,6BAA6B,EAAAiC,QAAA,KACxBL,IAAI;IACRF,KAAK,EAAE3B,UAAU,CAACmC,OAAO,CAACR,KAAK,CAAE;IACjCnB,MAAM,EAAEsB,eAAgB;IACxBd,SAAS,EAAEgB,kBAAmB;IAC9BI,UAAU,EAAEd,KAAM;IAClBe,QAAQ,EAAEd,GAAI;IACdC,QAAQ,EAAEA,QAAS;IACnBC,KAAK,EAAEA,KAAM;IACbC,WAAW,EAAEA;EAAY,IAExBE,QAC4B,CAAC;AAEpC;AAEA,eAAeP,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ViewProps } from 'react-native';
|
|
2
|
+
import type { Float, Int32 } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
export interface NativeLinearGradientPoint {
|
|
4
|
+
x: Float;
|
|
5
|
+
y: Float;
|
|
6
|
+
}
|
|
7
|
+
export interface NativeLinearGradientProps extends ViewProps {
|
|
8
|
+
/**
|
|
9
|
+
* An array of colors in integer format (processed by processColor)
|
|
10
|
+
*/
|
|
11
|
+
colors: ReadonlyArray<Int32>;
|
|
12
|
+
/**
|
|
13
|
+
* An array of locations for each color stop, values should be between 0 and 1
|
|
14
|
+
*/
|
|
15
|
+
locations?: ReadonlyArray<Float>;
|
|
16
|
+
/**
|
|
17
|
+
* The start point of the gradient (x: 0 = left, 1 = right; y: 0 = top, 1 = bottom)
|
|
18
|
+
*/
|
|
19
|
+
startPoint?: NativeLinearGradientPoint;
|
|
20
|
+
/**
|
|
21
|
+
* The end point of the gradient (x: 0 = left, 1 = right; y: 0 = top, 1 = bottom)
|
|
22
|
+
*/
|
|
23
|
+
endPoint?: NativeLinearGradientPoint;
|
|
24
|
+
/**
|
|
25
|
+
* If true, use angle instead of start/end points
|
|
26
|
+
*/
|
|
27
|
+
useAngle?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Angle of the gradient in degrees (0 = up, 90 = right, 180 = down, 270 = left)
|
|
30
|
+
*/
|
|
31
|
+
angle?: Float;
|
|
32
|
+
/**
|
|
33
|
+
* The center point for the angle rotation
|
|
34
|
+
*/
|
|
35
|
+
angleCenter?: NativeLinearGradientPoint;
|
|
36
|
+
}
|
|
37
|
+
declare const _default: import("react-native/Libraries/Utilities/codegenNativeComponent").NativeComponentType<NativeLinearGradientProps>;
|
|
38
|
+
export default _default;
|
|
39
|
+
//# sourceMappingURL=LinearGradientNativeComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinearGradientNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/LinearGradientNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAC;AAE9E,MAAM,WAAW,yBAAyB;IACxC,CAAC,EAAE,KAAK,CAAC;IACT,CAAC,EAAE,KAAK,CAAC;CACV;AAED,MAAM,WAAW,yBAA0B,SAAQ,SAAS;IAC1D;;OAEG;IACH,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;IAC7B;;OAEG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;IACjC;;OAEG;IACH,UAAU,CAAC,EAAE,yBAAyB,CAAC;IACvC;;OAEG;IACH,QAAQ,CAAC,EAAE,yBAAyB,CAAC;IACrC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;OAEG;IACH,WAAW,CAAC,EAAE,yBAAyB,CAAC;CACzC;;AAED,wBAEE"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ColorValue, StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
export interface Point {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
}
|
|
7
|
+
export interface LinearGradientProps {
|
|
8
|
+
/**
|
|
9
|
+
* An array of at least 2 colors that represent gradient colors
|
|
10
|
+
*/
|
|
11
|
+
colors: ColorValue[];
|
|
12
|
+
/**
|
|
13
|
+
* An array of locations for each color stop, values should be between 0 and 1
|
|
14
|
+
* The array length must match the colors array length
|
|
15
|
+
*/
|
|
16
|
+
locations?: number[];
|
|
17
|
+
/**
|
|
18
|
+
* The start point of the gradient
|
|
19
|
+
* Default: { x: 0.5, y: 0 } (top center)
|
|
20
|
+
*/
|
|
21
|
+
start?: Point;
|
|
22
|
+
/**
|
|
23
|
+
* The end point of the gradient
|
|
24
|
+
* Default: { x: 0.5, y: 1 } (bottom center)
|
|
25
|
+
*/
|
|
26
|
+
end?: Point;
|
|
27
|
+
/**
|
|
28
|
+
* If true, use angle instead of start/end points
|
|
29
|
+
* Default: false
|
|
30
|
+
*/
|
|
31
|
+
useAngle?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Angle of the gradient in degrees (0 = up, 90 = right, 180 = down, 270 = left)
|
|
34
|
+
* Only used when useAngle is true
|
|
35
|
+
* Default: 0
|
|
36
|
+
*/
|
|
37
|
+
angle?: number;
|
|
38
|
+
/**
|
|
39
|
+
* The center point for the angle rotation
|
|
40
|
+
* Default: { x: 0.5, y: 0.5 }
|
|
41
|
+
*/
|
|
42
|
+
angleCenter?: Point;
|
|
43
|
+
/**
|
|
44
|
+
* Style for the gradient view
|
|
45
|
+
*/
|
|
46
|
+
style?: StyleProp<ViewStyle>;
|
|
47
|
+
/**
|
|
48
|
+
* Children elements to render on top of the gradient
|
|
49
|
+
*/
|
|
50
|
+
children?: React.ReactNode;
|
|
51
|
+
}
|
|
52
|
+
export declare function LinearGradient({ colors, locations, start, end, useAngle, angle, angleCenter, style, children, ...rest }: LinearGradientProps): React.ReactElement;
|
|
53
|
+
export default LinearGradient;
|
|
54
|
+
//# sourceMappingURL=index.d.ts.map
|