Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Rafa Castillo Passols
/
peponator
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e7c7e494
authored
May 02, 2025
by
Diego Pérez Peña
Committed by
Tecnicos
May 02, 2025
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Arreglada página de récords y agregada parcialmente la pantalla de puntuación final
parent
6c25f5e9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
218 additions
and
89 deletions
lib/paginas/pantalla_juego.dart
lib/paginas/pantalla_records.dart
lib/peponator_app.dart
lib/paginas/pantalla_juego.dart
View file @
e7c7e494
import
'package:flutter/material.dart'
;
import
'package:peponator/modelo/pista.dart'
;
import
'package:peponator/paginas/paginas.dart'
;
import
'package:peponator/widgets/pantalla_pausa.dart'
;
import
'package:peponator/widgets/peponator_mensaje.dart'
;
import
'dart:math'
;
...
...
@@ -21,6 +22,7 @@ class PantallaJuego extends StatefulWidget {
class
_PantallaJuegoState
extends
State
<
PantallaJuego
>
with
SingleTickerProviderStateMixin
{
late
final
TextEditingController
textController
=
TextEditingController
();
late
final
TextEditingController
recordTextController
=
TextEditingController
();
late
final
ScrollController
scrollController
=
ScrollController
();
late
final
AnimationController
_controller
;
...
...
@@ -49,6 +51,10 @@ class _PantallaJuegoState extends State<PantallaJuego>
late
bool
espera
;
late
bool
victoria
;
late
int
puntuacion
;
late
int
posicion
;
late
String
jugador
;
@override
void
initState
()
{
super
.
initState
();
...
...
@@ -56,6 +62,12 @@ class _PantallaJuegoState extends State<PantallaJuego>
// TODO: Cargar el máximo de intentos
maxIntentos
=
21
;
recordTextController
.
addListener
(()
=>
setState
(()
{
jugador
=
recordTextController
.
text
;
})
);
_controller
=
AnimationController
(
duration:
Duration
(
milliseconds:
200
),
vsync:
this
...
...
@@ -114,10 +126,21 @@ class _PantallaJuegoState extends State<PantallaJuego>
error
=
false
;
espera
=
false
;
victoria
=
false
;
puntuacion
=
0
;
posicion
=
PantallaRecords
.
maxRecords
;
jugador
=
""
;
});
}
@override
void
dispose
()
{
textController
.
dispose
();
recordTextController
.
dispose
();
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
OrientationBuilder
(
builder:
(
context
,
orientation
)
{
...
...
@@ -623,7 +646,98 @@ class _PantallaJuegoState extends State<PantallaJuego>
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
;
if
(
victoria
&&
posicion
<
PantallaRecords
.
maxRecords
){
return
SizedBox
(
width:
fullWidth
,
height:
fullHeight
,
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
16.0
),
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
spaceAround
,
crossAxisAlignment:
CrossAxisAlignment
.
stretch
,
children:
[
Column
(
children:
[
Text
(
'¡Nuevo récord!'
,
textAlign:
TextAlign
.
center
,
style:
Theme
.
of
(
context
).
textTheme
.
headlineMedium
,
),
const
SizedBox
(
height:
16.0
),
Text
(
(
posicion
==
0
)?
'¡Esta es tu mejor puntuación!'
:
'Esta es tu
${posicion+1}
ª mejor puntuación'
,
textAlign:
TextAlign
.
center
,
style:
Theme
.
of
(
context
).
textTheme
.
titleLarge
,
),
],
),
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
16.0
),
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
stretch
,
children:
[
Text
(
'Introduce aquí tu nombre:'
,
style:
Theme
.
of
(
context
).
textTheme
.
bodyLarge
,
),
TextField
(
controller:
recordTextController
,
textAlign:
TextAlign
.
center
,
style:
Theme
.
of
(
context
).
textTheme
.
titleLarge
,
maxLength:
10
,
decoration:
InputDecoration
(
hintText:
'Tu nombre...'
,
border:
OutlineInputBorder
(),
errorBorder:
OutlineInputBorder
(
borderSide:
BorderSide
(
color:
Colors
.
red
,
width:
5.0
)
),
errorText:
(
jugador
.
isEmpty
)?
''
:
null
,
errorStyle:
TextStyle
(
fontSize:
0
)
),
)
],
),
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceAround
,
children:
[
Expanded
(
child:
TextButton
(
style:
TextButton
.
styleFrom
(
backgroundColor:
Colors
.
green
,
disabledBackgroundColor:
Colors
.
white12
,
foregroundColor:
Color
.
fromARGB
(
255
,
237
,
237
,
237
)
),
onPressed:
(
jugador
.
isNotEmpty
)?
()
{}
:
null
,
child:
Text
(
'Guardar récord'
,
textScaler:
TextScaler
.
linear
(
1.1
),
)
)
),
Expanded
(
child:
TextButton
(
onPressed:
()
{},
child:
Text
(
'Salir sin guardar'
,
textScaler:
TextScaler
.
linear
(
1.1
),
)
)
)
],
)
],
),
),
);
}
return
SizedBox
(
width:
fullWidth
,
height:
fullHeight
,
...
...
@@ -815,6 +929,10 @@ class _PantallaJuegoState extends State<PantallaJuego>
}
if
(
numeroEscogido
!
==
numeroAdivinar
){
victoria
=
true
;
// TODO: Calcular puntuación
puntuacion
=
2000
;
// TODO: Calcular posición en la tabla de récords
posicion
=
0
;
}
numeroEscogido
=
null
;
intentos
++;
...
...
@@ -857,4 +975,4 @@ enum OpcionesFinPartida {
return
null
;
}
}
}
}
\ No newline at end of file
lib/paginas/pantalla_records.dart
View file @
e7c7e494
...
...
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import
'package:peponator/modelo/modelo.dart'
;
class
PantallaRecords
extends
StatelessWidget
{
static
const
int
maxRecords
=
20
;
const
PantallaRecords
({
super
.
key
});
...
...
@@ -83,105 +84,114 @@ class PantallaRecords extends StatelessWidget {
final
records
=
_loadMockData
();
if
(
records
.
isNotEmpty
)
{
return
Expanded
(
child:
ListView
.
builder
(
shrinkWrap:
true
,
itemCount:
records
.
length
,
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
;
final
vistaRecords
=
ListView
.
builder
(
shrinkWrap:
true
,
itemCount:
records
.
length
,
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
if
(
index
==
1
){
c
=
Colors
.
grey
.
shade400
;
t
=
Colors
.
black
;
else
{
c
=
Colors
.
yellow
;
}
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
;
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
(
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
),
],
)
),
Flexible
(
child:
Text
(
records
[
index
].
puntuacion
.
toString
(),
textAlign:
TextAlign
.
end
,
style:
Theme
.
of
(
context
).
textTheme
.
headlineLarge
?.
copyWith
(
color:
t
,
),
)
)
],
),
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
,
),
)
)
],
),
),
)
;
},
)
)
,
);
},
);
if
(
orientation
==
Orientation
.
portrait
){
return
Expanded
(
child:
vistaRecords
);
}
else
{
return
vistaRecords
;
}
}
else
{
return
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
stretch
,
children:
[
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
,
)
),
),
],
final
message
=
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
,
)
);
if
(
orientation
==
Orientation
.
portrait
){
return
Expanded
(
child:
message
,
);
}
else
{
return
message
;
}
}
}
...
...
lib/peponator_app.dart
View file @
e7c7e494
...
...
@@ -17,7 +17,7 @@ class PeponatorApp extends StatelessWidget {
),
darkTheme:
ThemeData
.
dark
(),
themeMode:
ThemeMode
.
system
,
home:
Pantalla
Records
(
)
home:
Pantalla
Juego
(
fromHome:
true
)
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment