Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FloatyItem add Click handler #268

Closed
ThePredators opened this issue Aug 22, 2019 · 2 comments
Closed

FloatyItem add Click handler #268

ThePredators opened this issue Aug 22, 2019 · 2 comments

Comments

@ThePredators
Copy link

ThePredators commented Aug 22, 2019

Hello,

I tried to setup a floaty like this :

        let floaty = Floaty()
        floaty.buttonColor = #colorLiteral(red: 2.387956192e-05, green: 0.5332912803, blue: 0.8063663244, alpha: 1)
        floaty.plusColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
        floaty.openAnimationType = .pop
        let floatyItem = FloatyItem()
        floatyItem.title = "Hello"
        floatyItem.icon = UIImage(named: "add")
        floatyItem.titleLabel.borderColor = #colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1)
        floatyItem.titleLabel.backgroundColor = #colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1)
        floatyItem.titleLabel.textColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)
        floatyItem.titleLabel.cornerRadius = 2
        floatyItem.titleLabel.borderWidth = 1
        floaty.addItem(item: floatyItem)
        self.view.addSubview(floaty)

But i dont find any method to use the click handler on the floatyItem !

Any idea please ?

@ThePredators ThePredators changed the title FloatyItem add handler FloatyItem add Click handler Aug 22, 2019
@ThisIsBugFixxer
Copy link

Hey, did you get any solution for this ? I need to call a custom method for haptics on click, but can’t seem figure out how.
thanks !!

@ThePredators
Copy link
Author

ThePredators commented Feb 9, 2023

Wow its been a long time @ThisIsBugFixxer

I created this function then i call it in viewDidLoad. Don't forget to replace <ParentController> with the parent controller.

    func setupFab() -> Floaty {
        let floaty = Floaty()
        floaty.buttonColor = #colorLiteral(red: 2.387956192e-05, green: 0.5332912803, blue: 0.8063663244, alpha: 1)
        floaty.plusColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
        floaty.openAnimationType = .pop
        let floatyItem = FloatyItem()
        floatyItem.title = "..."
        floatyItem.icon = UIImage(named: "Groupe 3024")
        floatyItem.titleLabel.layer.frame = CGRect(x: -210, y: 0, width: 205, height: 40)
        let padding = UIEdgeInsets(top: 6, left: 16, bottom: 6, right: 16)
        floatyItem.titleLabel.layer.bounds.inset(by: padding)
        floatyItem.titleLabel.font = UIFont(name: "Avenir Medium", size: 16)
        floatyItem.titleLabel.textAlignment = .center
        floatyItem.titleLabel.layer.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
        floatyItem.titleLabel.layer.cornerRadius = 7
        floatyItem.titleLabel.layer.borderColor = #colorLiteral(red: 0.8039215803, green: 0.8039215803, blue: 0.8039215803, alpha: 1)
        floatyItem.titleLabel.layer.borderWidth = 1
        floatyItem.titleLabel.textColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)
        // Item Click
        floatyItem.handler = { item in
            (self.parent?.parent as! <ParentController>).showAlert()
            floaty.close()
        }
        floaty.addItem(item: floatyItem)
        return floaty
    }

    override func viewDidLoad() {
        super.viewDidLoad()        
        self.view.addSubview(setupFab())
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants