codeandtheory / ybottomsheet-ios

An easy-to-use bottom sheet controller for iOS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use new `Animation` structure to define sheet present / dismiss animations

mpospese opened this issue · comments

Intro

Y—CoreUI 1.6.0+ has a new Animation struct (used in Y—Snackbar) that lets us configure component animations without even needing to know the animation type (e.g. regular curve vs spring-dampening). We should adopt it for Y—BottomSheet's animations to allow increased customizations.

Task

  1. Replace the following three properties on BottomSheetController.Appearance
public var animationDuration: TimeInterval
public var presentAnimationCurve: UIView.AnimationOptions
public var dismissAnimationCurve: UIView.AnimationOptions

with two new properties:

public var presentAnimation: Animation
public var dismissAnimation: Animation
  1. Add an Animation+BottomSheet.swift file with the following default animations defined:
/// Default animation properties for bottom sheet
public extension Animation {
    /// Default animation for presenting bottom sheet (ease in)
    static let defaultPresent = Animation(curve: .regular(options: .curveEaseIn))

    /// Default animation for dismissing bottom sheet (ease out)
    static let defaultDismiss= Animation(curve: .regular(options: .curveEaseOut))
}
  1. In BottomSheetController.Appearance use the above defaults as the default parameters when initializing an Appearance object.

  2. Have the present and dismiss animators leverage these new appearance properties for their animations.

  3. Update unit tests for 100% coverage and properly testing the new functionality.

Note: when Reduced Motion is on, we will ignore the provided curve (it might be spring-dampening which does not make sense for a cross-dissolve) and replace it with a default easing curve (see Y—Snackbar).