aromajoin / material-showcase-ios

✨ An elegant way to guide your beloved users in iOS apps - Material Showcase.
https://aromajoin.com/
Other
363 stars 128 forks source link

Click event on showcase #1

Closed vre142 closed 7 years ago

vre142 commented 7 years ago

Hi, I have one question How can i check event click for example when showcase show first tab item after user click on it I want to show next tab item as show case. How can I do this? Another question is how can I change default background color of circle?

Thanks, vafa

quangctkm9207 commented 7 years ago

Hi,

Thank you for your feedback. I am working on chaining feature. Currently, you can do it manually by calling two showcases inside each tab item listener method. For example.

  // Show tab item 1
  showcaseItem1()

  func tabItem1Click(_ sender: Any) {
    // ....
    // Show tab item 2 after item 1 clicked
    showcaseItem2()
  }

Default background color of circle is white as default. I would like to put this property as public. I will ping in this thread when new update comes.

hsklia commented 7 years ago

+1

joshoconnor89 commented 7 years ago

I added a pull request to easily do this: https://github.com/aromajoin/material-showcase-ios/pulls

I added a delegate method so the user knows when the showcase is being dismissed. One this delegate method showCaseWillDismiss is called, just create another instance of the showcase. If you accept this pull request please update the docs:

Creating MaterialShowcase object: let showcase = MaterialShowcase(delegate: self) and the delegate method:

Implementing delegate method:

extension MyClass:  MaterialShowcaseDelegate {
     func showCaseWillDismiss() {
        //Create another instance here
     }
}
quangctkm9207 commented 7 years ago

@joshoconnor89 : Thank you for spending time on this issue. It still does not address the issue. The main point is that we need to trigger view click under showcase click and notify when it's done.

joshoconnor89 commented 7 years ago

When I ran:

showcase.show(completion: {
    _ in
    print("Test")
})

It printed "Test" in my console immediately when showcase was shown. Not when I tapped to dismiss. When I do:

let showcase = MaterialShowcase()
showcase.setTargetView(view: button) // always required to set targetView
showcase.primaryText = "Action 1"
showcase.secondaryText = "Click here to go into details"
showcase.show(completion: {
    _ in
        let showcase2 = MaterialShowcase()
        showcase2.setTargetView(view: button) // always required to set targetView
        showcase2.primaryText = "Action 2"
        showcase2.secondaryText = "Secondary text 2"
        showcase2.show(completion: {
            _ in
    })
})

it shows both showcases at the same time. So the completion handler has something wrong with it. In my example, when showCaseWillDismiss() is called via the delegate, I create another showCase and present it with a .3 second delay, and able to go from one button to the next immediately after I login to my app. Works like a charm and is wonderful.

Regardless, I highly recommend setting up a delegate with your library :)

quangctkm9207 commented 7 years ago

Exactly as you said, I made a mistake. Yes. completion in material.show() handles the action right after the showcase view is shown, not when it is dismissed. I check it one more time and maybe set delegate up. Just considering the way to make codes concise.

petemillermultimedia commented 7 years ago

A delegate method was committed in #9ea5aa6 then removed in #9c887be. Why was it removed? I need this capability.

quangctkm9207 commented 7 years ago

@joshoconnor89 : I have just re-added your delegate solution with slight modifications (optional and support two event callbacks).
@petemillermultimedia : Please check new commit(#11096) with delegate supported.
Besides, the latest version (0.1.4) is also published on CocoaPods, and check out README for documentation update.