Skip to content

Commit

Permalink
Implemented setting to hide the confirmation button on the confirmati…
Browse files Browse the repository at this point in the history
…on step
  • Loading branch information
ernestoyaquello committed Jun 8, 2021
1 parent 5c0b8f7 commit 44e41a4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,20 @@ public Builder displayCancelButtonInLastStep(boolean displayCancelButtonInLastSt
return this;
}

/**
* Specifies whether or not a confirmation button should be displayed in the last step.
* If displayed, this button will invoke the callback onCompletedForm() when clicked.
*
* @param displayNextButtonInLastStep True to display a confirmation button in the last step;
* false to not.
* @return The builder instance.
*/
public Builder displayNextButtonInLastStep(boolean displayNextButtonInLastStep) {
formView.style.displayNextButtonInLastStep = displayNextButtonInLastStep;

return this;
}

/**
* Specifies whether or not a confirmation step should be added as an extra step at the end of
* the form.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ private void setupStepViews(final VerticalStepperFormView form, View stepLayout)
cancelButtonView.setVisibility(View.VISIBLE);
}

if (!formStyle.displayNextButtonInLastStep && isLast) {
nextButtonView.setVisibility(View.GONE);
}

if (!formStyle.displayStepButtons && !isConfirmationStep()) {
nextButtonView.setVisibility(View.GONE);
}
Expand Down Expand Up @@ -226,6 +230,15 @@ void updateStepViewsAfterPositionChange(VerticalStepperFormView form) {
cancelButtonView.setVisibility(View.GONE);
}

if (formStyle.displayNextButtonInLastStep && isLast) {
String nextButtonText = formStyle.lastStepNextButtonText == null
? "" : formStyle.lastStepNextButtonText;
nextButtonView.setText(nextButtonText);
nextButtonView.setVisibility(View.VISIBLE);
} else {
nextButtonView.setVisibility(View.GONE);
}

lineView1.setVisibility(isLast ? View.GONE : View.VISIBLE);
lineView2.setVisibility(isLast ? View.GONE : View.VISIBLE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ private void onConstructed(Context context, AttributeSet attrs, int defStyleAttr
style.displayBottomNavigation = true;
style.displayStepButtons = true;
style.displayCancelButtonInLastStep = false;
style.displayNextButtonInLastStep = true;
style.displayStepDataInSubtitleOfClosedSteps = true;
style.displayDifferentBackgroundColorOnDisabledElements = false;
style.includeConfirmationStep = true;
Expand Down Expand Up @@ -754,6 +755,9 @@ private void onConstructed(Context context, AttributeSet attrs, int defStyleAttr
style.displayCancelButtonInLastStep = vars.getBoolean(
R.styleable.VerticalStepperFormView_form_display_cancel_button_in_last_step,
style.displayCancelButtonInLastStep);
style.displayNextButtonInLastStep = vars.getBoolean(
R.styleable.VerticalStepperFormView_form_display_next_button_in_last_step,
style.displayNextButtonInLastStep);
style.displayStepDataInSubtitleOfClosedSteps = vars.getBoolean(
R.styleable.VerticalStepperFormView_form_display_step_data_in_subtitle_of_closed_steps,
style.displayStepDataInSubtitleOfClosedSteps);
Expand Down Expand Up @@ -1198,6 +1202,7 @@ class FormStyle {
boolean displayBottomNavigation;
boolean displayStepButtons;
boolean displayCancelButtonInLastStep;
boolean displayNextButtonInLastStep;
boolean displayStepDataInSubtitleOfClosedSteps;
boolean displayDifferentBackgroundColorOnDisabledElements;
boolean includeConfirmationStep;
Expand Down
1 change: 1 addition & 0 deletions vertical-stepper-form/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<attr name="form_display_bottom_navigation" format="boolean" />
<attr name="form_display_step_buttons" format="boolean" />
<attr name="form_display_cancel_button_in_last_step" format="boolean" />
<attr name="form_display_next_button_in_last_step" format="boolean" />
<attr name="form_display_step_data_in_subtitle_of_closed_steps" format="boolean" />
<attr name="form_display_different_background_color_on_disabled_elements" format="boolean" />
<attr name="form_include_confirmation_step" format="boolean" />
Expand Down

0 comments on commit 44e41a4

Please sign in to comment.