Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
fix: reduce tutorial status builds
Browse files Browse the repository at this point in the history
  • Loading branch information
alestiago committed Mar 12, 2024
1 parent 414d43f commit 57711f5
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions packages/trashy_road/lib/src/game/widgets/tutorial_hud.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ enum _TutorialStatus {
trashDeposit,

/// The tutorial has been completed.
completed,
completed;
}

/// {@template TutorialHud}
Expand All @@ -30,7 +30,7 @@ class TutorialHud extends StatefulWidget {
}

class _TutorialHudState extends State<TutorialHud> {
_TutorialStatus _tutorialStatus = _TutorialStatus.movement;
var _tutorialStatus = _TutorialStatus.movement;

@override
Widget build(BuildContext context) {
Expand All @@ -45,19 +45,25 @@ class _TutorialHudState extends State<TutorialHud> {
final hasDepositedTrash =
previous.collectedTrash < current.collectedTrash;

late final _TutorialStatus newTutorialStatus;
if (_tutorialStatus == _TutorialStatus.movement && hasMoved) {
_tutorialStatus = _TutorialStatus.trashCollection;
newTutorialStatus = _TutorialStatus.trashCollection;
} else if (_tutorialStatus == _TutorialStatus.trashCollection &&
hasCollectedTrash) {
_tutorialStatus = _TutorialStatus.trashDeposit;
newTutorialStatus = _TutorialStatus.trashDeposit;
} else if (_tutorialStatus == _TutorialStatus.trashDeposit &&
hasDepositedTrash) {
_tutorialStatus = _TutorialStatus.completed;
newTutorialStatus = _TutorialStatus.completed;
} else {
return false;
newTutorialStatus = _TutorialStatus.completed;
}

return true;
final hasChangedStatus = newTutorialStatus != _tutorialStatus;
if (hasChangedStatus) {
_tutorialStatus = newTutorialStatus;
}

return hasChangedStatus;
},
builder: (context, state) {
switch (_tutorialStatus) {
Expand Down

0 comments on commit 57711f5

Please sign in to comment.