ActionsDrawer 0.1.1

ActionsDrawer 0.1.1

Maintained by Fine crafted apps.



  • By
  • Francis

ActionsDrawer

CI Status Version License Platform

What does it look like?

How to use

// Using the hardcoded title approach

func present() {
    let drawerViewController = ActionsDrawerViewController(title: "Title provided as a string", actionGroups: [
        ActionGroup(actions: [
            Action(icon: nil, title: "Do the thing", tintColor: .blue, handler: {
                print("Did the thing")
            }),
            Action(icon: nil, title: "Do the other thing", tintColor: .blue, handler: {
                print("Did the other thing")
            })
        ]),
        ActionGroup(actions: [
            Action(icon: nil, title: "Do the dangerous thing thing", tintColor: .red, handler: {
                print("Did the dangerous thing")
            })
        ])
    ])
    self.drawerController = drawerViewController
    drawerViewController.delegate = self
    drawerViewController.transitioningDelegate = drawerViewController
    present(drawerViewController, animated: true, completion: nil)
}

// Using the protocol approach

struct Pizza {
    let radius: Int
    let toppings: [String]
}

extension Pizza: ActionableItem {
    var drawerView: UIView {
        let view = UILabel()
        view.text = "\(radius) inch pizza - \(toppings.count) toppings"
        view.textColor  = UIColor.orange
        view.font = UIFont.systemFont(ofSize: 14)
        view.textAlignment = .center
        return view
    }
}

// ...

func present() {
    let pizza = Pizza(radius: 12, toppings: ["Pepperonni", "Cheese"])

    let viewController = ActionsDrawerViewController(actionableItem: pizza, actionGroups: [
        ActionGroup(actions: [
            Action(icon: UIImage(named: "oven"), title: "Bake", tintColor: .blue, handler: {
                print("Baking the pizza")
            }),
            Action(icon: UIImage(named: "pizzaCar"), title: "Deliver", tintColor: .blue, handler: {
                print("Delivering the pizza")
            })
        ]),
        ActionGroup(actions: [
            Action(icon: UIImage(named: "garbage"), title: "Garbage", tintColor: .red, handler: {
                print("Pizza tastes bad. Putting in the garbage")
            })
        ])
    ])
}

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

ActionsDrawer is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ActionsDrawer'

Author

Francis, [email protected]

License

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