GithubHelp home page GithubHelp logo

robertherdzik / rhsidebuttons Goto Github PK

View Code? Open in Web Editor NEW
168.0 12.0 22.0 4.64 MB

Library provides easy to implement variation of Android (Material Design) Floating Action Button for iOS. You can use it as your app small side menu. 🌢

License: MIT License

Swift 90.13% Ruby 7.63% Objective-C 2.25%
material demo android rhsidebuttons-library floating action-buttons buttons menu sidemenu

rhsidebuttons's Introduction

Version License Platform Language Twitter

RHSideButtons 🌢

Library provides easy to implement variation of Android (Material Design) Floating Action Button for iOS. You can use it as your app small side menu. 🌢

Play with it 😎

Installation

You can install RHSideButtons library using CocoaPods:

pod 'RHSideButtons'

or you can simply copy RHSideButtons folder to your project.

Usage

You just need implement RHSideButtonsDataSource and RHSideButtonsDelegate similar to well-known UIKit design.

// You need to firstly create trigger button. You can do this using block or your builder object which should conform to 'RHButtonViewConfigProtocol'
// RHTriggerButtonView allows you to change image for pressed state! πŸ‘ŒπŸ»
let triggerButton = RHTriggerButtonView(pressedImage: UIImage(named: "exit_icon")!) {
    $0.image = UIImage(named: "trigger_img")
    $0.hasShadow = true
}

// Then you need to create instance of SideButtons coordinator class with your View Controller view (it can be even TableView)
sideButtonsView = RHSideButtons(parentView: view, triggerButton: triggerButton)
sideButtonsView.delegate = self
sideButtonsView.dataSource = self

// When SideButtons controller is initialized properly you should set thier position in view in e.g. viewWillAppear method:
override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)

    sideBttns?.setTriggerButtonPosition(CGPoint(x: bounds.width - 85, y: bounds.height - 85))
}

... let us prepare our data models for buttons πŸ’₯ below you can see one of many ways to do this:

//Finally you should create array of buttons which will feed our dataSource and Delegate methods :) e.g.:
let button_1 = RHButtonView {
    $0.image = UIImage(named: "icon_1")
    $0.hasShadow = true
}

let button_2 = RHButtonView {
    $0.image = UIImage(named: "icon_2")
    $0.hasShadow = true
}

let button_3 = RHButtonView {
    $0.image = UIImage(named: "icon_3")
    $0.hasShadow = true
}

buttonsArr.appendContentsOf([button_1, button_2, button_3])

//Similar as it is in TableView, now you should reload buttons with new values
sideButtonsView.reloadButtons()

πŸ’‘ important thing is that you need to reload buttons when your datasource has changed using reloadButtons() method (😱 simple right❓)

RHSideButtonsDataSource

func sideButtonsNumberOfButtons(sideButtons: RHSideButtons) -> Int
func sideButtons(sideButtons: RHSideButtons, buttonAtIndex index: Int) -> RHButtonView

RHSideButtonsDelegate

func sideButtons(sideButtons: RHSideButtons, didSelectButtonAtIndex index: Int)
func sideButtons(sideButtons: RHSideButtons, didTriggerButtonChangeStateTo state: RHButtonState)

Support for left-handers :)

If you decide to position RHSideButtons on the left site of view, buttons will dissapears to the left side of screen automatically.

e.g.:

sideBttns?.setTriggerButtonPosition(CGPoint(x:25, y: frame.size.height - 85))

Swift support

Library ver Swift ver
1.0 2.2
1.0.1 3.0
1.1.0 4.0

Check the Demo project

Please check out the demo project, you can see there what is the best (in my opinion πŸ€”) way to implement my buttons. Please keep in mind that Readme contains the simplest way to implement this control.

rhsidebuttons's People

Contributors

readmecritic avatar robertherdzik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rhsidebuttons's Issues

Size

Hi, thanks for your great job
is it possible to change the size of buttons?

No such model 'RHSideButtons'

I getting this error when opening the RHSideButtonsExample.xcworkspace and running the demo project. I'm using Xcode 8.3 btw

Installation Section

Hey, your library is really interesting.

The only problem I found was the README.md, which lacks an Installation Section
I created this iOS Open source Readme Template so you can take a look on how to easily create an Installation Section
If you want, I can help you to organize the lib.

What are your thoughts? πŸ˜„

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.