Skip to content

FluidGroup/Rideau

Repository files navigation

πŸŽͺ Rideau

Rideau is a drawer UI similar to what Apple's apps use. (e.g Maps, Shortcuts)

Overview

  • πŸ’Ž Supports multiple snap points (e.g. most hidden, half visible, full visible, and we can add more snap points.)
  • πŸ’Ž Supports Animations alongside moving (e.g. dimming background color)
  • πŸ’Ž Supports handling scrolling of scrollview inside RideauView
  • πŸ’Ž Supports resizing based on intrinsic content size of view that RideauView has
  • βœ… Interactive Animations come from UIViewPropertyAnimator, with this it's actual interruptible animation and no glitches. (it can't get from UIView.animate)

RideauView allows for flexible snap points. Snap points pertains to specified offsets where the draggable view "snaps to" when the dragging has ended. There are usually 2 or 3 snap points.


Objects we will commonly use:

  • RideauView
  • RideauViewController
  • RideauSnapPoint

RideauView is the core object in this library. We typically add our own view to RideauView.

RideauViewController contains a RideauView. It allows us to present the RideauView as modal dialog.

RideauSnapPoint defines where the content view stops.

πŸ”Ά Requirements

iOS 10.0+ Xcode 13+ Swift 5.5+

πŸ“± Features

  • Multiple snap-point
  • Smooth integration with dragging and UIScrollView's scrolling.
  • Tracking UIScrollView automatically
  • Set UIScrollView to track manually
  • Use UIViewPropertyAnimator between snap-points.

πŸ‘¨πŸ»β€πŸ’» Usage

Present inline

let rideauView = RideauView(
  frame: .zero,
  configuration: .init { config in
    config.snapPoints = [.autoPointsFromBottom, .fraction(0.6), .fraction(1)]
  }
)

let someView: UIView = ...

rideauView.containerView.set(
  bodyView: someView,
  resizingOption: .resizeToVisibleArea
)

Present with Modal Presentation

let targetViewController: YourViewController = ...

let controller = RideauViewController(
  bodyViewController: targetViewController,
  configuration: .init { config in
    config.snapPoints = [.autoPointsFromBottom, .fraction(1)]
  },
  initialSnapPoint: .autoPointsFromBottom,
  resizingOption: .resizeToVisibleArea
)

present(controller, animated: true, completion: nil)

Multiple SnapPoints

We can define snap-point with RideauSnapPoint.

public enum RideauSnapPoint: Hashable {

  case fraction(CGFloat)
  case pointsFromTop(CGFloat)
  case pointsFromBottom(CGFloat)
  case autoPointsFromBottom

  case hidden

  public static let full: RideauSnapPoint = .fraction(1)
}
config.snapPoints = [.pointsFromBottom(200), .fraction(0.5), .fraction(0.8), .fraction(1)]

βš™οΈ Details

RideauContentContainerView has two ways of resizing the content view that is added.

  • RideauContentContainerView.ResizingOption
    • noResize
    • resizeToVisibleArea
public final class RideauContentContainerView: UIView {
  public func set(bodyView: UIView, resizingOption: ResizingOption)
}

πŸ”Œ Components

Rideau provides the following components that may help us.

RideauMaskedCornerRoundedViewController

A Container view controller that implements masked rounded corner interface and has some options.

  • More customizable
let targetViewController: YourViewController = ...

let controller = RideauViewController(
  bodyViewController: RideauMaskedCornerRoundedViewController(viewController: targetViewController),
  configuration: .init { config in
    config.snapPoints = [.autoPointsFromBottom, .fraction(1)]
  },
  initialSnapPoint: .autoPointsFromBottom,
  resizingOption: .resizeToVisibleArea
)

RideauMaskedCornerRoundedView

  • More customizable

RideauThumbView

  • More customizable

Installation

CocoaPods

Rideau is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Rideau'

Carthage

For Carthage, add the following to your Cartfile:

github "muukii/Rideau"

What's using Rideau

Author

Contributors

SwiftUI Edition

https://github.com/nerdsupremacist/Snap

License

Rideau is released under the MIT license.

About

πŸŽͺ Rideau is a drawer UI similar to what Apple's apps use. (e.g Maps, Shortcuts) Supports multiple snap points

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

 
 
 

Contributors