Giter Club home page Giter Club logo

musicplayertransition's Introduction

MusicPlayerTransition

Swift 5.0 Platforms iOS Xcode 10.2+

capture

Custom interactive transition like Apple Music iOS App. written in Swift.

Demo

See demo on Appetize.io

Using Transition Animator

This sample have created as a showcase of ARNTransitionAnimator.

ARNTransitionAnimator

Requirements

  • iOS 10.0+
  • Swift 5.0+
  • Xcode 10.2+
  • CocoaPods 1.6.1+

License

MIT license. See the LICENSE file for more info.

New Version

Please check new transition!

MusicAppTransition

new_capture

musicplayertransition's People

Contributors

xxxairinxxx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

musicplayertransition's Issues

UI Problems

When I place on the music player screen controls like play.. next, previous and so on.. they disappearing when I taped on the mini player.
The problem exist only when navigationbarcontroller is present. What is going on?

Bad frame on orientation change

Hi!

I just found out that when modifying the test app for handling multiple orientations the framework doesn't work quite well. The size of the transition container view is different from the main view.

The steps to reproduce the issue are:

  • Swiping up the LineView
  • Swiping down
  • Changing the orientation
  • Swiping up again

Is there any quick way to fix it?
Thanks!

Installation section

Hey, your library is really interesting.

The only problem I found was the README.md, which lacks an Installation Section
I created this iOS Open source Readme Template so you can take a look on how to easily create an Installation Section
If you want, I can help you to organize the lib.

What are your thoughts? ๐Ÿ˜„

Unbalanced calls to begin/end appearance transitions for

Hi, when I do the music player transition and I close it, the collection view or the table view segue said this: unbalanced calls to begin/end appearance transitions for . I search it in google and this is cause when you try and display a new viewcontroller before the current view controller is finished displaying.
I revised all my code and only happens when I show the player from the miniplayer and I close it. So when I show again the mini player and close it and I try to do a segue on the table to another viewcontroller who has a table it happens again. Can you solve it?

What if I don't have a tab bar? [need help]

Hi, this is freakin awesome, compared to the LNTransitionController or something. This is easy to use, however, I wanna know how to implement the animator if I do not have a tab bar? Thanks!

Exc_Bad_Access(code=2) Error and app crash

Add a view controller before tab bar view and navigate to tab bar view controller on button click then application crash showing Exc_Bad_Access error in MusicPlayerTransitionAnimation line no 119 where self.modalVC.view.removeFromSuperview() method call (when we slide up the view).

Only add a view controller and navigate on button click app get crash whileslide up the view.
Below is the screen shot of the storyboard and where its crash

(When we tap the song title bar then crash the application in TransitionAnimator line no 42)

screen shot 2017-07-07 at 12 00 07 am

screen shot 2017-07-06 at 11 55 05 pm

swipe to dismiss not working

First it was not presenting properly. then i replaced pod file with yours then presenting started working.
Now, problem is swipe to dismiss is not working. I tried to copy your exact code and controller too.
I don't seem to find the problem.
Please help to solve
I am working with xcode-9 and swift 4
Error while dismiss- Unbalanced calls to begin/end appearance transitions for

How to remove bounce up animation?

When transitioned to player I can swipe up and the view will go up a little bit
How can I prevent that? could not find anything related in code
Thank you

How to use?

Could we please have some instructions on how to use this music player? I'm a novice at this .. and this is cool stuff.

How to use it ?

Hi ,
I need to use this library but it make me confuse , I can't find enough information about how to use it , like how others libraries does in README.md file .
README.md doesn't contents enough information. Could you please update it ?

UITransitionView not removed

While playing around with the demo app, there is a very strange bug where UITransitionView was not removed and it freezes all user action:
Steps to reproduce

  1. swipe up and down or swipe up MiniPlayerView and release finger without letting to present ModalViewController
  2. Continue step 1 for n times until the screen is freeze

Here is the print log before freezing the app

ViewController viewWillAppear
ModalViewController viewWillDisappear
ModalViewController viewWillAppear
MusicPlayerTransitionAnimation willAnimation(_ transitionType: TransitionType, containerView: UIView)
ViewController viewWillAppear
screen shot 2018-08-01 at 6 07 50 pm

Swift 3 example

Hi i have used my code as follows in swift 2.3 but after update it to 3.0 i can not find any methods and its giving me lots of errors can you give me a sample code ?

