Skip to content

Commit 13ca7c2

Browse files
Piotr Zawadzkizawadz88
authored andcommitted
- updated README for 2.0.0
1 parent 00790a8 commit 13ca7c2

File tree

1 file changed

+38
-16
lines changed

1 file changed

+38
-16
lines changed

README.md

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ public static class MyStepperAdapter extends AbstractFragmentStepAdapter {
105105
public int getCount() {
106106
return 3;
107107
}
108+
109+
@NonNull
110+
@Override
111+
public StepViewModel getViewModel(@IntRange(from = 0) int position) {
112+
//Override this method to set Step title for the Tabs, not necessary for other stepper types
113+
return new StepViewModel.Builder(context)
114+
.setTitle(R.string.tab_title) //can be a CharSequence instead
115+
.create();
116+
}
108117
}
109118

110119
```
@@ -231,25 +240,36 @@ public class DelayedTransitionStepFragmentSample extends Fragment implements Blo
231240
}
232241
```
233242

234-
### Changing the Next button text per step
235-
<b>TODO update + add tutorial for Back button</b>
236-
Sometimes you might want to have different labels on the Next button on different steps e.g. use the default label on the first few steps,
243+
### Changing Back/Next button labels per step
244+
Sometimes you might want to have different labels on the Next and/or Back navigation buttons on different steps e.g. use the default labels on the first few steps,
237245
but display 'Summary' just before the last page.
238246
<p><img src ="./gifs/different-next-buttons.gif" width="360" height="640"/></p>
239-
In such case you need to override the `getNextButtonText(int)` method in the `AbstractStepAdapter` e.g.
247+
In such case you need to override the `getViewModel(int)` method from the `StepAdapter` e.g.
240248
```java
241-
@StringRes
242-
@Override
243-
public int getNextButtonText(int position) {
244-
switch (position) {
245-
case 0:
246-
return R.string.ms_next;
247-
case 1:
248-
return R.string.go_to_summary;
249-
default:
250-
throw new IllegalArgumentException("Unsupported position: " + position);
251-
}
249+
@NonNull
250+
@Override
251+
public StepViewModel getViewModel(@IntRange(from = 0) int position) {
252+
StepViewModel.Builder builder = new StepViewModel.Builder(context)
253+
.setTitle(R.string.tab_title);
254+
switch (position) {
255+
case 0:
256+
builder
257+
.setNextButtonLabel("This way")
258+
.setBackButtonLabel("Go to first");
259+
break;
260+
case 1:
261+
builder
262+
.setNextButtonLabel(R.string.go_to_summary)
263+
.setBackButtonLabel("Go to first");
264+
break;
265+
case 2:
266+
builder.setBackButtonLabel("Go back");
267+
break;
268+
default:
269+
throw new IllegalArgumentException("Unsupported position: " + position);
252270
}
271+
return builder.create();
272+
}
253273
```
254274

255275
### Using the same stepper styling across the application
@@ -288,7 +308,9 @@ This behaviour can be changed by setting ```ms_showBackButtonOnFirstStep``` to `
288308
To get a callback when this button was pressed you need set a ```StepperListener``` and write your own custom return logic in the ```onReturn()``` method to e.g. close the Activity.
289309

290310
### Using with Views instead of Fragments
291-
<b>TODO: document</b>
311+
It is possible to use this library without the need to rely on Fragments.
312+
To do so you need to use ```AbstractStepAdapter``` instead of ```AbstractFragmentStepAdapter```.
313+
For an example of how to use it with views please see the sample app.
292314

293315
### Advanced usage
294316
For other examples, e.g. persisting state on rotation, displaying errors, changing whether the user can go to the next step, etc. check out the sample app.

0 commit comments

Comments
 (0)