Skip to content

iqbalprabu/material-stepper

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Material Stepper

Android Arsenal git-card

Dependency

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }

Add the dependency

dependencies {
   compile 'com.github.fcannizzaro:material-stepper:1.2.2'
}

Preview

text progress dots tabs

Stepper

Extend one of these classes TextStepper, ProgressStepper, DotStepper, TabStepper

Methods

setTitle(String)

set stepper title

addStep(String)

add a step

setPrimaryColor(int)

set primary color (Toolbar/ Progress & Dot & Tab Circle color )

setDarkPrimaryColor(int)

set status bar & text color

setErrorTimeout(int)

set timeout (milliseconds) of error message

setStateAdapter()

use FragmentStatePagerAdapter for ViewPager instead of FragmentPagerAdapter

setStartPreviousButton()

show initial "previous" button (first step)

Tab Stepper Methods

setLinear(boolean)

limit user path (user has to complete previous step before move to next)

setPreviousVisible()

show previous button on the left

setDisabledTouch()

disable user touch on tabs (prevent click)

setAlternativeTab(boolean)

use alternative tab style

  • classic

classic

  • alternative

alternative

Toolbar getToolbar();

get stepper toolbar

Override Method

void onComplete()

void onComplete(Bundle data)

called when 'complete' button is pressed

public class Sample extends TabStepper {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
	
	/*
		...
		
		methods
		
		...
	*/
	
	// call super at the end
	super.onCreate(savedInstanceState);
    }

Step

Extend AbstractStep

Override Methods

String name()

override step name

String error()

override error message (HTML supported)

boolean isOptional()

override if is optional [Default = false]

boolean nextIf()

override condition to move to next step [Default = true]

void onStepVisible()

called when a step is visible

void onNext()

called when next button is pressed

void onPrevious()

called when previous button is pressed

public class StepSample extends AbstractStep {

    // step name
    @Override
    public String name() {
        return "Step title";
    }

    // step optional title (default: "Optional")
    @Override
    public String optional() {
        return "Optional subtitle";
    }
    
    // set step optional or not (default: false)
    @Override
    public boolean isOptional() {
        return true;
    }

    // override only if step is limited by condition
    @Override
    public boolean nextIf() {
        return i > 5;
    }

    // error showed on change next step ( see nextIf )
    @Override
    public String error() {
        return "<b>Condition</b>";
    }

    // do something when step is visible
    @Override
    public void onStepVisible() {
        super.onStepVisible();
    }

}

Share Data between steps

Bundle getStepData()

get available bundle for current step

Bundle getStepDataFor(int step)

get bundle for specific step and set your data

Bundle getLastStepData()

get bundle for last step

// get bundle for step 3
Bundle data = getStepDataFor(3);
data.putInt("test",5);

Save Stepper Result

Save data returned in onActivityResult

Bundle data = mStepper.getExtras();

Strings

Overwrite these strings for support multilanguage / custom titles

<string name="ms_prev">PREV</string>
<string name="ms_next">NEXT</string>
<string name="ms_end">COMPLETE</string>
<string name="ms_continue">CONTINUE</string>
<string name="ms_optional">Optional</string>
<string name="ms_text_step">Step $current of $total</string>

About

Android Library to create simple stepper activities

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%