Skip to content

Commit af9578e

Browse files
Piotr Zawadzkizawadz88
Piotr Zawadzki
authored andcommitted
Release 3.3.0
Added missing JavaDoc in StepperLayout. Added info about hiding bottom navigation in README Added missing tests for hiding bottom navigation bar
1 parent 8108ff5 commit af9578e

File tree

5 files changed

+105
-5
lines changed

5 files changed

+105
-5
lines changed

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Moreover, you can find there other examples, e.g. how to persist state on rotati
2727
- [Showing an error on tabs if step verification failed](#showing-an-error-on-tabs-if-step-verification-failed)
2828
- [Stepper feedback](#stepper-feedback)
2929
- [Changing button text color when going to the next step should be disabled](#changing-button-text-color-when-going-to-the-next-step-should-be-disabled)
30+
- [Hiding bottom navigation bar](#hiding-bottom-navigation-bar)
3031
- [StepperLayout attributes](#stepperlayout-attributes)
3132
- [View attributes](#view-attributes)
3233
- [StepperLayout style attributes](#stepperlayout-style-attributes)
@@ -56,7 +57,7 @@ Moreover, you can find there other examples, e.g. how to persist state on rotati
5657

5758
### Download (from JCenter)
5859
```groovy
59-
compile 'com.stepstone.stepper:material-stepper:3.2.3'
60+
compile 'com.stepstone.stepper:material-stepper:3.3.0'
6061
```
6162

6263
### Create layout in XML
@@ -435,6 +436,13 @@ In order to set that color:
435436
mStepperLayout.setCompleteButtonVerificationFailed(!enabled);
436437
```
437438

439+
### Hiding bottom navigation bar
440+
Bottom navigation bar is shown by default. If in your UI you would like to
441+
hide the bottom navigation bar you can do that by either setting
442+
the `ms_showBottomNavigation` attribute in XML to `false`
443+
or by setting it programmatically by calling ```StepperLayout#setShowBottomNavigation(boolean)```
444+
with `false`.
445+
438446
## StepperLayout attributes
439447

440448
### View attributes
@@ -463,6 +471,7 @@ For advanced styling please see [StepperLayout style attributes](#stepperlayout-
463471
| *ms_showErrorStateOnBackEnabled*| boolean | Flag indicating whether to keep showing the error state when user moves back. Only applicable for 'tabs' type. False by default. |
464472
| *ms_tabNavigationEnabled* | boolean | Flag indicating whether step navigation is possible by clicking on the tabs directly. Only applicable for 'tabs' type. True by default. |
465473
| *ms_stepperFeedbackType* | flag(s): `none` or `tabs`, `content` & `disabled_bottom_navigation` | Type(s) of stepper feedback. Can be a combination of `tabs`, `content` & `disabled_bottom_navigation`. Default is `none`.|
474+
| *ms_showBottomNavigation* | boolean | Flag indicating if the Bottom Navigation bar should be shown on the layout. True by default. |
466475
| *ms_stepperLayoutTheme* | reference | Theme to use for even more custom styling of the stepper layout. It is recommended that it should extend @style/MSDefaultStepperLayoutTheme, which is the default theme used. |
467476
468477
### StepperLayout style attributes

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919

2020
POM_GROUP_ID=com.stepstone.stepper
2121
POM_ARTIFACT_ID=material-stepper
22-
POM_VERSION=3.2.3
22+
POM_VERSION=3.3.0

material-stepper/src/main/java/com/stepstone/stepper/StepperLayout.java

+32
Original file line numberDiff line numberDiff line change
@@ -433,26 +433,58 @@ public int getCurrentStepPosition() {
433433
return mCurrentStepPosition;
434434
}
435435

436+
/**
437+
* Sets whether the Next button in the bottom navigation bar should be in the
438+
* 'verification failed' state i.e. still clickable but with an option to display it
439+
* differently to indicate to the user that he cannot go to the next step yet.
440+
* @param verificationFailed false if verification failed, true otherwise
441+
*/
436442
public void setNextButtonVerificationFailed(boolean verificationFailed) {
437443
mNextNavigationButton.setVerificationFailed(verificationFailed);
438444
}
439445

446+
/**
447+
* Sets whether the Complete button in the bottom navigation bar should be in the
448+
* 'verification failed' state i.e. still clickable but with an option to display it
449+
* differently to indicate to the user that he cannot finish the process yet.
450+
* @param verificationFailed false if verification failed, true otherwise
451+
*/
440452
public void setCompleteButtonVerificationFailed(boolean verificationFailed) {
441453
mCompleteNavigationButton.setVerificationFailed(verificationFailed);
442454
}
443455

456+
/**
457+
* Sets whether the Next button in the bottom navigation bar should be enabled (clickable).
458+
* setting this to <i>false</i> will make it unclickable.
459+
* @param enabled true if the button should be clickable, false otherwise
460+
*/
444461
public void setNextButtonEnabled(boolean enabled) {
445462
mNextNavigationButton.setEnabled(enabled);
446463
}
447464

465+
/**
466+
* Sets whether the Complete button in the bottom navigation bar should be enabled (clickable).
467+
* setting this to <i>false</i> will make it unclickable.
468+
* @param enabled true if the button should be clickable, false otherwise
469+
*/
448470
public void setCompleteButtonEnabled(boolean enabled) {
449471
mCompleteNavigationButton.setEnabled(enabled);
450472
}
451473

474+
/**
475+
* Sets whether the Back button in the bottom navigation bar should be enabled (clickable).
476+
* setting this to <i>false</i> will make it unclickable.
477+
* @param enabled true if the button should be clickable, false otherwise
478+
*/
452479
public void setBackButtonEnabled(boolean enabled) {
453480
mBackNavigationButton.setEnabled(enabled);
454481
}
455482

483+
/**
484+
* Set whether the bottom navigation bar (with Back/Next/Complete buttons) should be visible.
485+
* <i>true</i> by default.
486+
* @param showBottomNavigation true if bottom navigation should be visible, false otherwise
487+
*/
456488
public void setShowBottomNavigation(boolean showBottomNavigation) {
457489
mStepNavigation.setVisibility(showBottomNavigation ? View.VISIBLE : View.GONE);
458490
}

material-stepper/src/test/java/com/stepstone/stepper/StepperLayoutTest.kt

+52
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,58 @@ class StepperLayoutTest {
153153
assertStepperLayout().hasOrientation(LinearLayout.VERTICAL)
154154
}
155155

156+
@Test
157+
fun `Horizontal orientation should be set by default`() {
158+
//given
159+
val attributeSet = createAttributeSetWithStepperType(TYPE_DOTS)
160+
161+
//when
162+
stepperLayout = createStepperLayoutInActivity(attributeSet)
163+
164+
//then
165+
assertStepperLayout().hasOrientation(LinearLayout.VERTICAL)
166+
}
167+
168+
@Test
169+
fun `Bottom navigation should be visible by default`() {
170+
//given
171+
val attributeSet = createAttributeSetWithStepperType(TYPE_TABS)
172+
173+
//when
174+
stepperLayout = createStepperLayoutInActivity(attributeSet)
175+
176+
//then
177+
assertStepperLayout().hasBottomNavigationShown()
178+
}
179+
180+
@Test
181+
fun `Bottom navigation should be hidden if 'ms_showBottomNavigation' attribute is set to 'false' in XML`() {
182+
//given
183+
val attributeSet = Robolectric.buildAttributeSet()
184+
.addAttribute(R.attr.ms_stepperType, TYPE_TABS)
185+
.addAttribute(R.attr.ms_showBottomNavigation, "false")
186+
.build()
187+
188+
//when
189+
stepperLayout = createStepperLayoutInActivity(attributeSet)
190+
191+
//then
192+
assertStepperLayout().hasBottomNavigationHidden()
193+
}
194+
195+
@Test
196+
fun `Bottom navigation should be hidden if set programmatically`() {
197+
//given
198+
val attributeSet = createAttributeSetWithStepperType(TYPE_TABS)
199+
stepperLayout = createStepperLayoutInActivity(attributeSet)
200+
201+
//when
202+
stepperLayout.setShowBottomNavigation(false)
203+
204+
//then
205+
assertStepperLayout().hasBottomNavigationHidden()
206+
}
207+
156208
fun createAttributeSetWithStepperType(stepperType: String): AttributeSet {
157209
return Robolectric.buildAttributeSet()
158210
.addAttribute(R.attr.ms_stepperType, stepperType)

material-stepper/src/test/java/com/stepstone/stepper/test/assertion/StepperLayoutAssert.kt

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package com.stepstone.stepper.test.assertion
22

33
import android.support.annotation.IdRes
4-
import android.view.View
5-
64
import com.stepstone.stepper.R
75
import com.stepstone.stepper.StepperLayout
8-
96
import org.assertj.android.api.Assertions
107
import org.assertj.android.api.view.ViewAssert
118
import org.assertj.android.api.widget.AbstractLinearLayoutAssert
@@ -53,6 +50,16 @@ class StepperLayoutAssert constructor(actual: StepperLayout) : AbstractLinearLay
5350
return this
5451
}
5552

53+
fun hasBottomNavigationShown(): StepperLayoutAssert {
54+
hasNotNullChildView(R.id.ms_bottomNavigation).isVisible
55+
return this
56+
}
57+
58+
fun hasBottomNavigationHidden(): StepperLayoutAssert {
59+
hasNotNullChildView(R.id.ms_bottomNavigation).isGone
60+
return this
61+
}
62+
5663
private fun hasNotNullChildView(@IdRes childId: Int): ViewAssert {
5764
val progressBar = actual.findViewById(childId)
5865
return Assertions.assertThat(progressBar).isNotNull

0 commit comments

Comments
 (0)