babylonhealth / DrawerKit

DrawerKit lets an UIViewController modally present another UIViewController in a manner similar to the way Apple's Maps app works.
https://github.com/Babylonpartners
MIT License
781 stars 44 forks source link

Add `DrawerBackgroundConfiguration` to customize arbitrary background #100

Closed inamiy closed 11 months ago

inamiy commented 5 years ago

This PR adds customizability of background view via DrawerBackgroundConfiguration. Currently supporting DrawerBackgroundConfiguration.dark as a built-in style, and can be tested from Demo app.

Also, this PR will supersede #63 by importing 3rd party dynamic blur view library e.g. https://github.com/efremidze/VisualEffectView and add the following configuration manually:

extension DrawerBackgroundConfiguration {
    public static func visualEffect(style: UIBlurEffectStyle, blurRadius: CGFloat) -> DrawerBackgroundConfiguration {
        return DrawerBackgroundConfiguration(
            make: { () -> VisualEffectView in
                let effect = UIBlurEffect(style: style)
                let blurView = VisualEffectView(effect: effect)
                return blurView
            },
            handle: {
                $0.blurRadius = blurRadius * (1 - $1.currentY / $1.containerHeight)
            }
        )
    }
}