Skip to content

Commit

Permalink
Merge pull request #9 from dillonfagan/shuffle
Browse files Browse the repository at this point in the history
Add shuffle functionality to SetupPage
  • Loading branch information
dillonfagan authored Nov 1, 2022
2 parents 8a35d8b + 64a2b9e commit ec37b13
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
13 changes: 13 additions & 0 deletions lib/pages/setup/setup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ class _SetupPageState extends State<SetupPage> {
final turnLength = mob.turnLength;

return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
leading: mobbers.length > 1
? IconButton(
onPressed: () {
mob.shuffleMobbers();
},
icon: const Icon(Icons.rotate_left_rounded),
tooltip: 'Shuffle mobbers',
)
: null,
),
body: Center(
child: Container(
constraints: BoxConstraints(
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/timer/widgets/appbar_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AppBarFactory {
leading: IconButton(
onPressed: () {
mob.reset();
Navigator.of(context).pushReplacement(MaterialPageRoute(
Navigator.of(context).pop(MaterialPageRoute(
builder: (_) => const SetupPage(),
));
},
Expand Down
5 changes: 5 additions & 0 deletions lib/providers/mob.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ class MobProvider extends ChangeNotifier {
int _currentMobberIndex = 0;
int _turns = 0;

void shuffleMobbers() {
_mobbers.shuffle();
notifyListeners();
}

MobState _state = MobState.waiting;

MobState get state => _state;
Expand Down

0 comments on commit ec37b13

Please sign in to comment.