Continuando la l10n y mejorado el FAB de borrar récords

parent 0f078eea
...@@ -34,5 +34,51 @@ ...@@ -34,5 +34,51 @@
}, },
"@reallyDeleteHiScores": { "@reallyDeleteHiScores": {
"description": "Interrogates the user whether they are sure that they want to delete all of their Hi-Scores" "description": "Interrogates the user whether they are sure that they want to delete all of their Hi-Scores"
},
"yourGuess": "Your guess...",
"attempts": "Attempts",
"maximum": "Maximum",
"minimum": "Minimum",
"@yourGuess": {
"description": "Text that awaits user input for its guessed number"
},
"@attempts": {
"description": "Expression for the maximum number of mistakes that the user can make to guess the number"
},
"@maximum": {
"description": "Mathematical expression for the biggest possible number"
},
"@minimum": {
"description": "Mathematical expression for the smallest possible number"
},
"specialHints": "Special Hints",
"hintsWarning": "Be careful! Unlocking hints is penalized",
"evenOrOdd": "Is it even or odd?",
"divisible": "By which number is it divisible?",
"digitsSum": "What do its digits add up to?",
"digitsCount": "How many digits does it have?",
"pause": "Pause",
"resume": "Resume",
"changeHand": "Change hand",
"newGame": "New game",
"changeDifficulty": "Change difficulty",
"exitGame": "Exit game",
"@pause": {
"description": "Expression of the frozen state of a game"
},
"@resume": {
"description": "Text that refers to continuing the game from frozen state"
},
"@changeHand": {
"description": "Text that indicates the possibility of changing the dominant hand"
},
"@newGame": {
"description": "Text that refers to starting a new game"
},
"@changeDifficulty": {
"description": "Text that refers to choosing new configurations to make the game easier or harder"
},
"@exitGame": {
"description": "Text that refers to quitting the current game and returning to the main menu"
} }
} }
\ No newline at end of file
...@@ -7,5 +7,15 @@ ...@@ -7,5 +7,15 @@
"playToRegister": "¡Juega y registra el primero!", "playToRegister": "¡Juega y registra el primero!",
"deleteHighScores": "Borrar récords", "deleteHighScores": "Borrar récords",
"noUndo": "Esta acción no se puede deshacer.", "noUndo": "Esta acción no se puede deshacer.",
"reallyDeleteHiScores": "¿Seguro que quieres borrar todos los récords?" "reallyDeleteHiScores": "¿Seguro que quieres borrar todos los récords?",
"yourGuess": "Tu respuesta...",
"attempts": "Intentos",
"maximum": "Máximo",
"minimum": "Mínimo",
"pause": "Pausa",
"resume": "Reanudar",
"changeHand": "Cambiar de mano",
"newGame": "Nueva partida",
"changeDifficulty": "Cambiar dificultad",
"exitGame": "Terminar partida"
} }
\ No newline at end of file
...@@ -148,6 +148,66 @@ abstract class AppLocalizations { ...@@ -148,6 +148,66 @@ abstract class AppLocalizations {
/// In en, this message translates to: /// In en, this message translates to:
/// **'Do you really want to delete all Hi-Scores?'** /// **'Do you really want to delete all Hi-Scores?'**
String get reallyDeleteHiScores; String get reallyDeleteHiScores;
/// Text that awaits user input for its guessed number
///
/// In en, this message translates to:
/// **'Your guess...'**
String get yourGuess;
/// Expression for the maximum number of mistakes that the user can make to guess the number
///
/// In en, this message translates to:
/// **'Attempts'**
String get attempts;
/// Mathematical expression for the biggest possible number
///
/// In en, this message translates to:
/// **'Maximum'**
String get maximum;
/// Mathematical expression for the smallest possible number
///
/// In en, this message translates to:
/// **'Minimum'**
String get minimum;
/// Expression of the frozen state of a game
///
/// In en, this message translates to:
/// **'Pause'**
String get pause;
/// Text that refers to continuing the game from frozen state
///
/// In en, this message translates to:
/// **'Resume'**
String get resume;
/// Text that indicates the possibility of changing the dominant hand
///
/// In en, this message translates to:
/// **'Change hand'**
String get changeHand;
/// Text that refers to starting a new game
///
/// In en, this message translates to:
/// **'New game'**
String get newGame;
/// Text that refers to choosing new configurations to make the game easier or harder
///
/// In en, this message translates to:
/// **'Change difficulty'**
String get changeDifficulty;
/// Text that refers to quitting the current game and returning to the main menu
///
/// In en, this message translates to:
/// **'Exit game'**
String get exitGame;
} }
class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> { class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {
......
...@@ -34,4 +34,34 @@ class AppLocalizationsEn extends AppLocalizations { ...@@ -34,4 +34,34 @@ class AppLocalizationsEn extends AppLocalizations {
@override @override
String get reallyDeleteHiScores => 'Do you really want to delete all Hi-Scores?'; String get reallyDeleteHiScores => 'Do you really want to delete all Hi-Scores?';
@override
String get yourGuess => 'Your guess...';
@override
String get attempts => 'Attempts';
@override
String get maximum => 'Maximum';
@override
String get minimum => 'Minimum';
@override
String get pause => 'Pause';
@override
String get resume => 'Resume';
@override
String get changeHand => 'Change hand';
@override
String get newGame => 'New game';
@override
String get changeDifficulty => 'Change difficulty';
@override
String get exitGame => 'Exit game';
} }
...@@ -34,4 +34,34 @@ class AppLocalizationsEs extends AppLocalizations { ...@@ -34,4 +34,34 @@ class AppLocalizationsEs extends AppLocalizations {
@override @override
String get reallyDeleteHiScores => '¿Seguro que quieres borrar todos los récords?'; String get reallyDeleteHiScores => '¿Seguro que quieres borrar todos los récords?';
@override
String get yourGuess => 'Tu respuesta...';
@override
String get attempts => 'Intentos';
@override
String get maximum => 'Máximo';
@override
String get minimum => 'Mínimo';
@override
String get pause => 'Pausa';
@override
String get resume => 'Reanudar';
@override
String get changeHand => 'Cambiar de mano';
@override
String get newGame => 'Nueva partida';
@override
String get changeDifficulty => 'Cambiar dificultad';
@override
String get exitGame => 'Terminar partida';
} }
...@@ -3,6 +3,7 @@ import 'dart:convert'; ...@@ -3,6 +3,7 @@ import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:peponator/l10n/app_localizations.dart';
import 'package:peponator/modelo/peponator_record.dart'; import 'package:peponator/modelo/peponator_record.dart';
import 'package:peponator/modelo/pista.dart'; import 'package:peponator/modelo/pista.dart';
import 'package:peponator/paginas/paginas.dart'; import 'package:peponator/paginas/paginas.dart';
...@@ -480,7 +481,7 @@ class _PantallaJuegoState extends State<PantallaJuego> ...@@ -480,7 +481,7 @@ class _PantallaJuegoState extends State<PantallaJuego>
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleLarge, style: Theme.of(context).textTheme.titleLarge,
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'Tu respuesta...', hintText: AppLocalizations.of(context)?.yourGuess ?? 'Tu respuesta...',
border: OutlineInputBorder(), border: OutlineInputBorder(),
errorBorder: OutlineInputBorder( errorBorder: OutlineInputBorder(
borderSide: BorderSide( borderSide: BorderSide(
...@@ -512,7 +513,7 @@ class _PantallaJuegoState extends State<PantallaJuego> ...@@ -512,7 +513,7 @@ class _PantallaJuegoState extends State<PantallaJuego>
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
Text( Text(
'Intentos', AppLocalizations.of(context)?.attempts ?? 'Intentos',
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleMedium?.copyWith( style: Theme.of(context).textTheme.titleMedium?.copyWith(
color: Theme.of(context).colorScheme.primary, color: Theme.of(context).colorScheme.primary,
...@@ -551,7 +552,7 @@ class _PantallaJuegoState extends State<PantallaJuego> ...@@ -551,7 +552,7 @@ class _PantallaJuegoState extends State<PantallaJuego>
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
Text( Text(
'Máximo', AppLocalizations.of(context)?.maximum ?? 'Máximo',
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleMedium?.copyWith( style: Theme.of(context).textTheme.titleMedium?.copyWith(
color: Colors.red, color: Colors.red,
...@@ -637,7 +638,7 @@ class _PantallaJuegoState extends State<PantallaJuego> ...@@ -637,7 +638,7 @@ class _PantallaJuegoState extends State<PantallaJuego>
), ),
), ),
Text( Text(
'Mínimo', AppLocalizations.of(context)?.minimum ?? 'Mínimo',
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleMedium?.copyWith( style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w800, fontWeight: FontWeight.w800,
......
...@@ -110,7 +110,6 @@ class _PantallaRecordsState extends State<PantallaRecords> { ...@@ -110,7 +110,6 @@ class _PantallaRecordsState extends State<PantallaRecords> {
} }
Widget _buildRecordsView(BuildContext context, Orientation orientation, List<PeponatorRecord> records){ Widget _buildRecordsView(BuildContext context, Orientation orientation, List<PeponatorRecord> records){
records.add(new PeponatorRecord(jugador: "AAAAA", puntuacion: 2000, fecha: DateTime.now()));
if(records.isNotEmpty) { if(records.isNotEmpty) {
final vistaRecords = ListView.builder( final vistaRecords = ListView.builder(
shrinkWrap: true, shrinkWrap: true,
...@@ -228,11 +227,7 @@ class _PantallaRecordsState extends State<PantallaRecords> { ...@@ -228,11 +227,7 @@ class _PantallaRecordsState extends State<PantallaRecords> {
Widget _buildFAB(BuildContext context, Orientation orientation){ Widget _buildFAB(BuildContext context, Orientation orientation){
final noUndo = AppLocalizations.of(context)?.noUndo ?? 'Esta acción no se puede deshacer.'; final noUndo = AppLocalizations.of(context)?.noUndo ?? 'Esta acción no se puede deshacer.';
final reallyDeleteHiScores = AppLocalizations.of(context)?.reallyDeleteHiScores ?? '¿Seguro que quieres borrar todos los récords?'; final reallyDeleteHiScores = AppLocalizations.of(context)?.reallyDeleteHiScores ?? '¿Seguro que quieres borrar todos los récords?';
return Align( return FloatingActionButton(
alignment: (orientation == Orientation.portrait)? Alignment.bottomCenter : Alignment.bottomRight,
child: Padding(
padding: const EdgeInsets.only(left: 32.0),
child: FloatingActionButton.extended(
onPressed: () { onPressed: () {
showDialog( showDialog(
context: context, context: context,
...@@ -277,7 +272,6 @@ class _PantallaRecordsState extends State<PantallaRecords> { ...@@ -277,7 +272,6 @@ class _PantallaRecordsState extends State<PantallaRecords> {
TextButton( TextButton(
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
Navigator.pop(context);
}, },
style: TextButton.styleFrom( style: TextButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.primary backgroundColor: Theme.of(context).colorScheme.primary
...@@ -298,13 +292,10 @@ class _PantallaRecordsState extends State<PantallaRecords> { ...@@ -298,13 +292,10 @@ class _PantallaRecordsState extends State<PantallaRecords> {
); );
}, },
backgroundColor: Colors.red, backgroundColor: Colors.red,
label: Text( child: Icon(
AppLocalizations.of(context)?.deleteHighScores ?? 'Borrar récords', Icons.delete_forever,
style: Theme.of(context).textTheme.titleLarge?.copyWith( color: Colors.white,
color: Colors.white size: 36,
),
),
),
), ),
); );
} }
......
...@@ -19,7 +19,7 @@ class PeponatorApp extends StatelessWidget { ...@@ -19,7 +19,7 @@ class PeponatorApp extends StatelessWidget {
supportedLocales: AppLocalizations.supportedLocales, supportedLocales: AppLocalizations.supportedLocales,
darkTheme: ThemeData.dark(), darkTheme: ThemeData.dark(),
themeMode: ThemeMode.system, themeMode: ThemeMode.system,
home: PantallaRecords() home: PantallaJuego(fromHome: true)
); );
} }
} }
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:peponator/l10n/app_localizations.dart';
class PantallaPausa extends StatelessWidget { class PantallaPausa extends StatelessWidget {
final Orientation orientacion; final Orientation orientacion;
...@@ -22,7 +23,7 @@ class PantallaPausa extends StatelessWidget { ...@@ -22,7 +23,7 @@ class PantallaPausa extends StatelessWidget {
return SimpleDialog( return SimpleDialog(
alignment: alignment, alignment: alignment,
title: Center(child: Text( title: Center(child: Text(
'Pausa', AppLocalizations.of(context)?.pause ?? 'Pausa',
style: (orientacion == Orientation.portrait)? style: (orientacion == Orientation.portrait)?
Theme.of(context).textTheme.headlineLarge : Theme.of(context).textTheme.headlineLarge :
Theme.of(context).textTheme.headlineSmall, Theme.of(context).textTheme.headlineSmall,
...@@ -47,7 +48,7 @@ class PantallaPausa extends StatelessWidget { ...@@ -47,7 +48,7 @@ class PantallaPausa extends StatelessWidget {
size: 32.0 size: 32.0
), ),
label: Text( label: Text(
element.text, element.getText(context),
style: Theme.of(context).textTheme.titleLarge?.copyWith( style: Theme.of(context).textTheme.titleLarge?.copyWith(
fontWeight: (Theme.of(context).brightness == Brightness.light)? null : FontWeight.bold, fontWeight: (Theme.of(context).brightness == Brightness.light)? null : FontWeight.bold,
color: element.getColor(Theme.of(context).brightness) ?? Theme.of(context).colorScheme.primary color: element.getColor(Theme.of(context).brightness) ?? Theme.of(context).colorScheme.primary
...@@ -61,16 +62,15 @@ class PantallaPausa extends StatelessWidget { ...@@ -61,16 +62,15 @@ class PantallaPausa extends StatelessWidget {
} }
enum OpcionPausa { enum OpcionPausa {
reanudar(Icons.play_arrow_outlined, "Reanudar"), reanudar(Icons.play_arrow_outlined),
cambioMano(Icons.front_hand_outlined, "Cambiar de mano"), cambioMano(Icons.front_hand_outlined),
nuevaPartida(Icons.refresh, "Nueva partida"), nuevaPartida(Icons.refresh),
cambiarDificultad(Icons.settings_outlined, "Cambiar dificultad"), cambiarDificultad(Icons.settings_outlined),
salir(Icons.logout, "Terminar partida"); salir(Icons.logout);
final IconData icon; final IconData icon;
final String text;
const OpcionPausa(this.icon, this.text); const OpcionPausa(this.icon);
Color? getColor(Brightness brillo) { Color? getColor(Brightness brillo) {
switch(this){ switch(this){
...@@ -88,4 +88,19 @@ enum OpcionPausa { ...@@ -88,4 +88,19 @@ enum OpcionPausa {
return null; return null;
} }
} }
String getText(BuildContext context) {
switch(this){
case OpcionPausa.reanudar:
return AppLocalizations.of(context)?.resume ?? 'Reanudar';
case OpcionPausa.cambioMano:
return AppLocalizations.of(context)?.changeHand ?? 'Cambiar de mano';
case OpcionPausa.nuevaPartida:
return AppLocalizations.of(context)?.newGame ?? 'Nueva partida';
case OpcionPausa.cambiarDificultad:
return AppLocalizations.of(context)?.changeDifficulty ?? 'Cambiar dificultad';
case OpcionPausa.salir:
return AppLocalizations.of(context)?.exitGame ?? 'Terminar partida';
}
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment