Git Product home page Git Product logo

liquidfloatingactionbutton's Introduction

LiquidFloatingActionButton

CI Status Version License Platform [Carthage compatible] (https://github.com/Carthage/Carthage)

LiquidFloatingActionButton is floating action button component of material design in liquid state, inspired by Material In a Liquid State. This is also spinner loader components in liquid state.

Demo

Features

  • liquid animation
  • Easily customizable
  • Objective-C compatible
  • Swift 5.0

You can play a demo with appetize.io

Usage

You just need implement LiquidFloatingActionButtonDataSource and LiquidFloatingActionButtonDelegate similar to well-known UIKit design.

let floatingActionButton = LiquidFloatingActionButton(frame: floatingFrame)
floatingActionButton.dataSource = self
floatingActionButton.delegate = self

LiquidFloatingActionButtonDataSource

func numberOfCells(liquidFloatingActionButton: LiquidFloatingActionButton) -> Int
func cellForIndex(index: Int) -> LiquidFloatingCell

LiquidFloatingActionButtonDelegate

optional func liquidFloatingActionButton(liquidFloatingActionButton: LiquidFloatingActionButton, didSelectItemAtIndex index: Int)

Easily customizable

Demo

Installation

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

pod "LiquidFloatingActionButton"

or, if you use Carthage, add the following line to your Carthage file.

github "yoavlt/LiquidFloatingActionButton"

License

LiquidFloatingActionButton is available under the MIT license. See the LICENSE file for more info.

liquidfloatingactionbutton's People

Contributors

alexanderkhitev avatar ansonyao avatar carlosgrossi avatar dinggong avatar distinctblur avatar ekkog avatar jesster2k10 avatar jrsalazares avatar manhpham90vn avatar reillywatson avatar yoavlt 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  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

liquidfloatingactionbutton's Issues

Failed cocoapods installation

When trying to install via cocoapods, an error is produced:

Analyzing dependencies
[!] Unable to satisfy the following requirements:

- `LiquidFloatingActionButton` required by `Podfile`

The "enableShadow" option is ignored (Objective-C)

I create a floating button like a pro... ;-)

CGRect floatingFrame = CGRectMake(self.view.frame.size.width - 84, self.view.frame.size.height - 84, 64, 64);
_floatingActionButton = [[LiquidFloatingActionButton alloc] initWithFrame: floatingFrame];
_floatingActionButton.enableShadow = false;
_floatingActionButton.color = ZG_COLOR_BLUE;
_floatingActionButton.dataSource = self;
_floatingActionButton.delegate = self;
[self.view addSubview:_floatingActionButton];

However, the "enableShadow" option does not propagate as it should.

If I manually edit "CircleLiquidBaseView" and change "var enableShadow = true" to "false", it works as expected...

Do not rotate image if no children

Hi, I put a floating button without children but when I click it I see the animation. I think the library should delegate button click and shouldn't call open() if no children buttons.

Autolayout Issue

let floatingFrame = CGRect(x: self.view.frame.width - 56 - 16, y: self.view.frame.height - 100 - 16, width: 56, height: 56)
let bottomRightButton = createButton(floatingFrame, .Up)

that code didnt work with when rotating the screen to landscape

Any help?

How to cater for more cells than the screen can show?

Hi,

So I added this pretty awesome floating button to my project, and have chose to display the cells to open to the left of the button (which is placed on the bottom right of my screen).

I noticed that, on an iPhone 4/5 screen, if I have more than 3 cells I lose them off the edge of the screen.

How can I accomodate or avoid this? I was hoping/thinking the cells would be either in a scroll view, or they would just form another row below/above the other cells..

This doesnt seem to be much of an active project any more, but if anybody could provide some help or insight it would be greatly appreciated.. thanks!

Action to plus button

Hi

Im new in coding and can't figure out to add the action to the plus button it self to call a function. Can you please help ? :-)

Im trying this in ViewDidload

floatingActionButton.targetForAction(Selector("plusButton:"), withSender: self)

func plusButton() { print("button tapped") }

Delegate method not called due to failing hit test

Created new objective-c project (iOS 9.2, XCode 7.2).
Added as framework using cocoapods.

UIView added to storyboard, added auto layout constraints for bottom, trailing, width and aspect.
Implemented datasource and delegate protocol in view controller, set in viewWillAppear to the buttons properties.

Button displays fine, opens properly the cells.

But neither does it close again nor does it call the delegate whenever I click onto a cell.

Debugging shows the the hitTest is failing for the cells:

if (CGRectContainsPoint(cell.bounds, pointForTargetView)) is always FALSE.

