react-native-morph-card 0.2.7 → 0.3.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 (34) hide show
  1. package/README.md +40 -31
  2. package/android/src/main/java/com/melivalesca/morphcard/MorphCardSourceView.kt +27 -72
  3. package/android/src/main/java/com/melivalesca/morphcard/MorphCardTargetManager.kt +2 -2
  4. package/android/src/main/java/com/melivalesca/morphcard/MorphCardTargetView.kt +34 -39
  5. package/android/src/main/java/com/melivalesca/morphcard/MorphCardUtils.kt +43 -0
  6. package/ios/Fabric/RNCMorphCardSourceComponentView.h +0 -3
  7. package/ios/Fabric/RNCMorphCardSourceComponentView.mm +110 -80
  8. package/ios/Fabric/RNCMorphCardTargetComponentView.h +1 -0
  9. package/ios/Fabric/RNCMorphCardTargetComponentView.mm +26 -14
  10. package/ios/RNCMorphCardSource.m +1 -1
  11. package/lib/commonjs/MorphCardSource.js +25 -2
  12. package/lib/commonjs/MorphCardSource.js.map +1 -1
  13. package/lib/commonjs/MorphCardTarget.js +31 -7
  14. package/lib/commonjs/MorphCardTarget.js.map +1 -1
  15. package/lib/commonjs/MorphChildrenRegistry.js +34 -0
  16. package/lib/commonjs/MorphChildrenRegistry.js.map +1 -0
  17. package/lib/module/MorphCardSource.js +25 -2
  18. package/lib/module/MorphCardSource.js.map +1 -1
  19. package/lib/module/MorphCardTarget.js +31 -7
  20. package/lib/module/MorphCardTarget.js.map +1 -1
  21. package/lib/module/MorphChildrenRegistry.js +27 -0
  22. package/lib/module/MorphChildrenRegistry.js.map +1 -0
  23. package/lib/typescript/src/MorphCardSource.d.ts +4 -4
  24. package/lib/typescript/src/MorphCardSource.d.ts.map +1 -1
  25. package/lib/typescript/src/MorphCardTarget.d.ts.map +1 -1
  26. package/lib/typescript/src/MorphChildrenRegistry.d.ts +13 -0
  27. package/lib/typescript/src/MorphChildrenRegistry.d.ts.map +1 -0
  28. package/lib/typescript/src/index.d.ts +1 -1
  29. package/lib/typescript/src/index.d.ts.map +1 -1
  30. package/package.json +1 -1
  31. package/src/MorphCardSource.tsx +27 -5
  32. package/src/MorphCardTarget.tsx +44 -9
  33. package/src/MorphChildrenRegistry.ts +43 -0
  34. package/src/index.tsx +1 -1
@@ -22,7 +22,7 @@ static UIWindow *getKeyWindow(void) {
22
22
  return nil;
23
23
  }
24
24
 
25
- static UIView *findScreenContainer(UIView *view) {
25
+ UIView *RNCMorphCardFindScreenContainer(UIView *view) {
26
26
  UIWindow *window = view.window;
27
27
  if (!window) return nil;
28
28
 
@@ -72,6 +72,15 @@ static CGRect imageFrameForScaleMode(UIViewContentMode mode,
72
72
  }
73
73
  }
74
74
 
75
+ #pragma mark - Private interface
76
+
77
+ @interface RNCMorphCardSourceComponentView ()
78
+
79
+ - (void)collapseFromTarget:(nullable UIView *)targetView
80
+ resolve:(RCTPromiseResolveBlock)resolve;
81
+
82
+ @end
83
+
75
84
  @implementation RNCMorphCardSourceComponentView {
76
85
  CGFloat _duration;
77
86
  CGFloat _expandDuration;
@@ -152,6 +161,64 @@ static CGRect imageFrameForScaleMode(UIViewContentMode mode,
152
161
  }];
153
162
  }
154
163
 
164
+ #pragma mark - Shared helpers
165
+
166
+ /// Compute the target frame and corner radius from the given target view
167
+ /// (or fall back to _cardFrame if targetView is nil).
168
+ - (CGRect)targetFrameForView:(UIView *)targetView
169
+ cornerRadius:(CGFloat *)outCornerRadius {
170
+ CGPoint targetOrigin = targetView
171
+ ? [targetView convertPoint:CGPointZero toView:nil]
172
+ : _cardFrame.origin;
173
+
174
+ CGFloat tw = self.pendingTargetWidth;
175
+ CGFloat th = self.pendingTargetHeight;
176
+ CGFloat tbr = self.pendingTargetBorderRadius;
177
+
178
+ CGRect targetFrame = CGRectMake(
179
+ targetOrigin.x,
180
+ targetOrigin.y,
181
+ tw > 0 ? tw : _cardFrame.size.width,
182
+ th > 0 ? th : _cardFrame.size.height);
183
+
184
+ if (outCornerRadius) {
185
+ *outCornerRadius = tbr >= 0 ? tbr : _cardCornerRadius;
186
+ }
187
+ return targetFrame;
188
+ }
189
+
190
+ /// Shared cleanup performed at the end of every collapse animation.
191
+ - (void)collapseCleanupWithContainer:(UIView *)container
192
+ resolve:(RCTPromiseResolveBlock)resolve {
193
+ [container removeFromSuperview];
194
+ _wrapperView = nil;
195
+ _snapshot = nil;
196
+ self.alpha = 1;
197
+ _isExpanded = NO;
198
+ _sourceScreenContainer = nil;
199
+ _targetScreenContainer = nil;
200
+ resolve(@(YES));
201
+ }
202
+
203
+ /// Schedule the screen-fade dispatch_after used by both collapse modes.
204
+ /// Guards against the race where the animation completes before the
205
+ /// dispatch fires — if cleanup already ran, _isExpanded is NO.
206
+ - (void)scheduleScreenFadeOut:(UIView *)screenView
207
+ duration:(NSTimeInterval)dur {
208
+ __weak RNCMorphCardSourceComponentView *weakSelf = self;
209
+ dispatch_after(
210
+ dispatch_time(DISPATCH_TIME_NOW, (int64_t)(dur * 0.15 * NSEC_PER_SEC)),
211
+ dispatch_get_main_queue(), ^{
212
+ RNCMorphCardSourceComponentView *strongSelf = weakSelf;
213
+ if (!strongSelf || !strongSelf->_isExpanded) return;
214
+ [UIView animateWithDuration:dur * 0.65
215
+ animations:^{
216
+ if (screenView) { screenView.alpha = 0; }
217
+ }
218
+ completion:nil];
219
+ });
220
+ }
221
+
155
222
  #pragma mark - Expand
