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

Support for pt-br and possibility of language changes #184

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions devtools_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extensions:
5 changes: 5 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,10 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
<string>pt</string>
</array>
</dict>
</plist>
31 changes: 24 additions & 7 deletions lib/app/view/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:super_dash/map_tester/map_tester.dart';
import 'package:super_dash/settings/settings.dart';
import 'package:super_dash/share/share.dart';

class App extends StatelessWidget {
class App extends StatefulWidget {
const App({
required this.audioController,
required this.settingsController,
Expand All @@ -29,6 +29,21 @@ class App extends StatelessWidget {
final AuthenticationRepository authenticationRepository;
final LeaderboardRepository leaderboardRepository;

@override
State<App> createState() => _AppState();

static _AppState? of(BuildContext context) =>
context.findAncestorStateOfType<_AppState>();
}

class _AppState extends State<App> {
Locale? _locale;
void setLocale(Locale value) {
setState(() {
_locale = value;
});
}

@override
Widget build(BuildContext context) {
return AppLifecycleObserver(
Expand All @@ -38,31 +53,33 @@ class App extends StatelessWidget {
create: (context) {
final lifecycleNotifier =
context.read<ValueNotifier<AppLifecycleState>>();
return audioController
return widget.audioController
..attachLifecycleNotifier(lifecycleNotifier);
},
lazy: false,
),
RepositoryProvider<SettingsController>.value(
value: settingsController,
value: widget.settingsController,
),
RepositoryProvider<ShareController>.value(
value: shareController,
value: widget.shareController,
),
RepositoryProvider<AuthenticationRepository>.value(
value: authenticationRepository..signInAnonymously(),
value: widget.authenticationRepository..signInAnonymously(),
),
RepositoryProvider<LeaderboardRepository>.value(
value: leaderboardRepository,
value: widget.leaderboardRepository,
),
],
child: MaterialApp(
locale: _locale,
theme: ThemeData(
textTheme: AppTextStyles.textTheme,
),
supportedLocales: AppLocalizations.supportedLocales,
localizationsDelegates: AppLocalizations.localizationsDelegates,
home: isTesting ? const MapTesterView() : const GameIntroPage(),
home:
widget.isTesting ? const MapTesterView() : const GameIntroPage(),
),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,20 +166,20 @@ class _CardContent extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Column(
children: [
_CardImage(assetPath: assetPath),
const SizedBox(height: 24),
Text(
title,
style: theme.textTheme.headlineSmall?.copyWith(
color: Colors.white,
fontWeight: FontWeight.bold,
return SingleChildScrollView(
child: Column(
children: [
_CardImage(assetPath: assetPath),
const SizedBox(height: 24),
Text(
title,
style: theme.textTheme.headlineSmall?.copyWith(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
),
const SizedBox(height: 12),
Expanded(
child: Padding(
const SizedBox(height: 12),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 24,
),
Expand All @@ -191,8 +191,8 @@ class _CardContent extends StatelessWidget {
),
),
),
),
],
],
),
);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import 'dart:ui' as ui;

import 'package:app_ui/app_ui.dart';
import 'package:flutter/material.dart';
import 'package:super_dash/app/view/app.dart';
import 'package:super_dash/l10n/l10n.dart';

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

static PageRoute<void> route() {
return HeroDialogRoute(
builder: (_) => BackdropFilter(
filter: ui.ImageFilter.blur(sigmaX: 8, sigmaY: 8),
child: const GameSelectLanguageOverlay(),
),
);
}

@override
Widget build(BuildContext context) {
return const GameSelectLanguageOverlayView();
}
}

class GameSelectLanguageOverlayView extends StatefulWidget {
const GameSelectLanguageOverlayView({super.key});

@override
State<GameSelectLanguageOverlayView> createState() =>
_GameSelectLanguageOverlayViewState();
}

class _GameSelectLanguageOverlayViewState
extends State<GameSelectLanguageOverlayView> {
@override
Widget build(BuildContext context) {
final l10n = context.l10n;
final theme = Theme.of(context);
final textTheme = theme.textTheme;
return AppDialog(
showCloseButton: false,
border: Border.all(color: Colors.white24),
backgroundColor: Colors.white24,
child: Column(
children: <Widget>[
Text(
l10n.selectLanguage,
textAlign: TextAlign.center,
style: textTheme.headlineSmall?.copyWith(
color: Colors.white,
),
),
const SizedBox(
height: 15,
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: AppLocalizations.supportedLocales
.map(
(e) => InkWell(
onTap: () {
App.of(context)?.setLocale(
Locale.fromSubtags(languageCode: e.languageCode),
);
},
child: Padding(
padding: const EdgeInsets.only(
bottom: 10,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
e.languageCode.toUpperCase(),
style: textTheme.bodyLarge?.copyWith(
color: Colors.white,
),
),
const SizedBox(
width: 10,
),
if (e.languageCode == context.l10n.localeName)
const Icon(
Icons.check,
size: 15,
color: Colors.white,
),
],
),
),
),
)
.toList(),
),
],
),
);
}
}
1 change: 1 addition & 0 deletions lib/game_intro/view/game_intro_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class _IntroPage extends StatelessWidget {
AudioButton(),
LeaderboardButton(),
InfoButton(),
LanguageButton(),
HowToPlayButton(),
],
),
Expand Down
15 changes: 15 additions & 0 deletions lib/game_intro/widgets/game_intro_buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:super_dash/game_intro/game_intro.dart';
import 'package:super_dash/game_intro/game_select_language/view/game_select_language_overlay.dart';
import 'package:super_dash/leaderboard/leaderboard.dart';
import 'package:super_dash/settings/settings_controller.dart';

Expand Down Expand Up @@ -61,3 +62,17 @@ class HowToPlayButton extends StatelessWidget {
);
}
}

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

@override
Widget build(BuildContext context) {
return GameIconButton(
icon: Icons.public_rounded,
onPressed: () => Navigator.of(context).push(
GameSelectLanguageOverlay.route(),
),
);
}
}
4 changes: 4 additions & 0 deletions lib/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,9 @@
"downloadAppLabel": "Download the app",
"@downloadAppLabel": {
"description": "Button lable for the app download"
},
"selectLanguage": "Select language",
"@selectLanguage": {
"description": "Text shown in language select overlay"
}
}
Loading