Example values for a button on the lower right corner of an iPad screen:

pointForTargetView:
▿ CGPoint

  • x : 961.5
  • y : 1171.5

cell.bounds:
▿ CGRect
▿ origin : CGPoint
- x : 0.0
- y : 0.0 { ... }
▿ size : CGSize
- width : 0.0 { ... }
- height : 0.0 { ... }

The cell returns an empty CGRect, thus the test will fail.
Was able to reproduce it multiple times with different simulators.

Any Ideas ?

Kind Regards,
Oggerschummer

Orientation changes

How can I make the button respect orientation changes if I created it programmatically and not via the storyboard? I don't see this being supported.

Thanks.

no such module LiquidFloatingActionButton

I am using objc and my podfile has :

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

Uncomment this line to define a global platform for your project

platform :ios, '8.0'

Uncomment this line if you're using Swift

use_frameworks!

target 'Test' do
pod 'LiquidFloatingActionButton'
end

target 'TestTests' do

end

target 'TestUITests' do

end

But not working :(

LiquidFloatingCell does not show the image

We tried below code to add LiquidFloatingCell in cellForIndex(), but the cells are showing white circle in the center, not the actual image (screengrab attached).

LiquidFloatingCell *lfcell = [[LiquidFloatingCell alloc] initWithIcon:[UIImage imageNamed:@"australia"]];

screen shot 2015-12-20 at 4 14 36 am

Can we change plus icon?

Thank you for making this. I am using this button kinda side menu. So, i would like to change initial "plus" icon to something more like "list" type icon or something custom i want. I attempted to do that but failed. At least if you can tell where it is initialised, i would try to change.

Extra space between first cell and button

Right now, the first cell always has a bigger space between it and the button, but I need the space to match the space between all of the other cells.

I basically need the same amount of space between all of the cells, and the first cell and the button.

So if all of the cells have 20px between them, I also need to have 20px of space between the button and the first cell.

So far I've been able to tweak the code to fit my needs but I can't seem to figure this one out.

Thanks for the help.

A couple of warnings in Xcode for Swift 2.0 branch

Hello,

I used the Swift 2.0 branch to check out this awesome library. I received warnings about some variables are not used. Is it possible if I can do some changes to the code and send it as a pull request?

Thank you! 😄

Adding Blur Effect when open() is called

Hello,

Great control by the way. I am trying to implement adding a blur and vibrancy effect to this control. I am able to get the blur to occur and the LiquidFloatingActionButton is indeed visible. The issue I am having is that although the floating buttons are visible they are not responding to touch events. I cannot close the control or choose any of the cells.

So far this is what I have done. I have subclasses LiquidFloatingActionButton and have override the open() function as follows.

...

override public func open() {
    let window = UIApplication.sharedApplication().windows.first

    var darkBlur = UIBlurEffect(style: UIBlurEffectStyle.Dark)
    var blurView = UIVisualEffectView(effect: darkBlur)
    blurView.frame = (window?.bounds)!
    blurView.center = (window?.center)!

    window?.addSubview(blurView)

    let vibrancyEffect = UIVibrancyEffect(forBlurEffect: darkBlur)
    let vibrancyView : UIVisualEffectView = UIVisualEffectView(effect: vibrancyEffect)

    vibrancyView.addSubview(self)
    blurView.contentView.addSubview(vibrancyView)

    super.open()

}

...

Any thoughts on how this might be implemented? Any help to point me in the right direction or adding it to your roadmap would be great. Just not sure why it is no longer responding to touch events.

Thanks,

Adding Tap Gesture recogniser

I would like to know when the floating action cell is tapped so that i can close it programmatically. However, adding a tap gesture recognizer to the floating cell 'breaks' it. In the sense that it wont open. Is this a know issue? is there a fix around it?

Does not compile on Xcode 7.1

6 errors , 8 warnings on 0.1.2 which I thought was the swift 2.0 branch

for example the 3 overrides below are failing with the following message:
/Users/mark/xcode/X2/Pods/LiquidFloatingActionButton/Pod/Classes/LiquidFloatingActionButton.swift:542:26: Method does not override any method from its superclass

//////////////////////////
// MARK: Events
public override func touchesBegan(touches: Set, withEvent event: UIEvent) {
self.touching = true
setNeedsDisplay()
}

public override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) {
    self.touching = false
    setNeedsDisplay()
    didTapped()
}

public override func touchesCancelled(touches: Set<NSObject>!, withEvent event: UIEvent!) {
    self.touching = false
    setNeedsDisplay()
}

Enhancement : Add information text to LiquidFloatingCell