func setupAnimator() {
        
        self.animator = ARNTransitionAnimator(operationType: .Present, fromVC: self, toVC: self.musicPlayerVC)
    
        self.animator.usingSpringWithDamping = 0.8
        self.animator.gestureTargetView = self.musicPlayerViewSmall
        self.animator.interactiveType = .Present
        
        // Present
        self.animator.presentationBeforeHandler = { [unowned self] containerView, transitionContext in
            print("start presentation")
            self.beginAppearanceTransition(false, animated: false)
            
            self.animator.direction = .Top
            
            self.musicPlayerVC.view.frame.origin.y = self.musicPlayerViewSmall.frame.origin.y + self.musicPlayerViewSmall.frame.size.height
            self.view.insertSubview(self.musicPlayerVC.view ,atIndex: 1)
            
            self.view.layoutIfNeeded()
            self.musicPlayerVC.view.layoutIfNeeded()
            
            // miniPlayerView
            let startOriginY = self.musicPlayerViewSmall.frame.origin.y
            let endOriginY = -self.musicPlayerViewSmall.frame.size.height
            let diff = -endOriginY + startOriginY
            // tabBar
            
            
            self.animator.presentationCancelAnimationHandler = { containerView in
                self.musicPlayerViewSmall.frame.origin.y = startOriginY
                self.musicPlayerVC.view.frame.origin.y = self.musicPlayerViewSmall.frame.origin.y + self.musicPlayerViewSmall.frame.size.height
                
                self.contrainerView.alpha = 1.0
                
                self.musicPlayerViewSmall.alpha = 1.0
                for subview in self.musicPlayerViewSmall.subviews {
                    subview.alpha = 1.0
                }
            }
            
            self.animator.presentationAnimationHandler = { [unowned self] containerView, percentComplete in
                let _percentComplete = percentComplete >= 0 ? percentComplete : 0
                self.musicPlayerViewSmall.frame.origin.y = startOriginY - (diff * _percentComplete)
                if self.musicPlayerViewSmall.frame.origin.y < endOriginY {
                    self.musicPlayerViewSmall.frame.origin.y = endOriginY
                }
                self.musicPlayerVC.view.frame.origin.y = self.musicPlayerViewSmall.frame.origin.y + self.musicPlayerViewSmall.frame.size.height
                
                
                let alpha = 1.0 - (1.0 * _percentComplete)
                self.contrainerView.alpha = alpha + 0.5
                
                for subview in self.musicPlayerViewSmall.subviews {
                    subview.alpha = alpha
                }
            }
            
            self.animator.presentationCompletionHandler = { containerView, completeTransition in
                self.endAppearanceTransition()
                
                if completeTransition {
                    self.musicPlayerViewSmall.alpha = 0.0
                    self.musicPlayerVC.view.removeFromSuperview()
                    containerView.addSubview(self.musicPlayerVC.view)
                    self.animator.interactiveType = .Dismiss
                    self.animator.gestureTargetView = self.musicPlayerVC.view
                    self.animator.direction = .Bottom
                } else {
                    self.beginAppearanceTransition(true, animated: false)
                    self.endAppearanceTransition()
                }
            }
        }
        
        // Dismiss
        
        self.animator.dismissalBeforeHandler = { [unowned self] containerView, transitionContext in
            print("start dismissal")
            self.beginAppearanceTransition(true, animated: false)
            
            self.view.insertSubview(self.musicPlayerVC.view, atIndex: 1)
            
            self.view.layoutIfNeeded()
            self.musicPlayerVC.view.layoutIfNeeded()
            
            // miniPlayerView
            let startOriginY = 0 - self.musicPlayerViewSmall.bounds.size.height
            let endOriginY = self.contrainerView.bounds.size.height - self.musicPlayerViewSmall.frame.size.height
            let diff = -startOriginY + endOriginY
            
            self.contrainerView.alpha = 0.5
            
            self.animator.dismissalCancelAnimationHandler = { containerView in
                self.musicPlayerViewSmall.frame.origin.y = startOriginY
                self.musicPlayerVC.view.frame.origin.y = self.musicPlayerViewSmall.frame.origin.y + self.musicPlayerViewSmall.frame.size.height
                
                self.contrainerView.alpha = 0.5
                
                self.musicPlayerViewSmall.alpha = 0.0
                for subview in self.musicPlayerViewSmall.subviews {
                    subview.alpha = 0.0
                }
            }
            
            self.animator.dismissalAnimationHandler = { containerView, percentComplete in
                let _percentComplete = percentComplete >= -0.05 ? percentComplete : -0.05
                self.musicPlayerViewSmall.frame.origin.y = startOriginY + (diff * _percentComplete)
                self.musicPlayerVC.view.frame.origin.y = self.musicPlayerViewSmall.frame.origin.y + self.musicPlayerViewSmall.frame.size.height
                
                
                let alpha = 1.0 * _percentComplete
                self.contrainerView.alpha = alpha + 0.5
                
                self.musicPlayerViewSmall.alpha = 1.0
                for subview in self.musicPlayerViewSmall.subviews {
                    subview.alpha = alpha
                }
            }
            
            self.animator.dismissalCompletionHandler = { containerView, completeTransition in
                self.endAppearanceTransition()
                
                if completeTransition {
                    self.musicPlayerVC.view.removeFromSuperview()
                    self.animator.gestureTargetView = self.musicPlayerViewSmall
                    self.animator.interactiveType = .Present
                } else {
                    self.musicPlayerVC.view.removeFromSuperview()
                    containerView.addSubview(self.musicPlayerVC.view)
                    self.beginAppearanceTransition(false, animated: false)
                    self.endAppearanceTransition()
                }
            }
        }
        
        self.musicPlayerVC.transitioningDelegate = self.animator
    }

