Coder Social home page Coder Social logo

brandy2015 / airbar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from uptechteam/airbar

1.0 1.0 0.0 5.58 MB

iOS library - UIScrollView driven expandable menu.

Home Page: https://blog.uptech.team/how-to-implement-expandable-menu-on-ios-like-in-airbnb-3d2bdd97b049

License: MIT License

Objective-C 0.83% Swift 98.22% Ruby 0.95%

airbar's Introduction

AirBar

UIScrollView driven expandable menu.


Description

AirBar is a library for creating cool expandable menus. Library observes UIScrollView scroll and provides state you can apply to your UI elements.

Demo

AirBar Demo

Installation

Library supports Carthage dependency manager. To install AirBar add following line to Cartfile in the root folder of your project.

github "uptechteam/AirBar" ~> 2.0

Using CocoaPods add following line to your project Podfile

pod 'AirBar', '~> 2.0'

Using Swift Package Manager, add the following line to your Package.swift:

dependencies: [
  .package(url: "https://github.com/uptechteam/AirBar.git", .exact("2.0.6")),
],

How to use

  1. Create BarController object using BarController(configuration Configuration, stateObserver: StateObserver) initializer, where Configuration is struct that contains height config and StateObserver is closure that will be called on state change.

  2. Bind BarController to your UIScrollView object using set(scrollView: UIScrollView) method.

  3. Provide UI transformations in closure passed as StateObserver init argument. Closure will receive State object that has following public methods:

  • height() - returns bar height;
  • transitionProgress() - returns bar transition progress between 0 and 2, where 0 - compact state, 1 - normal state, 2 - expanded state;
  • value(compactNormalRange: ValueRangeType, normalExpandedRange: ValueRangeType) - returns transformed CGFloat value that can be used for configuring UIKit element properties. ValueRangeType is enum with .range(CGFloat, CGFloat) and .value(CGFloat) cases. You can use it for example if you need static value 1 in normal-expanded transition and range (0, 1) in compact-normal transition.
  1. (Optional) Contribute to repository.

Also you can find example application in library project.

Multiple UIScrollView objects

BarController supports using multiple UIScrollView objects. You can use preconfigure(scrollView: UIScrollView) method to configure scrolling view before setting it with set(scrollView: UIScrollView) method.

TODO

  • Implement expansion/concatination resistance;
  • ...

airbar's People

Contributors

bfernandesbfs avatar foxacid7cd avatar

Stargazers

 avatar

Watchers

 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.