Just thought it would be nice to be able to have a small line of text telling users what the button does inline with the LiquidFloatingCell.

I am going to have a go at implementing it but thought I'd put it here in case anyone else has something for it.

Pretty laggy

Really nice animation but I am wondering why is pretty laggy now, same problem for Demo? I'm using swift 2 in iOS 9.

Method does not override any method from its superclass

Hey,

Im getting no less than 7 fatal errors and 7 warnings when trying to build after importing. Im using Objective C, and importing the swift file into my app - but thats not the problem. the problems are all within the Pod project itself - i get 7 "Method does not override any method from its superclass" - is there a fix? or did i just suck at importing? :-)

skaermbillede 2015-10-11 kl 17 21 49

Click effect(A white circle appears with animation)

Hi Guys,

Thanks for making such nice animations. I'm not saying this is an issue but curious to find animation in project, I could not find any other way to report about this other than creating new issue.

How can I add this animation on click? The animation which appears on click of plus button(in .gif files) and after this the floating buttons start appearing. Is it already in project? If yes how can I find it?

Regards,
Usman Mughal

Swift 2.0 branch not working from Navigation Bar Button

Hi! This is an awesome component, thank you for creating it. I am trying to incorporate it in one of my apps and the taps are not being detected.

I modified the demo app and it worked beautifully, using the following code:

    let rightBarButton:UIBarButtonItem = UIBarButtonItem()
    rightBarButton.customView = floatingActionButton
    self.navigationItem.rightBarButtonItem = rightBarButton

As I am targeting iOS 9.1 and Swift 2.0, I pulled the swift-2.0 branch and created a blank project with identical code. The menu shows up and expands, but the taps are not detected. If I just follow the addSubview method to create a floating menu, it works fine.

Can you please confirm that taps from the menu embedded in Navigation Bar should work in swift-2.0 branch?

Method does not override any method from its superclass

public override func touchesBegan(touches: Set, withEvent event: UIEvent) {
self.touching = true
setNeedsDisplay()
}
swift:196:26: Method does not override any method from its superclass

Is there something has changed in swift? My Xcode Version 7.2.1 (7C1002).

creating two buttons produces animation errors

anyone know how to properly create two buttons and not have animation errors when one is tapped, then the other one is tapped?

am i creating them incorrectly?

`
func createButtons() {
let createButton: (CGRect, LiquidFloatingActionButtonAnimateStyle) -> LiquidFloatingActionButton = { (frame, style) in
let floatingActionButton = LiquidFloatingActionButton(frame: frame)
floatingActionButton.animateStyle = style
floatingActionButton.color = UIColor.whiteColor()
floatingActionButton.dataSource = self
floatingActionButton.delegate = self
return floatingActionButton
}

    for var i=1; i<5; i++
    {
        let buttonFrame =  CGRect(x: 0, y: i*50, width: 64, height: 64)
        let button = createButton(buttonFrame, .Right)
        self.view.addSubview(button) 
    }

    let cellFactory: (String) -> LiquidFloatingCell = { (iconName) in
        return LiquidFloatingCell(icon: UIImage(named: iconName)!)
    }

    cells.append(cellFactory("pencil2"))  //edit
    cells.append(cellFactory("pencil2"))  //edit
    cells.append(cellFactory("trash"))  // edit
}`

Carthage - Build Failed

If I use Carthage to install LiquidFloatingActionButton.
There are some errors when build it.

LiquidFloatingActionButton.swift
    CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(2 failures)

/Carthage/Checkouts/LiquidFloatingActionButton/Pod/Classes/LiquidFloatingActionButton.swift:196:26: error: method does not override any method from its superclass

Please, check this and fix please.
Thank you.

Customize Plus button

I am using this framework to create floating button in my project. I have a requirement to add a button image other than the plus sign in my project. Is it possible,I have tried many ways but failed. Please suggest some codes or ideas to do so? Thanks.

Carthage build issue (Xcode 7.3)

