Agregados soporte para modo oscuro y horizontal. Terminada pantalla de récords

parent 53f5f12b
export 'pista.dart'; export 'pista.dart';
\ No newline at end of file export 'peponator_record.dart';
\ No newline at end of file
class PeponatorRecord {
final String jugador;
final int puntuacion;
final DateTime fecha;
PeponatorRecord({required this.jugador, required this.puntuacion, required this.fecha});
}
\ No newline at end of file
...@@ -10,14 +10,14 @@ class Pista{ ...@@ -10,14 +10,14 @@ class Pista{
late final int divisible; late final int divisible;
late final String mensaje; late final String mensaje;
EstadoPista estado = EstadoPista.BLOQUEADO; EstadoPista estado = EstadoPista.bloqueado;
Pista ({ Pista ({
required this.clase, required this.clase,
required int numero, required int numero,
this.onPressed this.onPressed
}) { }) {
if(clase != ClasePista.DIVISIBLE){ if(clase != ClasePista.divisible){
divisible = 0; divisible = 0;
} }
else{ else{
...@@ -43,29 +43,29 @@ class Pista{ ...@@ -43,29 +43,29 @@ class Pista{
} }
String _generaPista(int numero){ String _generaPista(int numero){
switch(this.clase){ switch(clase){
case ClasePista.PAR_IMPAR: case ClasePista.parImpar:
if(numero%2 == 0){ if(numero%2 == 0){
return 'El número es par'; return 'El número es par';
} }
return 'El número es impar'; return 'El número es impar';
case ClasePista.DIVISIBLE: case ClasePista.divisible:
if(divisible == 1){ if(divisible == 1){
return 'El número es primo inferior a 100'; return 'El número es primo inferior a 100';
} }
if(divisible == -1){ if(divisible == -1){
return 'El número NO es divisible entre primos inferiores a 100'; return 'El número NO es divisible entre primos inferiores a 100';
} }
return 'El número es divisible entre ${divisible}'; return 'El número es divisible entre $divisible';
case ClasePista.SUMA_CIFRAS: case ClasePista.sumaCifras:
int pseudo = numero; int pseudo = numero;
int suma = 0; int suma = 0;
while(pseudo > 0){ while(pseudo > 0){
suma += pseudo%10; suma += pseudo%10;
pseudo = (pseudo/10).floor(); pseudo = (pseudo/10).floor();
} }
return 'La suma de las cifras del número da ${suma}'; return 'La suma de las cifras del número da $suma';
case ClasePista.NUMERO_CIFRAS: case ClasePista.numeroCifras:
int div = 10; int div = 10;
int num = 1; int num = 1;
while(numero/div > 1){ while(numero/div > 1){
...@@ -75,15 +75,15 @@ class Pista{ ...@@ -75,15 +75,15 @@ class Pista{
if(num == 1){ if(num == 1){
return 'El número tiene 1 cifra'; return 'El número tiene 1 cifra';
} }
return 'El número tiene ${num} cifras'; return 'El número tiene $num cifras';
} }
} }
bool validarNumero(int adivinar, int numero){ bool validarNumero(int adivinar, int numero){
switch(this.clase){ switch(clase){
case ClasePista.PAR_IMPAR: case ClasePista.parImpar:
return adivinar%2 == numero%2; return adivinar%2 == numero%2;
case ClasePista.DIVISIBLE: case ClasePista.divisible:
if(divisible == 1){ if(divisible == 1){
return primos.contains(numero); return primos.contains(numero);
} }
...@@ -97,7 +97,7 @@ class Pista{ ...@@ -97,7 +97,7 @@ class Pista{
return true; return true;
} }
return adivinar%divisible == numero%divisible; return adivinar%divisible == numero%divisible;
case ClasePista.SUMA_CIFRAS: case ClasePista.sumaCifras:
int a = adivinar, b = numero; int a = adivinar, b = numero;
int sumaA = 0, sumaB = 0; int sumaA = 0, sumaB = 0;
while(a > 0 && b > 0){ while(a > 0 && b > 0){
...@@ -107,7 +107,7 @@ class Pista{ ...@@ -107,7 +107,7 @@ class Pista{
b = (b/10).floor(); b = (b/10).floor();
} }
return sumaA == sumaB; return sumaA == sumaB;
case ClasePista.NUMERO_CIFRAS: case ClasePista.numeroCifras:
int div = 10; int div = 10;
while(adivinar/div > 10){ while(adivinar/div > 10){
div *= 10; div *= 10;
...@@ -118,63 +118,83 @@ class Pista{ ...@@ -118,63 +118,83 @@ class Pista{
Widget createWidget(){ Widget createWidget(){
return PistaWidget( return PistaWidget(
key: Key(this.clase.name), key: Key(clase.name),
titulo: this.clase.getTitle(), titulo: clase.getTitle(),
mensaje: (estado.desbloqueada())? mensaje : estado.getMensaje(), mensaje: (estado.desbloqueada())? mensaje : estado.getMensaje(),
fondo: estado.getColorFondo(), estado: estado,
texto: estado.getColorTexto(), onPressed: (estado == EstadoPista.disponible || estado == EstadoPista.confirmacion)? onPressed : null
onPressed: (estado == EstadoPista.DISPONIBLE || estado == EstadoPista.CONFIRMACION)? onPressed : null
); );
} }
} }
enum ClasePista { enum ClasePista {
PAR_IMPAR, parImpar,
DIVISIBLE, divisible,
SUMA_CIFRAS, sumaCifras,
NUMERO_CIFRAS; numeroCifras;
String getTitle(){ String getTitle(){
switch(this){ switch(this){
case PAR_IMPAR: case parImpar:
return '¿Es par o impar?'; return '¿Es par o impar?';
case DIVISIBLE: case divisible:
return '¿Entre qué número es divisible?'; return '¿Entre qué número es divisible?';
case SUMA_CIFRAS: case sumaCifras:
return '¿Cuál es la suma de sus cifras?'; return '¿Cuál es la suma de sus cifras?';
case NUMERO_CIFRAS: case numeroCifras:
return '¿Cuántas cifras tiene?'; return '¿Cuántas cifras tiene?';
} }
} }
} }
enum EstadoPista { enum EstadoPista {
BLOQUEADO, bloqueado,
DISPONIBLE, disponible,
CONFIRMACION, confirmacion,
DESBLOQUEADO, desbloqueado,
CORRECTO, correcto,
INCORRECTO; incorrecto;
Color getColorFondo() { Color getColorFondo(Brightness brillo) {
switch(this){ switch(this){
case BLOQUEADO: case bloqueado:
if(brillo == Brightness.dark){
return Colors.grey.shade800;
}
return Colors.black87; return Colors.black87;
case DISPONIBLE: case disponible:
if(brillo == Brightness.dark){
return Colors.orange.shade700;
}
return Colors.orange; return Colors.orange;
case CONFIRMACION: case confirmacion:
if(brillo == Brightness.dark){
return Colors.yellow.shade700;
}
return Colors.yellow; return Colors.yellow;
case DESBLOQUEADO: case desbloqueado:
if(brillo == Brightness.dark){
return Colors.grey.shade400;
}
return Colors.white; return Colors.white;
case CORRECTO: case correcto:
if(brillo == Brightness.dark){
return Colors.green.shade700;
}
return Colors.green.shade400; return Colors.green.shade400;
case INCORRECTO: case incorrecto:
if(brillo == Brightness.dark){
return Colors.red.shade700;
}
return Colors.red; return Colors.red;
} }
} }
Color getColorTexto() { Color getColorTexto(Brightness brillo) {
if(this.index < 1 || this == EstadoPista.INCORRECTO){ if(index < 1 || this == EstadoPista.incorrecto){
return Colors.white;
}
if(brillo == Brightness.dark && this == EstadoPista.correcto){
return Colors.white; return Colors.white;
} }
return Colors.black; return Colors.black;
...@@ -182,11 +202,11 @@ enum EstadoPista { ...@@ -182,11 +202,11 @@ enum EstadoPista {
String getMensaje(){ String getMensaje(){
switch(this){ switch(this){
case BLOQUEADO: case bloqueado:
return "PISTA BLOQUEADA"; return "PISTA BLOQUEADA";
case DISPONIBLE: case disponible:
return "PULSA PARA DESBLOQUEAR"; return "PULSA PARA DESBLOQUEAR";
case CONFIRMACION: case confirmacion:
return "¿Seguro? Pulsa de nuevo para confirmar"; return "¿Seguro? Pulsa de nuevo para confirmar";
default: default:
return ""; return "";
...@@ -194,6 +214,6 @@ enum EstadoPista { ...@@ -194,6 +214,6 @@ enum EstadoPista {
} }
bool desbloqueada(){ bool desbloqueada(){
return this.index >= EstadoPista.DESBLOQUEADO.index; return index >= EstadoPista.desbloqueado.index;
} }
} }
export 'pantalla_juego.dart'; export 'pantalla_juego.dart';
\ No newline at end of file export 'pantalla_records.dart';
\ No newline at end of file
...@@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; ...@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:peponator/modelo/pista.dart'; import 'package:peponator/modelo/pista.dart';
import 'package:peponator/widgets/pantalla_pausa.dart'; import 'package:peponator/widgets/pantalla_pausa.dart';
import 'package:peponator/widgets/peponator_mensaje.dart'; import 'package:peponator/widgets/peponator_mensaje.dart';
import 'package:peponator/widgets/pista_widget.dart';
import 'dart:math'; import 'dart:math';
import 'package:peponator/widgets/teclado_numerico.dart'; import 'package:peponator/widgets/teclado_numerico.dart';
...@@ -19,10 +18,15 @@ class PantallaJuego extends StatefulWidget { ...@@ -19,10 +18,15 @@ class PantallaJuego extends StatefulWidget {
State<PantallaJuego> createState() => _PantallaJuegoState(); State<PantallaJuego> createState() => _PantallaJuegoState();
} }
class _PantallaJuegoState extends State<PantallaJuego> { class _PantallaJuegoState extends State<PantallaJuego>
with SingleTickerProviderStateMixin {
late final TextEditingController textController = TextEditingController(); late final TextEditingController textController = TextEditingController();
late final ScrollController scrollController = ScrollController(); late final ScrollController scrollController = ScrollController();
late final AnimationController _controller;
double animatedValue = 0.0;
bool _updateMaximum = false;
late int numeroAdivinar; late int numeroAdivinar;
late final int maxIntentos; late final int maxIntentos;
...@@ -52,11 +56,21 @@ class _PantallaJuegoState extends State<PantallaJuego> { ...@@ -52,11 +56,21 @@ class _PantallaJuegoState extends State<PantallaJuego> {
// TODO: Cargar el máximo de intentos // TODO: Cargar el máximo de intentos
maxIntentos = 21; maxIntentos = 21;
_controller = AnimationController(
duration: Duration(milliseconds: 200),
vsync: this
);
_controller.addListener(() {
setState(() {
animatedValue = _controller.value;
});
});
_nuevaPartida(); _nuevaPartida();
} }
void _nuevaPartida(){ void _nuevaPartida(){
Random random = new Random(); Random random = Random();
setState(() { setState(() {
textController.clear(); textController.clear();
...@@ -75,14 +89,14 @@ class _PantallaJuegoState extends State<PantallaJuego> { ...@@ -75,14 +89,14 @@ class _PantallaJuegoState extends State<PantallaJuego> {
clase: ClasePista.values[i], clase: ClasePista.values[i],
numero: numeroAdivinar, numero: numeroAdivinar,
onPressed: () { onPressed: () {
if(pistas[i].estado == EstadoPista.DISPONIBLE){ if(pistas[i].estado == EstadoPista.disponible){
setState(() { setState(() {
pistas[i].estado = EstadoPista.CONFIRMACION; pistas[i].estado = EstadoPista.confirmacion;
}); });
} }
else if(pistas[i].estado == EstadoPista.CONFIRMACION) { else if(pistas[i].estado == EstadoPista.confirmacion) {
setState(() { setState(() {
pistas[i].estado = EstadoPista.DESBLOQUEADO; pistas[i].estado = EstadoPista.desbloqueado;
}); });
_actualizarPistas(); _actualizarPistas();
} }
...@@ -90,7 +104,7 @@ class _PantallaJuegoState extends State<PantallaJuego> { ...@@ -90,7 +104,7 @@ class _PantallaJuegoState extends State<PantallaJuego> {
)); ));
} }
mensajes.add(PeponatorMensaje(message: "¡Hola! Estoy pensando en un número del ${limiteInferior} al ${limiteSuperior}. ¿Te crees capaz de adivinarlo?")); mensajes.add(PeponatorMensaje(message: "¡Hola! Estoy pensando en un número del $limiteInferior al $limiteSuperior. ¿Te crees capaz de adivinarlo?"));
mostrarPistas = false; mostrarPistas = false;
todasPistasBien = false; todasPistasBien = false;
...@@ -105,92 +119,108 @@ class _PantallaJuegoState extends State<PantallaJuego> { ...@@ -105,92 +119,108 @@ class _PantallaJuegoState extends State<PantallaJuego> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return OrientationBuilder(
backgroundColor: (mostrarPistas)? Theme.of(context).colorScheme.surfaceDim : null, builder: (context, orientation) {
body: SafeArea( return Scaffold(
child: Stack( backgroundColor: (mostrarPistas)? Theme.of(context).colorScheme.surfaceDim : null,
children: [ body: SafeArea(
Positioned( child: Stack(
top: 0, children: [
left: 0, Positioned(
child: SizedBox( top: 0,
width: MediaQuery.of(context).size.width, right: (orientation == Orientation.portrait || !manoDerecha)? 0 : null,
height: MediaQuery.of(context).size.height - 420, left: (orientation == Orientation.portrait || !manoDerecha)? null : 0,
child: (mostrarPistas)? _buildVistaPistas() : _buildVistaMensajes() child: SizedBox(
) width: (orientation == Orientation.portrait)?
), MediaQuery.of(context).size.width - MediaQuery.of(context).padding.horizontal :
Positioned( MediaQuery.of(context).size.width - MediaQuery.of(context).padding.horizontal - 420,
top: 0, height: (orientation == Orientation.portrait)?
right: 10, MediaQuery.of(context).size.height - 420 :
child: ElevatedButton( MediaQuery.of(context).size.height - MediaQuery.of(context).padding.vertical,
onPressed: () async { child: (mostrarPistas)? _buildVistaPistas(orientation) : _buildVistaMensajes()
switch(await showDialog<OpcionPausa>(context: context, )
builder: (context) { ),
return PantallaPausa(); if(!(victoria || intentos >= maxIntentos)) Positioned(
top: 0,
right: (orientation == Orientation.portrait || !manoDerecha)? 10 : null,
left: (orientation == Orientation.portrait || !manoDerecha)? null : 10,
child: ElevatedButton(
onPressed: () async {
switch(await showDialog<OpcionPausa>(context: context,
builder: (context) {
return PantallaPausa(
orientacion: orientation,
manoDerecha: manoDerecha,
);
}
)) {
case null:
case OpcionPausa.reanudar:
break;
case OpcionPausa.cambioMano:
setState(() {
manoDerecha = !manoDerecha;
});
break;
case OpcionPausa.nuevaPartida:
_nuevaPartida();
break;
case OpcionPausa.cambiarDificultad:
// TODO: Handle this case.
break;
case OpcionPausa.salir:
// TODO: Handle this case.
break;
} }
)) { },
case null: style: ButtonStyle(
case OpcionPausa.REANUDAR: elevation: WidgetStatePropertyAll<double>(5.0),
break; shape: WidgetStatePropertyAll<OutlinedBorder>(CircleBorder()),
case OpcionPausa.CAMBIO_MANO: padding: WidgetStatePropertyAll<EdgeInsets>(
setState(() { EdgeInsets.all(16.0)
manoDerecha = !manoDerecha; ),
}); side: WidgetStatePropertyAll<BorderSide>(
break; BorderSide(
case OpcionPausa.NUEVA_PARTIDA: width: 2.0,
_nuevaPartida(); color: (Theme.of(context).brightness == Brightness.light)?
break; Colors.black12 :
case OpcionPausa.CAMBIAR_DIFICULTAD: Colors.grey.shade400,
// TODO: Handle this case. )
break; )
case OpcionPausa.SALIR: ),
// TODO: Handle this case. child: Icon(
break; Icons.pause,
} size: 28.0,
},
style: ButtonStyle(
elevation: WidgetStatePropertyAll<double>(5.0),
shape: WidgetStatePropertyAll<OutlinedBorder>(CircleBorder()),
padding: WidgetStatePropertyAll<EdgeInsets>(
EdgeInsets.all(16.0)
),
side: WidgetStatePropertyAll<BorderSide>(
BorderSide(
width: 2.0,
color: Colors.black12
) )
) )
), ),
child: Icon( Positioned(
Icons.pause, bottom: 0,
size: 28.0, left: (manoDerecha)? null : 0,
right: (manoDerecha)? 0 : null,
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
colors: <Color>[
Theme.of(context).colorScheme.surface,
Theme.of(context).colorScheme.surface.withAlpha(0)
],
stops: <double>[
(orientation == Orientation.portrait)? 0.97 : 1.0,
1.0
]
)
),
child: (victoria || intentos >= maxIntentos)? _buildPantallaFinal(orientation) :_buildTeclado(orientation)
)
) )
) ],
),
Positioned(
bottom: 0,
left: 0,
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
colors: <Color>[
Theme.of(context).colorScheme.surface,
Theme.of(context).colorScheme.surface.withAlpha(0)
],
stops: <double>[
0.97,
1.0
]
)
),
child: (victoria || intentos >= maxIntentos)? _buildPantallaFinal() :_buildTeclado()
)
) )
], ),
) );
), }
); );
} }
...@@ -213,21 +243,25 @@ class _PantallaJuegoState extends State<PantallaJuego> { ...@@ -213,21 +243,25 @@ class _PantallaJuegoState extends State<PantallaJuego> {
); );
} }
Widget _buildVistaPistas(){ Widget _buildVistaPistas(Orientation orientation){
return Padding( return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0), padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.only(right: 56.0), padding: (orientation == Orientation.portrait || !manoDerecha)?
const EdgeInsets.only(right: 56.0) :
const EdgeInsets.only(left: 56.0),
child: Text( child: Text(
'Pistas Especiales', 'Pistas Especiales',
style: Theme.of(context).textTheme.headlineLarge, style: Theme.of(context).textTheme.headlineLarge,
), ),
), ),
Padding( Padding(
padding: const EdgeInsets.only(top: 8.0, right: 56.0), padding: (orientation == Orientation.portrait || !manoDerecha)?
const EdgeInsets.only(top: 8.0, right: 56.0) :
const EdgeInsets.only(top: 8.0, left: 56.0),
child: Text( child: Text(
'¡Atención! Usarlas quita puntos', '¡Atención! Usarlas quita puntos',
style: Theme.of(context).textTheme.titleLarge?.copyWith( style: Theme.of(context).textTheme.titleLarge?.copyWith(
...@@ -235,21 +269,28 @@ class _PantallaJuegoState extends State<PantallaJuego> { ...@@ -235,21 +269,28 @@ class _PantallaJuegoState extends State<PantallaJuego> {
), ),
), ),
), ),
ListView.builder( SizedBox(
itemBuilder: (context, index) { height: (orientation == Orientation.portrait)?
return pistas[index].createWidget(); MediaQuery.of(context).size.height - MediaQuery.of(context).padding.vertical - 448.0 :
}, MediaQuery.of(context).size.height - MediaQuery.of(context).padding.vertical - 76.0,
itemCount: pistas.length, child: ListView.builder(
shrinkWrap: true, itemBuilder: (context, index) {
return pistas[index].createWidget();
},
itemCount: pistas.length,
shrinkWrap: true,
),
), ),
], ],
), ),
); );
} }
Widget _buildTeclado() { Widget _buildTeclado(Orientation orientation) {
final fullWidth = MediaQuery.of(context).size.width; final fullWidth = (orientation == Orientation.portrait)?
final fullHeight = 380.0; MediaQuery.of(context).size.width - MediaQuery.of(context).padding.horizontal : 400.0;
final fullHeight = (orientation == Orientation.portrait)?
380.0 : MediaQuery.of(context).size.height - MediaQuery.of(context).padding.vertical;
final primeraFila = <Widget>[ final primeraFila = <Widget>[
SizedBox( SizedBox(
...@@ -273,6 +314,8 @@ class _PantallaJuegoState extends State<PantallaJuego> { ...@@ -273,6 +314,8 @@ class _PantallaJuegoState extends State<PantallaJuego> {
onNumberPress: _onNumberPress, onNumberPress: _onNumberPress,
onBackspacePress: _onBackspacePress, onBackspacePress: _onBackspacePress,
onEnterPress: _onEnterPress, onEnterPress: _onEnterPress,
numberBackgroundColor: (Theme.of(context).brightness == Brightness.light)?
Colors.cyan : Theme.of(context).colorScheme.inversePrimary,
invertBackspaceEnter: !manoDerecha, invertBackspaceEnter: !manoDerecha,
disableEnter: (numeroEscogido == null || error || espera), disableEnter: (numeroEscogido == null || error || espera),
), ),
...@@ -301,14 +344,16 @@ class _PantallaJuegoState extends State<PantallaJuego> { ...@@ -301,14 +344,16 @@ class _PantallaJuegoState extends State<PantallaJuego> {
Widget _buildHintToggleButton(){ Widget _buildHintToggleButton(){
onPressed() { onPressed() {
setState(() { if(!espera){
mostrarPistas = !mostrarPistas; setState(() {
for(Pista p in pistas){ mostrarPistas = !mostrarPistas;
if(p.estado == EstadoPista.CONFIRMACION){ for(Pista p in pistas){
p.estado = EstadoPista.DISPONIBLE; if(p.estado == EstadoPista.confirmacion){
p.estado = EstadoPista.disponible;
}
} }
} });
}); }
} }
const icon = Icon( const icon = Icon(
...@@ -316,7 +361,7 @@ class _PantallaJuegoState extends State<PantallaJuego> { ...@@ -316,7 +361,7 @@ class _PantallaJuegoState extends State<PantallaJuego> {
size: 35.0, size: 35.0,
); );
const style = ButtonStyle( final style = ButtonStyle(
shape: WidgetStatePropertyAll<OutlinedBorder>(CircleBorder()), shape: WidgetStatePropertyAll<OutlinedBorder>(CircleBorder()),
padding: WidgetStatePropertyAll<EdgeInsets>( padding: WidgetStatePropertyAll<EdgeInsets>(
EdgeInsets.all(16.0) EdgeInsets.all(16.0)
...@@ -324,7 +369,9 @@ class _PantallaJuegoState extends State<PantallaJuego> { ...@@ -324,7 +369,9 @@ class _PantallaJuegoState extends State<PantallaJuego> {
side: WidgetStatePropertyAll<BorderSide>( side: WidgetStatePropertyAll<BorderSide>(
BorderSide( BorderSide(
width: 2.0, width: 2.0,
color: Colors.black12 color: (Theme.of(context).brightness == Brightness.light)?
Colors.black12 :
Colors.grey.shade600,
) )
) )
); );
...@@ -359,30 +406,34 @@ class _PantallaJuegoState extends State<PantallaJuego> { ...@@ -359,30 +406,34 @@ class _PantallaJuegoState extends State<PantallaJuego> {
); );
} }
return IconButton( return Stack(
onPressed: onPressed, children: [
style: style, Center(
icon: (badgeIcon != null)? child: IconButton(
Badge( onPressed: onPressed,
label: Padding( style: style,
padding: const EdgeInsets.symmetric(vertical: 8.0), icon: icon
child: Icon( ),
badgeIcon, ),
size: 24, if(badgeIcon != null) Positioned(
color: Colors.white, right: manoDerecha? 0 : null,
left: manoDerecha? null : 0,
top: 0,
child: IgnorePointer(
child: Badge(
label: Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Icon(
badgeIcon,
size: 24,
color: Colors.white,
),
), ),
backgroundColor: (numeroEscogido != null && algunaDesbloqueada && todasPistasBien)? Colors.green : Colors.red,
), ),
backgroundColor: (numeroEscogido != null && algunaDesbloqueada && todasPistasBien)? Colors.green : Colors.red, ),
offset: Offset( )
manoDerecha? 16.0 : -58.0, ],
-16.0
),
child: const Icon(
Icons.lightbulb,
size: 35.0,
),
) :
icon
); );
} }
...@@ -439,13 +490,19 @@ class _PantallaJuegoState extends State<PantallaJuego> { ...@@ -439,13 +490,19 @@ class _PantallaJuegoState extends State<PantallaJuego> {
padding: const EdgeInsets.only(left: 8.0, right: 8.0, top: 8.0), padding: const EdgeInsets.only(left: 8.0, right: 8.0, top: 8.0),
child: Container( child: Container(
decoration: ShapeDecoration( decoration: ShapeDecoration(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
side: BorderSide( side: BorderSide(
color: Theme.of(context).colorScheme.primary, color: Theme.of(context).colorScheme.primary,
width: 3.0 width: 3.0
), ),
borderRadius: BorderRadius.all(Radius.circular(16.0)) borderRadius: BorderRadius.all(Radius.circular(16.0))
) ),
color: Color.lerp(
Theme.of(context).colorScheme.surface,
Theme.of(context).colorScheme.primary,
-(2.5*animatedValue*animatedValue)
+ (2.5*animatedValue)
)
), ),
child: Text( child: Text(
(maxIntentos - intentos).toString(), (maxIntentos - intentos).toString(),
...@@ -478,6 +535,12 @@ class _PantallaJuegoState extends State<PantallaJuego> { ...@@ -478,6 +535,12 @@ class _PantallaJuegoState extends State<PantallaJuego> {
width: 3.0 width: 3.0
), ),
borderRadius: BorderRadius.all(Radius.circular(16.0)) borderRadius: BorderRadius.all(Radius.circular(16.0))
),
color: (!_updateMaximum)? null : Color.lerp(
Theme.of(context).colorScheme.surface,
Colors.red,
-(2.5*animatedValue*animatedValue)
+ (2.5*animatedValue)
) )
), ),
child: Text( child: Text(
...@@ -525,6 +588,12 @@ class _PantallaJuegoState extends State<PantallaJuego> { ...@@ -525,6 +588,12 @@ class _PantallaJuegoState extends State<PantallaJuego> {
width: 3.0 width: 3.0
), ),
borderRadius: BorderRadius.all(Radius.circular(16.0)) borderRadius: BorderRadius.all(Radius.circular(16.0))
),
color: (_updateMaximum)? null : Color.lerp(
Theme.of(context).colorScheme.surface,
Colors.green,
-(2.5*animatedValue*animatedValue)
+ (2.5*animatedValue)
) )
), ),
child: Text( child: Text(
...@@ -548,7 +617,8 @@ class _PantallaJuegoState extends State<PantallaJuego> { ...@@ -548,7 +617,8 @@ class _PantallaJuegoState extends State<PantallaJuego> {
); );
} }
Widget _buildPantallaFinal(){ // TODO: Agregar una pantalla de registro de récords
Widget _buildPantallaFinal(Orientation orientation){
final fullWidth = MediaQuery.of(context).size.width; final fullWidth = MediaQuery.of(context).size.width;
final fullHeight = 380.0; final fullHeight = 380.0;
...@@ -581,18 +651,18 @@ class _PantallaJuegoState extends State<PantallaJuego> { ...@@ -581,18 +651,18 @@ class _PantallaJuegoState extends State<PantallaJuego> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: OpcionesFinPartida.values.map((element) { children: OpcionesFinPartida.values.map((element) {
final onPressed; final VoidCallback onPressed;
switch(element){ switch(element){
case OpcionesFinPartida.REPETIR: case OpcionesFinPartida.repetir:
onPressed = () { onPressed = () {
_nuevaPartida(); _nuevaPartida();
}; };
break; break;
case OpcionesFinPartida.CAMBIAR_DIFICULTAD: case OpcionesFinPartida.cambiarDificultad:
// TODO: Handle this case. // TODO: Handle this case.
onPressed = () { }; onPressed = () { };
break; break;
case OpcionesFinPartida.SALIR: case OpcionesFinPartida.salir:
// TODO: Handle this case. // TODO: Handle this case.
onPressed = () { }; onPressed = () { };
break; break;
...@@ -603,19 +673,22 @@ class _PantallaJuegoState extends State<PantallaJuego> { ...@@ -603,19 +673,22 @@ class _PantallaJuegoState extends State<PantallaJuego> {
onPressed: onPressed, onPressed: onPressed,
style: TextButton.styleFrom( style: TextButton.styleFrom(
side: BorderSide( side: BorderSide(
color: Colors.black26, color: (Theme.of(context).brightness == Brightness.light)?
Colors.black26 :
Colors.grey,
width: 3.0 width: 3.0
) )
), ),
icon: Icon( icon: Icon(
element.icon, element.icon,
color: element.color ?? Theme.of(context).colorScheme.primary, color: element.getColor(Theme.of(context).brightness) ?? Theme.of(context).colorScheme.primary,
size: 32.0 size: 32.0
), ),
label: Text( label: Text(
element.text, element.text,
style: Theme.of(context).textTheme.titleLarge?.copyWith( style: Theme.of(context).textTheme.titleLarge?.copyWith(
color: element.color ?? Theme.of(context).colorScheme.primary fontWeight: (Theme.of(context).brightness == Brightness.light)? null : FontWeight.bold,
color: element.getColor(Theme.of(context).brightness) ?? Theme.of(context).colorScheme.primary
), ),
), ),
), ),
...@@ -690,29 +763,29 @@ class _PantallaJuegoState extends State<PantallaJuego> { ...@@ -690,29 +763,29 @@ class _PantallaJuegoState extends State<PantallaJuego> {
}); });
for(int i = 0; i<pistas.length && i<(intentos/5).floor(); i++){ for(int i = 0; i<pistas.length && i<(intentos/5).floor(); i++){
if(pistas[i].estado == EstadoPista.BLOQUEADO){ if(pistas[i].estado == EstadoPista.bloqueado){
setState(() { setState(() {
porDesbloquear = true; porDesbloquear = true;
pistas[i].estado = EstadoPista.DISPONIBLE; pistas[i].estado = EstadoPista.disponible;
}); });
} }
else if(pistas[i].estado.desbloqueada()){ else if(pistas[i].estado.desbloqueada()){
if(!algunaDesbloqueada) algunaDesbloqueada = true; if(!algunaDesbloqueada) algunaDesbloqueada = true;
if(error || numeroEscogido == null){ if(error || numeroEscogido == null){
setState(() { setState(() {
pistas[i].estado = EstadoPista.DESBLOQUEADO; pistas[i].estado = EstadoPista.desbloqueado;
}); });
} }
else{ else{
if(pistas[i].validarNumero(numeroAdivinar, numeroEscogido!)){ if(pistas[i].validarNumero(numeroAdivinar, numeroEscogido!)){
setState(() { setState(() {
pistas[i].estado = EstadoPista.CORRECTO; pistas[i].estado = EstadoPista.correcto;
}); });
} }
else{ else{
setState(() { setState(() {
todasPistasBien = false; todasPistasBien = false;
pistas[i].estado = EstadoPista.INCORRECTO; pistas[i].estado = EstadoPista.incorrecto;
}); });
} }
} }
...@@ -729,12 +802,14 @@ class _PantallaJuegoState extends State<PantallaJuego> { ...@@ -729,12 +802,14 @@ class _PantallaJuegoState extends State<PantallaJuego> {
await Future.delayed(Duration(milliseconds: 600)); await Future.delayed(Duration(milliseconds: 600));
setState(() { setState(() {
// TODO: Construir respuesta de Peponator con cierto retardo // TODO: Construir respuesta de Peponator con cierto retardo
mensajes.add(PeponatorMensaje(message: "¡Hola! Estoy pensando en un número del ${limiteInferior} al ${limiteSuperior}. ¿Te crees capaz de adivinarlo?")); mensajes.add(PeponatorMensaje(message: "¡Hola! Estoy pensando en un número del $limiteInferior al $limiteSuperior. ¿Te crees capaz de adivinarlo?"));
if(numeroEscogido! < numeroAdivinar){ if(numeroEscogido! < numeroAdivinar){
limiteInferior = numeroEscogido!; limiteInferior = numeroEscogido! + 1;
_updateMaximum = false;
} }
if(numeroEscogido! > numeroAdivinar){ if(numeroEscogido! > numeroAdivinar){
limiteSuperior = numeroEscogido!; limiteSuperior = numeroEscogido! - 1;
_updateMaximum = true;
} }
if(numeroEscogido! == numeroAdivinar){ if(numeroEscogido! == numeroAdivinar){
victoria = true; victoria = true;
...@@ -742,6 +817,9 @@ class _PantallaJuegoState extends State<PantallaJuego> { ...@@ -742,6 +817,9 @@ class _PantallaJuegoState extends State<PantallaJuego> {
numeroEscogido = null; numeroEscogido = null;
intentos++; intentos++;
espera = false; espera = false;
_controller.reset();
_controller.forward();
}); });
_actualizarPistas(); _actualizarPistas();
...@@ -752,13 +830,29 @@ class _PantallaJuegoState extends State<PantallaJuego> { ...@@ -752,13 +830,29 @@ class _PantallaJuegoState extends State<PantallaJuego> {
} }
enum OpcionesFinPartida { enum OpcionesFinPartida {
REPETIR(Icons.play_arrow_outlined, "Jugar otra vez", Color.fromARGB(255, 0, 125, 0)), repetir(Icons.play_arrow_outlined, "Jugar otra vez"),
CAMBIAR_DIFICULTAD(Icons.settings_outlined, "Cambiar de dificultad"), cambiarDificultad(Icons.settings_outlined, "Cambiar de dificultad"),
SALIR(Icons.logout, "Volver al inicio", Color.fromARGB(255, 213, 0, 0)); salir(Icons.logout, "Volver al inicio");
final IconData icon; final IconData icon;
final String text; final String text;
final Color? color;
const OpcionesFinPartida(this.icon, this.text, [this.color]); const OpcionesFinPartida(this.icon, this.text);
Color? getColor(Brightness brillo) {
switch(this){
case repetir:
if(brillo == Brightness.dark){
return Colors.green;
}
return Color.fromARGB(255, 0, 125, 0);
case salir:
if(brillo == Brightness.dark){
return Colors.red;
}
return Color.fromARGB(255, 213, 0, 0);
default:
return null;
}
}
} }
import 'package:flutter/material.dart';
import 'package:peponator/modelo/modelo.dart';
class PantallaRecords extends StatelessWidget {
const PantallaRecords({super.key});
@override
Widget build(BuildContext context) {
// TODO: Cargar los récords (esto se haría con un archivo de texto en la carpeta privada de la aplicación)
final records = <PeponatorRecord>[];
records.add(PeponatorRecord(
jugador: "AAA",
puntuacion: 12211350,
fecha: DateTime.now()
));
records.add(PeponatorRecord(
jugador: "BBB",
puntuacion: 25,
fecha: DateTime.now()
));
records.add(PeponatorRecord(
jugador: "CCC",
puntuacion: 13,
fecha: DateTime.now()
));
records.add(PeponatorRecord(
jugador: "DDD",
puntuacion: 7,
fecha: DateTime.now()
));
records.add(PeponatorRecord(
jugador: "EEE",
puntuacion: 6,
fecha: DateTime.now()
));
records.add(PeponatorRecord(
jugador: "FFF",
puntuacion: 5,
fecha: DateTime.now()
));
records.add(PeponatorRecord(
jugador: "GGG",
puntuacion: 4,
fecha: DateTime.now()
));
records.add(PeponatorRecord(
jugador: "HHH",
puntuacion: 3,
fecha: DateTime.now()
));
return Scaffold(
body: SafeArea(
child: LayoutBuilder(
builder: (context, constraints) {
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Container(
color: Theme.of(context).colorScheme.primary,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
'Récords',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.headlineLarge?.copyWith(
color: Theme.of(context).colorScheme.onPrimary,
fontWeight: FontWeight.bold
),
),
const SizedBox(height: 8.0),
Text(
'¡Las 20 mejores puntuaciones registradas en el juego!',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleLarge?.copyWith(
color: Theme.of(context).colorScheme.onPrimary,
fontStyle: FontStyle.italic
),
),
],
),
)
),
if(records.isNotEmpty) Expanded(
child: ListView.builder(
itemBuilder: (context, index){
Color c = Theme.of(context).colorScheme.inversePrimary;
Color? t = Theme.of(context).textTheme.titleLarge?.color;
if(index == 0){
if(Theme.of(context).brightness == Brightness.dark){
c = Colors.yellow.shade600;
}
else{
c = Colors.yellow;
}
t = Colors.black;
}
else if(index == 1){
c = Colors.grey.shade400;
t = Colors.black;
}
else if(index == 2){
if(Theme.of(context).brightness == Brightness.dark){
c = Color.fromARGB(255, 180, 76, 12);
}
else{
c = Colors.orange.shade800;
}
t = Colors.white;
}
DateTime fecha = records[index].fecha.toLocal();
return Padding(
padding: EdgeInsets.only(
top: 8.0,
bottom: (index >= records.length-1)? 100 : 0
),
child: Container(
color: c,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
records[index].jugador.toString(),
textAlign: TextAlign.start,
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
color: t,
fontWeight: FontWeight.bold
),
),
const SizedBox(height: 8.0),
Text(
'${fecha.day}/${fecha.month}/${fecha.year}',
textAlign: TextAlign.start,
style: Theme.of(context).textTheme.titleLarge?.copyWith(
color: t,
),
),
],
)
),
Flexible(
child: Text(
records[index].puntuacion.toString(),
textAlign: TextAlign.end,
style: Theme.of(context).textTheme.headlineLarge?.copyWith(
color: t,
),
)
)
],
),
),
),
);
},
shrinkWrap: true,
itemCount: records.length,
)
)
else Expanded(
child: Center(
child: Text(
'No hay ningún récord registrado de momento.\n\n¡Juega y registra el primero!',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleLarge,
)
),
)
],
);
}
)
),
floatingActionButton: Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: const EdgeInsets.only(left: 32.0),
child: FloatingActionButton.extended(
onPressed: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Center(child: Text(
'Borrar récords',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleLarge,
)),
content: Text(
'Esta acción no se puede deshacer. ¿Seguro que quieres borrar todos los récords?',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleMedium,
),
actionsAlignment: MainAxisAlignment.spaceAround,
actions: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
style: TextButton.styleFrom(
side: BorderSide(
color: Colors.grey,
width: 2.0
)
),
child: Text(
'Sí',
style: Theme.of(context).textTheme.titleMedium?.copyWith(
color: Theme.of(context).colorScheme.primary
),
)
),
TextButton(
onPressed: () {
Navigator.pop(context);
},
style: TextButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.primary
),
child: Text(
'No',
style: Theme.of(context).textTheme.titleMedium?.copyWith(
color: Theme.of(context).colorScheme.onPrimary
),
)
)
],
);
}
);
},
backgroundColor: Colors.red,
label: Text(
'Borrar récords',
style: Theme.of(context).textTheme.titleLarge?.copyWith(
color: Colors.white
),
),
),
),
),
);
}
}
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:peponator/paginas/paginas.dart';
import 'package:peponator/paginas/pantalla_juego.dart'; import 'package:peponator/paginas/pantalla_juego.dart';
class PeponatorApp extends StatelessWidget { class PeponatorApp extends StatelessWidget {
...@@ -10,11 +11,13 @@ class PeponatorApp extends StatelessWidget { ...@@ -10,11 +11,13 @@ class PeponatorApp extends StatelessWidget {
return MaterialApp( return MaterialApp(
theme: ThemeData( theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.cyan) colorScheme: ColorScheme.fromSeed(seedColor: Colors.cyan),
brightness: Brightness.light,
useMaterial3: true
), ),
darkTheme: ThemeData.dark(), darkTheme: ThemeData.dark(),
themeMode: ThemeMode.system, themeMode: ThemeMode.system,
home: PantallaJuego(fromHome: true,), home: PantallaRecords()
); );
} }
} }
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class PantallaPausa extends StatelessWidget { class PantallaPausa extends StatelessWidget {
final Orientation orientacion;
final bool manoDerecha;
late final Alignment alignment;
const PantallaPausa({Key? key}): super(key: key); PantallaPausa({Key? key, required this.orientacion, required this.manoDerecha}): super(key: key) {
if(orientacion == Orientation.portrait){
alignment = Alignment.center;
}
else if(manoDerecha){
alignment = Alignment.centerLeft;
}
else {
alignment = Alignment.centerRight;
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SimpleDialog( return SimpleDialog(
alignment: alignment,
title: Center(child: Text( title: Center(child: Text(
'Pausa', 'Pausa',
style: Theme.of(context).textTheme.headlineLarge, style: (orientacion == Orientation.portrait)?
Theme.of(context).textTheme.headlineLarge :
Theme.of(context).textTheme.headlineSmall,
)), )),
children: OpcionPausa.values.map((element) { children: OpcionPausa.values.map((element) {
return SimpleDialogOption( return SimpleDialogOption(
...@@ -19,19 +35,22 @@ class PantallaPausa extends StatelessWidget { ...@@ -19,19 +35,22 @@ class PantallaPausa extends StatelessWidget {
}, },
style: TextButton.styleFrom( style: TextButton.styleFrom(
side: BorderSide( side: BorderSide(
color: Colors.black26, color: (Theme.of(context).brightness == Brightness.light)?
Colors.black26 :
Colors.grey,
width: 3.0 width: 3.0
) )
), ),
icon: Icon( icon: Icon(
element.icon, element.icon,
color: element.color ?? Theme.of(context).colorScheme.primary, color: element.getColor(Theme.of(context).brightness) ?? Theme.of(context).colorScheme.primary,
size: 32.0 size: 32.0
), ),
label: Text( label: Text(
element.text, element.text,
style: Theme.of(context).textTheme.titleLarge?.copyWith( style: Theme.of(context).textTheme.titleLarge?.copyWith(
color: element.color ?? Theme.of(context).colorScheme.primary fontWeight: (Theme.of(context).brightness == Brightness.light)? null : FontWeight.bold,
color: element.getColor(Theme.of(context).brightness) ?? Theme.of(context).colorScheme.primary
), ),
), ),
), ),
...@@ -42,15 +61,31 @@ class PantallaPausa extends StatelessWidget { ...@@ -42,15 +61,31 @@ class PantallaPausa extends StatelessWidget {
} }
enum OpcionPausa { enum OpcionPausa {
REANUDAR(Icons.play_arrow_outlined, "Reanudar", Color.fromARGB(255, 0, 125, 0)), reanudar(Icons.play_arrow_outlined, "Reanudar"),
CAMBIO_MANO(Icons.front_hand_outlined, "Cambiar de mano"), cambioMano(Icons.front_hand_outlined, "Cambiar de mano"),
NUEVA_PARTIDA(Icons.refresh, "Nueva partida"), nuevaPartida(Icons.refresh, "Nueva partida"),
CAMBIAR_DIFICULTAD(Icons.settings_outlined, "Cambiar dificultad"), cambiarDificultad(Icons.settings_outlined, "Cambiar dificultad"),
SALIR(Icons.logout, "Terminar partida", Color.fromARGB(255, 213, 0, 0)); salir(Icons.logout, "Terminar partida");
final IconData icon; final IconData icon;
final String text; final String text;
final Color? color;
const OpcionPausa(this.icon, this.text, [this.color]); const OpcionPausa(this.icon, this.text);
Color? getColor(Brightness brillo) {
switch(this){
case reanudar:
if(brillo == Brightness.dark){
return Colors.green;
}
return Color.fromARGB(255, 0, 125, 0);
case salir:
if(brillo == Brightness.dark){
return Colors.red;
}
return Color.fromARGB(255, 213, 0, 0);
default:
return null;
}
}
} }
\ No newline at end of file
...@@ -33,7 +33,10 @@ class PeponatorMensaje extends StatelessWidget { ...@@ -33,7 +33,10 @@ class PeponatorMensaje extends StatelessWidget {
alignment: Alignment.center, alignment: Alignment.center,
transform: Matrix4.rotationY(pi), transform: Matrix4.rotationY(pi),
child: CustomPaint( child: CustomPaint(
painter: _Triangle(Colors.grey.shade300), painter: _Triangle(
(Theme.of(context).brightness == Brightness.light)?
Colors.grey.shade300 : Colors.grey.shade800
),
), ),
), ),
Flexible( Flexible(
...@@ -41,7 +44,8 @@ class PeponatorMensaje extends StatelessWidget { ...@@ -41,7 +44,8 @@ class PeponatorMensaje extends StatelessWidget {
child: Container( child: Container(
padding: EdgeInsets.all(14), padding: EdgeInsets.all(14),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.grey.shade300, color: (Theme.of(context).brightness == Brightness.light)?
Colors.grey.shade300 : Colors.grey.shade800,
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
topRight: Radius.circular(18), topRight: Radius.circular(18),
bottomLeft: Radius.circular(18), bottomLeft: Radius.circular(18),
...@@ -50,7 +54,12 @@ class PeponatorMensaje extends StatelessWidget { ...@@ -50,7 +54,12 @@ class PeponatorMensaje extends StatelessWidget {
), ),
child: Text( child: Text(
message, message,
style: TextStyle(color: Colors.black, fontFamily: 'Monstserrat', fontSize: 14), style: TextStyle(
color: (Theme.of(context).brightness == Brightness.light)?
Colors.black : Colors.white,
fontFamily: 'Monstserrat',
fontSize: 14
),
), ),
), ),
), ),
......
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:peponator/modelo/modelo.dart';
class PistaWidget extends StatelessWidget { class PistaWidget extends StatelessWidget {
final String titulo; final String titulo;
final String mensaje; final String mensaje;
final Color fondo; final EstadoPista estado;
final Color texto;
final VoidCallback? onPressed; final VoidCallback? onPressed;
PistaWidget({Key? key, required this.titulo, required this.mensaje, required this.fondo, required this.texto, this.onPressed}): const PistaWidget({Key? key, required this.titulo, required this.mensaje, required this.estado, this.onPressed}):
super(key: key); super(key: key);
@override @override
...@@ -27,12 +27,12 @@ class PistaWidget extends StatelessWidget { ...@@ -27,12 +27,12 @@ class PistaWidget extends StatelessWidget {
child: TextButton( child: TextButton(
onPressed: onPressed, onPressed: onPressed,
style: TextButton.styleFrom( style: TextButton.styleFrom(
backgroundColor: fondo, backgroundColor: estado.getColorFondo(Theme.of(context).brightness),
), ),
child: Text( child: Text(
mensaje, mensaje,
style: Theme.of(context).textTheme.titleMedium?.copyWith( style: Theme.of(context).textTheme.titleMedium?.copyWith(
color: texto color: estado.getColorTexto(Theme.of(context).brightness)
), ),
), ),
), ),
......
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'dart:math';
class TuMensaje extends StatelessWidget { class TuMensaje extends StatelessWidget {
final String message; final String message;
...@@ -12,30 +11,30 @@ class TuMensaje extends StatelessWidget { ...@@ -12,30 +11,30 @@ class TuMensaje extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final messageTextGroup = Flexible( final messageTextGroup = Flexible(
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Flexible( Flexible(
child: Container( child: Container(
padding: EdgeInsets.all(14), padding: EdgeInsets.all(14),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.blueAccent.shade400, color: Colors.blueAccent.shade400,
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
topLeft: Radius.circular(18), topLeft: Radius.circular(18),
bottomLeft: Radius.circular(18), bottomLeft: Radius.circular(18),
bottomRight: Radius.circular(18), bottomRight: Radius.circular(18),
),
),
child: Text(
message,
style: TextStyle(color: Colors.white, fontFamily: 'Monstserrat', fontSize: 18),
), ),
), ),
child: Text(
message,
style: TextStyle(color: Colors.white, fontFamily: 'Monstserrat', fontSize: 18),
),
), ),
CustomPaint(painter: _Triangle(Colors.blueAccent.shade400)), ),
], CustomPaint(painter: _Triangle(Colors.blueAccent.shade400)),
)); ],
));
return Padding( return Padding(
padding: EdgeInsets.only(right: 18.0, left: 50, top: 5, bottom: 5), padding: EdgeInsets.only(right: 18.0, left: 50, top: 5, bottom: 5),
......
export 'tu_mensaje.dart'; export 'tu_mensaje.dart';
export 'peponator_mensaje.dart'; export 'peponator_mensaje.dart';
export 'pista_widget.dart'; export 'pista_widget.dart';
export 'teclado_numerico.dart'; export 'teclado_numerico.dart';
\ No newline at end of file export 'pantalla_pausa.dart';
\ 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