Skip to content

Commit

Permalink
feat: update dependencies and refactor the code (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
BBarisKilic authored Apr 15, 2023
2 parents 4d9b3ec + 7124698 commit 80aaa62
Show file tree
Hide file tree
Showing 11 changed files with 257 additions and 274 deletions.
81 changes: 37 additions & 44 deletions lib/entities/boy/states/boy_state.freezed.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark

part of 'boy_state.dart';

Expand All @@ -25,9 +25,9 @@ mixin _$BoyState {
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult Function()? idle,
TResult Function()? run,
TResult Function()? jump,
TResult? Function()? idle,
TResult? Function()? run,
TResult? Function()? jump,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
Expand All @@ -47,9 +47,9 @@ mixin _$BoyState {
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult Function(_Idle value)? idle,
TResult Function(_Run value)? run,
TResult Function(_Jump value)? jump,
TResult? Function(_Idle value)? idle,
TResult? Function(_Run value)? run,
TResult? Function(_Jump value)? jump,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
Expand All @@ -65,16 +65,18 @@ mixin _$BoyState {
/// @nodoc
abstract class $BoyStateCopyWith<$Res> {
factory $BoyStateCopyWith(BoyState value, $Res Function(BoyState) then) =
_$BoyStateCopyWithImpl<$Res>;
_$BoyStateCopyWithImpl<$Res, BoyState>;
}

/// @nodoc
class _$BoyStateCopyWithImpl<$Res> implements $BoyStateCopyWith<$Res> {
class _$BoyStateCopyWithImpl<$Res, $Val extends BoyState>
implements $BoyStateCopyWith<$Res> {
_$BoyStateCopyWithImpl(this._value, this._then);

final BoyState _value;
// ignore: unused_field
final $Res Function(BoyState) _then;
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
}

/// @nodoc
Expand All @@ -84,13 +86,10 @@ abstract class _$$_IdleCopyWith<$Res> {
}

/// @nodoc
class __$$_IdleCopyWithImpl<$Res> extends _$BoyStateCopyWithImpl<$Res>
class __$$_IdleCopyWithImpl<$Res> extends _$BoyStateCopyWithImpl<$Res, _$_Idle>
implements _$$_IdleCopyWith<$Res> {
__$$_IdleCopyWithImpl(_$_Idle _value, $Res Function(_$_Idle) _then)
: super(_value, (v) => _then(v as _$_Idle));

@override
_$_Idle get _value => super._value as _$_Idle;
: super(_value, _then);
}

/// @nodoc
Expand Down Expand Up @@ -125,9 +124,9 @@ class _$_Idle implements _Idle {
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult Function()? idle,
TResult Function()? run,
TResult Function()? jump,
TResult? Function()? idle,
TResult? Function()? run,
TResult? Function()? jump,
}) {
return idle?.call();
}
Expand Down Expand Up @@ -159,9 +158,9 @@ class _$_Idle implements _Idle {
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult Function(_Idle value)? idle,
TResult Function(_Run value)? run,
TResult Function(_Jump value)? jump,
TResult? Function(_Idle value)? idle,
TResult? Function(_Run value)? run,
TResult? Function(_Jump value)? jump,
}) {
return idle?.call(this);
}
Expand Down Expand Up @@ -192,13 +191,10 @@ abstract class _$$_RunCopyWith<$Res> {
}

/// @nodoc
class __$$_RunCopyWithImpl<$Res> extends _$BoyStateCopyWithImpl<$Res>
class __$$_RunCopyWithImpl<$Res> extends _$BoyStateCopyWithImpl<$Res, _$_Run>
implements _$$_RunCopyWith<$Res> {
__$$_RunCopyWithImpl(_$_Run _value, $Res Function(_$_Run) _then)
: super(_value, (v) => _then(v as _$_Run));

@override
_$_Run get _value => super._value as _$_Run;
: super(_value, _then);
}

/// @nodoc
Expand Down Expand Up @@ -233,9 +229,9 @@ class _$_Run implements _Run {
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult Function()? idle,
TResult Function()? run,
TResult Function()? jump,
TResult? Function()? idle,
TResult? Function()? run,
TResult? Function()? jump,
}) {
return run?.call();
}
Expand Down Expand Up @@ -267,9 +263,9 @@ class _$_Run implements _Run {
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult Function(_Idle value)? idle,
TResult Function(_Run value)? run,
TResult Function(_Jump value)? jump,
TResult? Function(_Idle value)? idle,
TResult? Function(_Run value)? run,
TResult? Function(_Jump value)? jump,
}) {
return run?.call(this);
}
Expand Down Expand Up @@ -300,13 +296,10 @@ abstract class _$$_JumpCopyWith<$Res> {
}

/// @nodoc
class __$$_JumpCopyWithImpl<$Res> extends _$BoyStateCopyWithImpl<$Res>
class __$$_JumpCopyWithImpl<$Res> extends _$BoyStateCopyWithImpl<$Res, _$_Jump>
implements _$$_JumpCopyWith<$Res> {
__$$_JumpCopyWithImpl(_$_Jump _value, $Res Function(_$_Jump) _then)
: super(_value, (v) => _then(v as _$_Jump));

@override
_$_Jump get _value => super._value as _$_Jump;
: super(_value, _then);
}

/// @nodoc
Expand Down Expand Up @@ -341,9 +334,9 @@ class _$_Jump implements _Jump {
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult Function()? idle,
TResult Function()? run,
TResult Function()? jump,
TResult? Function()? idle,
TResult? Function()? run,
TResult? Function()? jump,
}) {
return jump?.call();
}
Expand Down Expand Up @@ -375,9 +368,9 @@ class _$_Jump implements _Jump {
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult Function(_Idle value)? idle,
TResult Function(_Run value)? run,
TResult Function(_Jump value)? jump,
TResult? Function(_Idle value)? idle,
TResult? Function(_Run value)? run,
TResult? Function(_Jump value)? jump,
}) {
return jump?.call(this);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/game/view/widgets/menu_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MenuButton extends StatelessWidget {
super.key,
});

