acefalobi / android-stepper

A library for creating a wizard-like step-through user interface that uses navigation components and menus for displaying steps with advanced customization.
Apache License 2.0
325 stars 38 forks source link

Auto Scroll when goToNextStep() or goToPreviousStep() executed. #43

Closed sherwin14 closed 1 year ago

sherwin14 commented 1 year ago

Hi @acefalobi , I just want to ask if there's a way how to auto center the current step after goToNextStep() or goToPreviousStep() click.

acefalobi commented 1 year ago

I'm assuming this is for the tab steppers. That feature doesn't currently exist.

If you need to do that, you would need to fork this repo and add the functionality in the updateUI method for TabStepperMenu.kt or TabNumberedStepperMenu.kt depending on which stepper type you want to customize.

sherwin14 commented 1 year ago

I'm assuming this is for the tab steppers. That feature doesn't currently exist.

If you need to do that, you would need to fork this repo and add the functionality in the updateUI method for TabStepperMenu.kt or TabNumberedStepperMenu.kt depending on which stepper type you want to customize.

Hi @acefalobi Yes I'm using Tab Steppers. Btw I have successfully achieved the features without forking the repo..

What I did is: Inside of OnStepChange(step: Int).

override fun onStepChanged(step: Int) {

        val menu = binding.stepper[0] as TabStepperMenu
        val item = menu.getItem(step) as TabStepperMenuItem

        if (binding.stepper.currentStep == 0)
            binding.buttonPrevious.visibility = View.GONE else
            binding.buttonPrevious.visibility = View.VISIBLE

        binding.stepper.postDelayed({
            binding.stepper.smoothScrollTo(item.labelView.left, 0)
        }, 100L)
    }

this will also working when you click previous and next button.