react-native-gleam 1.0.0-beta.1 → 1.0.0-beta.2
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/ios/GleamView.mm +21 -12
- package/package.json +1 -1
package/ios/GleamView.mm
CHANGED
|
@@ -55,7 +55,6 @@ static void _unregisterView(GleamView *view) {
|
|
|
55
55
|
#pragma mark - GleamView
|
|
56
56
|
|
|
57
57
|
@implementation GleamView {
|
|
58
|
-
UIView *_contentView;
|
|
59
58
|
CAGradientLayer *_shimmerLayer;
|
|
60
59
|
BOOL _loading;
|
|
61
60
|
BOOL _wasLoading;
|
|
@@ -111,10 +110,6 @@ static void _unregisterView(GleamView *view) {
|
|
|
111
110
|
_shimmerOpacity = 1.0;
|
|
112
111
|
_contentAlpha = 0.0;
|
|
113
112
|
|
|
114
|
-
_contentView = [[UIView alloc] init];
|
|
115
|
-
_contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
|
116
|
-
_contentView.alpha = 0.0;
|
|
117
|
-
|
|
118
113
|
_shimmerLayer = [CAGradientLayer layer];
|
|
119
114
|
// Disable implicit animations on the gradient layer
|
|
120
115
|
_shimmerLayer.actions = @{
|
|
@@ -126,11 +121,18 @@ static void _unregisterView(GleamView *view) {
|
|
|
126
121
|
@"transform": [NSNull null],
|
|
127
122
|
};
|
|
128
123
|
|
|
129
|
-
self.contentView = _contentView;
|
|
130
124
|
}
|
|
131
125
|
return self;
|
|
132
126
|
}
|
|
133
127
|
|
|
128
|
+
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index
|
|
129
|
+
{
|
|
130
|
+
[super mountChildComponentView:childComponentView index:index];
|
|
131
|
+
if (_loading) {
|
|
132
|
+
childComponentView.alpha = 0.0;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
134
136
|
- (void)layoutSubviews
|
|
135
137
|
{
|
|
136
138
|
[super layoutSubviews];
|
|
@@ -257,7 +259,7 @@ static void _unregisterView(GleamView *view) {
|
|
|
257
259
|
switch (_transitionTypeValue) {
|
|
258
260
|
case 1: { // Shrink — scale down with mask clipping
|
|
259
261
|
_contentAlpha = eased;
|
|
260
|
-
|
|
262
|
+
[self _setChildrenAlpha:_contentAlpha];
|
|
261
263
|
CGFloat shrinkOpacity = 1.0 - fmin(eased * 2.5, 1.0);
|
|
262
264
|
_shimmerLayer.opacity = shrinkOpacity;
|
|
263
265
|
CGFloat scale = 1.0 - eased * 0.5;
|
|
@@ -278,7 +280,7 @@ static void _unregisterView(GleamView *view) {
|
|
|
278
280
|
}
|
|
279
281
|
case 2: { // Collapse — vertically then horizontally via clip rect
|
|
280
282
|
_contentAlpha = eased;
|
|
281
|
-
|
|
283
|
+
[self _setChildrenAlpha:_contentAlpha];
|
|
282
284
|
CGFloat collapseOpacity = 1.0 - fmin(eased * 2.5, 1.0);
|
|
283
285
|
_shimmerLayer.opacity = collapseOpacity;
|
|
284
286
|
CGRect bounds = self.bounds;
|
|
@@ -301,7 +303,7 @@ static void _unregisterView(GleamView *view) {
|
|
|
301
303
|
}
|
|
302
304
|
default: // Fade
|
|
303
305
|
_contentAlpha = eased;
|
|
304
|
-
|
|
306
|
+
[self _setChildrenAlpha:_contentAlpha];
|
|
305
307
|
_shimmerOpacity = 1.0 - eased;
|
|
306
308
|
_shimmerLayer.opacity = _shimmerOpacity;
|
|
307
309
|
break;
|
|
@@ -317,6 +319,13 @@ static void _unregisterView(GleamView *view) {
|
|
|
317
319
|
}
|
|
318
320
|
}
|
|
319
321
|
|
|
322
|
+
- (void)_setChildrenAlpha:(CGFloat)alpha
|
|
323
|
+
{
|
|
324
|
+
for (UIView *subview in self.subviews) {
|
|
325
|
+
subview.alpha = alpha;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
320
329
|
- (void)_updateGradientPosition
|
|
321
330
|
{
|
|
322
331
|
CGFloat progress = [self _computeProgress];
|
|
@@ -378,7 +387,7 @@ static void _unregisterView(GleamView *view) {
|
|
|
378
387
|
_isTransitioning = NO;
|
|
379
388
|
_contentAlpha = 0.0;
|
|
380
389
|
_shimmerOpacity = 1.0;
|
|
381
|
-
|
|
390
|
+
[self _setChildrenAlpha:0.0];
|
|
382
391
|
_shimmerLayer.opacity = 1.0;
|
|
383
392
|
_shimmerLayer.frame = self.bounds;
|
|
384
393
|
if (_shimmerLayer.superlayer != self.layer) {
|
|
@@ -396,7 +405,7 @@ static void _unregisterView(GleamView *view) {
|
|
|
396
405
|
// Clock stays registered to drive the transition
|
|
397
406
|
} else {
|
|
398
407
|
[self _unregisterClock];
|
|
399
|
-
|
|
408
|
+
[self _setChildrenAlpha:1.0];
|
|
400
409
|
_shimmerLayer.opacity = 0.0;
|
|
401
410
|
[_shimmerLayer removeFromSuperlayer];
|
|
402
411
|
[self _emitTransitionEnd:YES];
|
|
@@ -408,7 +417,7 @@ static void _unregisterView(GleamView *view) {
|
|
|
408
417
|
{
|
|
409
418
|
_isTransitioning = NO;
|
|
410
419
|
[self _unregisterClock];
|
|
411
|
-
|
|
420
|
+
[self _setChildrenAlpha:1.0];
|
|
412
421
|
_shimmerLayer.opacity = 0.0;
|
|
413
422
|
_shimmerLayer.transform = CATransform3DIdentity;
|
|
414
423
|
_shimmerLayer.mask = nil;
|
package/package.json
CHANGED