156
223
 
157
224
  - (void)expandToTarget:(UIView *)targetView
@@ -179,30 +246,18 @@ static CGRect imageFrameForScaleMode(UIViewContentMode mode,
179
246
  UIImage *cardImage = [self captureSnapshot];
180
247
 
181
248
  // ── 3. Keep source screen visible during navigation transition ──
182
- UIView *sourceScreen = findScreenContainer(self);
249
+ UIView *sourceScreen = RNCMorphCardFindScreenContainer(self);
183
250
  _sourceScreenContainer = sourceScreen;
184
- _targetScreenContainer = findScreenContainer(targetView);
251
+ _targetScreenContainer = RNCMorphCardFindScreenContainer(targetView);
185
252
 
186
253
  if (sourceScreen) {
187
254
  sourceScreen.alpha = 1;
188
255
  }
189
256
 
190
257
  // ── 4. Compute target frame and corner radius ──
191
- CGPoint targetOrigin = targetView
192
- ? [targetView convertPoint:CGPointZero toView:nil]
193
- : _cardFrame.origin;
194
-
195
- CGFloat tw = self.pendingTargetWidth;
196
- CGFloat th = self.pendingTargetHeight;
197
- CGFloat tbr = self.pendingTargetBorderRadius;
198
-
199
- CGRect targetFrame = CGRectMake(
200
- targetOrigin.x,
201
- targetOrigin.y,
202
- tw > 0 ? tw : _cardFrame.size.width,
203
- th > 0 ? th : _cardFrame.size.height);
204
-
205
- CGFloat targetCornerRadius = tbr >= 0 ? tbr : _cardCornerRadius;
258
+ CGFloat targetCornerRadius = 0;
259
+ CGRect targetFrame = [self targetFrameForView:targetView
260
+ cornerRadius:&targetCornerRadius];
206
261
 
207
262
  NSTimeInterval dur = (_expandDuration > 0 ? _expandDuration : _duration) / 1000.0;
208
263
 
@@ -255,10 +310,13 @@ static CGRect imageFrameForScaleMode(UIViewContentMode mode,
255
310
  }
256
311
 
257
312
  // Start fading in screen content early (at 15% of the animation).
313
+ __weak RNCMorphCardSourceComponentView *weakSelf = self;
258
314
  dispatch_after(
259
315
  dispatch_time(DISPATCH_TIME_NOW, (int64_t)(dur * 0.15 * NSEC_PER_SEC)),
260
316
  dispatch_get_main_queue(), ^{
261
- UIView *ts = self->_targetScreenContainer;
317
+ RNCMorphCardSourceComponentView *strongSelf = weakSelf;
318
+ if (!strongSelf || !strongSelf->_isExpanded) return;
319
+ UIView *ts = strongSelf->_targetScreenContainer;
262
320
  if (ts) {
263
321
  [UIView animateWithDuration:dur * 0.5
264
322
  animations:^{ ts.alpha = 1; }
@@ -280,6 +338,12 @@ static CGRect imageFrameForScaleMode(UIViewContentMode mode,
280
338
  cornerRadius:targetCornerRadius
281
339
  backgroundColor:wrapperBg];
282
340
  }
341
+ // Crossfade snapshot out to reveal live React children underneath
342
+ dispatch_after(
343
+ dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)),
344
+ dispatch_get_main_queue(), ^{
345
+ [target fadeOutSnapshot];
346
+ });
283
347
  }
284
348
  if (targetView) { targetView.hidden = NO; }
285
349
  self.alpha = 1;
@@ -334,10 +398,13 @@ static CGRect imageFrameForScaleMode(UIViewContentMode mode,
334
398
  }];
335
399
 
336
400
  // Start fading in screen content early (at 15% of the animation).
