mirror of
				https://github.com/SoPat712/YTLitePlus.git
				synced 2025-10-30 20:34:03 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			49 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
| //
 | |
| //  BottomSheetTransition.swift
 | |
| //  Alderis
 | |
| //
 | |
| //  Created by Adam Demasi on 20/9/20.
 | |
| //  Copyright © 2020 HASHBANG Productions. All rights reserved.
 | |
| //
 | |
| 
 | |
| import UIKit
 | |
| 
 | |
| internal class BottomSheetTransitioningDelegate: NSObject, UIViewControllerTransitioningDelegate {
 | |
| 
 | |
| 	func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
 | |
| 		return BottomSheetTransition(direction: true)
 | |
| 	}
 | |
| 
 | |
| 	func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
 | |
| 		return BottomSheetTransition(direction: false)
 | |
| 	}
 | |
| 
 | |
| }
 | |
| 
 | |
| internal class BottomSheetTransition: NSObject, UIViewControllerAnimatedTransitioning {
 | |
| 
 | |
| 	// Opening: true
 | |
| 	// Closing: false
 | |
| 	let direction: Bool
 | |
| 
 | |
| 	init(direction: Bool) {
 | |
| 		self.direction = direction
 | |
| 	}
 | |
| 
 | |
| 	func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
 | |
| 		0.4
 | |
| 	}
 | |
| 
 | |
| 	func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
 | |
| 		if direction {
 | |
| 			let to = transitionContext.viewController(forKey: .to)!
 | |
| 			transitionContext.containerView.addSubview(to.view)
 | |
| 		}
 | |
| 
 | |
| 		Timer.scheduledTimer(withTimeInterval: transitionDuration(using: transitionContext), repeats: false) { _ in
 | |
| 			transitionContext.completeTransition(true)
 | |
| 		}
 | |
| 	}
 | |
| 
 | |
| }
 | 
