Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: clickable mascot #553

Merged
merged 4 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions lib/team_selection/view/team_selection_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class _TeamSelectorLarge extends StatelessWidget {
child: SizedBox(
width: mascotWidth,
height: mascotHeight,
child: TeamSelectionMascot(Mascots.dash),
child: _LargeMascot(Mascots.dash),
),
),
Positioned(
Expand All @@ -169,7 +169,7 @@ class _TeamSelectorLarge extends StatelessWidget {
child: SizedBox(
width: mascotWidth,
height: mascotHeight,
child: TeamSelectionMascot(Mascots.sparky),
child: _LargeMascot(Mascots.sparky),
),
),
Positioned(
Expand All @@ -178,7 +178,7 @@ class _TeamSelectorLarge extends StatelessWidget {
child: SizedBox(
width: mascotWidth,
height: mascotHeight,
child: TeamSelectionMascot(Mascots.android),
child: _LargeMascot(Mascots.android),
),
),
Positioned(
Expand All @@ -187,7 +187,7 @@ class _TeamSelectorLarge extends StatelessWidget {
child: SizedBox(
width: mascotWidth,
height: mascotHeight,
child: TeamSelectionMascot(Mascots.dino),
child: _LargeMascot(Mascots.dino),
),
),
],
Expand Down Expand Up @@ -547,3 +547,19 @@ class _SmallMascot extends StatelessWidget {
);
}
}

class _LargeMascot extends StatelessWidget {
const _LargeMascot(this.mascot);

final Mascots mascot;

@override
Widget build(BuildContext context) {
return GestureDetector(
jsgalarraga marked this conversation as resolved.
Show resolved Hide resolved
onTap: () {
context.read<TeamSelectionCubit>().selectTeam(mascot.index);
},
child: TeamSelectionMascot(mascot),
);
}
}
26 changes: 26 additions & 0 deletions test/team_selection/view/team_selection_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -322,5 +322,31 @@ void main() {
},
);
});

testWidgets(
'select Sparky mascot when tapped '
'on large layout', (tester) async {
tester.view.physicalSize = const Size(1600, 1600);

when(() => teamSelectionCubit.state).thenReturn(
TeamSelectionState(assetsStatus: AssetsLoadingStatus.success),
);

await tester.pumpApp(
widget,
layout: IoLayoutData.large,
);

await tester.pump();

await tester.tap(
find.byType(TeamSelectionMascot).at(Mascots.sparky.index),
);

verify(() => teamSelectionCubit.selectTeam(Mascots.sparky.index))
.called(1);

addTearDown(tester.view.resetPhysicalSize);
});
});
}
Loading