Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
feat: add game intro (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcossevilla authored Nov 1, 2023
1 parent 7d06ef3 commit 93e61d8
Show file tree
Hide file tree
Showing 20 changed files with 583 additions and 26 deletions.
Binary file added assets/images/acorn.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/auto_run_instruction.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/avoid_bugs_instruction.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/egg.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/game_logo.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/intro_background.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/level_gates_instruction.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/powerful_wings_instruction.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/tap_to_jump_instruction.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 11 additions & 9 deletions lib/app/view/app.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:dash_run/app_lifecycle/app_lifecycle.dart';
import 'package:dash_run/audio/audio.dart';
import 'package:dash_run/game/game.dart';
import 'package:dash_run/game_intro/game_intro.dart';
import 'package:dash_run/l10n/l10n.dart';
import 'package:dash_run/map_tester/map_tester.dart';
import 'package:dash_run/settings/settings_controller.dart';
Expand All @@ -9,25 +9,25 @@ import 'package:flutter_bloc/flutter_bloc.dart';

class App extends StatelessWidget {
const App({
required this.settingsController,
required this.audioController,
super.key,
required this.settingsController,
this.isTesting = false,
super.key,
});

final bool isTesting;
final SettingsController settingsController;
final AudioController audioController;
final SettingsController settingsController;

@override
Widget build(BuildContext context) {
return AppLifecycleObserver(
child: MultiRepositoryProvider(
providers: [
RepositoryProvider.value(
RepositoryProvider<SettingsController>.value(
value: settingsController,
),
RepositoryProvider(
RepositoryProvider<AudioController>(
create: (context) {
final lifecycleNotifier =
context.read<ValueNotifier<AppLifecycleState>>();
Expand All @@ -38,14 +38,16 @@ class App extends StatelessWidget {
],
child: MaterialApp(
theme: ThemeData(
appBarTheme: const AppBarTheme(color: Color(0xFF13B9FF)),
appBarTheme: const AppBarTheme(
color: Color(0xFF13B9FF),
),
colorScheme: ColorScheme.fromSwatch(
accentColor: const Color(0xFF13B9FF),
),
),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: isTesting ? const MapTesterView() : const GameView(),
localizationsDelegates: AppLocalizations.localizationsDelegates,
home: isTesting ? const MapTesterView() : const GameIntroPage(),
),
),
);
Expand Down
6 changes: 6 additions & 0 deletions lib/game/view/game_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import 'package:flutter_bloc/flutter_bloc.dart';
class GameView extends StatelessWidget {
const GameView({super.key});

static MaterialPageRoute<void> route() {
return MaterialPageRoute<void>(
builder: (_) => const GameView(),
);
}

@override
Widget build(BuildContext context) {
return DecoratedBox(
Expand Down
1 change: 1 addition & 0 deletions lib/game_intro/game_intro.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'view/view.dart';
89 changes: 89 additions & 0 deletions lib/game_intro/view/game_intro_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import 'package:app_ui/app_ui.dart';
import 'package:dash_run/game/game.dart';
import 'package:dash_run/gen/assets.gen.dart';
import 'package:dash_run/l10n/l10n.dart';
import 'package:dash_run/settings/settings.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

class GameIntroPage extends StatelessWidget {
const GameIntroPage({super.key});

@override
Widget build(BuildContext context) {
final l10n = context.l10n;
final theme = Theme.of(context);
return Scaffold(
body: Stack(
children: [
Positioned.fill(
child: Assets.images.introBackground.image(
fit: BoxFit.fill,
),
),
Column(
children: [
const Spacer(),
Assets.images.gameLogo.image(),
const Spacer(flex: 4),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
l10n.gameIntroPageHeadline,
textAlign: TextAlign.center,
style: theme.textTheme.titleMedium?.copyWith(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
const SizedBox(height: 32),
GameElevatedButton(
label: l10n.gameIntroPagePlayButtonText,
onPressed: () => Navigator.of(context).push(GameView.route()),
),
const Spacer(),
const _Actions(),
const SizedBox(height: 32),
],
),
],
),
);
}
}

class _Actions extends StatelessWidget {
const _Actions();

@override
Widget build(BuildContext context) {
final settingsController = context.watch<SettingsController>();
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ValueListenableBuilder<bool>(
valueListenable: settingsController.soundsOn,
builder: (context, soundsOn, child) => GameIconButton(
icon: soundsOn ? Icons.volume_up : Icons.volume_off,
onPressed: soundsOn
? settingsController.toggleMuted
: settingsController.toggleMusicOn,
),
),
GameIconButton(
icon: Icons.leaderboard,
onPressed: () {},
),
GameIconButton(
onPressed: () {},
icon: Icons.info,
),
GameIconButton(
onPressed: () {},
icon: Icons.help,
),
],
);
}
}
1 change: 1 addition & 0 deletions lib/game_intro/view/view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'game_intro_page.dart';
Loading

0 comments on commit 93e61d8

Please sign in to comment.