@nativescript/core 8.5.0-alpha.2 → 8.5.0-alpha.3
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/file-system/file-system-access.android.d.ts +13 -0
- package/file-system/file-system-access.android.js +141 -0
- package/file-system/file-system-access.android.js.map +1 -1
- package/file-system/file-system-access.d.ts +12 -0
- package/file-system/file-system-access.ios.d.ts +7 -0
- package/file-system/file-system-access.ios.js +56 -0
- package/file-system/file-system-access.ios.js.map +1 -1
- package/package.json +1 -1
- package/platforms/android/widgets-release.aar +0 -0
- package/ui/core/view/index.android.js +1 -22
- package/ui/core/view/index.android.js.map +1 -1
- package/ui/core/view/index.ios.js +28 -12
- package/ui/core/view/index.ios.js.map +1 -1
- package/ui/core/view/view-common.d.ts +4 -0
- package/ui/core/view/view-common.js +26 -12
- package/ui/core/view/view-common.js.map +1 -1
- package/ui/core/view/view-helper/index.ios.d.ts +10 -0
- package/ui/core/view/view-helper/index.ios.js +99 -40
- package/ui/core/view/view-helper/index.ios.js.map +1 -1
- package/ui/frame/fragment.transitions.d.ts +0 -4
- package/ui/frame/frame-common.d.ts +2 -2
- package/ui/frame/frame-common.js.map +1 -1
- package/ui/frame/index.android.js +2 -4
- package/ui/frame/index.android.js.map +1 -1
- package/ui/frame/index.ios.js +58 -9
- package/ui/frame/index.ios.js.map +1 -1
- package/ui/index.d.ts +2 -0
- package/ui/index.js +2 -0
- package/ui/index.js.map +1 -1
- package/ui/page/index.ios.d.ts +4 -1
- package/ui/page/index.ios.js +81 -56
- package/ui/page/index.ios.js.map +1 -1
- package/ui/styling/background.ios.js +3 -0
- package/ui/styling/background.ios.js.map +1 -1
- package/ui/transition/fade-transition.d.ts +1 -3
- package/ui/transition/fade-transition.ios.d.ts +14 -1
- package/ui/transition/fade-transition.ios.js +60 -26
- package/ui/transition/fade-transition.ios.js.map +1 -1
- package/ui/transition/index.android.d.ts +0 -3
- package/ui/transition/index.android.js +0 -5
- package/ui/transition/index.android.js.map +1 -1
- package/ui/transition/index.d.ts +9 -9
- package/ui/transition/index.ios.d.ts +0 -3
- package/ui/transition/index.ios.js +0 -33
- package/ui/transition/index.ios.js.map +1 -1
- package/ui/transition/modal-transition.android.d.ts +3 -4
- package/ui/transition/modal-transition.android.js +4 -51
- package/ui/transition/modal-transition.android.js.map +1 -1
- package/ui/transition/modal-transition.ios.d.ts +6 -1
- package/ui/transition/modal-transition.ios.js +287 -79
- package/ui/transition/modal-transition.ios.js.map +1 -1
- package/ui/transition/page-transition.android.d.ts +4 -4
- package/ui/transition/page-transition.android.js +44 -33
- package/ui/transition/page-transition.android.js.map +1 -1
- package/ui/transition/page-transition.ios.d.ts +21 -1
- package/ui/transition/page-transition.ios.js +471 -181
- package/ui/transition/page-transition.ios.js.map +1 -1
- package/ui/transition/shared-transition.d.ts +80 -7
- package/ui/transition/shared-transition.js +37 -8
- package/ui/transition/shared-transition.js.map +1 -1
- package/ui/transition/slide-transition.android.d.ts +1 -1
- package/ui/transition/slide-transition.android.js +1 -1
- package/ui/transition/slide-transition.android.js.map +1 -1
- package/ui/transition/slide-transition.d.ts +1 -1
- package/ui/transition/slide-transition.ios.d.ts +15 -2
- package/ui/transition/slide-transition.ios.js +86 -52
- package/ui/transition/slide-transition.ios.js.map +1 -1
- package/utils/native-helper.d.ts +35 -0
- package/utils/native-helper.ios.d.ts +13 -0
- package/utils/native-helper.ios.js +73 -0
- package/utils/native-helper.ios.js.map +1 -1
- package/utils/number-utils.d.ts +10 -0
- package/utils/number-utils.js +12 -0
- package/utils/number-utils.js.map +1 -1
- package/ui/frame/fragment.transitions.ios.d.ts +0 -2
- package/ui/frame/fragment.transitions.ios.js +0 -71
- package/ui/frame/fragment.transitions.ios.js.map +0 -1
|
@@ -1,199 +1,489 @@
|
|
|
1
|
-
import { Transition
|
|
1
|
+
import { Transition } from '.';
|
|
2
2
|
import { Screen } from '../../platform';
|
|
3
|
-
import {
|
|
3
|
+
import { iOSNativeHelper } from '../../utils/native-helper';
|
|
4
|
+
import { isNumber } from '../../utils/types';
|
|
5
|
+
import { GestureStateTypes } from '../gestures';
|
|
6
|
+
import { SharedTransition, SharedTransitionAnimationType, DEFAULT_DURATION, DEFAULT_SPRING } from './shared-transition';
|
|
4
7
|
export class PageTransition extends Transition {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const state = SharedTransition.getState(this.id);
|
|
11
|
-
if (!state) {
|
|
12
|
-
return;
|
|
8
|
+
iosNavigatedController(navigationController, operation, fromVC, toVC) {
|
|
9
|
+
this.navigationController = navigationController;
|
|
10
|
+
if (!this.transitionController) {
|
|
11
|
+
this.presented = toVC;
|
|
12
|
+
this.presenting = fromVC;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
console.log('
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
iosMatchLayerProperties(sharedElementSnapshot, presentingSharedElement);
|
|
55
|
-
sharedElementSnapshot.clipsToBounds = true;
|
|
56
|
-
// console.log('---> snapshot: ', sharedElementSnapshot);
|
|
57
|
-
const startFrame = presentingSharedElement.convertRectToView(presentingSharedElement.bounds, transitionContext.containerView);
|
|
58
|
-
const endFrame = presentedSharedElement.convertRectToView(presentedSharedElement.bounds, transitionContext.containerView);
|
|
59
|
-
sharedElementSnapshot.frame = startFrame;
|
|
60
|
-
console.log('---> ', presentingView.sharedTransitionTag, ' frame:', iosPrintRect(sharedElementSnapshot.frame));
|
|
61
|
-
this.sharedElements.presenting.push({
|
|
62
|
-
view: presentingView,
|
|
63
|
-
startFrame,
|
|
64
|
-
endFrame,
|
|
65
|
-
snapshot: sharedElementSnapshot,
|
|
66
|
-
startOpacity: presentingView.opacity,
|
|
67
|
-
endOpacity: presentedView.opacity,
|
|
68
|
-
});
|
|
69
|
-
this.sharedElements.presented.push({
|
|
70
|
-
view: presentedView,
|
|
71
|
-
startFrame: endFrame,
|
|
72
|
-
endFrame: startFrame,
|
|
73
|
-
startOpacity: presentedView.opacity,
|
|
74
|
-
endOpacity: presentingView.opacity,
|
|
14
|
+
this.transitionController = PageTransitionController.initWithOwner(new WeakRef(this));
|
|
15
|
+
// console.log('iosNavigatedController presenting:', this.presenting);
|
|
16
|
+
this.operation = operation;
|
|
17
|
+
return this.transitionController;
|
|
18
|
+
}
|
|
19
|
+
iosInteractionDismiss(animator) {
|
|
20
|
+
// console.log('-- iosInteractionDismiss --');
|
|
21
|
+
this.interactiveController = PercentInteractiveController.initWithOwner(new WeakRef(this));
|
|
22
|
+
return this.interactiveController;
|
|
23
|
+
}
|
|
24
|
+
setupInteractiveGesture(startCallback, view) {
|
|
25
|
+
// console.log(' -- setupInteractiveGesture --');
|
|
26
|
+
this._interactiveStartCallback = startCallback;
|
|
27
|
+
if (!this._interactiveDismissGesture) {
|
|
28
|
+
// console.log('setup but tearing down first!');
|
|
29
|
+
view.off('pan', this._interactiveDismissGesture);
|
|
30
|
+
this._interactiveDismissGesture = this._interactiveDismissGestureHandler.bind(this);
|
|
31
|
+
}
|
|
32
|
+
view.on('pan', this._interactiveDismissGesture);
|
|
33
|
+
this._interactiveGestureTeardown = () => {
|
|
34
|
+
// console.log(`-- TEARDOWN setupInteractiveGesture --`);
|
|
35
|
+
view.off('pan', this._interactiveDismissGesture);
|
|
36
|
+
this._interactiveDismissGesture = null;
|
|
37
|
+
};
|
|
38
|
+
return this._interactiveGestureTeardown;
|
|
39
|
+
}
|
|
40
|
+
_interactiveDismissGestureHandler(args) {
|
|
41
|
+
if (args?.ios?.view) {
|
|
42
|
+
// console.log('this.id:', this.id);
|
|
43
|
+
const state = SharedTransition.getState(this.id);
|
|
44
|
+
const percent = state.interactive?.dismiss?.percentFormula ? state.interactive.dismiss.percentFormula(args) : args.deltaX / (args.ios.view.bounds.size.width / 2);
|
|
45
|
+
if (SharedTransition.DEBUG) {
|
|
46
|
+
console.log('Interactive dismissal percentage:', percent);
|
|
47
|
+
}
|
|
48
|
+
switch (args.state) {
|
|
49
|
+
case GestureStateTypes.began:
|
|
50
|
+
SharedTransition.updateState(this.id, {
|
|
51
|
+
interactiveBegan: true,
|
|
52
|
+
interactiveCancelled: false,
|
|
75
53
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const cleanupPresent = () => {
|
|
85
|
-
for (const presented of this.sharedElements.presented) {
|
|
86
|
-
presented.view.opacity = presented.startOpacity;
|
|
87
|
-
}
|
|
88
|
-
// TODO: Discuss with Igor whether this is necessary
|
|
89
|
-
// potential this could help smooth some shared element transitions
|
|
90
|
-
UIView.animateWithDurationAnimationsCompletion(0, // Igor: disabled for now, we'll talk about this and decide
|
|
91
|
-
() => {
|
|
92
|
-
for (const presenting of this.sharedElements.presenting) {
|
|
93
|
-
presenting.snapshot.alpha = presenting.endOpacity;
|
|
54
|
+
if (this._interactiveStartCallback) {
|
|
55
|
+
this._interactiveStartCallback();
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
case GestureStateTypes.changed:
|
|
59
|
+
if (percent < 1) {
|
|
60
|
+
if (this.interactiveController) {
|
|
61
|
+
this.interactiveController.updateInteractiveTransition(percent);
|
|
94
62
|
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
63
|
+
}
|
|
64
|
+
break;
|
|
65
|
+
case GestureStateTypes.cancelled:
|
|
66
|
+
case GestureStateTypes.ended:
|
|
67
|
+
if (this.interactiveController) {
|
|
68
|
+
const finishThreshold = isNumber(state.interactive?.dismiss?.finishThreshold) ? state.interactive.dismiss.finishThreshold : 0.5;
|
|
69
|
+
if (percent > finishThreshold) {
|
|
70
|
+
if (this._interactiveGestureTeardown) {
|
|
71
|
+
this._interactiveGestureTeardown();
|
|
72
|
+
this._interactiveGestureTeardown = null;
|
|
73
|
+
}
|
|
74
|
+
this.interactiveController.finishInteractiveTransition();
|
|
98
75
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const startWidth = typeof state.toPageStart?.width === 'number' ? state.toPageStart?.width : Screen.mainScreen.widthDIPs;
|
|
134
|
-
const startHeight = typeof state.toPageStart?.height === 'number' ? state.toPageStart?.height : Screen.mainScreen.heightDIPs;
|
|
135
|
-
this.presented.view.frame = CGRectMake(startX, startY, startWidth, startHeight);
|
|
136
|
-
UIView.animateWithDurationDelayUsingSpringWithDampingInitialSpringVelocityOptionsAnimationsCompletion(typeof state.toPageStart?.duration === 'number' ? state.toPageStart?.duration / 1000 : DEFAULT_DURATION, 0, 0.5, 3, 0 /* UIViewAnimationOptions.CurveEaseInOut */, () => {
|
|
137
|
-
// animate page properties to the following:
|
|
138
|
-
this.presented.view.alpha = typeof state.toPageEnd?.opacity === 'number' ? state.toPageEnd?.opacity : 1;
|
|
139
|
-
const endX = typeof state.toPageEnd?.x === 'number' ? state.toPageEnd?.x : 0;
|
|
140
|
-
const endY = typeof state.toPageEnd?.y === 'number' ? state.toPageEnd?.y : 0;
|
|
141
|
-
const endWidth = typeof state.toPageEnd?.width === 'number' ? state.toPageEnd?.width : Screen.mainScreen.widthDIPs;
|
|
142
|
-
const endHeight = typeof state.toPageEnd?.height === 'number' ? state.toPageEnd?.height : Screen.mainScreen.heightDIPs;
|
|
143
|
-
this.presented.view.frame = CGRectMake(endX, endY, endWidth, endHeight);
|
|
144
|
-
updateFramePresent();
|
|
145
|
-
}, () => {
|
|
146
|
-
cleanupPresent();
|
|
147
|
-
});
|
|
148
|
-
break;
|
|
76
|
+
else {
|
|
77
|
+
SharedTransition.updateState(this.id, {
|
|
78
|
+
interactiveCancelled: true,
|
|
79
|
+
});
|
|
80
|
+
this.interactiveController.cancelInteractiveTransition();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
var PercentInteractiveController = /** @class */ (function (_super) {
|
|
89
|
+
__extends(PercentInteractiveController, _super);
|
|
90
|
+
function PercentInteractiveController() {
|
|
91
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
92
|
+
_this.started = false;
|
|
93
|
+
_this.added = false;
|
|
94
|
+
return _this;
|
|
95
|
+
}
|
|
96
|
+
PercentInteractiveController.initWithOwner = function (owner) {
|
|
97
|
+
var ctrl = PercentInteractiveController.new();
|
|
98
|
+
ctrl.owner = owner;
|
|
99
|
+
return ctrl;
|
|
100
|
+
};
|
|
101
|
+
PercentInteractiveController.prototype.startInteractiveTransition = function (transitionContext) {
|
|
102
|
+
var _a;
|
|
103
|
+
// console.log('startInteractiveTransition');
|
|
104
|
+
this.transitionContext = transitionContext;
|
|
105
|
+
if (!this.started) {
|
|
106
|
+
this.started = true;
|
|
107
|
+
var owner = (_a = this.owner) === null || _a === void 0 ? void 0 : _a.deref();
|
|
108
|
+
if (owner) {
|
|
109
|
+
this.transitionContext.containerView.insertSubviewBelowSubview(owner.presenting.view, owner.presented.view);
|
|
149
110
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
for (
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
PercentInteractiveController.prototype.updateInteractiveTransition = function (percentComplete) {
|
|
114
|
+
var _a;
|
|
115
|
+
var owner = (_a = this.owner) === null || _a === void 0 ? void 0 : _a.deref();
|
|
116
|
+
if (owner) {
|
|
117
|
+
if (!this.added) {
|
|
118
|
+
this.added = true;
|
|
119
|
+
for (var _i = 0, _b = owner.sharedElements.presented; _i < _b.length; _i++) {
|
|
120
|
+
var p = _b[_i];
|
|
159
121
|
p.view.opacity = 0;
|
|
160
122
|
}
|
|
161
|
-
for (
|
|
123
|
+
for (var _c = 0, _d = owner.sharedElements.presenting; _c < _d.length; _c++) {
|
|
124
|
+
var p = _d[_c];
|
|
162
125
|
p.snapshot.alpha = p.endOpacity;
|
|
163
|
-
transitionContext.containerView.addSubview(p.snapshot);
|
|
126
|
+
this.transitionContext.containerView.addSubview(p.snapshot);
|
|
164
127
|
}
|
|
165
|
-
|
|
166
|
-
|
|
128
|
+
var state = SharedTransition.getState(owner.id);
|
|
129
|
+
var props_1 = state.fromPageEnd;
|
|
130
|
+
this.backgroundAnimation = UIViewPropertyAnimator.alloc().initWithDurationDampingRatioAnimations(1, 1, function () {
|
|
131
|
+
for (var _i = 0, _a = owner.sharedElements.presenting; _i < _a.length; _i++) {
|
|
132
|
+
var p = _a[_i];
|
|
133
|
+
p.snapshot.frame = p.startFrame;
|
|
134
|
+
iOSNativeHelper.copyLayerProperties(p.snapshot, p.view.ios);
|
|
135
|
+
p.snapshot.alpha = 1;
|
|
136
|
+
}
|
|
137
|
+
owner.presented.view.alpha = isNumber(props_1 === null || props_1 === void 0 ? void 0 : props_1.opacity) ? props_1 === null || props_1 === void 0 ? void 0 : props_1.opacity : 0;
|
|
138
|
+
var endX = isNumber(props_1 === null || props_1 === void 0 ? void 0 : props_1.x) ? props_1 === null || props_1 === void 0 ? void 0 : props_1.x : Screen.mainScreen.widthDIPs;
|
|
139
|
+
var endY = isNumber(props_1 === null || props_1 === void 0 ? void 0 : props_1.y) ? props_1 === null || props_1 === void 0 ? void 0 : props_1.y : 0;
|
|
140
|
+
var endWidth = isNumber(props_1 === null || props_1 === void 0 ? void 0 : props_1.width) ? props_1 === null || props_1 === void 0 ? void 0 : props_1.width : Screen.mainScreen.widthDIPs;
|
|
141
|
+
var endHeight = isNumber(props_1 === null || props_1 === void 0 ? void 0 : props_1.height) ? props_1 === null || props_1 === void 0 ? void 0 : props_1.height : Screen.mainScreen.heightDIPs;
|
|
142
|
+
owner.presented.view.frame = CGRectMake(endX, endY, endWidth, endHeight);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
this.backgroundAnimation.fractionComplete = percentComplete;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
PercentInteractiveController.prototype.cancelInteractiveTransition = function () {
|
|
149
|
+
var _this = this;
|
|
150
|
+
var _a, _b, _c;
|
|
151
|
+
// console.log('cancelInteractiveTransition');
|
|
152
|
+
var owner = (_a = this.owner) === null || _a === void 0 ? void 0 : _a.deref();
|
|
153
|
+
if (owner && this.added) {
|
|
154
|
+
var state = SharedTransition.getState(owner.id);
|
|
155
|
+
if (!state) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (this.backgroundAnimation) {
|
|
159
|
+
this.backgroundAnimation.reversed = true;
|
|
160
|
+
var duration = isNumber((_b = state.toPageStart) === null || _b === void 0 ? void 0 : _b.duration) ? ((_c = state.toPageStart) === null || _c === void 0 ? void 0 : _c.duration) / 1000 : 0.35;
|
|
161
|
+
this.backgroundAnimation.continueAnimationWithTimingParametersDurationFactor(null, duration);
|
|
162
|
+
setTimeout(function () {
|
|
163
|
+
for (var _i = 0, _a = owner.sharedElements.presented; _i < _a.length; _i++) {
|
|
164
|
+
var p = _a[_i];
|
|
165
|
+
p.view.opacity = 1;
|
|
166
|
+
}
|
|
167
|
+
for (var _b = 0, _c = owner.sharedElements.presenting; _b < _c.length; _b++) {
|
|
168
|
+
var p = _c[_b];
|
|
169
|
+
p.snapshot.removeFromSuperview();
|
|
170
|
+
}
|
|
171
|
+
owner.presented.view.alpha = 1;
|
|
172
|
+
_this.backgroundAnimation = null;
|
|
173
|
+
_this.added = false;
|
|
174
|
+
_this.transitionContext.cancelInteractiveTransition();
|
|
175
|
+
_this.transitionContext.completeTransition(false);
|
|
176
|
+
}, duration * 1000);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
PercentInteractiveController.prototype.finishInteractiveTransition = function () {
|
|
181
|
+
var _this = this;
|
|
182
|
+
var _a, _b, _c;
|
|
183
|
+
// console.log('finishInteractiveTransition');
|
|
184
|
+
var owner = (_a = this.owner) === null || _a === void 0 ? void 0 : _a.deref();
|
|
185
|
+
if (owner && this.added) {
|
|
186
|
+
if (this.backgroundAnimation) {
|
|
187
|
+
this.backgroundAnimation.reversed = false;
|
|
188
|
+
var state = SharedTransition.getState(owner.id);
|
|
189
|
+
if (!state) {
|
|
190
|
+
SharedTransition.finishState(owner.id);
|
|
191
|
+
this.transitionContext.completeTransition(true);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
var duration = isNumber((_b = state.fromPageEnd) === null || _b === void 0 ? void 0 : _b.duration) ? ((_c = state.fromPageEnd) === null || _c === void 0 ? void 0 : _c.duration) / 1000 : 0.35;
|
|
195
|
+
this.backgroundAnimation.continueAnimationWithTimingParametersDurationFactor(null, duration);
|
|
196
|
+
setTimeout(function () {
|
|
197
|
+
for (var _i = 0, _a = owner.sharedElements.presenting; _i < _a.length; _i++) {
|
|
198
|
+
var presenting = _a[_i];
|
|
167
199
|
presenting.view.opacity = presenting.startOpacity;
|
|
168
200
|
presenting.snapshot.removeFromSuperview();
|
|
169
201
|
}
|
|
170
|
-
SharedTransition.finishState(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
iosMatchLayerProperties(presenting.snapshot, presenting.view.ios);
|
|
177
|
-
presenting.snapshot.frame = presenting.startFrame;
|
|
178
|
-
presenting.snapshot.alpha = presenting.startOpacity;
|
|
179
|
-
console.log(`---> ${presenting.view.sharedTransitionTag} animate to: `, iosPrintRect(presenting.startFrame));
|
|
180
|
-
}
|
|
181
|
-
console.log(' ');
|
|
182
|
-
};
|
|
183
|
-
UIView.animateWithDurationDelayUsingSpringWithDampingInitialSpringVelocityOptionsAnimationsCompletion(typeof state.fromPageEnd?.duration === 'number' ? state.fromPageEnd?.duration / 1000 : DEFAULT_DURATION, 0, 0.5, 3, 0 /* UIViewAnimationOptions.CurveEaseInOut */, () => {
|
|
184
|
-
this.presented.view.alpha = typeof state.fromPageEnd?.opacity === 'number' ? state.fromPageEnd?.opacity : 0;
|
|
185
|
-
const endX = typeof state.fromPageEnd?.x === 'number' ? state.fromPageEnd?.x : Screen.mainScreen.widthDIPs;
|
|
186
|
-
const endY = typeof state.fromPageEnd?.y === 'number' ? state.fromPageEnd?.y : 0;
|
|
187
|
-
const endWidth = typeof state.fromPageEnd?.width === 'number' ? state.fromPageEnd?.width : Screen.mainScreen.widthDIPs;
|
|
188
|
-
const endHeight = typeof state.fromPageEnd?.height === 'number' ? state.fromPageEnd?.height : Screen.mainScreen.heightDIPs;
|
|
189
|
-
this.presented.view.frame = CGRectMake(endX, endY, endWidth, endHeight);
|
|
190
|
-
updateFrameDismiss();
|
|
191
|
-
}, () => {
|
|
192
|
-
cleanupDismiss();
|
|
193
|
-
});
|
|
194
|
-
break;
|
|
202
|
+
SharedTransition.finishState(owner.id);
|
|
203
|
+
_this.backgroundAnimation = null;
|
|
204
|
+
_this.added = false;
|
|
205
|
+
_this.transitionContext.finishInteractiveTransition();
|
|
206
|
+
_this.transitionContext.completeTransition(true);
|
|
207
|
+
}, duration * 1000);
|
|
195
208
|
}
|
|
196
209
|
}
|
|
210
|
+
};
|
|
211
|
+
PercentInteractiveController.ObjCProtocols = [UIViewControllerInteractiveTransitioning];
|
|
212
|
+
return PercentInteractiveController;
|
|
213
|
+
}(UIPercentDrivenInteractiveTransition));
|
|
214
|
+
var PageTransitionController = /** @class */ (function (_super) {
|
|
215
|
+
__extends(PageTransitionController, _super);
|
|
216
|
+
function PageTransitionController() {
|
|
217
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
197
218
|
}
|
|
198
|
-
|
|
219
|
+
PageTransitionController.initWithOwner = function (owner) {
|
|
220
|
+
var ctrl = PageTransitionController.new();
|
|
221
|
+
ctrl.owner = owner;
|
|
222
|
+
return ctrl;
|
|
223
|
+
};
|
|
224
|
+
PageTransitionController.prototype.transitionDuration = function (transitionContext) {
|
|
225
|
+
var owner = this.owner.deref();
|
|
226
|
+
if (owner) {
|
|
227
|
+
return owner.getDuration();
|
|
228
|
+
}
|
|
229
|
+
return DEFAULT_DURATION;
|
|
230
|
+
};
|
|
231
|
+
PageTransitionController.prototype.animateTransition = function (transitionContext) {
|
|
232
|
+
var owner = this.owner.deref();
|
|
233
|
+
if (owner) {
|
|
234
|
+
// console.log('--- PageTransitionController animateTransition');
|
|
235
|
+
// console.log('owner.presented:', owner.presented);
|
|
236
|
+
// console.log('owner.presenting:', owner.presenting);
|
|
237
|
+
// console.log('owner.id:', owner.id);
|
|
238
|
+
var state_1 = SharedTransition.getState(owner.id);
|
|
239
|
+
if (!state_1) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
// console.log('state.activeType:', state.activeType);
|
|
243
|
+
// console.log('operation:', owner.operation);
|
|
244
|
+
// switch (state.activeType) {
|
|
245
|
+
switch (owner.operation) {
|
|
246
|
+
case UINavigationControllerOperation.Push: {
|
|
247
|
+
// console.log('pushing!!');
|
|
248
|
+
// this.presented = toViewCtrl;
|
|
249
|
+
// this.presenting = fromViewCtrl;
|
|
250
|
+
transitionContext.containerView.insertSubviewAboveSubview(owner.presented.view, owner.presenting.view);
|
|
251
|
+
owner.presented.view.layoutIfNeeded();
|
|
252
|
+
var _a = SharedTransition.getSharedElements(state_1.page, state_1.toPage), sharedElements = _a.sharedElements, presented = _a.presented;
|
|
253
|
+
if (SharedTransition.DEBUG) {
|
|
254
|
+
console.log(' PageTransition: Push');
|
|
255
|
+
console.log("1. Found sharedTransitionTags to animate:", sharedElements.map(function (v) { return v.sharedTransitionTag; }));
|
|
256
|
+
console.log("2. Take snapshots of shared elements and position them based on presenting view:");
|
|
257
|
+
}
|
|
258
|
+
var _loop_1 = function (presentingView) {
|
|
259
|
+
if (!owner.sharedElements) {
|
|
260
|
+
owner.sharedElements = {
|
|
261
|
+
presented: [],
|
|
262
|
+
presenting: [],
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
var presentingSharedElement = presentingView.ios;
|
|
266
|
+
// 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
|
|
267
|
+
// Note: snapshot may be most efficient/simple
|
|
268
|
+
// console.log('---> ', presentingView.sharedTransitionTag, ': ', presentingSharedElement)
|
|
269
|
+
var presentedView = presented.find(function (v) { return v.sharedTransitionTag === presentingView.sharedTransitionTag; });
|
|
270
|
+
var presentedSharedElement = presentedView.ios;
|
|
271
|
+
var sharedElementSnapshot = UIImageView.alloc().init(); // WithImage(snapshotView(presentedSharedElement));
|
|
272
|
+
// treat images differently...
|
|
273
|
+
if (presentedSharedElement instanceof UIImageView) {
|
|
274
|
+
// in case the image is loaded async, we need to update the snapshot when it changes
|
|
275
|
+
// todo: remove listener on transition end
|
|
276
|
+
presentedView.on('imageSourceChange', function () {
|
|
277
|
+
sharedElementSnapshot.image = iOSNativeHelper.snapshotView(presentedSharedElement, Screen.mainScreen.scale);
|
|
278
|
+
sharedElementSnapshot.tintColor = presentedSharedElement.tintColor;
|
|
279
|
+
});
|
|
280
|
+
sharedElementSnapshot.tintColor = presentedSharedElement.tintColor;
|
|
281
|
+
sharedElementSnapshot.contentMode = presentedSharedElement.contentMode;
|
|
282
|
+
}
|
|
283
|
+
iOSNativeHelper.copyLayerProperties(sharedElementSnapshot, presentingSharedElement);
|
|
284
|
+
sharedElementSnapshot.clipsToBounds = true;
|
|
285
|
+
// console.log('---> snapshot: ', sharedElementSnapshot);
|
|
286
|
+
var startFrame = presentingSharedElement.convertRectToView(presentingSharedElement.bounds, transitionContext.containerView);
|
|
287
|
+
var endFrame = presentedSharedElement.convertRectToView(presentedSharedElement.bounds, transitionContext.containerView);
|
|
288
|
+
sharedElementSnapshot.frame = startFrame;
|
|
289
|
+
if (SharedTransition.DEBUG) {
|
|
290
|
+
console.log('---> ', presentingView.sharedTransitionTag, ' frame:', iOSNativeHelper.printCGRect(sharedElementSnapshot.frame));
|
|
291
|
+
}
|
|
292
|
+
owner.sharedElements.presenting.push({
|
|
293
|
+
view: presentingView,
|
|
294
|
+
startFrame: startFrame,
|
|
295
|
+
endFrame: endFrame,
|
|
296
|
+
snapshot: sharedElementSnapshot,
|
|
297
|
+
startOpacity: presentingView.opacity,
|
|
298
|
+
endOpacity: presentedView.opacity,
|
|
299
|
+
});
|
|
300
|
+
owner.sharedElements.presented.push({
|
|
301
|
+
view: presentedView,
|
|
302
|
+
startFrame: endFrame,
|
|
303
|
+
endFrame: startFrame,
|
|
304
|
+
startOpacity: presentedView.opacity,
|
|
305
|
+
endOpacity: presentingView.opacity,
|
|
306
|
+
});
|
|
307
|
+
// set initial opacity to match the source view opacity
|
|
308
|
+
sharedElementSnapshot.alpha = presentingView.opacity;
|
|
309
|
+
// hide both while animating within the transition context
|
|
310
|
+
presentingView.opacity = 0;
|
|
311
|
+
presentedView.opacity = 0;
|
|
312
|
+
// add snapshot to animate
|
|
313
|
+
transitionContext.containerView.addSubview(sharedElementSnapshot);
|
|
314
|
+
};
|
|
315
|
+
for (var _i = 0, sharedElements_1 = sharedElements; _i < sharedElements_1.length; _i++) {
|
|
316
|
+
var presentingView = sharedElements_1[_i];
|
|
317
|
+
_loop_1(presentingView);
|
|
318
|
+
}
|
|
319
|
+
var cleanupPresent_1 = function () {
|
|
320
|
+
for (var _i = 0, _a = owner.sharedElements.presented; _i < _a.length; _i++) {
|
|
321
|
+
var presented_1 = _a[_i];
|
|
322
|
+
presented_1.view.opacity = presented_1.startOpacity;
|
|
323
|
+
}
|
|
324
|
+
for (var _b = 0, _c = owner.sharedElements.presenting; _b < _c.length; _b++) {
|
|
325
|
+
var presenting = _c[_b];
|
|
326
|
+
presenting.snapshot.removeFromSuperview();
|
|
327
|
+
}
|
|
328
|
+
SharedTransition.updateState(owner.id, {
|
|
329
|
+
activeType: SharedTransitionAnimationType.dismiss,
|
|
330
|
+
});
|
|
331
|
+
owner.presenting.view.removeFromSuperview();
|
|
332
|
+
transitionContext.completeTransition(true);
|
|
333
|
+
};
|
|
334
|
+
var updateFramePresent_1 = function () {
|
|
335
|
+
// https://stackoverflow.com/a/27997678/1418981
|
|
336
|
+
// In order to have proper layout. Seems mostly needed when presenting.
|
|
337
|
+
// For instance during presentation, destination view doesn't account navigation bar height.
|
|
338
|
+
// Not sure if best to leave all the time?
|
|
339
|
+
// owner.presented.view.setNeedsLayout();
|
|
340
|
+
// owner.presented.view.layoutIfNeeded();
|
|
341
|
+
if (SharedTransition.DEBUG) {
|
|
342
|
+
console.log('3. Animating shared elements:');
|
|
343
|
+
}
|
|
344
|
+
var _loop_2 = function (presented_2) {
|
|
345
|
+
var presentingMatch = owner.sharedElements.presenting.find(function (v) { return v.view.sharedTransitionTag === presented_2.view.sharedTransitionTag; });
|
|
346
|
+
// Workaround wrong origin due ongoing layout process.
|
|
347
|
+
var updatedEndFrame = presented_2.view.ios.convertRectToView(presented_2.view.ios.bounds, transitionContext.containerView);
|
|
348
|
+
var correctedEndFrame = CGRectMake(updatedEndFrame.origin.x, updatedEndFrame.origin.y, presentingMatch.endFrame.size.width, presentingMatch.endFrame.size.height);
|
|
349
|
+
presentingMatch.snapshot.frame = correctedEndFrame;
|
|
350
|
+
// apply view and layer properties to the snapshot view to match the source/presented view
|
|
351
|
+
iOSNativeHelper.copyLayerProperties(presentingMatch.snapshot, presented_2.view.ios);
|
|
352
|
+
// create a snapshot of the presented view
|
|
353
|
+
presentingMatch.snapshot.image = iOSNativeHelper.snapshotView(presented_2.view.ios, Screen.mainScreen.scale);
|
|
354
|
+
// apply correct alpha
|
|
355
|
+
presentingMatch.snapshot.alpha = presentingMatch.endOpacity;
|
|
356
|
+
if (SharedTransition.DEBUG) {
|
|
357
|
+
console.log("---> ".concat(presentingMatch.view.sharedTransitionTag, " animate to: "), iOSNativeHelper.printCGRect(correctedEndFrame));
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
for (var _i = 0, _a = owner.sharedElements.presented; _i < _a.length; _i++) {
|
|
361
|
+
var presented_2 = _a[_i];
|
|
362
|
+
_loop_2(presented_2);
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
// starting page properties
|
|
366
|
+
var toProps = state_1.toPageStart;
|
|
367
|
+
owner.presented.view.alpha = isNumber(toProps === null || toProps === void 0 ? void 0 : toProps.opacity) ? toProps === null || toProps === void 0 ? void 0 : toProps.opacity : 0;
|
|
368
|
+
var startX = isNumber(toProps === null || toProps === void 0 ? void 0 : toProps.x) ? toProps === null || toProps === void 0 ? void 0 : toProps.x : Screen.mainScreen.widthDIPs;
|
|
369
|
+
var startY = isNumber(toProps === null || toProps === void 0 ? void 0 : toProps.y) ? toProps === null || toProps === void 0 ? void 0 : toProps.y : 0;
|
|
370
|
+
var startWidth = isNumber(toProps === null || toProps === void 0 ? void 0 : toProps.width) ? toProps === null || toProps === void 0 ? void 0 : toProps.width : Screen.mainScreen.widthDIPs;
|
|
371
|
+
var startHeight = isNumber(toProps === null || toProps === void 0 ? void 0 : toProps.height) ? toProps === null || toProps === void 0 ? void 0 : toProps.height : Screen.mainScreen.heightDIPs;
|
|
372
|
+
owner.presented.view.frame = CGRectMake(startX, startY, startWidth, startHeight);
|
|
373
|
+
var animateProperties_1 = function () {
|
|
374
|
+
var props = state_1.toPageEnd;
|
|
375
|
+
// animate page properties to the following:
|
|
376
|
+
owner.presented.view.alpha = isNumber(props === null || props === void 0 ? void 0 : props.opacity) ? props === null || props === void 0 ? void 0 : props.opacity : 1;
|
|
377
|
+
var endX = isNumber(props === null || props === void 0 ? void 0 : props.x) ? props === null || props === void 0 ? void 0 : props.x : 0;
|
|
378
|
+
var endY = isNumber(props === null || props === void 0 ? void 0 : props.y) ? props === null || props === void 0 ? void 0 : props.y : 0;
|
|
379
|
+
var endWidth = isNumber(props === null || props === void 0 ? void 0 : props.width) ? props === null || props === void 0 ? void 0 : props.width : Screen.mainScreen.widthDIPs;
|
|
380
|
+
var endHeight = isNumber(props === null || props === void 0 ? void 0 : props.height) ? props === null || props === void 0 ? void 0 : props.height : Screen.mainScreen.heightDIPs;
|
|
381
|
+
owner.presented.view.frame = CGRectMake(endX, endY, endWidth, endHeight);
|
|
382
|
+
};
|
|
383
|
+
if (isNumber(toProps === null || toProps === void 0 ? void 0 : toProps.duration)) {
|
|
384
|
+
// override spring and use only linear animation
|
|
385
|
+
UIView.animateWithDurationAnimationsCompletion((toProps === null || toProps === void 0 ? void 0 : toProps.duration) / 1000, function () {
|
|
386
|
+
animateProperties_1();
|
|
387
|
+
updateFramePresent_1();
|
|
388
|
+
}, function () {
|
|
389
|
+
cleanupPresent_1();
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
var spring = toProps === null || toProps === void 0 ? void 0 : toProps.spring;
|
|
394
|
+
iOSNativeHelper.animateWithSpring({
|
|
395
|
+
tension: isNumber(spring === null || spring === void 0 ? void 0 : spring.tension) ? spring === null || spring === void 0 ? void 0 : spring.tension : DEFAULT_SPRING.tension,
|
|
396
|
+
friction: isNumber(spring === null || spring === void 0 ? void 0 : spring.friction) ? spring === null || spring === void 0 ? void 0 : spring.tension : DEFAULT_SPRING.friction,
|
|
397
|
+
animations: function () {
|
|
398
|
+
animateProperties_1();
|
|
399
|
+
updateFramePresent_1();
|
|
400
|
+
},
|
|
401
|
+
completion: function () {
|
|
402
|
+
cleanupPresent_1();
|
|
403
|
+
},
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
break;
|
|
407
|
+
}
|
|
408
|
+
case UINavigationControllerOperation.Pop: {
|
|
409
|
+
// console.log('popping!');
|
|
410
|
+
transitionContext.containerView.insertSubviewBelowSubview(owner.presenting.view, owner.presented.view);
|
|
411
|
+
// console.log('transitionContext.containerView.subviews.count:', transitionContext.containerView.subviews.count);
|
|
412
|
+
if (SharedTransition.DEBUG) {
|
|
413
|
+
console.log(' PageTransition: Pop');
|
|
414
|
+
console.log("1. Dismiss sharedTransitionTags to animate:", owner.sharedElements.presented.map(function (p) { return p.view.sharedTransitionTag; }));
|
|
415
|
+
console.log("2. Add back previously stored sharedElements to dismiss:");
|
|
416
|
+
}
|
|
417
|
+
for (var _b = 0, _c = owner.sharedElements.presented; _b < _c.length; _b++) {
|
|
418
|
+
var p = _c[_b];
|
|
419
|
+
p.view.opacity = 0;
|
|
420
|
+
}
|
|
421
|
+
for (var _d = 0, _e = owner.sharedElements.presenting; _d < _e.length; _d++) {
|
|
422
|
+
var p = _e[_d];
|
|
423
|
+
p.snapshot.alpha = p.endOpacity;
|
|
424
|
+
transitionContext.containerView.addSubview(p.snapshot);
|
|
425
|
+
}
|
|
426
|
+
var cleanupDismiss_1 = function () {
|
|
427
|
+
for (var _i = 0, _a = owner.sharedElements.presenting; _i < _a.length; _i++) {
|
|
428
|
+
var presenting = _a[_i];
|
|
429
|
+
presenting.view.opacity = presenting.startOpacity;
|
|
430
|
+
presenting.snapshot.removeFromSuperview();
|
|
431
|
+
}
|
|
432
|
+
SharedTransition.finishState(owner.id);
|
|
433
|
+
transitionContext.completeTransition(true);
|
|
434
|
+
};
|
|
435
|
+
var updateFrameDismiss_1 = function () {
|
|
436
|
+
if (SharedTransition.DEBUG) {
|
|
437
|
+
console.log('3. Dismissing shared elements:');
|
|
438
|
+
}
|
|
439
|
+
for (var _i = 0, _a = owner.sharedElements.presenting; _i < _a.length; _i++) {
|
|
440
|
+
var presenting = _a[_i];
|
|
441
|
+
iOSNativeHelper.copyLayerProperties(presenting.snapshot, presenting.view.ios);
|
|
442
|
+
presenting.snapshot.frame = presenting.startFrame;
|
|
443
|
+
presenting.snapshot.alpha = presenting.startOpacity;
|
|
444
|
+
if (SharedTransition.DEBUG) {
|
|
445
|
+
console.log("---> ".concat(presenting.view.sharedTransitionTag, " animate to: "), iOSNativeHelper.printCGRect(presenting.startFrame));
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
var props_1 = state_1.fromPageEnd;
|
|
450
|
+
var animateProperties_2 = function () {
|
|
451
|
+
owner.presented.view.alpha = isNumber(props_1 === null || props_1 === void 0 ? void 0 : props_1.opacity) ? props_1 === null || props_1 === void 0 ? void 0 : props_1.opacity : 0;
|
|
452
|
+
var endX = isNumber(props_1 === null || props_1 === void 0 ? void 0 : props_1.x) ? props_1 === null || props_1 === void 0 ? void 0 : props_1.x : Screen.mainScreen.widthDIPs;
|
|
453
|
+
var endY = isNumber(props_1 === null || props_1 === void 0 ? void 0 : props_1.y) ? props_1 === null || props_1 === void 0 ? void 0 : props_1.y : 0;
|
|
454
|
+
var endWidth = isNumber(props_1 === null || props_1 === void 0 ? void 0 : props_1.width) ? props_1 === null || props_1 === void 0 ? void 0 : props_1.width : Screen.mainScreen.widthDIPs;
|
|
455
|
+
var endHeight = isNumber(props_1 === null || props_1 === void 0 ? void 0 : props_1.height) ? props_1 === null || props_1 === void 0 ? void 0 : props_1.height : Screen.mainScreen.heightDIPs;
|
|
456
|
+
owner.presented.view.frame = CGRectMake(endX, endY, endWidth, endHeight);
|
|
457
|
+
};
|
|
458
|
+
if (isNumber(props_1 === null || props_1 === void 0 ? void 0 : props_1.duration)) {
|
|
459
|
+
// override spring and use only linear animation
|
|
460
|
+
UIView.animateWithDurationAnimationsCompletion((props_1 === null || props_1 === void 0 ? void 0 : props_1.duration) / 1000, function () {
|
|
461
|
+
animateProperties_2();
|
|
462
|
+
updateFrameDismiss_1();
|
|
463
|
+
}, function () {
|
|
464
|
+
cleanupDismiss_1();
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
else {
|
|
468
|
+
var spring = props_1 === null || props_1 === void 0 ? void 0 : props_1.spring;
|
|
469
|
+
iOSNativeHelper.animateWithSpring({
|
|
470
|
+
tension: isNumber(spring === null || spring === void 0 ? void 0 : spring.tension) ? spring === null || spring === void 0 ? void 0 : spring.tension : DEFAULT_SPRING.tension,
|
|
471
|
+
friction: isNumber(spring === null || spring === void 0 ? void 0 : spring.friction) ? spring === null || spring === void 0 ? void 0 : spring.tension : DEFAULT_SPRING.friction,
|
|
472
|
+
animations: function () {
|
|
473
|
+
animateProperties_2();
|
|
474
|
+
updateFrameDismiss_1();
|
|
475
|
+
},
|
|
476
|
+
completion: function () {
|
|
477
|
+
cleanupDismiss_1();
|
|
478
|
+
},
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
break;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
PageTransitionController.ObjCProtocols = [UIViewControllerAnimatedTransitioning];
|
|
487
|
+
return PageTransitionController;
|
|
488
|
+
}(NSObject));
|
|
199
489
|
//# sourceMappingURL=page-transition.ios.js.map
|