A drawer view implemented by SwiftUI

Overview

DrawerView-SwiftUI

A drawer view implemented by SwiftUI. This is not just simply a demo, instead, it can be directly used in project as a module as it has rudimentary customization flexibility.

To-Dos

  • Fix the computed property error

Introduction & Demo

Basic Functionality Demo

A drawer with some bouncing animation

Further Step

Click Anywhere of the Background to Dismiss DrawerView

You can click anywhere of the darken background to dismiss the DrawerView

Drag to Dismiss DrawerView

  • You can drag the draggable area to dismiss the DrawerView

  • However, if the translation of drag action is shorter than you want, you can still restore the DrawerView.

  • Actually, you can even drag it up if you want. You can modify this behavior in the code.

Usage

The entire DrawerView is coded in the file with the same name as DrawerView.swift. The setup code written in Content.swift which demonstrates how to use DrawerView.swift.

DrawerView takes one required argument isShow to open and dismiss itself. You need to create one in your main view and bind it to DrawerView

  • Use DrawerView as overlay

    The code provided in the Content.swift uses DrawerView as a overlay of the main view.

    VStack {
      // Create your own main view
    }
    .overlay(
      DrawerView(isShow: $isShow, content: SampleInnerView())
    )
  • Use DrawerView in ZStack

    ZStack {
      VStack {
        // Create your own main view
      }
      
      DrawerView(isShow: $isShow, content: SampleInnerView())
    }

    In the above code, content is the inner view of DrawerView.

    For example:

    // file: SampleInnerView.swift
    struct SampleInnerView: View {
      var body: some View {
        Text("This is the inner view of DrawerView")
      }
    }
    

Customization

All customizable properties have been provided in the DrawerView.swift. You can directly assign the preferred value to these variables when you initialize the DrawerView

  • backLayerColor

  • backLayerOpacity

  • backLayerAnimation

  • drawerOrientation

  • drawerHeight

  • drawerWidth

  • drawerCornerRadius

  • drawerBackgroundColor

  • drawerOutAnimation

  • isDrawerShadowEnable

  • drawerShadowRadius

    If you want to customize this property, you need to set isDrawerShadowEnable to true first. By default, the animation of shadow is suppressed, but you can change it in source file.

  • content

    This is property is required in the initializer. You can assign the view you want.

  • To Be Continued

Contribution

This project is for demonstration purpose. Any contribution is welcome!

Best Luck and Happy Coding!

You might also like...
 Garland View seamlessly transitions between multiple lists of content.
Garland View seamlessly transitions between multiple lists of content.

Garland View seamlessly transitions between multiple lists of content. We specialize in the designing and coding of custom UI for Mobile

List a collection of items in a horizontally scrolling view. A scaling factor controls the size of the items relative to the center.
List a collection of items in a horizontally scrolling view. A scaling factor controls the size of the items relative to the center.

CAROUSEL List a collection of items in a horizontally scrolling view. A scaling factor controls the size of the items relative to the center. We speci

A library of custom iOS View Controller Animations and Interactions.
A library of custom iOS View Controller Animations and Interactions.

RZTransitions is a library to help make iOS7 custom View Controller transitions slick and simple. Installation CocoaPods (Recommended) Add the followi

An easy way to add a simple, shimmering effect to any view in an iOS app.
An easy way to add a simple, shimmering effect to any view in an iOS app.

Shimmer Shimmer is an easy way to add a shimmering effect to any view in your app. It's useful as an unobtrusive loading indicator. Shimmer was origin

CCMRadarView uses the IBDesignable tools to make an easy customizable radar view with animation
CCMRadarView uses the IBDesignable tools to make an easy customizable radar view with animation

CCMRadarView CCMRadarView is a simple to use view that uses the new IBDesignable and IBInspectable features of XCode6 to easily configure the icon in

RippleEffectView - A Neat Rippling View Effect
RippleEffectView - A Neat Rippling View Effect

RippleEffectView Not only Uber-like animated screen background. RippleEffectView inspired by RayWenderlich.com article How To Create an Uber Splash Sc

Various view's effects for iOS, written in Swift. Allows you to animate views nicely with easy to use extensions
Various view's effects for iOS, written in Swift. Allows you to animate views nicely with easy to use extensions

Various view's effects for iOS, written in Swift. Allows you to animate views nicely with easy to use extensions. Every animation is randomized. Currently supported animations:

An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.
An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.

LoadingShimmer An easy way to add a shimmering effect to any view with just single line of code. It is useful as an unobtrusive loading indicator. Thi

MGFlipView allows to create flipping view in easy way without worrying about flipping animation and flipping logic.
MGFlipView allows to create flipping view in easy way without worrying about flipping animation and flipping logic.

MGFlipView About If you are looking for an easy way of implement 3D flipping view, you are in the right place. MGFlipView allows to create flipping vi

Owner
Yibo Yan
Code Matters!
Yibo Yan
Inspired by Fabric - Answers animation. Allows to "build" given view with pieces. Allows to "destroy" given view into pieces

ADPuzzleAnimation Whats inside Custom animation for UIView inspired by Fabric - Answers animation. Easy to use To create your first animation you need

Anton 126 Dec 25, 2022
Library for creating swipe actions for any SwiftUI View

SwipeActions Library for creating swipe actions for any SwiftUI View, similar to

Alexander Kraev 24 Dec 26, 2022
Shimmer: A super-light modifier that adds a shimmering effect to any SwiftUI View

SwiftUI-Shimmer ✨ Shimmer is a super-light modifier that adds a shimmering effec

Vikram Kriplaney 389 Jan 2, 2023
Pure SwiftUI state-driven library to present view sequences and hierarchies.

PathPresenter swiftUIOnboarding.mp4 Pure SwiftUI routing with transitions, animations, and .sheet() support. In SwiftUI, View is a function of the sta

Aleksandr Dremov 21 Nov 15, 2022
A lightweight loading animation that can be applied to any SwiftUI view with 1 line of code.

SimpleAFLoader A lightweight loading animation that can be applied to any SwiftUI view with 1 line of code. All animations are built using the SwiftUI

Fahim Rahman 2 Aug 25, 2022
SwiftUI-Text-Animation-Library - Text animation library for SwiftUI

⚠️ This repository is under construction. SwiftUI Text Animation Library Make yo

null 28 Jan 8, 2023
Swiftui-animation-observer - Track SwiftUI animation progress and completion via callbacks

SwiftUI Animation Observer Track SwiftUI animation progress and completion via c

Gordan Glavaš 9 Nov 5, 2022
ChainPageCollectionView A custom View with two level chained collection views and fancy transition animation

ChainPageCollectionView A custom View with two level chained collection views and fancy transition animation. Demo Requirements iOS 9.0+ Xcode 8 Insta

Yansong Li 775 Dec 7, 2022
A Swift library to take the power of UIView.animateWithDuration(_:, animations:...) to a whole new level - layers, springs, chain-able animations and mixing view and layer animations together!

ver 2.0 NB! Breaking changes in 2.0 - due to a lot of requests EasyAnimation does NOT automatically install itself when imported. You need to enable i

Marin Todorov 3k Dec 27, 2022