janheinrichmerker / material-intro

A simple material design app intro with cool animations and a fluent API.
https://jitpack.io/#com.heinrichreimer/material-intro
MIT License
1.74k stars 307 forks source link

For `canGoBackward` and `canGoForward`, support callbacks in addition to precomputed booleans #290

Open chimbori opened 4 years ago

chimbori commented 4 years ago

Use Case

The use case is that the value of canGoBackward can change by clicking on the CTA button. In my case, the CTA button takes the user to grant custom permissions, and they can proceed when they have granted permission.

The current API for doing this for each slide takes a single Boolean which does not work, because it is never recomputed after initial setting.

The alternative way of setNavigationPolicy comes with its own challenges: it passes in a position parameter, so it is generic to all slides. In our code, some slides are optional, and only added in the flow if certain conditions are met. This makes keeping track of the slide positions quite challenging.

API Proposal

Add an overloaded canGoBackward and canGoForward that takes in an interface with a single-abstract-method that returns a boolean. At every instance where the library wants to decide if it can go forward or backward, it will call these methods once for each such occurrence.

I can implement this myself, but posting an issue to seek blessings for the proposed change and implementation direction. Thanks!