-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#259): controll that tutorial only opens once
- Loading branch information
Showing
4 changed files
with
49 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import 'dart:async'; | ||
|
||
import '../../module.dart'; | ||
import 'container.dart'; | ||
|
||
class TutorialController { | ||
factory TutorialController() { | ||
return _instance; | ||
} | ||
TutorialController._(); | ||
static final TutorialController _instance = TutorialController._(); | ||
|
||
bool _isOpen = false; | ||
|
||
FutureOr<void> showTutorial({ | ||
required BuildContext context, | ||
required List<TutorialContent> pages, | ||
String? lastNextButtonText, | ||
FutureOr<void> Function()? onClose, | ||
}) { | ||
if (_isOpen) return null; | ||
_isOpen = true; | ||
return showModalBottomSheet( | ||
context: context, | ||
enableDrag: true, | ||
showDragHandle: true, | ||
isDismissible: false, | ||
isScrollControlled: true, | ||
useSafeArea: true, | ||
elevation: 0, | ||
builder: (context) => TutorialContainer( | ||
pages: pages, | ||
lastNextButtonText: lastNextButtonText, | ||
finishTutorial: () async { | ||
final closeTutorial = Navigator.of(context).pop; | ||
if (onClose != null) await onClose(); | ||
_isOpen = false; | ||
closeTutorial(); | ||
}, | ||
), | ||
); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters