Giter VIP home page Giter VIP logo

fapanels's Introduction

Alt text

Swift version Support Dependecy Manager Version License Platform

Features


  • Implementation with code & storyboard
  • Left, right and center panel supported
  • Change left, right or center panel
  • Open left, right or center panel
  • Supports Animations
  • Multiple Panel configurations
  • Supports status bar preffered style for all panels

Transitions supported


  • Flip From Left
  • Flip From Right
  • Flip From Top
  • Flip From Bottom
  • Curl Up
  • Curl Down
  • Cross Dissolve

Panel configurations

// Panels width

var leftPanelWidth : CGFloat = 280  //  It will override the gap percentage value
var rightPanelWidth: CGFloat = 280

var leftPanelGapPercentage : CGFloat = 0.8
var rightPanelGapPercentage: CGFloat = 0.8


// resizes all subviews as well

var resizeLeftPanel : Bool = false
var resizeRightPanel: Bool = false


// Adds push animation on side panels

var pusheSidePanels: Bool = false


// Bounce effects on panel animations

var bounceOnLeftPanelOpen  : Bool = true
var bounceOnRightPanelOpen : Bool = true
var bounceOnCenterPanelOpen: Bool = true


var bounceOnLeftPanelClose   : Bool = false
var bounceOnRightPanelClose  : Bool = false
var bounceOnCenterPanelChange: Bool = true


var bouncePercentage : CGFloat = 0.075
var bounceDuration   : CGFloat = 0.1


//  Panning Gesture

var canRecognizePanGesture: Bool = true

var panFromEdge          : Bool = false
var minEdgeForLeftPanel  : CGFloat = 70.0
var minEdgeForRightPanel : CGFloat = 70.0

var canLeftSwipe : Bool = true
var canRightSwipe: Bool = true


// restricts panning gesture to work for top VC of Navigation/TabBar Controller

var restrictPanningToTopVC: Bool = true


// Handles the interface auto rotation of visible panel

var handleAutoRotation: Bool = true


// Applies corner radius to panels

var cornerRadius: CGFloat = 0.0


// Remove panels from super view when possible

var unloadRightPanel: Bool = false
var unloadLeftPanel : Bool = false


// Max animation duration for animations of side panels

var maxAnimDuration  : CGFloat = 0.20


// percentage of screen's width to the centerPanel.view must move for panGesture to succeed

var minMovePercentage: CGFloat = 0.15


// Only Center Panel Change animation

var changeCenterPanelAnimated : Bool = true
var centerPanelTransitionType : FAPanelTransitionType = .crossDissolve
var centerPanelTransitionDuration: TimeInterval = 0.60

Installation

Cocoapods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate FAPanel into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target '<Your Target Name>' do
pod 'FAPanels'
end

Then, run the following command:

$ pod install

Usage

Step 1

  • Set the root window as FAPanel controller as shown in below image,

Alt text

Step 2

  • Add the following code in AppDelegate.swift file,
//  Load the Controllers 

let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)

let leftMenuVC: LeftMenuVC = mainStoryboard.instantiateViewController(withIdentifier: "LeftMenuVC") as! LeftMenuVC

let rightMenuVC: RightMenuVC = mainStoryboard.instantiateViewController(withIdentifier: "RightMenuVC") as! RightMenuVC

let centerVC: CenterVC = mainStoryboard.instantiateViewController(withIdentifier: "CenterVC1") as! CenterVC
let centerNavVC = UINavigationController(rootViewController: centerVC)




//  Set the Panel controllers with just two lines of code

let rootController: FAPanelController = window?.rootViewController as! FAPanelController
rootController.center(centerNavVC).letf(leftMenuVC).right(rightMenuVC)
  • All done! Run the code and see the magic.

Step 2 (Continue - Panel Controllers)

  • Don't want to set RightMenuVC then just remove the right panel code i.e,
//  This is the code to set all panels 

rootController.center(centerNavVC).letf(leftMenuVC).right(rightMenuVC)


//  Updated code which have only left and center panels 

rootController.center(centerNavVC).letf(leftMenuVC)


//  Similarly, if left panel is not needed the remove the left panel code.

rootController.center(centerNavVC).right(rightMenuVC)


//  In case you only want the center panel, then update code to

rootController.center(centerNavVC)

Step 2 (Continue - Panel Configurations)

  • Configre the Panels before setting the panels
rootController.configs.rightPanelWidth = 80
rootController.configs.bounceOnRightPanelOpen = false



//  Should Pan from edge? Add these lines of code, 

rootController.configs.panFromEdge = false
rootController.configs.minEdgeForLeftPanel  = 70
rootController.configs.minEdgeForRightPanel = 70


rootController.center(centerNavVC).letf(leftMenuVC).right(rightMenuVC)


//  For more configurations and their details, Please have a look into ``` FAPanelConfigurations.swift ``` file 

Access Panel

  • Panel can be accessed from any view controller,
panel?.configs = FAPanelConfigurations()

Open/Close Panels

  • Open Left or Right panels with/without animations
panel?.openLeft(animated: true)
panel?.openRight(animated: true)
  • Open/Close Panels Preview

Change/Remove Panels

  • Change Left, Right or Center Panel from any view controller
//  Change Center panel

let centerVC: UIViewController = mainStoryboard.instantiateViewController(withIdentifier: "CenterVC2")
let centerNavVC = UINavigationController(rootViewController: centerVC)

panel!.center(centerNavVC)



//  Change Left panel

let leftVC: UIViewController = mainStoryboard.instantiateViewController(withIdentifier: "LeftVC")
panel!.left(leftVC)


//  Remove Left panel

panel!.left(nil)
  • Preview, when changing center panel from left/right panels

Change Center Panel (With custom transitions and durations)

  • Change Left, Right or Center Panel from any view controller
//  Specify the transition type

panel!.configs.centerPanelTransitionType = .transitionOption     // Transitions supported are mentioned in FAPanelTransitionType


//  Specify the transition duration

panel!.configs.centerPanelTransitionDuration = 0.60


//  Update the center panel

panel!.center(centerNavVC)
  • Transitions Preview
flipFromLeft flipFromRight
flipFromTop flipFromBottom
curlUp curlDown
crossDissolve

Supports interface rotation

License

FAPanels is licensed under the Apache License 2.0.

For more details visit http://www.apache.org/licenses/LICENSE-2.0

Author

Fahid Attique - (https://github.com/fahidattique55)

fapanels's People

Watchers

Muhammad Azher avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.