refactor: renamed GoogleLetterState

pull/286/head
alestiago 3 years ago
parent f78edd3bb6
commit 0dcfacea85

@ -17,7 +17,7 @@ class GoogleWordBonusBehavior extends Component
// https://github.com/flame-engine/flame/pull/1538
letter.bloc.stream.listen((_) {
final achievedBonus = googleLetters
.every((letter) => letter.bloc.state == GoogleLetterState.active);
.every((letter) => letter.bloc.state == GoogleLetterState.lit);
if (achievedBonus) {
gameRef.audio.googleBonus();

@ -5,13 +5,13 @@ import 'package:bloc/bloc.dart';
part 'google_letter_state.dart';
class GoogleLetterCubit extends Cubit<GoogleLetterState> {
GoogleLetterCubit() : super(GoogleLetterState.inactive);
GoogleLetterCubit() : super(GoogleLetterState.dimmed);
void onBallContacted() {
emit(GoogleLetterState.active);
emit(GoogleLetterState.lit);
}
void onReset() {
emit(GoogleLetterState.inactive);
emit(GoogleLetterState.dimmed);
}
}

@ -1,10 +1,8 @@
// ignore_for_file: public_member_api_docs
part of 'google_letter_cubit.dart';
/// Indicates the [GoogleLetterCubit]'s current state.
enum GoogleLetterState {
/// A lit up letter.
active,
/// A dimmed letter.
inactive,
lit,
dimmed,
}

@ -29,9 +29,9 @@ class GoogleLetter extends BodyComponent with InitialPosition {
children: [
_GoogleLetterSpriteGroupComponent(
activeAssetPath: _GoogleLetterSpriteGroupComponent
.spritePaths[index][GoogleLetterState.active]!,
.spritePaths[index][GoogleLetterState.lit]!,
inactiveAssetPath: _GoogleLetterSpriteGroupComponent
.spritePaths[index][GoogleLetterState.inactive]!,
.spritePaths[index][GoogleLetterState.dimmed]!,
current: bloc.state,
),
GoogleLetterBallContactBehavior(),
@ -96,33 +96,33 @@ class _GoogleLetterSpriteGroupComponent
static final spritePaths = <Map<GoogleLetterState, String>>[
{
GoogleLetterState.active: Assets.images.googleWord.letter1.active.keyName,
GoogleLetterState.inactive:
GoogleLetterState.lit: Assets.images.googleWord.letter1.active.keyName,
GoogleLetterState.dimmed:
Assets.images.googleWord.letter1.inactive.keyName,
},
{
GoogleLetterState.active: Assets.images.googleWord.letter2.active.keyName,
GoogleLetterState.inactive:
GoogleLetterState.lit: Assets.images.googleWord.letter2.active.keyName,
GoogleLetterState.dimmed:
Assets.images.googleWord.letter2.inactive.keyName,
},
{
GoogleLetterState.active: Assets.images.googleWord.letter3.active.keyName,
GoogleLetterState.inactive:
GoogleLetterState.lit: Assets.images.googleWord.letter3.active.keyName,
GoogleLetterState.dimmed:
Assets.images.googleWord.letter3.inactive.keyName,
},
{
GoogleLetterState.active: Assets.images.googleWord.letter4.active.keyName,
GoogleLetterState.inactive:
GoogleLetterState.lit: Assets.images.googleWord.letter4.active.keyName,
GoogleLetterState.dimmed:
Assets.images.googleWord.letter4.inactive.keyName,
},
{
GoogleLetterState.active: Assets.images.googleWord.letter5.active.keyName,
GoogleLetterState.inactive:
GoogleLetterState.lit: Assets.images.googleWord.letter5.active.keyName,
GoogleLetterState.dimmed:
Assets.images.googleWord.letter5.inactive.keyName,
},
{
GoogleLetterState.active: Assets.images.googleWord.letter6.active.keyName,
GoogleLetterState.inactive:
GoogleLetterState.lit: Assets.images.googleWord.letter6.active.keyName,
GoogleLetterState.dimmed:
Assets.images.googleWord.letter6.inactive.keyName,
},
];
@ -133,10 +133,10 @@ class _GoogleLetterSpriteGroupComponent
parent.bloc.stream.listen((state) => current = state);
final sprites = {
GoogleLetterState.active: Sprite(
GoogleLetterState.lit: Sprite(
gameRef.images.fromCache(_activeAssetPath),
),
GoogleLetterState.inactive: Sprite(
GoogleLetterState.dimmed: Sprite(
gameRef.images.fromCache(_inactiveAssetPath),
),
};

@ -31,7 +31,7 @@ void main() {
whenListen(
bloc,
const Stream<GoogleLetterState>.empty(),
initialState: GoogleLetterState.active,
initialState: GoogleLetterState.lit,
);
final googleLetter = GoogleLetter.test(bloc: bloc);

@ -10,14 +10,14 @@ void main() {
'onBallContacted emits active',
build: GoogleLetterCubit.new,
act: (bloc) => bloc.onBallContacted(),
expect: () => [GoogleLetterState.active],
expect: () => [GoogleLetterState.lit],
);
blocTest<GoogleLetterCubit, GoogleLetterState>(
'onReset emits inactive',
build: GoogleLetterCubit.new,
act: (bloc) => bloc.onReset(),
expect: () => [GoogleLetterState.inactive],
expect: () => [GoogleLetterState.dimmed],
);
},
);

@ -108,7 +108,7 @@ void main() {
whenListen(
bloc,
const Stream<GoogleLetterState>.empty(),
initialState: GoogleLetterState.active,
initialState: GoogleLetterState.lit,
);
when(bloc.close).thenAnswer((_) async {});
final googleLetter = GoogleLetter.test(bloc: bloc);

Loading…
Cancel
Save