Browse Source

Properly pin the mini player to above the tab bar

Samuel Giddins 6 years ago
parent
commit
6b74f73932

+ 1 - 0
Sources/Coordinators/AppCoordinator.swift

@@ -44,6 +44,7 @@ class Services: NSObject {
         viewController.addChildViewController(playerController)
         viewController.view.addSubview(playerController.view)
         playerController.view.layoutMargins = UIEdgeInsets(top: 0, left: 0, bottom: tabBarController.tabBar.frame.size.height, right: 0)
+        playerController.realBottomAnchor = tabBarController.tabBar.topAnchor
         playerController.didMove(toParentViewController: viewController)
     }
 

+ 1 - 0
Sources/VLCPlayerDisplayController.h

@@ -33,6 +33,7 @@ typedef NS_ENUM(NSUInteger, VLCPlayerDisplayControllerDisplayMode) {
 
 @property (nonatomic, assign) VLCPlayerDisplayControllerDisplayMode displayMode;
 @property (nonatomic, weak) VLCPlaybackController *playbackController;
+@property (nonatomic, strong) NSLayoutYAxisAnchor *realBottomAnchor;
 
 - (instancetype)init NS_UNAVAILABLE;
 - (instancetype)initWithNibName:(NSString *)nibNameOrNil

+ 7 - 1
Sources/VLCPlayerDisplayController.m

@@ -318,7 +318,13 @@ static NSString *const VLCPlayerDisplayControllerDisplayModeKey = @"VLCPlayerDis
                               delay:animationDuration
                             options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionAllowUserInteraction
                          animations:^{
-                             self.bottomConstraint.constant = needsHide ? 0 : -self->_miniPlaybackView.frame.size.height -self.view.layoutMargins.bottom;
+                             self.bottomConstraint.active = NO;
+                             if (needsShow) {
+                                 self.bottomConstraint = [miniPlaybackView.bottomAnchor constraintEqualToAnchor:self.realBottomAnchor];
+                             } else {
+                                 self.bottomConstraint = [miniPlaybackView.topAnchor constraintEqualToAnchor:self.bottomLayoutGuide.bottomAnchor];
+                             }
+                             self.bottomConstraint.active = YES;
                              [self.view layoutIfNeeded];
                          }
                          completion:completionBlock];