Panels is a framework to easily add sliding panels to your application

Overview

Build Status Carthage compatible CocoaPods Platform Language

Twitter

Panels is a framework to easily add sliding panels to your application. It takes care of the safe area in new devices and moving your panel when the keyboard is presented/dismissed.

Updated to Swift 5.1

Sliding Panel demo1 Sliding Panel demo2 Sliding Panel demo3

Usage

First, create your own panel, you can use Interface Builder, use as reference the examples provided. Make sure that you conform the protocol Panelable

import UIKit
import Panels

class PanelOptions: UIViewController, Panelable {
    @IBOutlet var headerHeight: NSLayoutConstraint!
    @IBOutlet var headerPanel: UIView!
}

This protocol defines the interface needed to be able to adjust the sliding panel to the container, expanding and collapsing. It will take care of the safe area

Then in your ViewController, where the panel is presented:

class YourViewController: UIViewController {
    lazy var panelManager = Panels(target: self)
    override func viewDidLoad() {
        super.viewDidLoad()
        let panel = UIStoryboard.instantiatePanel(identifier: "YourPanelName")
        let panelConfiguration = PanelConfiguration(size: .oneThird)
        
        // To present the panel
        panelManager.show(panel: panel, config: panelConfiguration)
        ....
        // To dismiss the panel
        panelManager.dismiss()
    }
}

If you want to get notifications when the panel is presented, collapsed or expanded, just conform the protocol PanelNotifications

You can find extra options in the PanelConfiguration object:

    /// Storyboard name, the first Viewcontroller will be instantiated
    public var panelName: String

    /// Panel height
    public var panelSize: PanelDimensions

    /// Panel margins between the header and the next views.
    public var panelMargin: CGFloat

    /// Visible area when the panel is collapsed
    public var panelVisibleArea: CGFloat

    /// Safe area is avoided if this flag is true.
    public var useSafeArea = true

    /// Collapse and expand when tapping the header view.
    public var respondToTap = true

    /// Collapse and expand when dragging the header view.
    public var respondToDrag = true

    /// Collapse when tapping outside the panel
    public var closeOutsideTap = true

    /// Animate the panel when the superview is shown.
    public var animateEntry = false

    /// If parent view is a navigationcontroller child, this flag allow a better calculation when the panelSize is .fullScreen
    public var enclosedNavigationBar = true

You could add an arrow indicator to give more feedback to your panels. The perfect companion for Panels is Arrows

Arrows Example

Installation

CocoaPods

Add the line pod "Panels" to your Podfile

Carthage

Add the line github "antoniocasero/Panels" to your Cartfile

SPM

dependencies: [
  .package(url: "https://github.com/antoniocasero/Panels.git", from: "2.2.3")
]

Author

Project created by Antonio Casero (@acaserop on Twitter).

Credits

Sketch UI (Elements)

