Swiftpack.co - public-value-tech/play-button as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by public-value-tech.
public-value-tech/play-button v1.0.2
An animated play button written in Swift
⭐️ 26
🕓 3 weeks ago
iOS tvOS
.package(url: "https://github.com/public-value-tech/play-button.git", from: "v1.0.2")

PlayButton

build

A button that can render four different playback related modes and animate between them.

Different play button appearances

Installation (Swift Package Manager)

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding PlayButton as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
  .package(url: "https://github.com/public-value-tech/play-button.git", .branch("main"))
]

Usage

import PlayButton

let playButton = PlayButton() // defaults to CGSize(width: 44, height: 44)
playButton.playBufferingBackgroundColor = .systemBlue
playButton.pauseStopBackgroundColor = .systemBlue
playButton.playBufferingTintColor = .white
playButon.pauseStopTintColor = .white

// Animate the mode update
playButton.setMode(.stop, animated: true)

// iOS / macCatalyst 
playButton.addTarget(self, action: #selector(playButtonTapped), for: .touchUpInside))

// tvOS
playButton.addTarget(self, action: #selector(playButtonTapped), forsrc="https://raw.github.com/public-value-tech/play-button/main/imaryActionTriggered)

Documentation

Check out the documentation or just compile it yourself when you add the package to your projects.

Tests

The tests mostly consist of snapshot tests. We use a CADisplayLink to sample some frames from the animation and diff them against reference snapshots. Since there is some expected deviation we add some tolerance to the tests.

How it all started

You may wonder what's so special about this play button. In this article we describe the difficulties we have faced implementing an interruptible and reversible animation in Core Animation.

GitHub

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

Release Notes

1.0.2
3 weeks ago

What's Changed

  • Layout fixes for different content modes

Full Changelog: https://github.com/public-value-tech/play-button/compare/v1.0.1...v1.0.2

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