final void Function() onPressed;
final VoidCallback onPressed;
final String text;

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/injector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:get_it/get_it.dart';
import 'package:one_dungeon/assets_manager/assets_manager.dart';
import 'package:one_dungeon/game/game.dart';
import 'package:one_dungeon/one_dungeon_audio/one_dungeon_audio.dart';
import 'package:one_dungeon/start_game/cubit/start_game_cubit.dart';
import 'package:one_dungeon/start_game/start_game.dart';

final injector = GetIt.instance;

Expand Down
2 changes: 1 addition & 1 deletion lib/one_dungeon_audio/one_dungeon_audio_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,5 @@ class OneDungeonAudioPlayer {
}

/// Stops background music.
Future<void> stop() async => _stopBackgroundAudio();
Future<void> stop() => _stopBackgroundAudio();
}
16 changes: 8 additions & 8 deletions lib/one_dungeon_audio/one_dungeon_audio_player_x.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ extension OneDungeonAudioPlayerX on OneDungeonAudioPlayer {
PreCacheSingleAudio preCacheSingleAudio,
) {
return [
() async => preCacheSingleAudio(GameAssets.kBackgroudMusic),
() async => preCacheSingleAudio(GameAssets.kDescendingSfx),
() async => preCacheSingleAudio(GameAssets.kJumpSfx),
() async => preCacheSingleAudio(GameAssets.kLandingSfx),
() async => preCacheSingleAudio(GameAssets.kPickUpStarSfx),
() async => preCacheSingleAudio(GameAssets.kPickUpSfx),
() async => preCacheSingleAudio(GameAssets.kSelectSfx),
() async => preCacheSingleAudio(GameAssets.kSuccessSfx),
() => preCacheSingleAudio(GameAssets.kBackgroudMusic),
() => preCacheSingleAudio(GameAssets.kDescendingSfx),
() => preCacheSingleAudio(GameAssets.kJumpSfx),
() => preCacheSingleAudio(GameAssets.kLandingSfx),
() => preCacheSingleAudio(GameAssets.kPickUpStarSfx),
() => preCacheSingleAudio(GameAssets.kPickUpSfx),
() => preCacheSingleAudio(GameAssets.kSelectSfx),
() => preCacheSingleAudio(GameAssets.kSuccessSfx),
];
}
}
43 changes: 29 additions & 14 deletions lib/start_game/cubit/start_game_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,36 @@ import 'package:bloc/bloc.dart';
import 'package:flutter/foundation.dart';
import 'package:freezed_annotation/freezed_annotation.dart';

part 'start_game_state.dart';
part 'start_game_cubit.freezed.dart';
part 'start_game_state.dart';

class StartGameCubit extends Cubit<StartGameState> {
StartGameCubit() : super(const StartGameState.initial());

void onPlayPressed() => emit(const StartGameState.play());

void onSoundPressed() => emit(const StartGameState.sound());

void onLanguagePressed() => emit(const StartGameState.language());

void onHowToPlayPressed() => emit(const StartGameState.howToPlay());

void onAboutPressed() => emit(const StartGameState.about());

void setBackToInitial() => emit(const StartGameState.initial());
StartGameCubit() : super(const StartGameState.menu());

void onPlayPressed() {
emit(const StartGameState.play());
_reset();
}

void onSoundPressed() {
emit(const StartGameState.sound());
_reset();
}

void onLanguagePressed() {
emit(const StartGameState.language());
_reset();
}

void onHowToPlayPressed() {
emit(const StartGameState.howToPlay());
_reset();
}

void onAboutPressed() {
emit(const StartGameState.about());
_reset();
}

void _reset() => emit(const StartGameState.menu());
}
Loading

0 comments on commit 80aaa62

Please sign in to comment.