401
+ __weak RNCMorphCardSourceComponentView *weakSelf2 = self;
337
402
  dispatch_after(
338
403
  dispatch_time(DISPATCH_TIME_NOW, (int64_t)(dur * 0.15 * NSEC_PER_SEC)),
339
404
  dispatch_get_main_queue(), ^{
340
- UIView *ts = self->_targetScreenContainer;
405
+ RNCMorphCardSourceComponentView *strongSelf2 = weakSelf2;
406
+ if (!strongSelf2 || !strongSelf2->_isExpanded) return;
407
+ UIView *ts = strongSelf2->_targetScreenContainer;
341
408
  if (ts) {
342
409
  [UIView animateWithDuration:dur * 0.5
343
410
  animations:^{ ts.alpha = 1; }
@@ -353,6 +420,12 @@ static CGRect imageFrameForScaleMode(UIViewContentMode mode,
353
420
  frame:target.bounds
354
421
  cornerRadius:targetCornerRadius
355
422
  backgroundColor:nil];
423
+ // Crossfade snapshot out to reveal live React children underneath
424
+ dispatch_after(
425
+ dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)),
426
+ dispatch_get_main_queue(), ^{
427
+ [target fadeOutSnapshot];
428
+ });
356
429
  }
357
430
  if (targetView) { targetView.hidden = NO; }
358
431
  self.alpha = 1;
@@ -386,9 +459,11 @@ static CGRect imageFrameForScaleMode(UIViewContentMode mode,
386
459
  UIView *targetScreen = _targetScreenContainer;
387
460
  UIView *sourceScreen = _sourceScreenContainer;
388
461
 
389
- // Clear the snapshot from the target view before re-creating the overlay
462
+ // Clear the snapshot and hide the target view so live children
463
+ // don't show behind the animating collapse overlay
390
464
  if (targetView && [targetView isKindOfClass:[RNCMorphCardTargetComponentView class]]) {
391
465
  [(RNCMorphCardTargetComponentView *)targetView clearSnapshot];
466
+ targetView.hidden = YES;
392
467
  }
393
468
 
394
469
  CGFloat collapseDur = 0;
@@ -405,17 +480,9 @@ static CGRect imageFrameForScaleMode(UIViewContentMode mode,
405
480
  UIImage *cardImage = [self captureSnapshot];
406
481
  self.alpha = 0;
407
482
 
408
- CGPoint targetOrigin = targetView
409
- ? [targetView convertPoint:CGPointZero toView:nil]
410
- : _cardFrame.origin;
411
- CGFloat tw = self.pendingTargetWidth;
412
- CGFloat th = self.pendingTargetHeight;
413
- CGFloat tbr = self.pendingTargetBorderRadius;
414
- CGRect targetFrame = CGRectMake(
415
- targetOrigin.x, targetOrigin.y,
416
- tw > 0 ? tw : _cardFrame.size.width,
417
- th > 0 ? th : _cardFrame.size.height);
418
- CGFloat targetCornerRadius = tbr >= 0 ? tbr : _cardCornerRadius;
483
+ CGFloat targetCornerRadius = 0;
484
+ CGRect targetFrame = [self targetFrameForView:targetView
485
+ cornerRadius:&targetCornerRadius];
419
486
 
420
487
  CGFloat contentOffsetY = self.pendingContentOffsetY;
421
488
  BOOL contentCentered = self.pendingContentCentered;
@@ -462,25 +529,11 @@ static CGRect imageFrameForScaleMode(UIViewContentMode mode,
462
529
  }
463
530
  }];
464
531
 
465
- // Fade out target screen concurrently at 15%, over 65% of duration
466
- dispatch_after(
467
- dispatch_time(DISPATCH_TIME_NOW, (int64_t)(dur * 0.15 * NSEC_PER_SEC)),
468
- dispatch_get_main_queue(), ^{
469
- [UIView animateWithDuration:dur * 0.65
470
- animations:^{
471
- if (targetScreen) { targetScreen.alpha = 0; }
472
- }
473
- completion:nil];
474
- });
532
+ // Fade out target screen
533
+ [self scheduleScreenFadeOut:targetScreen duration:dur];
475
534
 
476
535
  [animator addCompletion:^(UIViewAnimatingPosition pos) {
477
- [wrapper removeFromSuperview];
478
- self->_wrapperView = nil;
479
- self.alpha = 1;
480
- self->_isExpanded = NO;
481
- self->_sourceScreenContainer = nil;
482
- self->_targetScreenContainer = nil;
483
- resolve(@(YES));
536
+ [self collapseCleanupWithContainer:wrapper resolve:resolve];
484
537
  }];
485
538
 
486
539
  [animator startAnimation];
@@ -495,17 +548,9 @@ static CGRect imageFrameForScaleMode(UIViewContentMode mode,
495
548
  UIImage *cardImage = [self captureSnapshot];
496
549
  self.alpha = 0;
497
550
 
498
- CGPoint targetOrigin = targetView
499
- ? [targetView convertPoint:CGPointZero toView:nil]
500
- : _cardFrame.origin;
501
- CGFloat tw = self.pendingTargetWidth;
502
- CGFloat th = self.pendingTargetHeight;
503
- CGFloat tbr = self.pendingTargetBorderRadius;
504
- CGRect targetFrame = CGRectMake(
505
- targetOrigin.x, targetOrigin.y,
506
- tw > 0 ? tw : _cardFrame.size.width,
507
- th > 0 ? th : _cardFrame.size.height);
508
- CGFloat targetCornerRadius = tbr >= 0 ? tbr : _cardCornerRadius;
551
+ CGFloat targetCornerRadius = 0;
552
+ CGRect targetFrame = [self targetFrameForView:targetView
553
+ cornerRadius:&targetCornerRadius];
509
554
 
510
555
  CGSize imageSize = cardImage.size;
511
556
  CGRect imageFrame = imageFrameForScaleMode(
@@ -530,38 +575,23 @@ static CGRect imageFrameForScaleMode(UIViewContentMode mode,
530
575
  sourceScreen.alpha = 1;
531
576
  }
532
577
 
533
- UICubicTimingParameters *timing2 = [[UICubicTimingParameters alloc]
578
+ UICubicTimingParameters *timing = [[UICubicTimingParameters alloc]
534
579
  initWithControlPoint1:CGPointMake(0.25, 1.0)
535
580
  controlPoint2:CGPointMake(0.5, 1.0)];
536
581
  UIViewPropertyAnimator *animator = [[UIViewPropertyAnimator alloc]
537
582
  initWithDuration:dur
538
- timingParameters:timing2];
583
+ timingParameters:timing];
539
584
  [animator addAnimations:^{
540
585
  container.frame = self->_cardFrame;
541
586
  container.layer.cornerRadius = self->_cardCornerRadius;
542
587
  snapshot.frame = (CGRect){CGPointZero, self->_cardFrame.size};
543
588
  }];
544
589
 
545
- // Fade out target screen concurrently at 15%, over 65% of duration
546
- dispatch_after(
547
- dispatch_time(DISPATCH_TIME_NOW, (int64_t)(dur * 0.15 * NSEC_PER_SEC)),
548
- dispatch_get_main_queue(), ^{
549
- [UIView animateWithDuration:dur * 0.65
550
- animations:^{
551
- if (targetScreen) { targetScreen.alpha = 0; }
552
- }
553
- completion:nil];
554
- });
590
+ // Fade out target screen
591
+ [self scheduleScreenFadeOut:targetScreen duration:dur];
555
592
 
556
593
  [animator addCompletion:^(UIViewAnimatingPosition pos) {
557
- [container removeFromSuperview];
558
- self->_wrapperView = nil;
559
- self->_snapshot = nil;
560
- self.alpha = 1;
561
- self->_isExpanded = NO;
562
- self->_sourceScreenContainer = nil;
563
- self->_targetScreenContainer = nil;
564
- resolve(@(YES));
594
+ [self collapseCleanupWithContainer:container resolve:resolve];
565
595
  }];
566
596
 
567
597
  [animator startAnimation];
@@ -14,6 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
14
14
  frame:(CGRect)frame
15
15
  cornerRadius:(CGFloat)cornerRadius
16
16
  backgroundColor:(nullable UIColor *)bgColor;
17
+ - (void)fadeOutSnapshot;
17
18
  - (void)clearSnapshot;
18
19
 
19
20
  @end
@@ -1,4 +1,5 @@
1
1
  #import "RNCMorphCardTargetComponentView.h"
2
+ #import "RNCMorphCardSourceComponentView.h"
2
3
  #import "RNCMorphCardViewRegistry.h"
3
4
 
4
5
  #import <React/RCTFabricComponentsPlugins.h>
@@ -7,9 +8,11 @@
7
8
 
8
9
  using namespace facebook::react;
9
10
 
11
+ // Declared in RNCMorphCardSourceComponentView.mm
12
+ extern UIView *RNCMorphCardFindScreenContainer(UIView *view);
13
+
10
14
  @implementation RNCMorphCardTargetComponentView {
11
15
  UIView *_snapshotContainer; // our own view — Fabric can't reset its styles
12
- UIImageView *_snapshotView;
13
16
  }
14
17
 
15
18
  + (ComponentDescriptorProvider)componentDescriptorProvider {
@@ -35,17 +38,7 @@ using namespace facebook::react;
35
38
 
36
39
  // Immediately hide the detail screen container to prevent flicker.
37
40
  // The expand animation will fade it back in.
38
- UIWindow *window = self.window;
39
- CGRect windowBounds = window.bounds;
40
- UIView *current = self.superview;
41
- UIView *screenContainer = nil;
42
- while (current && current != window) {
43
- CGRect frameInWindow = [current convertRect:current.bounds toView:nil];
44
- if (CGRectEqualToRect(frameInWindow, windowBounds)) {
45
- screenContainer = current;
46
- }
47
- current = current.superview;
48
- }
41
+ UIView *screenContainer = RNCMorphCardFindScreenContainer(self);
49
42
  if (screenContainer) {
50
43
  screenContainer.alpha = 0;
51
44
  }
@@ -77,14 +70,33 @@ using namespace facebook::react;
77
70
 
78
71
  [self addSubview:container];
79
72
  _snapshotContainer = container;
80
- _snapshotView = iv;
73
+ }
74
+
75
+ - (void)fadeOutSnapshot {
76
+ UIView *snap = _snapshotContainer;
77
+ if (!snap) return;
78
+ // Only fade out if there are React children underneath to reveal.
79
+ // If no children (scaleMode bitmap-only), keep the snapshot.
80
+ BOOL hasReactChildren = NO;
81
+ for (UIView *child in self.subviews) {
82
+ if (child != _snapshotContainer) { hasReactChildren = YES; break; }
83
+ }
84
+ if (!hasReactChildren) return;
85
+
86
+ [UIView animateWithDuration:0.15
87
+ animations:^{ snap.alpha = 0; }
88
+ completion:^(BOOL finished) {
89
+ [snap removeFromSuperview];
90
+ if (self->_snapshotContainer == snap) {
91
+ self->_snapshotContainer = nil;
92
+ }
93
+ }];
81
94
  }
82
95
 
83
96
  - (void)clearSnapshot {
84
97
  if (_snapshotContainer) {
85
98
  [_snapshotContainer removeFromSuperview];
86
99
  _snapshotContainer = nil;
87
- _snapshotView = nil;
88
100
  }
89
101
  }
90
102
 
@@ -24,7 +24,7 @@
24
24
  @implementation RNCMorphCardSource {
25
25
  // Saved state for collapsing back.
26
26
  CGRect _originalFrame;
27
- UIView *_originalSuperview;
27
+ __weak UIView *_originalSuperview;
28
28
  NSInteger _originalIndex;
29
29
  CGFloat _originalCornerRadius;
30
30
  BOOL _isExpanded;
@@ -11,6 +11,7 @@ var React = _interopRequireWildcard(require("react"));
11
11
  var _reactNative = require("react-native");
12
12
  var _NativeMorphCardModule = _interopRequireDefault(require("./specs/NativeMorphCardModule"));
13
13
  var _NativeMorphCardSource = _interopRequireDefault(require("./specs/NativeMorphCardSource"));
14
+ var _MorphChildrenRegistry = require("./MorphChildrenRegistry");
14
15
  var _jsxRuntime = require("react/jsx-runtime");
15
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
17
  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); }
@@ -23,12 +24,23 @@ const MorphCardSource = ({
23
24
  height,
24
25
  borderRadius,
25
26
  backgroundColor,
26
- scaleMode,
27
+ resizeMode,
27
28
  onPress,
28
29
  ref
29
30
  }) => {
30
31
  const nativeRef = React.useRef(null);
31
32
  React.useImperativeHandle(ref, () => nativeRef.current);
33
+
34
+ // Store children in shared registry so MorphCardTarget can clone them
35
+ React.useEffect(() => {
36
+ const tag = (0, _reactNative.findNodeHandle)(nativeRef.current);
37
+ if (tag != null) {
38
+ (0, _MorphChildrenRegistry.setSourceEntry)(tag, children, backgroundColor, resizeMode);
39
+ }
40
+ return () => {
41
+ if (tag != null) (0, _MorphChildrenRegistry.clearSourceEntry)(tag);
42
+ };
43
+ }, [children, backgroundColor, resizeMode]);
32
44
  const style = {};
33
45
  if (width != null) style.width = width;
34
46
  if (height != null) style.height = height;
@@ -37,6 +49,16 @@ const MorphCardSource = ({
37
49
  style.overflow = 'hidden';
38
50
  }
39
51
  if (backgroundColor != null) style.backgroundColor = backgroundColor;
52
+ const handleLayout = React.useCallback(e => {
53
+ const tag = (0, _reactNative.findNodeHandle)(nativeRef.current);
54
+ if (tag != null) {
55
+ const {
56
+ width: lw,
57
+ height: lh
58
+ } = e.nativeEvent.layout;
59
+ (0, _MorphChildrenRegistry.setSourceLayout)(tag, lw, lh);
60
+ }
61
+ }, []);
40
62
  const handlePress = React.useCallback(() => {
41
63
  if (!onPress) return;
42
64
  const tag = (0, _reactNative.findNodeHandle)(nativeRef.current);
@@ -52,9 +74,10 @@ const MorphCardSource = ({
52
74
  ref: nativeRef,
53
75
  duration: duration,
54
76
  expandDuration: expandDuration,
55
- scaleMode: scaleMode,
77
+ scaleMode: resizeMode === 'contain' ? 'aspectFit' : resizeMode === 'stretch' ? 'stretch' : 'aspectFill',
56
78
  cardBorderRadius: borderRadius,
57
79
  style: style,
80
+ onLayout: handleLayout,
58
81
  children: children
59
82
  });
60
83
  if (onPress) {
@@ -1 +1 @@
1
- {"version":3,"names":["React","_interopRequireWildcard","require","_reactNative","_NativeMorphCardModule","_interopRequireDefault","_NativeMorphCardSource","_jsxRuntime","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","NativeSourceView","NativeSourceViewSpec","View","MorphCardSource","children","duration","expandDuration","width","height","borderRadius","backgroundColor","scaleMode","onPress","ref","nativeRef","useRef","useImperativeHandle","current","style","overflow","handlePress","useCallback","tag","findNodeHandle","NativeMorphCardModule","prepareExpand","requestAnimationFrame","content","jsx","cardBorderRadius","Pressable","exports","getViewTag","viewRef","morphExpand","sourceRef","targetRef","sourceTag","targetTag","expand","morphCollapse","collapse"],"sourceRoot":"../../src","sources":["MorphCardSource.tsx"],"mappings":";;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAOA,IAAAE,sBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAD,sBAAA,CAAAH,OAAA;AAAiE,IAAAK,WAAA,GAAAL,OAAA;AAAA,SAAAG,uBAAAG,CAA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AAhC,WAAA,CAAAgD,GAAA,EAACpD,YAAA,CAAAsD,SAAS;MAAClB,OAAO,EAAEQ,WAAY;MAAAhB,QAAA,EAAEuB;IAAO,CAAY,CAAC;EAC/D;EAEA,OAAOA,OAAO;AAChB,CAAC;;AAED;AACA;AACA;AACA;AAHAI,OAAA,CAAA5B,eAAA,GAAAA,eAAA;AAIO,SAAS6B,UAAUA,CAACC,OAA6B,EAAiB;EACvE,OAAO,IAAAV,2BAAc,EAACU,OAAO,CAAChB,OAAO,CAAC;AACxC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeiB,WAAWA,CAC/BC,SAA+B,EAC/BC,SAA+B,EACb;EAClB,MAAMC,SAAS,GAAG,IAAAd,2BAAc,EAACY,SAAS,CAAClB,OAAO,CAAC;EACnD,MAAMqB,SAAS,GAAG,IAAAf,2BAAc,EAACa,SAAS,CAACnB,OAAO,CAAC;EACnD,IAAI,CAACoB,SAAS,IAAI,CAACC,SAAS,EAAE,OAAO,KAAK;EAC1C,OAAOd,8BAAqB,CAACe,MAAM,CAACF,SAAS,EAAEC,SAAS,CAAC;AAC3D;;AAEA;AACA;AACA;AACA;AACA;AACO,eAAeE,aAAaA,CAACH,SAAiB,EAAoB;EACvE,OAAOb,8BAAqB,CAACiB,QAAQ,CAACJ,SAAS,CAAC;AAClD","ignoreList":[]}
1
+ {"version":3,"names":["React","_interopRequireWildcard","require","_reactNative","_NativeMorphCardModule","_interopRequireDefault","_NativeMorphCardSource","_MorphChildrenRegistry","_jsxRuntime","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","NativeSourceView","NativeSourceViewSpec","View","MorphCardSource","children","duration","expandDuration","width","height","borderRadius","backgroundColor","resizeMode","onPress","ref","nativeRef","useRef","useImperativeHandle","current","useEffect","tag","findNodeHandle","setSourceEntry","clearSourceEntry","style","overflow","handleLayout","useCallback","lw","lh","nativeEvent","layout","setSourceLayout","handlePress","NativeMorphCardModule","prepareExpand","requestAnimationFrame","content","jsx","scaleMode","cardBorderRadius","onLayout","Pressable","exports","getViewTag","viewRef","morphExpand","sourceRef","targetRef","sourceTag","targetTag","expand","morphCollapse","collapse"],"sourceRoot":"../../src","sources":["MorphCardSource.tsx"],"mappings":";;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAQA,IAAAE,sBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,sBAAA,GAAAL,OAAA;AAA4F,IAAAM,WAAA,GAAAN,OAAA;AAAA,SAAAG,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAZ,uBAAA,YAAAA,CAAAQ,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAE,CAAA,CAAAI,GAAA,CAAAX,CAAA,UAAAO,CAAA,CAAAK,GAAA,CAAAZ,CAAA,GAAAO,CAAA,CAAAM,GAAA,CAAAb,CAAA,EAAAS,CAAA,gBAAAN,CAAA,IAAAH,CAAA,gBAAAG,CAAA,OAAAW,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAG,CAAA,OAAAK,CAAA,IAAAD,CAAA,GAAAS,MAAA,CAAA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gB,EAAE9B,YAAa;IAACc,KAAK,EAAEA,KAAM;IAACiB,QAAQ,EAAEf,YAAa;IAAArB,QAAA,EACjQA;EAAQ,CACO,CACnB;EAED,IAAIQ,OAAO,EAAE;IACX,oBAAO,IAAAhC,WAAA,CAAAyD,GAAA,EAAC9D,YAAA,CAAAkE,SAAS;MAAC7B,OAAO,EAAEoB,WAAY;MAAA5B,QAAA,EAAEgC;IAAO,CAAY,CAAC;EAC/D;EAEA,OAAOA,OAAO;AAChB,CAAC;;AAED;AACA;AACA;AACA;AAHAM,OAAA,CAAAvC,eAAA,GAAAA,eAAA;AAIO,SAASwC,UAAUA,CAACC,OAA6B,EAAiB;EACvE,OAAO,IAAAxB,2BAAc,EAACwB,OAAO,CAAC3B,OAAO,CAAC;AACxC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe4B,WAAWA,CAC/BC,SAA+B,EAC/BC,SAA+B,EACb;EAClB,MAAMC,SAAS,GAAG,IAAA5B,2BAAc,EAAC0B,SAAS,CAAC7B,OAAO,CAAC;EACnD,MAAMgC,SAAS,GAAG,IAAA7B,2BAAc,EAAC2B,SAAS,CAAC9B,OAAO,CAAC;EACnD,IAAI,CAAC+B,SAAS,IAAI,CAACC,SAAS,EAAE,OAAO,KAAK;EAC1C,OAAOhB,8BAAqB,CAACiB,MAAM,CAACF,SAAS,EAAEC,SAAS,CAAC;AAC3D;;AAEA;AACA;AACA;AACA;AACA;AACO,eAAeE,aAAaA,CAACH,SAAiB,EAAoB;EACvE,OAAOf,8BAAqB,CAACmB,QAAQ,CAACJ,SAAS,CAAC;AAClD","ignoreList":[]}
@@ -8,6 +8,7 @@ var React = _interopRequireWildcard(require("react"));
8
8
  var _reactNative = require("react-native");
9
9
  var _NativeMorphCardModule = _interopRequireDefault(require("./specs/NativeMorphCardModule"));
10
10
  var _NativeMorphCardTarget = _interopRequireDefault(require("./specs/NativeMorphCardTarget"));
11
+ var _MorphChildrenRegistry = require("./MorphChildrenRegistry");
11
12
  var _jsxRuntime = require("react/jsx-runtime");
12
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
14
  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); }
@@ -52,16 +53,32 @@ const MorphCardTarget = ({
52
53
  _NativeMorphCardModule.default.setTargetConfig(sourceTag, lw, lh, borderRadius != null ? borderRadius : -1, contentOffsetY ?? 0, contentCentered ?? false);
53
54
  _NativeMorphCardModule.default.expand(sourceTag, targetTag);
54
55
  }, [sourceTag, borderRadius, contentOffsetY, contentCentered]);
55
- const sizeStyle = {};
56
+ const sourceEntry = (0, _MorphChildrenRegistry.getSourceEntry)(sourceTag);
57
+ const containerStyle = {
58
+ overflow: 'hidden'
59
+ };
60
+ if (sourceEntry?.backgroundColor) {
61
+ containerStyle.backgroundColor = sourceEntry.backgroundColor;
62
+ }
63
+ if (contentCentered) {
64
+ containerStyle.justifyContent = 'center';
65
+ containerStyle.alignItems = 'center';
66
+ }
67
+ if (contentOffsetY) {
68
+ containerStyle.paddingTop = contentOffsetY;
69
+ }
56
70
  if (width != null) {
57
- sizeStyle.width = width;
71
+ containerStyle.width = width;
58
72
  } else if (sourceSize) {
59
- sizeStyle.width = sourceSize.width;
73
+ containerStyle.width = sourceSize.width;
60
74
  }
61
75
  if (height != null) {
62
- sizeStyle.height = height;
76
+ containerStyle.height = height;
63
77
  } else if (sourceSize) {
64
- sizeStyle.height = sourceSize.height;
78
+ containerStyle.height = sourceSize.height;
79
+ }
80
+ if (borderRadius) {
81
+ containerStyle.borderRadius = borderRadius;
65
82
  }
66
83
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(NativeTargetView, {
67
84
  ref: nativeRef,
@@ -70,8 +87,15 @@ const MorphCardTarget = ({
70
87
  targetWidth: 0,
71
88
  targetHeight: 0,
72
89
  targetBorderRadius: borderRadius != null ? borderRadius : -1,
73
- style: sizeStyle,
74
- onLayout: handleLayout
90
+ style: containerStyle,
91
+ onLayout: handleLayout,
92
+ children: sourceEntry && !sourceEntry.scaleMode && (sourceEntry.backgroundColor && sourceEntry.layoutWidth ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
93
+ style: {
94
+ width: sourceEntry.layoutWidth,
95
+ height: sourceEntry.layoutHeight
96
+ },
97
+ children: sourceEntry.children
98
+ }) : sourceEntry.children)
75
99
  });
76
100
  };
77
101
  exports.MorphCardTarget = MorphCardTarget;
@@ -1 +1 @@
1
- {"version":3,"names":["React","_interopRequireWildcard","require","_reactNative","_NativeMorphCardModule","_interopRequireDefault","_NativeMorphCardTarget","_jsxRuntime","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","NativeTargetView","NativeTargetViewSpec","View","MorphCardTarget","sourceTag","collapseDuration","width","height","borderRadius","contentOffsetY","contentCentered","nativeRef","useRef","expandedRef","sourceSize","setSourceSize","useState","useEffect","cancelled","NativeMorphCardModule","getSourceSize","then","size","catch","handleLayout","useCallback","current","lw","lh","nativeEvent","layout","targetTag","findNodeHandle","setTargetConfig","expand","sizeStyle","jsx","ref","targetWidth","targetHeight","targetBorderRadius","style","onLayout","exports"],"sourceRoot":"../../src","sources":["MorphCardTarget.tsx"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAOA,IAAAE,sBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAD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,EAAE,EACFC,EAAE,EACFpB,YAAY,IAAI,IAAI,GAAGA,YAAY,GAAG,CAAC,CAAC,EACxCC,cAAc,IAAI,CAAC,EACnBC,eAAe,IAAI,KACrB,CAAC;IACDS,8BAAqB,CAACe,MAAM,CAAC9B,SAAS,EAAE2B,SAAS,CAAC;EACpD,CAAC,EACD,CAAC3B,SAAS,EAAEI,YAAY,EAAEC,cAAc,EAAEC,eAAe,CAC3D,CAAC;EAED,MAAMyB,SAAoB,GAAG,CAAC,CAAC;EAC/B,IAAI7B,KAAK,IAAI,IAAI,EAAE;IACjB6B,SAAS,CAAC7B,KAAK,GAAGA,KAAK;EACzB,CAAC,MAAM,IAAIQ,UAAU,EAAE;IACrBqB,SAAS,CAAC7B,KAAK,GAAGQ,UAAU,CAACR,KAAK;EACpC;EACA,IAAIC,MAAM,IAAI,IAAI,EAAE;IAClB4B,SAAS,CAAC5B,MAAM,GAAGA,MAAM;EAC3B,CAAC,MAAM,IAAIO,UAAU,EAAE;IACrBqB,SAAS,CAAC5B,MAAM,GAAGO,UAAU,CAACP,MAAM;EACtC;EAEA,oBACE,IAAA3B,WAAA,CAAAwD,GAAA,EAACpC,gBAAgB;IACfqC,GAAG,EAAE1B,SAAU;IACfP,SAAS,EAAEA,SAAU;IACrBC,gBAAgB,EAAEA,gBAAiB;IACnCiC,WAAW,EAAE,CAAE;IACfC,YAAY,EAAE,CAAE;IAChBC,kBAAkB,EAAEhC,YAAY,IAAI,IAAI,GAAGA,YAAY,GAAG,CAAC,CAAE;IAC7DiC,KAAK,EAAEN,SAAU;IACjBO,QAAQ,EAAElB;EAAa,CACxB,CAAC;AAEN,CAAC;AAACmB,OAAA,CAAAxC,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"names":["React","_interopRequireWildcard","require","_reactNative","_NativeMorphCardModule","_interopRequireDefault","_NativeMorphCardTarget","_MorphChildrenRegistry","_jsxRuntime","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","NativeTargetView","NativeTargetViewSpec","View","MorphCardTarget","sourceTag","collapseDuration","width","height","borderRadius","contentOffsetY","contentCentered","nativeRef","useRef","expandedRef","sourceSize","setSourceSize","useState","useEffect","cancelled","NativeMorphCardModule","getSourceSize","then","size","catch","handleLayout","useCallback","current","lw","lh","nativeEvent","layout","targetTag","findNodeHandle","setTargetConfig","expand","sourceEntry","getSourceEntry","containerStyle","overflow","backgroundColor","justifyContent","alignItems","paddingTop","jsx","ref","targetWidth","targetHeight","targetBorderRadius","style","onLayout","children","scaleMode","layoutWidth","layoutHeight","exports"],"sourceRoot":"../../src","sources":["MorphCardTarget.tsx"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAOA,IAAAE,sBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,sBAAA,GAAAL,OAAA;AAAyD,IAAAM,WAAA,GAAAN,OAAA;AAAA,SAAAG,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAZ,uBAAA,YAAAA,CAAAQ,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAE,CAAA,CAAAI,G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I,OAAA,CAAAnD,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.clearSourceEntry = clearSourceEntry;
7
+ exports.getSourceEntry = getSourceEntry;
8
+ exports.setSourceEntry = setSourceEntry;
9
+ exports.setSourceLayout = setSourceLayout;
10
+ const registry = new Map();
11
+ function setSourceEntry(tag, children, backgroundColor, scaleMode) {
12
+ const existing = registry.get(tag);
13
+ registry.set(tag, {
14
+ children,
15
+ backgroundColor,
16
+ scaleMode,
17
+ layoutWidth: existing?.layoutWidth,
18
+ layoutHeight: existing?.layoutHeight
19
+ });
20
+ }
21
+ function setSourceLayout(tag, width, height) {
22
+ const existing = registry.get(tag);
23
+ if (existing) {
24
+ existing.layoutWidth = width;
25
+ existing.layoutHeight = height;
26
+ }
27
+ }
28
+ function getSourceEntry(tag) {
29
+ return registry.get(tag);
30
+ }
31
+ function clearSourceEntry(tag) {
32
+ registry.delete(tag);
33
+ }
34
+ //# sourceMappingURL=MorphChildrenRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["registry","Map","setSourceEntry","tag","children","backgroundColor","scaleMode","existing","get","set","layoutWidth","layoutHeight","setSourceLayout","width","height","getSourceEntry","clearSourceEntry","delete"],"sourceRoot":"../../src","sources":["MorphChildrenRegistry.ts"],"mappings":";;;;;;;;;AAUA,MAAMA,QAAQ,GAAG,IAAIC,GAAG,CAAsB,CAAC;AAExC,SAASC,cAAcA,CAC5BC,GAAW,EACXC,QAAmB,EACnBC,eAAwB,EACxBC,SAAkB,EAClB;EACA,MAAMC,QAAQ,GAAGP,QAAQ,CAACQ,GAAG,CAACL,GAAG,CAAC;EAClCH,QAAQ,CAACS,GAAG,CAACN,GAAG,EAAE;IAChBC,QAAQ;IACRC,eAAe;IACfC,SAAS;IACTI,WAAW,EAAEH,QAAQ,EAAEG,WAAW;IAClCC,YAAY,EAAEJ,QAAQ,EAAEI;EAC1B,CAAC,CAAC;AACJ;AAEO,SAASC,eAAeA,CAACT,GAAW,EAAEU,KAAa,EAAEC,MAAc,EAAE;EAC1E,MAAMP,QAAQ,GAAGP,QAAQ,CAACQ,GAAG,CAACL,GAAG,CAAC;EAClC,IAAII,QAAQ,EAAE;IACZA,QAAQ,CAACG,WAAW,GAAGG,KAAK;IAC5BN,QAAQ,CAACI,YAAY,GAAGG,MAAM;EAChC;AACF;AAEO,SAASC,cAAcA,CAACZ,GAAW,EAA2B;EACnE,OAAOH,QAAQ,CAACQ,GAAG,CAACL,GAAG,CAAC;AAC1B;AAEO,SAASa,gBAAgBA,CAACb,GAAW,EAAE;EAC5CH,QAAQ,CAACiB,MAAM,CAACd,GAAG,CAAC;AACtB","ignoreList":[]}