@nativescript/core 8.5.0 → 8.5.1-next-04-22-2023-4770720184

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 (105) hide show
  1. package/accessibility/accessibility-css-helper.js +2 -2
  2. package/accessibility/accessibility-css-helper.js.map +1 -1
  3. package/accessibility/accessibility-properties.d.ts +4 -1
  4. package/accessibility/accessibility-properties.js +21 -0
  5. package/accessibility/accessibility-properties.js.map +1 -1
  6. package/css/LICENSE +9 -0
  7. package/css/Readme.md +278 -0
  8. package/css-value/LICENSE +9 -0
  9. package/css-value/Readme.md +45 -0
  10. package/fetch/LICENSE +20 -0
  11. package/fetch/README.md +1 -0
  12. package/file-system/file-system-access.android.d.ts +3 -0
  13. package/file-system/file-system-access.android.js +29 -0
  14. package/file-system/file-system-access.android.js.map +1 -1
  15. package/file-system/file-system-access.d.ts +32 -0
  16. package/file-system/file-system-access.ios.d.ts +3 -0
  17. package/file-system/file-system-access.ios.js +62 -0
  18. package/file-system/file-system-access.ios.js.map +1 -1
  19. package/file-system/index.js +35 -0
  20. package/file-system/index.js.map +1 -1
  21. package/global-types.d.ts +10 -2
  22. package/index.d.ts +2 -1
  23. package/index.js +2 -1
  24. package/index.js.map +1 -1
  25. package/js-libs/easysax/LICENSE +20 -0
  26. package/js-libs/easysax/README.md +46 -0
  27. package/package.json +1 -1
  28. package/platforms/README.md +1 -0
  29. package/platforms/android/widgets-release.aar +0 -0
  30. package/ui/builder/component-builder/index.js +1 -1
  31. package/ui/builder/component-builder/index.js.map +1 -1
  32. package/ui/builder/index.js +1 -1
  33. package/ui/builder/index.js.map +1 -1
  34. package/ui/core/view/index.d.ts +15 -0
  35. package/ui/core/view/view-common.d.ts +6 -0
  36. package/ui/core/view/view-common.js +20 -2
  37. package/ui/core/view/view-common.js.map +1 -1
  38. package/ui/core/view-base/index.js +1 -1
  39. package/ui/core/view-base/index.js.map +1 -1
  40. package/ui/editable-text-base/editable-text-base-common.d.ts +1 -0
  41. package/ui/editable-text-base/editable-text-base-common.js.map +1 -1
  42. package/ui/editable-text-base/index.android.js +4 -0
  43. package/ui/editable-text-base/index.android.js.map +1 -1
  44. package/ui/editable-text-base/index.d.ts +7 -1
  45. package/ui/frame/fragment.transitions.android.js +30 -0
  46. package/ui/frame/fragment.transitions.android.js.map +1 -1
  47. package/ui/frame/frame-common.js +7 -2
  48. package/ui/frame/frame-common.js.map +1 -1
  49. package/ui/frame/index.android.js +0 -9
  50. package/ui/frame/index.android.js.map +1 -1
  51. package/ui/frame/index.ios.js +2 -3
  52. package/ui/frame/index.ios.js.map +1 -1
  53. package/ui/image/image-common.d.ts +2 -2
  54. package/ui/image/image-common.js.map +1 -1
  55. package/ui/image/index.android.js.map +1 -1
  56. package/ui/image/index.d.ts +3 -2
  57. package/ui/image/index.ios.js.map +1 -1
  58. package/ui/index.d.ts +2 -2
  59. package/ui/index.js +1 -1
  60. package/ui/index.js.map +1 -1
  61. package/ui/layouts/root-layout/index.d.ts +1 -1
  62. package/ui/layouts/root-layout/root-layout-common.d.ts +16 -1
  63. package/ui/layouts/root-layout/root-layout-common.js +86 -60
  64. package/ui/layouts/root-layout/root-layout-common.js.map +1 -1
  65. package/ui/styling/style/index.d.ts +4 -1
  66. package/ui/styling/style/index.js.map +1 -1
  67. package/ui/styling/style-properties.d.ts +5 -4
  68. package/ui/styling/style-properties.js +7 -7
  69. package/ui/styling/style-properties.js.map +1 -1
  70. package/ui/styling/style-scope.js +1 -1
  71. package/ui/styling/style-scope.js.map +1 -1
  72. package/ui/text-base/index.ios.js +30 -15
  73. package/ui/text-base/index.ios.js.map +1 -1
  74. package/ui/text-field/index.ios.js +24 -9
  75. package/ui/text-field/index.ios.js.map +1 -1
  76. package/ui/transition/fade-transition.ios.js +2 -2
  77. package/ui/transition/fade-transition.ios.js.map +1 -1
  78. package/ui/transition/index.d.ts +15 -1
  79. package/ui/transition/index.ios.js +2 -1
  80. package/ui/transition/index.ios.js.map +1 -1
  81. package/ui/transition/modal-transition.ios.js +24 -2
  82. package/ui/transition/modal-transition.ios.js.map +1 -1
  83. package/ui/transition/page-transition.android.d.ts +3 -2
  84. package/ui/transition/page-transition.android.js +84 -4
  85. package/ui/transition/page-transition.android.js.map +1 -1
  86. package/ui/transition/page-transition.ios.d.ts +1 -0
  87. package/ui/transition/page-transition.ios.js +29 -11
  88. package/ui/transition/page-transition.ios.js.map +1 -1
  89. package/ui/transition/shared-transition-helper.ios.js +235 -184
  90. package/ui/transition/shared-transition-helper.ios.js.map +1 -1
  91. package/ui/transition/shared-transition.d.ts +54 -17
  92. package/ui/transition/shared-transition.js +45 -22
  93. package/ui/transition/shared-transition.js.map +1 -1
  94. package/ui/transition/slide-transition.ios.js +2 -2
  95. package/ui/transition/slide-transition.ios.js.map +1 -1
  96. package/utils/common.d.ts +33 -0
  97. package/utils/common.js +70 -1
  98. package/utils/common.js.map +1 -1
  99. package/utils/native-helper.d.ts +2 -1
  100. package/utils/native-helper.ios.d.ts +4 -1
  101. package/utils/native-helper.ios.js +7 -26
  102. package/utils/native-helper.ios.js.map +1 -1
  103. package/ui/builder/module-name-sanitizer.d.ts +0 -6
  104. package/ui/builder/module-name-sanitizer.js +0 -24
  105. package/ui/builder/module-name-sanitizer.js.map +0 -1
