Giter VIP home page Giter VIP logo

loady's Introduction

Version License Platform Swift

Loady

this is a small library to show loading and indicator in UIButton, with fully customizable styles. there are 6 different styles, you can set the colors from interface builder or programmatically.

Todo

  • animation style : like appstore download button
  • animation style : 4 phases Animation(normal, loading, success, error)
  • animation style : like android
  • animation style : downloading
  • extendable to accept new animations
  • animation style : like telegram sharing
  • Carthage Support

TOP_LINE

Requirements

loady minimum target requirement is iOS 10.0

Installation

loady is available through Swift Package Manager or Cocoapods

Swift Package Manager (Recommended)

dependencies: [
    .package(url: "https://github.com/farshadjahanmanesh/loady.git", .upToNextMajor(from: "1.0.8"))
]

Cocoapods

pod "loady"

Manual

simply copy the Source Code into your project, take a look at the example project for more info

Configs

Setup programmatically :

       // sets animation type
        self.loadyButton.setAnimation(LoadyAnimationType.backgroundHighlighter())
        
        // starts loading animation
        self.loadyButton?.startLoading()
        
        // some animations have filling background, or change the circle stroke, this sets the filling percent, number is something between 0 to 100
        loadyButton.update(percent: percent)

4 Phases Animation :

        // setup colors, titles and images
        self.fourPhases?.loadingColor = UIColor(red:0.38, green:0.66, blue:0.09, alpha:1.0)
        self.fourPhases.loadingColor = UIColor(red:0.38, green:0.66, blue:0.09, alpha:1.0)
			self.fourPhases.setPhases(phases: .init(
				normalPhase:
			(title: "Lock", image: UIImage(named: "unlocked"), background: UIColor(red:0.00, green:0.49, blue:0.90, alpha:1.0)), loadingPhase:
			(title: "Waiting...", image: nil, background: UIColor(red:0.17, green:0.24, blue:0.31, alpha:1.0)),
				successPhase:
			(title: "Activated", image: UIImage(named: "locked"), background: UIColor(red:0.15, green:0.68, blue:0.38, alpha:1.0)), errorPhase:
			(title: "Error", image: UIImage(named: "unlocked"), background: UIColor(red:0.64, green:0.00, blue:0.15, alpha:1.0))
				)
			)
        
        // then later in your code after user click on the button just call, this line take the button to loading phase, 
        self.fourPhasesLoadyButton?.startLoading()

        // in loading phase three different stage is available, you can cancel the loading by calling
        self.fourPhasesLoadyButton?.normalPhase()
        
        // you can take the button to success phase by calling
        self.fourPhasesLoadyButton?.successPhase()
        
        // you can take the button to error phase by calling
        self.fourPhasesLoadyButton?.errorPhase()
        
Loading To Normal Loading To Success Loading To Error

Downloading Animation :

// setup download button details
       self.downloadingLoadyButton.setAnimation(LoadyAnimationType.downloading(with: .init(
				downloadingLabel: (title: "Copying Data...", font: UIFont.boldSystemFont(ofSize: 18), textColor : UIColor(red:0, green:0.71, blue:0.8, alpha:1)),
				percentageLabel: (font: UIFont.boldSystemFont(ofSize: 14), textColor : UIColor(red:0, green:0.71, blue:0.8, alpha:1)),
				downloadedLabel: (title: "Completed.", font: UIFont.boldSystemFont(ofSize: 20), textColor : UIColor(red:0, green:0.71, blue:0.8, alpha:1))
				)
			))


Setup in interface builder

Set class change attributes

if you are a fan of NVActivityIndicatorView, its very easy to integrate it with loady, you can replace our default iOS indicatorView with NVActivityIndicatorView <3 now we have a new property which accepts LoadyActivityIndicator Protocol, just set it with your favorite activity indicator view like below

// first conform to the LoadyActivityIndicator protocol like this
extension NVActivityIndicatorView : LoadyActivityIndicator {
    
}

// then replace loady default activity indicator with yours
let nv = NVActivityIndicatorView(frame: .zero)
nv.type = .circleStrokeSpin
nv.color = .red
nv.padding = 12
self.loadyButton?.activiyIndicator = nv

| | |

troubleshoot

  1. Unable to find a specification for loady

if you get some error like this with cocoapod, just update your pod with this commands in your terminal

    > [!] Unable to find a specification for `loady`
    
    $ pod repo update
    $ pod install
    

loady's People

Contributors

guidev avatar moonbvb avatar tounaobun avatar valentinjahanmanesh 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

loady's Issues

Adaptive indicatorviewstyle.

How can i adapt indicatorviewstyle depending on whether app is in dark or light mode when setting button animation

Rounded Corners

Hey!

Unlike your examples, my button doesn't have rounded edges.

button.layer.cornerRadius

doesn't work either. How can I round the corners?

Indicator animation stops after reloading collection view

Indicator animation stops after reloading collection view and startLoading doesn't restart the animation. Looks like this has to do with UIActivityIndicatorView not restarting, but LoadyIndicatorAnimation.isLoading is never reset, you can't restart the animation.

I played around with using activityIndicator's isAnimating to indicate loading, but the title inset logic kept pushing the title back on each call. A work around is to reset the animation each time the cell is configured, but this still results in too many insets on the title.

Carthage Support

Thanks for this awesome library.
Please add Carthage support or provide a manual installation guide in the Readme file.
Thanks.

Pod Error

I got this error when trying to install loady with cocoapod
_

[!] Unable to find a specification for loady

_

FourPhases CurrentState

Thank you for this library. 🙂
I implemented the FourPhase Button, but i didn't find an option to access the currentState of the Button. Is there an option to get the state of the Button (loading, success, error or lock)?

when start in viewdidload,button image will not show

when start in viewdidload,button image will not show

class ViewController: UIViewController {
    var tempTimer1 : Timer?
    @IBOutlet var fillingView : LoadyButton!

    override func viewDidLoad() {
        super.viewDidLoad()
        
        // start and stop animating on user touch
        self.fillingView.setAnimation(LoadyAnimationType.backgroundHighlighter())
        self.fillingView.startLoading()
        var percent : CGFloat = 100
        if #available(iOS 10.0, *) {
            self.tempTimer1 = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { (t) in
                percent -= 10
                self.fillingView.update(percent: percent)
                if percent <= 0 {
                    percent = 0
                    self.tempTimer1?.invalidate()
                }
            }
        }
        self.tempTimer1?.fire()
    }
    
    @IBAction func animateView(_ sender : UIButton){
        guard let button = sender as? LoadyButton else {
            return
        }
        if button.loadingIsShowing() {
            button.stopLoading()
            return
        }
    }
}

Can't find public func when OC calls swift

I'm familiar with oc, but I don't know swift, I want to use a library written in swift. I imported the header file, but when I setup in interface builder, and called the swift method, he reported an error, as follows.

Button i added in xib
enter image description here
what should I do?I don't know swift, Thank you.

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.