modalPresentationStyle should be .FullScreen

Since there is no custom UIPresentationController, then the ModalViewController's modalPresentationStyle should be .FullScreen.

There are two different level of custom presentation.

  1. custom animator only
    https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/CustomizingtheTransitionAnimations.html#//apple_ref/doc/uid/TP40007457-CH16-SW1
  2. custom UIPresentationController, which manage all staff about presentation (including the dimming View) https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/DefiningCustomPresentations.html#//apple_ref/doc/uid/TP40007457-CH25-SW1

since the musicPlayerTransition do not need custom UIPresentationController, the the ModalViewController's should be .FullScreen, and system will call viewWillAppear, viewDidAppear, viewDidDisappear, viewWillDisappear automatically.

missing appearance function call at ViewController

ViewController should call

            self!.beginAppearanceTransition(false, animated:true)
            self!.endAppearanceTransition()

at appropriate location.
otherwise, the ViewController's viewWillDisappear, viewDidDisappear, viewWillAppear, viewDidAppear, will not be called when ModalViewController being presented or dismissed.

        self.animator.presentationBeforeHandler = { [weak self] (containerView: UIView, transitionContext:
            UIViewControllerContextTransitioning) in
            self!.beginAppearanceTransition(false, animated:true) //added
            ...
           self!.animator.presentationCompletionHandler = {(containerView: UIView, completeTransition: Bool) in
                if completeTransition {
                    self!.view.removeFromSuperview()
                    self!.modalVC.view.removeFromSuperview()
                    containerView.addSubview(self!.modalVC.view)
                    self!.animator.interactiveType = .Dismiss
                    self!.animator.gestureTargetView = self!.playerVC.backgroundView
                    self!.animator.direction = .Bottom
                    self!.endAppearanceTransition() //added
                } else {
                    UIApplication.sharedApplication().keyWindow!.addSubview(self!.view)
                    self!.beginAppearanceTransition(true, animated: false) //added
                    self!.endAppearanceTransition() //added
                }
            }
            }
 self!.beginAppearanceTransition(true, animated:true) //added

            self!.animator.dismissalCancelAnimationHandler = { (containerView: UIView) in
           ...

            self!.animator.dismissalCompletionHandler = { (containerView: UIView, completeTransition: Bool) in
                if completeTransition {
                    self!.modalVC.view.removeFromSuperview()
                    self!.animator.gestureTargetView = self!.tabBarPalettle
                    self!.animator.interactiveType = .Present
                    UIApplication.sharedApplication().keyWindow!.addSubview(self!.view)
                    self!.endAppearanceTransition() // added
                } else {
                    self!.beginAppearanceTransition(false, animated: false) //added
                    self!.endAppearanceTransition() //added
                }
            }

Tab Bar Problem

I removed tab bar because I don't need it and removed the code that is related to the tab bar root.

Now the app crashes.
Can you provide maybe another version without the tab bar or help what to delete properly to prevent the crash
Thank you!

Propose Logo/Icon

Hi @xxxAIRINxxx .. I'm a graphic designer. I wanted to contribute to your project and I've designed a logo for your project. If you like it, you can use it. it's free. I'll send you files and pr. is there anything you want to change please let me know. waiting for your feedback. Best Regard
Mirza Zulfan
mpt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.