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
6c25f5e9
authored
Apr 25, 2025
by
Diego Pérez Peña
Committed by
Tecnicos
Apr 25, 2025
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Agregada orientación para la pantalla final y la de récords
parent
508e88e1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
267 additions
and
204 deletions
lib/paginas/pantalla_juego.dart
lib/paginas/pantalla_records.dart
lib/paginas/pantalla_juego.dart
View file @
6c25f5e9
...
@@ -619,8 +619,10 @@ class _PantallaJuegoState extends State<PantallaJuego>
...
@@ -619,8 +619,10 @@ class _PantallaJuegoState extends State<PantallaJuego>
// TODO: Agregar una pantalla de registro de récords
// TODO: Agregar una pantalla de registro de récords
Widget
_buildPantallaFinal
(
Orientation
orientation
){
Widget
_buildPantallaFinal
(
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
;
return
SizedBox
(
return
SizedBox
(
width:
fullWidth
,
width:
fullWidth
,
...
...
lib/paginas/pantalla_records.dart
View file @
6c25f5e9
...
@@ -8,7 +8,267 @@ class PantallaRecords extends StatelessWidget {
...
@@ -8,7 +8,267 @@ class PantallaRecords extends StatelessWidget {
@override
@override
Widget
build
(
BuildContext
context
)
{
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)
// TODO: Cargar los récords (esto se haría con un archivo de texto en la carpeta privada de la aplicación)
return
OrientationBuilder
(
builder:
(
context
,
orientation
)
{
return
Scaffold
(
body:
SafeArea
(
child:
LayoutBuilder
(
builder:
(
context
,
constraints
)
{
if
(
orientation
==
Orientation
.
portrait
){
return
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
stretch
,
children:
[
_buildTitle
(
context
,
orientation
),
_buildRecordsView
(
context
,
orientation
)
],
);
}
else
{
return
Row
(
children:
[
SizedBox
(
height:
constraints
.
maxHeight
,
width:
constraints
.
maxWidth
/
4
,
child:
_buildTitle
(
context
,
orientation
),
),
SizedBox
(
height:
constraints
.
maxHeight
,
width:
constraints
.
maxWidth
*
3
/
4
,
child:
_buildRecordsView
(
context
,
orientation
),
)
],
);
}
}
)
),
floatingActionButton:
_buildFAB
(
context
,
orientation
),
);
});
}
Widget
_buildTitle
(
BuildContext
context
,
Orientation
orientation
){
return
Container
(
color:
Theme
.
of
(
context
).
colorScheme
.
primary
,
child:
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
16.0
,
horizontal:
8.0
),
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
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
),
),
],
),
)
);
}
Widget
_buildRecordsView
(
BuildContext
context
,
Orientation
orientation
){
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
;
}
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
,
),
)
)
],
),
),
),
);
},
)
);
}
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
,
)
),
),
],
);
}
}
Widget
_buildFAB
(
BuildContext
context
,
Orientation
orientation
){
return
Align
(
alignment:
(
orientation
==
Orientation
.
portrait
)?
Alignment
.
bottomCenter
:
Alignment
.
bottomRight
,
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
(
(
orientation
==
Orientation
.
portrait
)?
'Esta acción no se puede deshacer. ¿Seguro que quieres borrar todos los récords?'
:
'Esta acción no se puede deshacer.
\n
¿Seguro que quieres borrar todos los récords?'
,
textAlign:
TextAlign
.
center
,
style:
Theme
.
of
(
context
).
textTheme
.
titleMedium
,
),
actionsAlignment:
MainAxisAlignment
.
spaceAround
,
actions:
[
TextButton
(
onPressed:
()
{
// TODO: Borrar récords
Navigator
.
pop
(
context
);
},
style:
TextButton
.
styleFrom
(
side:
BorderSide
(
color:
Colors
.
grey
,
width:
2.0
)
),
child:
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
24.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:
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
24.0
),
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
),
),
),
),
);
}
List
<
PeponatorRecord
>
_loadMockData
()
{
final
records
=
<
PeponatorRecord
>[];
final
records
=
<
PeponatorRecord
>[];
records
.
add
(
PeponatorRecord
(
records
.
add
(
PeponatorRecord
(
jugador:
"AAA"
,
jugador:
"AAA"
,
puntuacion:
12211350
,
puntuacion:
12211350
,
...
@@ -50,206 +310,6 @@ class PantallaRecords extends StatelessWidget {
...
@@ -50,206 +310,6 @@ class PantallaRecords extends StatelessWidget {
fecha:
DateTime
.
now
()
fecha:
DateTime
.
now
()
));
));
return
Scaffold
(
return
records
;
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
),
),
),
),
),
);
}
}
}
}
\ No newline at end of file
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