20
20
21
21
@implementation MDMViewControllerTransitionContext {
22
22
id <UIViewControllerContextTransitioning> _transitionContext;
23
+ UIPercentDrivenInteractiveTransition *_percent;
23
24
}
24
25
25
26
@synthesize direction = _direction;
26
27
@synthesize sourceViewController = _sourceViewController;
27
28
@synthesize backViewController = _backViewController;
28
29
@synthesize foreViewController = _foreViewController;
29
30
@synthesize presentationController = _presentationController;
30
-
31
+ @synthesize wasCancelled = _wasCancelled;
31
32
- (nonnull instancetype )initWithTransition : (nonnull id <MDMTransition>)transition
32
33
direction : (MDMTransitionDirection)direction
33
34
sourceViewController : (nullable UIViewController *)sourceViewController
@@ -44,6 +45,7 @@ - (nonnull instancetype)initWithTransition:(nonnull id<MDMTransition>)transition
44
45
_presentationController = presentationController;
45
46
46
47
_transition = [self fallbackForTransition: _transition];
48
+ _percent = [[UIPercentDrivenInteractiveTransition alloc ] init ];
47
49
}
48
50
if (!_transition) {
49
51
return nil ;
@@ -82,7 +84,14 @@ - (UIView *)containerView {
82
84
}
83
85
84
86
- (void )transitionDidEnd {
85
- [_transitionContext completeTransition: true ];
87
+ BOOL wasCanceled = [_transitionContext transitionWasCancelled ];
88
+ if (wasCanceled) {
89
+ _wasCancelled = false ;
90
+ [_transitionContext completeTransition: false ];
91
+ } else {
92
+ _wasCancelled = true ;
93
+ [_transitionContext completeTransition: true ];
94
+ }
86
95
87
96
_transition = nil ;
88
97
@@ -173,4 +182,20 @@ - (void)anticipateOnlyExplicitAnimations {
173
182
return transition;
174
183
}
175
184
185
+ - (UIPercentDrivenInteractiveTransition *_Nonnull)getPercentIT {
186
+ return _percent;
187
+ }
188
+
189
+ - (void )updatePercent : (CGFloat )percent {
190
+ [_percent updateInteractiveTransition: percent];
191
+ }
192
+
193
+ - (void )finishInteractiveTransition {
194
+ [_percent finishInteractiveTransition ];
195
+ }
196
+
197
+ - (void )cancelInteractiveTransition {
198
+ [_percent cancelInteractiveTransition ];
199
+ }
200
+
176
201
@end
0 commit comments