Skip to content

Commit

Permalink
customProgress
Browse files Browse the repository at this point in the history
  • Loading branch information
Macacoazul01 committed Feb 10, 2023
1 parent 09e3d07 commit 6cefa3e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ This is the full list:
- Define your custom Back button (Widget), by using `overrideBack`
- This param or `back` are required if you set `showBackButton: true`
- This parameter has priority over the `skip` parameter.
- Define your custom dots widget (or the widget that you want on that position), by using `customProgress`

#### Manage display of pre-made or custom buttons

Expand Down
52 changes: 30 additions & 22 deletions lib/src/introduction_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,17 @@ class IntroductionScreen extends StatefulWidget {
/// @Default `true`
final bool showBottomPart;

/// Is the Back button should be display
/// If the Back button should be display
///
/// @Default `false`
final bool showBackButton;

/// Is the progress indicator should be display
/// If a custom Widget should be used instead of the default progress indicator
///
/// @Default `null`
final Widget? customProgress;

/// If the progress indicator should be display
///
/// @Default `true`
final bool isProgress;
Expand All @@ -95,7 +100,7 @@ class IntroductionScreen extends StatefulWidget {
/// @Default `true`
final bool isProgressTap;

/// Is the user is allow to change page
/// If the user is allow to change page
///
/// @Default `false`
final bool freeze;
Expand Down Expand Up @@ -230,7 +235,7 @@ class IntroductionScreen extends StatefulWidget {
/// @Default `BouncingScrollPhysics()`
final ScrollPhysics scrollPhysics;

/// Is right to left behaviour
/// If is right to left behaviour
///
/// @Default `false`
final bool rtl;
Expand Down Expand Up @@ -281,6 +286,7 @@ class IntroductionScreen extends StatefulWidget {
this.showDoneButton = true,
this.showBottomPart = true,
this.showBackButton = false,
this.customProgress,
this.isProgress = true,
this.isProgressTap = true,
this.freeze = false,
Expand Down Expand Up @@ -384,7 +390,7 @@ class IntroductionScreenState extends State<IntroductionScreen> {
int getPagesLength() {
return (widget.pages ?? widget.rawPages!).length;
}

int getCurrentPageNumber() => _currentPage.round();

Future<void> _autoScroll(int? _durationInt) async {
Expand Down Expand Up @@ -575,23 +581,25 @@ class IntroductionScreenState extends State<IntroductionScreen> {
Expanded(
flex: widget.dotsFlex,
child: Center(
child: widget.isProgress
? Semantics(
label:
"Page ${_currentPage.round() + 1} of ${getPagesLength()}",
excludeSemantics: true,
child: DotsIndicator(
reversed: widget.rtl,
dotsCount: getPagesLength(),
position: _currentPage,
decorator: widget.dotsDecorator,
onTap: widget.isProgressTap &&
!widget.freeze
? (pos) => animateScroll(pos.toInt())
: null,
),
)
: const SizedBox(),
child: widget.customProgress ??
(widget.isProgress
? Semantics(
label:
"Page ${_currentPage.round() + 1} of ${getPagesLength()}",
excludeSemantics: true,
child: DotsIndicator(
reversed: widget.rtl,
dotsCount: getPagesLength(),
position: _currentPage,
decorator: widget.dotsDecorator,
onTap: widget.isProgressTap &&
!widget.freeze
? (pos) =>
animateScroll(pos.toInt())
: null,
),
)
: const SizedBox()),
),
),
Expanded(
Expand Down

0 comments on commit 6cefa3e

Please sign in to comment.