Swiftpack.co - farshadjahanmanesh/loady as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by farshadjahanmanesh.
farshadjahanmanesh/loady delete
fully customizable loading button with 9 different styles
⭐️ 831
🕓 2 weeks ago
.package(url: "https://github.com/farshadjahanmanesh/loady.git", from: "delete")

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 asrc="https://raw.github.com/farshadjahanmanesh/loady/master/ 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 | | src="https://raw.github.com/farshadjahanmanesh/loady/master/-------- | ------------- | ------------- | | <img style="max-width:100%;" src="examples/_cancelPhasesrc="https://raw.github.com/farshadjahanmanesh/loady/master/ height="200px" style="text-align:center"> | <img style="max-width:100%;" src="examples/_successPhasesrc="https://raw.github.com/farshadjahanmanesh/loady/master/ height="200px" style="text-align:center"> | |


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,src="https://raw.github.com/farshadjahanmanesh/loady/master/n:0.71, blue:0.8, alpha:1))
				)
			))


Setup in interface builder

Set class changesrc="https://raw.github.com/farshadjahanmanesh/loady/master/ibutes
<img style="max-width:100%;" src="examples/_setClasrc="https://raw.github.com/farshadjahanmanesh/loady/master/g" width="100%" style="text-align:center">

BONUS - NVActivityIndicatorView

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

| <img style="max-width:100%;" src="https://raw.githubusercontent.com/ninjaprox/NVActivityIndicatorView/master/Dsrc="https://raw.github.com/farshadjahanmanesh/loady/master/if" width="20%" style="text-align:center"> | <img style="max-width:100%;" src="examples/_nvaccsrc="https://raw.github.com/farshadjahanmanesh/loady/master/yindicator1.gif?raw=true" style="text-align:center"> |

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
    

GitHub

link
Stars: 831
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics