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

refactor: update team selection UI #310

Merged
merged 19 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from 10 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
49 changes: 40 additions & 9 deletions api/packages/game_domain/lib/src/models/mascots.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,47 @@
/// {@template mascots}
/// Google Mascots enum
/// Google Mascots enum.
/// {@endtemplate}
enum Mascots {
/// Flutter Dash mascot
dash,
/// Flutter Dash mascot.
dash(
displayName: 'Dash',
idleAnimation: 'dash_idle.png',
platformAnimation: 'android_platform.png',
jsgalarraga marked this conversation as resolved.
Show resolved Hide resolved
),

/// Firebase Sparky mascot
sparky,
/// Firebase Sparky mascot.
sparky(
displayName: 'Sparky',
idleAnimation: 'dash_idle.png',
platformAnimation: 'android_platform.png',
),

/// Chrome Dino mascot
dino,
/// Android mascot.
android(
displayName: 'Android',
idleAnimation: 'dash_idle.png',
platformAnimation: 'android_platform.png',
),

/// Android mascot
android,
/// Chrome Dino mascot.
dino(
displayName: 'Dino',
idleAnimation: 'dash_idle.png',
platformAnimation: 'android_platform.png',
);

const Mascots({
required this.displayName,
required this.idleAnimation,
required this.platformAnimation,
});

/// The display name of the mascot.
final String displayName;

/// The file name of the idle animation.
final String idleAnimation;

/// The file name of the platform animation.
final String platformAnimation;
}
Binary file added assets/anim/android_celebration.png
jsgalarraga marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/anim/android_drop_in.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/anim/android_idle.png
Binary file not shown.
Binary file added assets/anim/android_picking_up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/anim/dash_celebration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/anim/dash_dangle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/anim/dash_looking_up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/android_idle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/android_platform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/dash_idle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/dash_platform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions assets/images/gradient.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/platform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/platform_large.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/platform_not_selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/sparky_platform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/tile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/tile_large.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
102 changes: 95 additions & 7 deletions lib/assets/assets.gen.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 26 additions & 3 deletions lib/team_selection/cubit/team_selection_cubit.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:flame/flame.dart';
import 'package:game_domain/game_domain.dart';

class TeamSelectionCubit extends Cubit<int> {
TeamSelectionCubit() : super(0);
part 'team_selection_state.dart';

class TeamSelectionCubit extends Cubit<TeamSelectionState> {
TeamSelectionCubit() : super(const TeamSelectionState());

Future<void> load() async {
emit(state.copyWith(status: TeamSelectionStatus.loading));
await Flame.images.loadAll([
jsgalarraga marked this conversation as resolved.
Show resolved Hide resolved
Mascots.dash.idleAnimation,
Mascots.dash.platformAnimation,
Mascots.android.idleAnimation,
Mascots.android.platformAnimation,
Mascots.sparky.idleAnimation,
Mascots.sparky.platformAnimation,
Mascots.dino.idleAnimation,
Mascots.dino.platformAnimation,
]);

if (!isClosed) {
emit(state.copyWith(status: TeamSelectionStatus.loadingComplete));
}
}

void selectTeam(int teamIndex) {
emit(teamIndex);
emit(state.copyWith(index: teamIndex));
}
}
34 changes: 34 additions & 0 deletions lib/team_selection/cubit/team_selection_state.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
part of 'team_selection_cubit.dart';

enum TeamSelectionStatus {
loading,

loadingComplete,
}

class TeamSelectionState extends Equatable {
const TeamSelectionState({
this.status = TeamSelectionStatus.loading,
this.index = 0,
});

final TeamSelectionStatus status;

final int index;

TeamSelectionState copyWith({
TeamSelectionStatus? status,
int? index,
}) {
return TeamSelectionState(
status: status ?? this.status,
index: index ?? this.index,
);
}

@override
List<Object> get props => [
status,
index,
];
}
1 change: 1 addition & 0 deletions lib/team_selection/team_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ library;

export 'cubit/team_selection_cubit.dart';
export 'view/view.dart';
export 'widgets/widgets.dart';
Loading
Loading