@@ -1,24 +1,22 @@
1
1
  import { getPageStartDefaultsForType, getRectFromProps, getSpringFromProps, SharedTransition, SharedTransitionAnimationType } from './shared-transition';
2
2
  import { isNumber } from '../../utils/types';
3
3
  import { Screen } from '../../platform';
4
+ import { CORE_ANIMATION_DEFAULTS } from '../../utils/common';
4
5
  import { iOSNativeHelper } from '../../utils/native-helper';
5
6
  export class SharedTransitionHelper {
6
7
  static animate(state, transitionContext, type) {
7
8
  const transition = state.instance;
8
- setTimeout(() => {
9
+ setTimeout(async () => {
9
10
  // Run on next tick
10
11
  // ensures that existing UI state finishes before snapshotting
11
12
  // (eg, button touch up state)
12
13
  switch (state.activeType) {
13
14
  case SharedTransitionAnimationType.present: {
14
15
  // console.log('-- Transition present --');
15
- SharedTransition.events().notify({
16
- eventName: SharedTransition.startedEvent,
17
- data: {
18
- id: transition.id,
19
- type,
20
- action: 'present',
21
- },
16
+ SharedTransition.notifyEvent(SharedTransition.startedEvent, {
17
+ id: transition.id,
18
+ type,
19
+ action: 'present',
22
20
  });
23
21
  if (type === 'modal') {
24
22
  transitionContext.containerView.addSubview(transition.presented.view);
@@ -28,6 +26,7 @@ export class SharedTransitionHelper {
28
26
  }
29
27
  transition.presented.view.layoutIfNeeded();
30
28
  const { sharedElements, presented, presenting } = SharedTransition.getSharedElements(state.page, state.toPage);
29
+ const sharedElementTags = sharedElements.map((v) => v.sharedTransitionTag);
31
30
  if (!transition.sharedElements) {
32
31
  transition.sharedElements = {
33
32
  presented: [],
@@ -37,130 +36,164 @@ export class SharedTransitionHelper {
37
36
  }
38
37
  if (SharedTransition.DEBUG) {
39
38
  console.log(` ${type}: Present`);
40
- console.log(`1. Found sharedTransitionTags to animate:`, sharedElements.map((v) => v.sharedTransitionTag));
39
+ console.log(`1. Found sharedTransitionTags to animate:`, sharedElementTags);
41
40
  console.log(`2. Take snapshots of shared elements and position them based on presenting view:`);
42
41
  }
43
42
  const pageStart = state.pageStart;
44
43
  const startFrame = getRectFromProps(pageStart, getPageStartDefaultsForType(type));
45
44
  const pageEnd = state.pageEnd;
46
- const pageEndIndependentTags = Object.keys(pageEnd?.sharedTransitionTags || {});
45
+ const pageEndTags = pageEnd?.sharedTransitionTags || {};
47
46
  // console.log('pageEndIndependentTags:', pageEndIndependentTags);
48
- for (const presentingView of sharedElements) {
49
- const presentingSharedElement = presentingView.ios;
50
- // console.log('fromTarget instanceof UIImageView:', fromTarget instanceof UIImageView)
51
- // TODO: discuss whether we should check if UIImage/UIImageView type to always snapshot images or if other view types could be duped/added vs. snapshotted
52
- // Note: snapshot may be most efficient/simple
53
- // console.log('---> ', presentingView.sharedTransitionTag, ': ', presentingSharedElement)
54
- const presentedView = presented.find((v) => v.sharedTransitionTag === presentingView.sharedTransitionTag);
55
- const presentedSharedElement = presentedView.ios;
56
- const snapshot = UIImageView.alloc().init();
57
- // treat images differently...
58
- if (presentedSharedElement instanceof UIImageView) {
59
- // in case the image is loaded async, we need to update the snapshot when it changes
60
- // todo: remove listener on transition end
61
- presentedView.on('imageSourceChange', () => {
62
- snapshot.image = iOSNativeHelper.snapshotView(presentedSharedElement, Screen.mainScreen.scale);
47
+ const positionSharedTags = async () => {
48
+ for (const presentingView of sharedElements) {
49
+ const presentingSharedElement = presentingView.ios;
50
+ // console.log('fromTarget instanceof UIImageView:', fromTarget instanceof UIImageView)
51
+ // TODO: discuss whether we should check if UIImage/UIImageView type to always snapshot images or if other view types could be duped/added vs. snapshotted
52
+ // Note: snapshot may be most efficient/simple
53
+ // console.log('---> ', presentingView.sharedTransitionTag, ': ', presentingSharedElement)
54
+ const presentedView = presented.find((v) => v.sharedTransitionTag === presentingView.sharedTransitionTag);
55
+ const presentedSharedElement = presentedView.ios;
56
+ const pageEndProps = pageEndTags[presentingView.sharedTransitionTag];
57
+ const snapshot = UIImageView.alloc().init();
58
+ if (pageEndProps?.callback) {
59
+ await pageEndProps?.callback(presentedView, 'present');
60
+ }
61
+ // treat images differently...
62
+ if (presentedSharedElement instanceof UIImageView) {
63
+ // in case the image is loaded async, we need to update the snapshot when it changes
64
+ // todo: remove listener on transition end
65
+ presentedView.on('imageSourceChange', () => {
66
+ snapshot.image = iOSNativeHelper.snapshotView(presentedSharedElement, Screen.mainScreen.scale);
67
+ snapshot.tintColor = presentedSharedElement.tintColor;
68
+ });
63
69
  snapshot.tintColor = presentedSharedElement.tintColor;
70
+ snapshot.contentMode = presentedSharedElement.contentMode;
71
+ }
72
+ iOSNativeHelper.copyLayerProperties(snapshot, presentingSharedElement, pageEndProps?.propertiesToMatch);
73
+ snapshot.clipsToBounds = true;
74
+ // console.log('---> snapshot: ', snapshot);
75
+ const startFrame = presentingSharedElement.convertRectToView(presentingSharedElement.bounds, transitionContext.containerView);
76
+ const endFrame = presentedSharedElement.convertRectToView(presentedSharedElement.bounds, transitionContext.containerView);
77
+ snapshot.frame = startFrame;
78
+ if (SharedTransition.DEBUG) {
79
+ console.log('---> ', presentingView.sharedTransitionTag, ' frame:', iOSNativeHelper.printCGRect(snapshot.frame));
80
+ }
81
+ transition.sharedElements.presenting.push({
82
+ view: presentingView,
83
+ startFrame,
84
+ endFrame,
85
+ snapshot,
86
+ startOpacity: presentingView.opacity,
87
+ endOpacity: isNumber(pageEndProps?.opacity) ? pageEndProps.opacity : presentedView.opacity,
88
+ propertiesToMatch: pageEndProps?.propertiesToMatch,
89
+ zIndex: isNumber(pageEndProps?.zIndex) ? pageEndProps.zIndex : 0,
64
90
  });
65
- snapshot.tintColor = presentedSharedElement.tintColor;
66
- snapshot.contentMode = presentedSharedElement.contentMode;
67
- }
68
- iOSNativeHelper.copyLayerProperties(snapshot, presentingSharedElement);
69
- snapshot.clipsToBounds = true;
70
- // console.log('---> snapshot: ', snapshot);
71
- const startFrame = presentingSharedElement.convertRectToView(presentingSharedElement.bounds, transitionContext.containerView);
72
- const endFrame = presentedSharedElement.convertRectToView(presentedSharedElement.bounds, transitionContext.containerView);
73
- snapshot.frame = startFrame;
74
- if (SharedTransition.DEBUG) {
75
- console.log('---> ', presentingView.sharedTransitionTag, ' frame:', iOSNativeHelper.printCGRect(snapshot.frame));
91
+ transition.sharedElements.presented.push({
92
+ view: presentedView,
93
+ startFrame: endFrame,
94
+ endFrame: startFrame,
95
+ startOpacity: presentedView.opacity,
96
+ endOpacity: presentingView.opacity,
97
+ propertiesToMatch: pageEndProps?.propertiesToMatch,
98
+ });
99
+ // set initial opacity to match the source view opacity
100
+ snapshot.alpha = presentingView.opacity;
101
+ // hide both while animating within the transition context
102
+ presentingView.opacity = 0;
103
+ presentedView.opacity = 0;
76
104
  }
77
- transition.sharedElements.presenting.push({
78
- view: presentingView,
79
- startFrame,
80
- endFrame,
81
- snapshot,
82
- startOpacity: presentingView.opacity,
83
- endOpacity: presentedView.opacity,
84
- });
85
- transition.sharedElements.presented.push({
86
- view: presentedView,
87
- startFrame: endFrame,
88
- endFrame: startFrame,
89
- startOpacity: presentedView.opacity,
90
- endOpacity: presentingView.opacity,
91
- });
92
- // set initial opacity to match the source view opacity
93
- snapshot.alpha = presentingView.opacity;
94
- // hide both while animating within the transition context
95
- presentingView.opacity = 0;
96
- presentedView.opacity = 0;
97
- // add snapshot to animate
98
- transitionContext.containerView.addSubview(snapshot);
99
- }
100
- for (const tag of pageEndIndependentTags) {
101
- // only consider start when there's a matching end
102
- const pageStartIndependentProps = pageStart?.sharedTransitionTags ? pageStart?.sharedTransitionTags[tag] : null;
103
- // console.log('start:', tag, pageStartIndependentProps);
104
- const pageEndIndependentProps = pageEnd?.sharedTransitionTags[tag];
105
- let independentView = presenting.find((v) => v.sharedTransitionTag === tag);
106
- let isPresented = false;
107
- if (!independentView) {
108
- independentView = presented.find((v) => v.sharedTransitionTag === tag);
109
- if (!independentView) {
110
- break;
105
+ };
106
+ const positionIndependentTags = async () => {
107
+ // independent tags
108
+ for (const tag in pageEndTags) {
109
+ // only handle if independent (otherwise it's shared between both pages and handled above)
110
+ if (!sharedElementTags.includes(tag)) {
111
+ // only consider start when there's a matching end
112
+ const pageStartIndependentProps = pageStart?.sharedTransitionTags ? pageStart?.sharedTransitionTags[tag] : null;
113
+ // console.log('start:', tag, pageStartIndependentProps);
114
+ const pageEndProps = pageEndTags[tag];
115
+ let independentView = presenting.find((v) => v.sharedTransitionTag === tag);
116
+ let isPresented = false;
117
+ if (!independentView) {
118
+ independentView = presented.find((v) => v.sharedTransitionTag === tag);
119
+ if (!independentView) {
120
+ break;
121
+ }
122
+ isPresented = true;
123
+ }
124
+ const independentSharedElement = independentView.ios;
125
+ if (pageEndProps?.callback) {
126
+ await pageEndProps?.callback(independentView, 'present');
127
+ }
128
+ let snapshot;
129
+ // if (isPresented) {
130
+ // snapshot = UIImageView.alloc().init();
131
+ // } else {
132
+ snapshot = UIImageView.alloc().initWithImage(iOSNativeHelper.snapshotView(independentSharedElement, Screen.mainScreen.scale));
133
+ // }
134
+ if (independentSharedElement instanceof UIImageView) {
135
+ // in case the image is loaded async, we need to update the snapshot when it changes
136
+ // todo: remove listener on transition end
137
+ // if (isPresented) {
138
+ // independentView.on('imageSourceChange', () => {
139
+ // snapshot.image = iOSNativeHelper.snapshotView(independentSharedElement, Screen.mainScreen.scale);
140
+ // snapshot.tintColor = independentSharedElement.tintColor;
141
+ // });
142
+ // }
143
+ snapshot.tintColor = independentSharedElement.tintColor;
144
+ snapshot.contentMode = independentSharedElement.contentMode;
145
+ }
146
+ snapshot.clipsToBounds = true;
147
+ const startFrame = independentSharedElement.convertRectToView(independentSharedElement.bounds, transitionContext.containerView);
148
+ const startFrameRect = getRectFromProps(pageStartIndependentProps);
149
+ // adjust for any specified start positions
150
+ const startFrameAdjusted = CGRectMake(startFrame.origin.x + startFrameRect.x, startFrame.origin.y + startFrameRect.y, startFrame.size.width, startFrame.size.height);
151
+ // console.log('startFrameAdjusted:', tag, iOSNativeHelper.printCGRect(startFrameAdjusted));
152
+ // if (pageStartIndependentProps?.scale) {
153
+ // snapshot.transform = CGAffineTransformConcat(CGAffineTransformMakeTranslation(startFrameAdjusted.origin.x, startFrameAdjusted.origin.y), CGAffineTransformMakeScale(pageStartIndependentProps.scale.x, pageStartIndependentProps.scale.y))
154
+ // } else {
155
+ snapshot.frame = startFrame; //startFrameAdjusted;
156
+ // }
157
+ if (SharedTransition.DEBUG) {
158
+ console.log('---> ', independentView.sharedTransitionTag, ' frame:', iOSNativeHelper.printCGRect(snapshot.frame));
159
+ }
160
+ const endFrameRect = getRectFromProps(pageEndProps);
161
+ const endFrame = CGRectMake(startFrame.origin.x + endFrameRect.x, startFrame.origin.y + endFrameRect.y, startFrame.size.width, startFrame.size.height);
162
+ // console.log('endFrame:', tag, iOSNativeHelper.printCGRect(endFrame));
163
+ transition.sharedElements.independent.push({
164
+ view: independentView,
165
+ isPresented,
166
+ startFrame,
167
+ snapshot,
168
+ endFrame,
169
+ startTransform: independentSharedElement.transform,
170
+ scale: pageEndProps.scale,
171
+ startOpacity: independentView.opacity,
172
+ endOpacity: isNumber(pageEndProps.opacity) ? pageEndProps.opacity : 0,
173
+ propertiesToMatch: pageEndProps?.propertiesToMatch,
174
+ zIndex: isNumber(pageEndProps?.zIndex) ? pageEndProps.zIndex : 0,
175
+ });
176
+ independentView.opacity = 0;
111
177
  }
112
- isPresented = true;
113
- }
114
- const independentSharedElement = independentView.ios;
115
- let snapshot;
116
- // if (isPresented) {
117
- // snapshot = UIImageView.alloc().init();
118
- // } else {
119
- snapshot = UIImageView.alloc().initWithImage(iOSNativeHelper.snapshotView(independentSharedElement, Screen.mainScreen.scale));
120
- // }
121
- if (independentSharedElement instanceof UIImageView) {
122
- // in case the image is loaded async, we need to update the snapshot when it changes
123
- // todo: remove listener on transition end
124
- // if (isPresented) {
125
- // independentView.on('imageSourceChange', () => {
126
- // snapshot.image = iOSNativeHelper.snapshotView(independentSharedElement, Screen.mainScreen.scale);
127
- // snapshot.tintColor = independentSharedElement.tintColor;
128
- // });
129
- // }
130
- snapshot.tintColor = independentSharedElement.tintColor;
131
- snapshot.contentMode = independentSharedElement.contentMode;
132
178
  }
133
- snapshot.clipsToBounds = true;
134
- const startFrame = independentSharedElement.convertRectToView(independentSharedElement.bounds, transitionContext.containerView);
135
- const startFrameRect = getRectFromProps(pageStartIndependentProps);
136
- // adjust for any specified start positions
137
- const startFrameAdjusted = CGRectMake(startFrame.origin.x + startFrameRect.x, startFrame.origin.y + startFrameRect.y, startFrame.size.width, startFrame.size.height);
138
- // console.log('startFrameAdjusted:', tag, iOSNativeHelper.printCGRect(startFrameAdjusted));
139
- // if (pageStartIndependentProps?.scale) {
140
- // snapshot.transform = CGAffineTransformConcat(CGAffineTransformMakeTranslation(startFrameAdjusted.origin.x, startFrameAdjusted.origin.y), CGAffineTransformMakeScale(pageStartIndependentProps.scale.x, pageStartIndependentProps.scale.y))
141
- // } else {
142
- snapshot.frame = startFrame; //startFrameAdjusted;
143
- // }
144
- if (SharedTransition.DEBUG) {
145
- console.log('---> ', independentView.sharedTransitionTag, ' frame:', iOSNativeHelper.printCGRect(snapshot.frame));
146
- }
147
- const endFrameRect = getRectFromProps(pageEndIndependentProps);
148
- const endFrame = CGRectMake(startFrame.origin.x + endFrameRect.x, startFrame.origin.y + endFrameRect.y, startFrame.size.width, startFrame.size.height);
149
- // console.log('endFrame:', tag, iOSNativeHelper.printCGRect(endFrame));
150
- transition.sharedElements.independent.push({
151
- view: independentView,
152
- isPresented,
153
- startFrame,
154
- snapshot,
155
- endFrame,
156
- startTransform: independentSharedElement.transform,
157
- scale: pageEndIndependentProps.scale,
158
- startOpacity: independentView.opacity,
159
- endOpacity: isNumber(pageEndIndependentProps.opacity) ? pageEndIndependentProps.opacity : 0,
160
- });
161
- independentView.opacity = 0;
179
+ };
180
+ // position all sharedTransitionTag elements
181
+ await positionSharedTags();
182
+ await positionIndependentTags();
183
+ // combine to order by zIndex and add to transition context
184
+ const snapshotData = transition.sharedElements.presenting.concat(transition.sharedElements.independent);
185
+ snapshotData.sort((a, b) => (a.zIndex > b.zIndex ? 1 : -1));
186
+ if (SharedTransition.DEBUG) {
187
+ console.log(`zIndex settings:`, snapshotData.map((s) => {
188
+ return {
189
+ sharedTransitionTag: s.view.sharedTransitionTag,
190
+ zIndex: s.zIndex,
191
+ };
192
+ }));
193
+ }
194
+ for (const data of snapshotData) {
162
195
  // add snapshot to animate
163
- transitionContext.containerView.addSubview(snapshot);
196
+ transitionContext.containerView.addSubview(data.snapshot);
164
197
  }
165
198
  // Important: always set after above shared element positions have had their start positions set
166
199
  transition.presented.view.alpha = isNumber(pageStart?.opacity) ? pageStart?.opacity : 0;
@@ -185,13 +218,10 @@ export class SharedTransitionHelper {
185
218
  transition.presenting.view.removeFromSuperview();
186
219
  }
187
220
  transitionContext.completeTransition(true);
188
- SharedTransition.events().notify({
189
- eventName: SharedTransition.finishedEvent,
190
- data: {
191
- id: transition?.id,
192
- type,
193
- action: 'present',
194
- },
221
+ SharedTransition.notifyEvent(SharedTransition.finishedEvent, {
222
+ id: transition.id,
223
+ type,
224
+ action: 'present',
195
225
  });
196
226
  };
197
227
  const animateProperties = () => {
@@ -215,7 +245,7 @@ export class SharedTransitionHelper {
215
245
  const correctedEndFrame = CGRectMake(updatedEndFrame.origin.x, updatedEndFrame.origin.y, presentingMatch.endFrame.size.width, presentingMatch.endFrame.size.height);
216
246
  presentingMatch.snapshot.frame = correctedEndFrame;
217
247
  // apply view and layer properties to the snapshot view to match the source/presented view
218
- iOSNativeHelper.copyLayerProperties(presentingMatch.snapshot, presented.view.ios);
248
+ iOSNativeHelper.copyLayerProperties(presentingMatch.snapshot, presented.view.ios, presented.propertiesToMatch);
219
249
  // create a snapshot of the presented view
220
250
  presentingMatch.snapshot.image = iOSNativeHelper.snapshotView(presented.view.ios, Screen.mainScreen.scale);
221
251
  // apply correct alpha
@@ -244,7 +274,7 @@ export class SharedTransitionHelper {
244
274
  };
245
275
  if (isNumber(pageEnd?.duration)) {
246
276
  // override spring and use only linear animation
247
- UIView.animateWithDurationAnimationsCompletion(pageEnd?.duration / 1000, () => {
277
+ UIView.animateWithDurationDelayOptionsAnimationsCompletion(pageEnd?.duration / 1000, 0, 0 /* UIViewAnimationOptions.CurveEaseInOut */, () => {
248
278
  animateProperties();
249
279
  }, () => {
250
280
  cleanupPresent();
@@ -265,13 +295,10 @@ export class SharedTransitionHelper {
265
295
  }
266
296
  case SharedTransitionAnimationType.dismiss: {
267
297
  // console.log('-- Transition dismiss --');
268
- SharedTransition.events().notify({
269
- eventName: SharedTransition.startedEvent,
270
- data: {
271
- id: transition?.id,
272
- type,
273
- action: 'dismiss',
274
- },
298
+ SharedTransition.notifyEvent(SharedTransition.startedEvent, {
299
+ id: transition.id,
300
+ type,
301
+ action: 'dismiss',
275
302
  });
276
303
  if (type === 'page') {
277
304
  transitionContext.containerView.insertSubviewBelowSubview(transition.presenting.view, transition.presented.view);
@@ -282,18 +309,53 @@ export class SharedTransitionHelper {
282
309
  console.log(`1. Dismiss sharedTransitionTags to animate:`, transition.sharedElements.presented.map((p) => p.view.sharedTransitionTag));
283
310
  console.log(`2. Add back previously stored sharedElements to dismiss:`);
284
311
  }
312
+ const pageEnd = state.pageEnd;
313
+ const pageEndTags = pageEnd?.sharedTransitionTags || {};
314
+ const pageReturn = state.pageReturn;
285
315
  for (const p of transition.sharedElements.presented) {
286
316
  p.view.opacity = 0;
287
317
  }
288
- for (const p of transition.sharedElements.presenting) {
289
- p.snapshot.alpha = p.endOpacity;
290
- transitionContext.containerView.addSubview(p.snapshot);
318
+ // combine to order by zIndex and add to transition context
319
+ const snapshotData = transition.sharedElements.presenting.concat(transition.sharedElements.independent);
320
+ snapshotData.sort((a, b) => (a.zIndex > b.zIndex ? 1 : -1));
321
+ if (SharedTransition.DEBUG) {
322
+ console.log(`zIndex settings:`, snapshotData.map((s) => {
323
+ return {
324
+ sharedTransitionTag: s.view.sharedTransitionTag,
325
+ zIndex: s.zIndex,
326
+ };
327
+ }));
291
328
  }
292
- for (const independent of transition.sharedElements.independent) {
293
- independent.snapshot.alpha = independent.endOpacity;
294
- transitionContext.containerView.addSubview(independent.snapshot);
329
+ // first loop through all the shared elements and fire the callback
330
+ for (const data of snapshotData) {
331
+ const pageEndProps = pageEndTags[data.view.sharedTransitionTag];
332
+ if (pageEndProps?.callback) {
333
+ await pageEndProps?.callback(data.view, 'dismiss');
334
+ }
335
+ }
336
+ // now that all the callbacks had their chance to run, we can take the snapshots
337
+ for (const data of snapshotData) {
338
+ const view = data.view.ios;
339
+ const currentAlpha = view.alpha;
340
+ if (pageReturn?.useStartOpacity) {
341
+ // when desired, reset the alpha to the start value so the view is visible in the snapshot
342
+ view.alpha = data.startOpacity;
343
+ }
344
+ // take a new snapshot
345
+ data.snapshot.image = iOSNativeHelper.snapshotView(view, Screen.mainScreen.scale);
346
+ // find the currently visible view with the same sharedTransitionTag
347
+ const fromView = transition.sharedElements.presented.find((p) => p.view.sharedTransitionTag === data.view.sharedTransitionTag)?.view;
348
+ if (fromView) {
349
+ // match the snapshot frame to the current frame of the fromView
350
+ data.snapshot.frame = fromView.ios.convertRectToView(fromView.ios.bounds, transitionContext.containerView);
351
+ }
352
+ // snapshot has been taken, we can restore the alpha
353
+ view.alpha = currentAlpha;
354
+ // we recalculate the startFrame because the view might have changed its position in the background
355
+ data.startFrame = view.convertRectToView(view.bounds, transitionContext.containerView);
356
+ // add snapshot to animate
357
+ transitionContext.containerView.addSubview(data.snapshot);
295
358
  }
296
- const pageReturn = state.pageReturn;
297
359
  const cleanupDismiss = () => {
298
360
  for (const presenting of transition.sharedElements.presenting) {
299
361
  presenting.view.opacity = presenting.startOpacity;
@@ -306,13 +368,10 @@ export class SharedTransitionHelper {
306
368
  SharedTransition.finishState(transition.id);
307
369
  transition.sharedElements = null;
308
370
  transitionContext.completeTransition(true);
309
- SharedTransition.events().notify({
310
- eventName: SharedTransition.finishedEvent,
311
- data: {
312
- id: transition?.id,
313
- type,
314
- action: 'dismiss',
315
- },
371
+ SharedTransition.notifyEvent(SharedTransition.finishedEvent, {
372
+ id: transition.id,
373
+ type,
374
+ action: 'dismiss',
316
375
  });
317
376
  };
318
377
  const animateProperties = () => {
@@ -323,11 +382,11 @@ export class SharedTransitionHelper {
323
382
  const endFrame = getRectFromProps(pageReturn, getPageStartDefaultsForType(type));
324
383
  transition.presented.view.frame = CGRectMake(endFrame.x, endFrame.y, endFrame.width, endFrame.height);
325
384
  for (const presenting of transition.sharedElements.presenting) {
326
- iOSNativeHelper.copyLayerProperties(presenting.snapshot, presenting.view.ios);
385
+ iOSNativeHelper.copyLayerProperties(presenting.snapshot, presenting.view.ios, presenting.propertiesToMatch);
327
386
  presenting.snapshot.frame = presenting.startFrame;
328
387
  presenting.snapshot.alpha = presenting.startOpacity;
329
388
  if (SharedTransition.DEBUG) {
330
- console.log(`---> ${presenting.view.sharedTransitionTag} animate to: `, iOSNativeHelper.printCGRect(presenting.startFrame));
389
+ console.log(`---> ${presenting.view.sharedTransitionTag} animate to: `, iOSNativeHelper.printCGRect(presenting.snapshot.frame));
331
390
  }
332
391
  }
333
392
  for (const independent of transition.sharedElements.independent) {
@@ -339,13 +398,13 @@ export class SharedTransitionHelper {
339
398
  independent.snapshot.frame = independent.startFrame;
340
399
  }
341
400
  if (SharedTransition.DEBUG) {
342
- console.log(`---> ${independent.view.sharedTransitionTag} animate to: `, iOSNativeHelper.printCGRect(independent.startFrame));
401
+ console.log(`---> ${independent.view.sharedTransitionTag} animate to: `, iOSNativeHelper.printCGRect(independent.snapshot.frame));
343
402
  }
344
403
  }
345
404
  };
346
405
  if (isNumber(pageReturn?.duration)) {
347
406
  // override spring and use only linear animation
348
- UIView.animateWithDurationAnimationsCompletion(pageReturn?.duration / 1000, () => {
407
+ UIView.animateWithDurationDelayOptionsAnimationsCompletion(pageReturn?.duration / 1000, 0, 0 /* UIViewAnimationOptions.CurveEaseInOut */, () => {
349
408
  animateProperties();
350
409
  }, () => {
351
410
  cleanupDismiss();
@@ -368,13 +427,10 @@ export class SharedTransitionHelper {
368
427
  });
369
428
  }
370
429
  static interactiveStart(state, interactiveState, type) {
371
- SharedTransition.events().notify({
372
- eventName: SharedTransition.startedEvent,
373
- data: {
374
- id: state?.instance?.id,
375
- type,
376
- action: 'interactiveStart',
377
- },
430
+ SharedTransition.notifyEvent(SharedTransition.startedEvent, {
431
+ id: state.instance.id,
432
+ type,
433
+ action: 'interactiveStart',
378
434
  });
379
435
  switch (type) {
380
436
  case 'page':
@@ -397,7 +453,7 @@ export class SharedTransitionHelper {
397
453
  interactiveState.propertyAnimator = UIViewPropertyAnimator.alloc().initWithDurationDampingRatioAnimations(1, 1, () => {
398
454
  for (const p of state.instance.sharedElements.presenting) {
399
455
  p.snapshot.frame = p.startFrame;
400
- iOSNativeHelper.copyLayerProperties(p.snapshot, p.view.ios);
456
+ iOSNativeHelper.copyLayerProperties(p.snapshot, p.view.ios, p.propertiesToMatch);
401
457
  p.snapshot.alpha = 1;
402
458
  }
403
459
  state.instance.presented.view.alpha = isNumber(state.pageReturn?.opacity) ? state.pageReturn?.opacity : 0;
@@ -405,19 +461,16 @@ export class SharedTransitionHelper {
405
461
  });
406
462
  }
407
463
  interactiveState.propertyAnimator.fractionComplete = percent;
408
- SharedTransition.events().notify({
409
- eventName: SharedTransition.interactiveUpdateEvent,
410
- data: {
411
- id: state?.instance?.id,
412
- type,
413
- percent,
414
- },
464
+ SharedTransition.notifyEvent(SharedTransition.interactiveUpdateEvent, {
465
+ id: state?.instance?.id,
466
+ type,
467
+ percent,
415
468
  });
416
469
  }
417
470
  static interactiveCancel(state, interactiveState, type) {
418
471
  if (state?.instance && interactiveState?.added && interactiveState?.propertyAnimator) {
419
472
  interactiveState.propertyAnimator.reversed = true;
420
- const duration = isNumber(state.pageEnd?.duration) ? state.pageEnd?.duration / 1000 : 0.35;
473
+ const duration = isNumber(state.pageEnd?.duration) ? state.pageEnd?.duration / 1000 : CORE_ANIMATION_DEFAULTS.duration;
421
474
  interactiveState.propertyAnimator.continueAnimationWithTimingParametersDurationFactor(null, duration);
422
475
  setTimeout(() => {
423
476
  for (const p of state.instance.sharedElements.presented) {
@@ -431,12 +484,13 @@ export class SharedTransitionHelper {
431
484
  interactiveState.added = false;
432
485
  interactiveState.transitionContext.cancelInteractiveTransition();
433
486
  interactiveState.transitionContext.completeTransition(false);
434
- SharedTransition.events().notify({
435
- eventName: SharedTransition.interactiveCancelledEvent,
436
- data: {
437
- id: state?.instance?.id,
438
- type,
439
- },
487
+ SharedTransition.updateState(state?.instance?.id, {
488
+ interactiveBegan: false,
489
+ interactiveCancelled: true,
490
+ });
491
+ SharedTransition.notifyEvent(SharedTransition.interactiveCancelledEvent, {
492
+ id: state?.instance?.id,
493
+ type,
440
494
  });
441
495
  }, duration * 1000);
442
496
  }
@@ -444,7 +498,7 @@ export class SharedTransitionHelper {
444
498
  static interactiveFinish(state, interactiveState, type) {
445
499
  if (state?.instance && interactiveState?.added && interactiveState?.propertyAnimator) {
446
500
  interactiveState.propertyAnimator.reversed = false;
447
- const duration = isNumber(state.pageReturn?.duration) ? state.pageReturn?.duration / 1000 : 0.35;
501
+ const duration = isNumber(state.pageReturn?.duration) ? state.pageReturn?.duration / 1000 : CORE_ANIMATION_DEFAULTS.duration;
448
502
  interactiveState.propertyAnimator.continueAnimationWithTimingParametersDurationFactor(null, duration);
449
503
  setTimeout(() => {
450
504
  for (const presenting of state.instance.sharedElements.presenting) {
@@ -456,13 +510,10 @@ export class SharedTransitionHelper {
456
510
  interactiveState.added = false;
457
511
  interactiveState.transitionContext.finishInteractiveTransition();
458
512
  interactiveState.transitionContext.completeTransition(true);
459
- SharedTransition.events().notify({
460
- eventName: SharedTransition.finishedEvent,
461
- data: {
462
- id: state?.instance?.id,
463
- type,
464
- action: 'interactiveFinish',
465
- },
513
+ SharedTransition.notifyEvent(SharedTransition.finishedEvent, {
514
+ id: state?.instance?.id,
515
+ type,
516
+ action: 'interactiveFinish',
466
517
  });
467
518
  }, duration * 1000);
468
519
  }