Issues
  • HeaderHeight calculation pushes Header further down with each show

    HeaderHeight calculation pushes Header further down with each show

    The premise is relatively simple, looking at https://github.com/antoniocasero/Panels/blob/master/Sources/Panels.swift#L50 the safeAreaBottom is added to the PanelHeightConstraint every time show is being executed.

    Now in my specific use case, I instantiate the Panelable VC with my parent VC and only show the Panel on didSelect, I dismiss it on didDeselect. With this behavior, the headerHeigh grows every time I execute show which ends up pushing my header further down each time. The examples show the same behavior (although, it's constraints break and recovery recovers the correct constraints).

    bug 
    opened by caffeineflo 7
  • Panel reopens after being dismissed

    Panel reopens after being dismissed

    I have created a Panel and when it is called I call the show function on the panel. Everything works fine here.

    lazy var panelManager = Panels(target: self)
    let panel = UIStoryboard.instantiatePanel(identifier: "Timer")
    var panelConfiguration = PanelConfiguration(size: .custom(230))
    panelConfiguration.animateEntry = true
    panelConfiguration.useSafeArea = false
    panelConfiguration.respondToDrag = true
    panelConfiguration.respondToTap = false
    self.panelManager.show(panel: panel, config: panelConfiguration)
    

    My issue arrises when I try to dismiss the panel using the panelManager. self.panelManager.dismiss() I'm calling the dismiss function when I Post to NotificationCenter that the timer was stopped. I'm using the PanelNotification to see when it is presented to begin observing when the timer will be stopped.

        func panelDidPresented() {
            isPannelOpen = true
            panelDismissed = false
            NotificationCenter.default.post(name: .CurrentSession, object: nil, userInfo: ["sessionInterval": sessionInterval,
                                                                                           "sessionClientName": sessionClientName])
            NotificationCenter.default.addObserver(self, selector: #selector(timeLeft(notification:)), name: .TimeLeft, object: nil)
            NotificationCenter.default.addObserver(self, selector: #selector(stopTimer(notification:)), name: .StopTimer, object: nil)
    
            print("Did present")
        }
    
        @objc func stopTimer(notification: Notification) {
            self.panelManager.dismiss()
            self.timer?.invalidate()
            self.timer = nil
            NotificationCenter.default.removeObserver(self, name: .TimeLeft, object: nil)
            NotificationCenter.default.removeObserver(self, name: .StopTimer, object: nil)
            NotificationCenter.default.removeObserver(TimerViewController(), name: .CurrentSession, object: nil)
        }
    

    Initially it works and the panel will be dismissed, but when I scroll up or down on the table view... weirdgrandioseghostshrimp-size_restricted

    I can't seem to figure out how to stop it from doing this. Does using NotificationCenter not work well with Panels?

    opened by JordanCoin 7
  • 2nd time dismiss animation works but panel stay

    2nd time dismiss animation works but panel stay

    Panel

    1. Show
    2. Dismiss
    3. Show
    4. Dismiss (Here after dismiss animation, panel stay remain on visible position )

    Any help?

    Below is my code, took latest from pods (2.0.3)

                if self.currentPanel != nil {
                    panelManager?.dismiss()
                    self.currentPanel = nil
                } else {
                    currentPanel = UIStoryboard.instantiatePanel(identifier: "PanelOptions")
                    var panelConfiguration = PanelConfiguration(size: .custom(200))
                    panelConfiguration.panelVisibleArea = 30
                    
                    panelManager?.show(panel: currentPanel as! UIViewController & Panelable, config: panelConfiguration)
                }
    
    opened by deshan 4
  • Fix spelling error

    Fix spelling error

    This pull request fixes a small spelling error (margen instead of margin).

    opened by julianschiavo 3
  • UITableViewController

    UITableViewController

    Hi, this doesn't work on when presenting from a UITableViewController :(

    opened by hobbesthetige 3
  • need some help

    need some help

    Hi,

    I've tried to put the material panel at the top of view controller but I couldn't. Is there any way to do this?

    opened by moisebc 3
  • crash when running on real device

    crash when running on real device

    Hi, I installed the panels pod and setup all the necessary code, then i launched the app on the simulator and everything works like a charm, but when i try to run on a real device the app crashs with the next error:

    dyld: Library not loaded: @rpath/Panels.framework/Panels Referenced from: /private/var/containers/Bundle/Application/4CA47637-BDFB-4473-9305-729F57C14B4A/Metro Sahel.app/Metro Sahel Reason: no suitable image found. Did find: /private/var/containers/Bundle/Application/4CA47637-BDFB-4473-9305-729F57C14B4A/Metro Sahel.app/Frameworks/Panels.framework/Panels: code signature invalid for '/private/var/containers/Bundle/Application/4CA47637-BDFB-4473-9305-729F57C14B4A/Metro Sahel.app/Frameworks/Panels.framework/Panels'

    Capture d’écran 2020-03-05 à 11 24 28 PM

    Xcode version : 11.3.1 Device used: iPhone 7 Plus / iOS 13.3.1

    opened by AmineNac 2
  • How to apply

    How to apply "modalPresentationStyle = .popover"?

    Hi, I want to make the background screen dark like modalpresentationstype = .popover. How can i do it?

    opened by yeonpark333 2
  • curveTopCorners() wont work

    curveTopCorners() wont work

    Installed Panels in my podfile, got the panel to work but i cant call curveTopCorners() anywhere

    opened by ghost 2
  • content height of collectionview inside panel wrong when orientation change

    content height of collectionview inside panel wrong when orientation change

    many error. so i decided to using other lib

    opened by fukemy 0
  • support orienation change

    support orienation change

    hi, i got this problem when orientation change, can u help? IMG_0230

    IMG_0229

    opened by fukemy 2
  • keyboard present and Penel moves up with the keyboard

    keyboard present and Penel moves up with the keyboard

    Hi I am getting this behavior when a panel is present and the keyboard is opened. Penel moves up and fits the keyboard top(below picture). How to stop this behavior? I have tried keyboard observer too but no success yet. conf.keyboardObserver = false Thanks for this nice library.

    IMG_475D92C76697-1

    opened by deshan 0
  • Panels Programmatically

    Panels Programmatically

    Is there a way to build Panels without the need for Storyboard?

    enhancement 
    opened by mmdock 8
  • Drag gesture doesn't follow the movement

    Drag gesture doesn't follow the movement

    Hi, great project to reproduce Android bottom sheets. It would be great to have a drag gesture that follow the movement, not just a toggle up/down. Best.

    enhancement 
    opened by appcornerit 2
Releases(2.2.3)
Owner
Antonio Casero
Software Engineer
Antonio Casero
Easily add drop shadows, borders, and round corners to a UIView.

Easily add drop shadows, borders, rounded corners to a UIView. Installation CocoaPods Add the follwing to your Podfile: pod 'Shades' Usage Storyboard

Aaron Sutton 14 Jun 20, 2020
⚙ Add a preferences window to your macOS app in minutes

Preferences Add a preferences window to your macOS app in minutes Just pass in some view controllers and this package will take care of the rest. Requ

Sindre Sorhus 1.1k Nov 17, 2021
Simple side/slide menu control for iOS, no code necessary! Lots of customization. Add it to your project in 5 minutes or less.

▤ SideMenu If you like SideMenu, give it a ★ at the top right of this page. SideMenu needs your help! If you're a skilled iOS developer and want to he

Jon Kent 5.2k Nov 14, 2021
BottomSheet is a SwiftUI library that lets you add custom bottom sheets to your iOS apps.

BottomSheet is a SwiftUI library that lets you add custom bottom sheets to your iOS apps.

Daniel Saidi 96 Nov 25, 2021
Full configurable spreadsheet view user interfaces for iOS applications. With this framework, you can easily create complex layouts like schedule, gantt chart or timetable as if you are using Excel.

kishikawakatsumi/SpreadsheetView has moved! It is being actively maintained at bannzai/SpreadsheetView. This fork was created when the project was mov

Kishikawa Katsumi 21 Nov 20, 2021
SwiftEntryKit is a presentation library for iOS. It can be used to easily display overlays within your iOS apps.

SwiftEntryKit ?? Donations can be made here. Table of Contents Overview Features Example Project Example Project Installation Presets Playground Requi

Daniel Huri 5.7k Nov 20, 2021
A swift and objective-C object that lets you add a background video to iOS views

BackgroundVideoiOS This is an Object/Class which lets you add a background video to iOS app views. This is seen at login views of some famous apps lik

Amro Gazlan 567 Nov 18, 2021
Dhiraj Rajendra Jadhao 200 Feb 6, 2021
A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.

BadgeHub A way to quickly add a notification badge icon to any view. Demo/Example For demo: $ pod try BadgeHub To run the example project, clone the r

Jogendra 643 Nov 14, 2021
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

Jogendra 1.3k Nov 20, 2021
Simple way to add parallax header to UIScrollView/UITableView written in Swift.

ParallaxHeader Simple way to add parallax header to UIScrollView or it's subclasses. One image view Slider with images Blur vibrant text Blur round ic

Roman Sorochak 853 Nov 13, 2021
A custom reusable circular / progress slider control for iOS application.

HGCircularSlider Example To run the example project, clone the repo, and run pod install from the Example directory first. You also may like HGPlaceho

Hamza Ghazouani 2.2k Nov 25, 2021
Easily integrate Credit Card payments module in iOS App. Swift 4.0

MFCard Buy me a coffee MFCard is an awesome looking Credit Card input & validation control. Written in Swift 3. YOoo, Now MFCard is on Swift 5. Swift

MobileFirst 359 Nov 24, 2021
Easily customizable floating button menu created with SwiftUI

FloatingButton Easily customizable floating button menu created with SwiftUI We are a development agency building phenomenal apps. Usage Create main b

Exyte 444 Nov 26, 2021
VKPinCodeView is simple and elegant UI component for input PIN. You can easily customise appearance and get auto fill (OTP) iOS 12 feature right from the box.

Features Variable PIN length Underline, border and custom styles The error status with / without shake animation Resetting the error status manually,

Vladimir Kokhanevich 89 Nov 6, 2021
:children_crossing: A child view controller framework that makes setting up your parent controllers as easy as pie.

Description Family is a child view controller framework that makes setting up your parent controllers as easy as pie. With a simple yet powerful publi

Christoffer Winterkvist 237 Nov 20, 2021
:cyclone: Blueprints - A framework that is meant to make your life easier when working with collection view flow layouts.

Description Blueprints is a collection of flow layouts that is meant to make your life easier when working with collection view flow layouts. It comes

Christoffer Winterkvist 956 Nov 22, 2021
Calculate the distance and angle of your device with regards to your face

EVFaceTracker TL;DR: Use face detection for calculating distance and angle of your phone. Here is a demo where this is used for setting the shadow and

Edwin Vermeer 254 Aug 1, 2021
curry is a framework built to enhance and compliment Foundation and UIKit.

curry Curry is an Cocoa Touch framework built to enhance and compliment Foundation and UIKit. If you're looking to see some of the framework in action

Devin Ross 46 Sep 1, 2021