浏览代码

fix info VC appearance animations
implement manual swipe down detection in addition to up arrow press to show info VC
only allow menu tap gesture recognizer to begin if currently scrubbing (removes the need for manual dismissal)

Tobias Conradi 9 年之前
父节点
当前提交
1c3372f63e

+ 21 - 14
VLC for Apple TV/VLCFullscreenMovieTVViewController.m

@@ -13,7 +13,7 @@
 #import "VLCPlaybackInfoTVViewController.h"
 #import "VLCPlaybackInfoTVViewController.h"
 
 
 
 
-@interface VLCFullscreenMovieTVViewController (UIViewControllerTransitioningDelegate) <UIViewControllerTransitioningDelegate>
+@interface VLCFullscreenMovieTVViewController (UIViewControllerTransitioningDelegate) <UIViewControllerTransitioningDelegate, UIGestureRecognizerDelegate>
 @end
 @end
 
 
 @interface VLCFullscreenMovieTVViewController ()
 @interface VLCFullscreenMovieTVViewController ()
@@ -60,15 +60,6 @@
 
 
     // Panning and Swiping
     // Panning and Swiping
 
 
-    // does not work with pan gesture
-//    UISwipeGestureRecognizer *swipeDownRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeDownRecognized:)];
-//    swipeDownRecognizer.direction = UISwipeGestureRecognizerDirectionDown;
-//    [self.view addGestureRecognizer:swipeDownRecognizer];
-
-    UITapGestureRecognizer *swipeDownRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(swipeDownRecognized:)];
-    swipeDownRecognizer.allowedPressTypes = @[@(UIPressTypeUpArrow)];
-    [self.view addGestureRecognizer:swipeDownRecognizer];
-
     UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGesture:)];
     UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGesture:)];
     [self.view addGestureRecognizer:panGestureRecognizer];
     [self.view addGestureRecognizer:panGestureRecognizer];
 
 
@@ -83,7 +74,13 @@
 
 
     UITapGestureRecognizer *menuTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(menuButtonPressed:)];
     UITapGestureRecognizer *menuTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(menuButtonPressed:)];
     menuTapGestureRecognizer.allowedPressTypes = @[@(UIPressTypeMenu)];
     menuTapGestureRecognizer.allowedPressTypes = @[@(UIPressTypeMenu)];
+    menuTapGestureRecognizer.delegate = self;
     [self.view addGestureRecognizer:menuTapGestureRecognizer];
     [self.view addGestureRecognizer:menuTapGestureRecognizer];
+
+    UITapGestureRecognizer *upArrowRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showInfoVCIfNotScrubbing)];
+    upArrowRecognizer.allowedPressTypes = @[@(UIPressTypeUpArrow)];
+    [self.view addGestureRecognizer:upArrowRecognizer];
+
 }
 }
 
 
 #pragma mark - view events
 #pragma mark - view events
@@ -147,8 +144,11 @@
     CGPoint translation = [panGestureRecognizer translationInView:view];
     CGPoint translation = [panGestureRecognizer translationInView:view];
 
 
     if (!bar.scrubbing) {
     if (!bar.scrubbing) {
-        if (ABS(translation.x) > 100.0) {
+        if (ABS(translation.x) > 150.0) {
             [self startScrubbing];
             [self startScrubbing];
+        } else if (translation.y > 200.0) {
+            [self showInfoVCIfNotScrubbing];
+            return;
         } else {
         } else {
             return;
             return;
         }
         }
@@ -184,12 +184,10 @@
         }];
         }];
         [self updateTimeLabelsForScrubbingFraction:bar.playbackFraction];
         [self updateTimeLabelsForScrubbingFraction:bar.playbackFraction];
         [self stopScrubbing];
         [self stopScrubbing];
-    } else {
-        [self dismissViewControllerAnimated:YES completion:nil];
     }
     }
 }
 }
 
 
-- (void)swipeDownRecognized:(UITapGestureRecognizer *)recognizer
+- (void)showInfoVCIfNotScrubbing
 {
 {
     if (self.transportBar.scrubbing) {
     if (self.transportBar.scrubbing) {
         return;
         return;
@@ -312,6 +310,15 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
     transportBar.playbackFraction = mediaPlayer.position;
     transportBar.playbackFraction = mediaPlayer.position;
 }
 }
 
 
+#pragma mark - gesture recognizer delegate
+
+- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
+    if ([gestureRecognizer.allowedPressTypes containsObject:@(UIPressTypeMenu)]) {
+        return self.transportBar.scrubbing;
+    }
+    return YES;
+}
+
 @end
 @end
 
 
 
 

+ 2 - 0
VLC for Apple TV/VLCPlaybackInfoTVViewController.m

@@ -96,6 +96,7 @@
     }
     }
 
 
     infoVC.view.frame = fromFrame;
     infoVC.view.frame = fromFrame;
+    [infoVC.view layoutIfNeeded];
 
 
     // fallback
     // fallback
     if (!infoVC) {
     if (!infoVC) {
@@ -105,6 +106,7 @@
     [UIView animateWithDuration:[self transitionDuration:transitionContext]
     [UIView animateWithDuration:[self transitionDuration:transitionContext]
                      animations:^{
                      animations:^{
                          infoVC.view.frame = toFrame;
                          infoVC.view.frame = toFrame;
+                         [infoVC.view layoutIfNeeded];
                          infoVC.dimmingView.alpha = targetAlpha;
                          infoVC.dimmingView.alpha = targetAlpha;
                      }
                      }
                      completion:^(BOOL finished) {
                      completion:^(BOOL finished) {