Skip to content

Commit

Permalink
Merge branch 'adding_showdonebutton_property' of https://github.com/M…
Browse files Browse the repository at this point in the history
…aRossetti/introduction_screen into MaRossetti-adding_showdonebutton_property
  • Loading branch information
Pyozer committed Mar 27, 2021
2 parents 65dc55e + 9adf4de commit 7e2e423
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,4 @@ There is other possibles parameters that you can add :
- Dots indicator flex, by adding `dotsFlex: 1` parameter. (Set 0 to disable Expanded behaviour)
- Next/Done button flex, by adding `nextFlex: 1` parameter. (Set 0 to disable Expanded behaviour)
- Animation type between pages, by adding `curve` parameter.
- Hide done button, by adding `showDoneButton: false` parameter.
28 changes: 23 additions & 5 deletions lib/src/introduction_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class IntroductionScreen extends StatefulWidget {
final List<Widget>? rawPages;

/// Callback when Done button is pressed
final VoidCallback onDone;
final VoidCallback? onDone;

/// Done button
final Widget done;
final Widget? done;

/// Callback when Skip button is pressed
final VoidCallback? onSkip;
Expand All @@ -44,6 +44,11 @@ class IntroductionScreen extends StatefulWidget {
/// @Default `true`
final bool showNextButton;

/// If the 'Done' button should be rendered at all the end
///
/// @Default `true`
final bool showDoneButton;

/// Is the progress indicator should be display
///
/// @Default `true`
Expand Down Expand Up @@ -118,14 +123,15 @@ class IntroductionScreen extends StatefulWidget {
Key? key,
this.pages,
this.rawPages,
required this.onDone,
required this.done,
this.onDone,
this.done,
this.onSkip,
this.onChange,
this.skip,
this.next,
this.showSkipButton = false,
this.showNextButton = true,
this.showDoneButton = true,
this.isProgress = true,
this.isProgressTap = true,
this.freeze = false,
Expand All @@ -149,6 +155,8 @@ class IntroductionScreen extends StatefulWidget {
(rawPages != null && rawPages.length > 0),
"You provide at least one page on introduction screen !",
),
assert(!showDoneButton || onDone != null),
assert(!showDoneButton || done != null),
assert((showSkipButton && skip != null) || !showSkipButton),
assert((showNextButton && next != null) || !showNextButton),
assert(skipFlex >= 0 && dotsFlex >= 0 && nextFlex >= 0),
Expand Down Expand Up @@ -241,7 +249,7 @@ class IntroductionScreenState extends State<IntroductionScreen> {
final doneBtn = IntroButton(
child: widget.done,
color: widget.doneColor ?? widget.color,
onPressed: widget.onDone,
onPressed: widget.showDoneButton && !_isScrolling ? widget.onDone : null,
);

return Scaffold(
Expand Down Expand Up @@ -299,6 +307,16 @@ class IntroductionScreenState extends State<IntroductionScreen> {
? nextBtn
: Opacity(opacity: 0.0, child: nextBtn),
),
Expanded(
flex: widget.nextFlex,
child: isLastPage
? widget.showDoneButton
? doneBtn
: Opacity(opacity: 0.0, child: doneBtn)
: widget.showNextButton
? nextBtn
: Opacity(opacity: 0.0, child: nextBtn),
),
],
),
),
Expand Down

0 comments on commit 7e2e423

Please sign in to comment.