Giter Site home page Giter Site logo

amerhukic / ahdownloadbutton Goto Github PK

View Code? Open in Web Editor NEW
479.0 10.0 59.0 311 KB

Customizable download button with progress and transition animations. It is based on Apple's App Store download button.

Home Page: https://www.amerhukic.com/replicating-app-store-download-button

License: MIT License

Ruby 2.20% Swift 95.83% Shell 1.97%
button ui swift ios ios11 downloadbutton animation download

ahdownloadbutton's People

Contributors

amerhukic avatar av0c0der avatar fabiotacke avatar fetzig avatar vortec4800 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

ahdownloadbutton's Issues

Unable to leave animationDispatchGroup if app goes to background...

Unable to leave animationDispatchGroup if app goes to background then back...and the UI is stuck with "startDownload" state

AHDownloadButton+StateTransitionAnimation.swift

// My simple fix

//From:
let completion: (Bool) -> Void = { completed in
    guard completed else { return }
    self.resetStateViews(except: newState)
    self.animationDispatchGroup.leave()
}

//To:
let completion: (Bool) -> Void = { completed in
    self.resetStateViews(except: newState)
    self.animationDispatchGroup.leave()
    guard completed else { return }
}

Can't tap AHDownloadButton which is inside UICollectionViewCell

Button is added inside awakeFromNib

override func awakeFromNib() {
        super.awakeFromNib()

        buttonContainer.addSubview(downloadButton)
        downloadButton.snp.makeConstraints { (maker) in
            maker.leading.trailing.equalToSuperview()
            maker.top.equalToSuperview().offset(2)
            maker.bottom.equalToSuperview().offset(2)
        }
    }

but next delegate function isn't called after tap on button

extension FileViewCell: AHDownloadButtonDelegate {
    func downloadButton(_ downloadButton: AHDownloadButton, tappedWithState state: AHDownloadButton.State) {...}
}

The workaround is to use touch API:

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        for touch in touches {
            if touch.view == downloadButton {
                downloadButton(downloadButton, tappedWithState: downloadButton.state)
                break
            }
        }
    }

But it only makes button container UIView tappable:

@IBOutlet weak var buttonContainer: UIView!

I had a feeling that overriding hitTest somehow could help, but not sure completely, will be thankful if somebody will help to understand what is the proper way of using this button inside collection cell

SwiftUI

Hey @amerhukic,

Any plans of re writing it to SwiftUI? Would be amazing! : )

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.