Swiftpack.co - Awesomeplayer165/PillboxView as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Awesomeplayer165.
Awesomeplayer165/PillboxView v1.0
A Pillbox Capsule-like informational view for iOS written in UIKit
⭐️ 3
🕓 14 weeks ago
iOS tvOS macCatalyst
.package(url: "https://github.com/Awesomeplayer165/PillboxView.git", from: "v1.0")

PillboxView

PillboxView is a small pill that presents a view on an asynchronous on-going task, the state of an asynchronous task, or instant task. It shows a small bubble, pill looking box that sides from the top of the screen. You most likely have seen this throughout iOS when the ringer state is changed, Airpods are connected and when you copy your Discord ID, among others.

Note: Discord does not use this dependency, they were my inspiration for creating this since I could not find a dependency that did this

📝 Here is the API documentation for the latest version powered by DocC

Installation

PillboxView is available through Swift Package Manager.

Example

  • Display a title message

  • Show an activity indicator to show ongoing activity IMG_439D92B0A93B-1

  • Indicate your task's success with a green checkmark IMG_9C967D1A90FD-1 or failure with a red x IMG_72EF15491E30-1

  • Animates between images and frames for clean effect

The repo of a complete example app can be found here

Quick Start

Asynchronous Task

This is great for network calls to assure the user that there is something going on.

All you have to do is pass in a title message and your UIViewController's UIView


import UIKit
import PillboxView

class ViewController: UIViewController {

    let pill = PillView()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        pill.show(title: "Refreshing Data", vcView: self.view)
        
        // some time later...
        DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
          pill.completedTask(state: true) // this indicates the task's success
        }
    }
}

Error

This is especially useful if you want to display a concise error message, and the task's completion time is very quick (like checking the values of a UITextField and reporting if any are invalid.)


import UIKit
import PillboxView

class ViewController: UIViewController {

    let pill = PillView()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        pill.showError(message: "Refreshing Data", vcView: self.view)
    }
}

Conclusion

Let me know how this is and help me improve this project with ideas, suggestions.

Requirements

iOS 13.0 or higher

License

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

GitHub

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

Release Notes

Update for Set Crashing
9 weeks ago

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