The following build commands failed:
CompileSwift normal arm64 XX/Carthage/Checkouts/LiquidFloatingActionButton/Pod/Classes/LiquidFloatingActionButton.swift
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(2 failures)
XX/Carthage/Checkouts/LiquidFloatingActionButton/Pod/Classes/LiquidFloatingActionButton.swift:196:26: error: method does not override any method from its superclass
XX/Carthage/Checkouts/LiquidFloatingActionButton/Pod/Classes/LiquidFloatingActionButton.swift:201:26: error: method does not override any method from its superclass
XX/Carthage/Checkouts/LiquidFloatingActionButton/Pod/Classes/LiquidFloatingActionButton.swift:207:26: error: method does not override any method from its superclass
XX/Carthage/Checkouts/LiquidFloatingActionButton/Pod/Classes/LiquidFloatingActionButton.swift:527:26: error: method does not override any method from its superclass
XX/Carthage/Checkouts/LiquidFloatingActionButton/Pod/Classes/LiquidFloatingActionButton.swift:535:26: error: method does not override any method from its superclass
XX/Carthage/Checkouts/LiquidFloatingActionButton/Pod/Classes/LiquidFloatingActionButton.swift:542:26: error: method does not override any method from its superclass
XX/Carthage/Checkouts/LiquidFloatingActionButton/Pod/Classes/LiquidFloatingActionButton.swift:77:15: error: a non-failable initializer cannot chain to failable initializer 'init(coder:)' written with 'init?'
XX/Carthage/Checkouts/LiquidFloatingActionButton/Pod/Classes/LiquidFloatingActionButton.swift:176:13: warning: variable 'paths' was never mutated; consider changing to 'let' constant
XX/Carthage/Checkouts/LiquidFloatingActionButton/Pod/Classes/LiquidFloatingActionButton.swift:251:16: warning: value 'source' was defined but never used; consider replacing with boolean test
XX/Carthage/Checkouts/LiquidFloatingActionButton/Pod/Classes/LiquidFloatingActionButton.swift:326:61: warning: use '#selector' instead of explicitly constructing a 'Selector'
XX/Carthage/Checkouts/LiquidFloatingActionButton/Pod/Classes/LiquidFloatingActionButton.swift:325:13: warning: initialization of immutable value 'distance' was never used; consider replacing with assignment to '' or removing it
XX/Carthage/Checkouts/LiquidFloatingActionButton/Pod/Classes/LiquidFloatingActionButton.swift:340:61: warning: use '#selector' instead of explicitly constructing a 'Selector'
XX/Carthage/Checkouts/LiquidFloatingActionButton/Pod/Classes/LiquidFloatingActionButton.swift:338:13: warning: initialization of immutable value 'distance' was never used; consider replacing with assignment to '
' or removing it
XX/Carthage/Checkouts/LiquidFloatingActionButton/Pod/Classes/LiquidFloatingActionButton.swift:446:13: warning: initialization of variable 't2' was never used; consider replacing with assignment to '_' or removing it
XX/Carthage/Checkouts/LiquidFloatingActionButton/Pod/Classes/LiquidFloatingActionButton.swift:520:35: warning: conditional cast from 'UIView' to 'UIView' always succeeds
XX/Carthage/Checkouts/LiquidFloatingActionButton/Pod/Classes/SimpleCircleLiquidEngine.swift:121:22: warning: immutable value 'd1' was never used; consider replacing with '' or removing it
XX/Carthage/Checkouts/LiquidFloatingActionButton/Pod/Classes/SimpleCircleLiquidEngine.swift:122:22: warning: immutable value 'd2' was never used; consider replacing with '' or removing it
A shell task failed with exit code 65:
** BUILD FAILED **

The following build commands failed:
CompileSwift normal arm64 XX/Carthage/Checkouts/LiquidFloatingActionButton/Pod/Classes/LiquidFloatingActionButton.swift
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(2 failures)

Viscosity and Cell Positions

Hi,
I've just integrated the lib in obj-c project;
all works fine, except :

  • i don't have the viscosity effect,
  • cells have an actual offset on the left while popping up, ie, while animatestyle is up;

can anyone help with this ?
Thanks,

Cocoapods Updation error

Following error was encountered when updating pods:

$ pod install
Updating local specs repositories
Analyzing dependencies
[!] Unable to satisfy the following requirements:

  • LiquidFloatingActionButton (~> 0.1) required by Podfile

Specs satisfying the LiquidFloatingActionButton (~> 0.1) dependency were found, but they required a higher minimum deployment target.

Error Found

For these functions I'm getting error and error message is "LiquidFloatingActionButton.swift:201:26: Method does not override any method from its superclass"

// MARK: Events
public override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
    self.touching = true
    setNeedsDisplay()
}

public override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) {
    self.touching = false
    setNeedsDisplay()
    didTapped()
}

public override func touchesCancelled(touches: Set<NSObject>!, withEvent event: UIEvent!) {
    self.touching = false
    setNeedsDisplay()
}

Scrolling with the Floating Button

I just found out that, I've a floating button in a tableView. When I'm trying to scroll the tableView, the floating button doesn't scroll with tableView, it just stick to its position. How do I fix this problem?
img_0101
img_0102

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.