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
a12724e8
authored
May 14, 2025
by
Rafa Castillo Passols
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
La mano escogida también se guarda en preferencias
parent
2efccfc7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
11 deletions
lib/modelo/listaDificultad.dart
lib/paginas/pantalla_juego.dart
lib/modelo/listaDificultad.dart
View file @
a12724e8
...
...
@@ -57,6 +57,6 @@ class ListaDificultad extends ChangeNotifier {
notifyListeners
();
final
prefs
=
await
SharedPreferences
.
getInstance
();
prefs
.
setInt
(
"dificultad"
,
_indiceSeleccionado
);
await
prefs
.
setInt
(
"dificultad"
,
_indiceSeleccionado
);
}
}
\ No newline at end of file
lib/paginas/pantalla_juego.dart
View file @
a12724e8
...
...
@@ -14,6 +14,7 @@ import 'package:peponator/widgets/peponator_mensaje.dart';
import
'package:peponator/widgets/teclado_numerico.dart'
;
import
'package:peponator/widgets/tu_mensaje.dart'
;
import
'package:provider/provider.dart'
;
import
'package:shared_preferences/shared_preferences.dart'
;
// TODO: PantallaJuego debería introducirse en una vista PageStorage para almacenar el estado del scrollController
...
...
@@ -47,6 +48,7 @@ class _PantallaJuegoState extends State<PantallaJuego>
List
<
Widget
>
mensajes
=
[];
final
Future
<
SharedPreferences
>
prefs
=
SharedPreferences
.
getInstance
();
late
bool
manoDerecha
=
true
;
List
<
Pista
>
pistas
=
[];
...
...
@@ -71,6 +73,8 @@ class _PantallaJuegoState extends State<PantallaJuego>
super
.
initState
();
_loadRecords
();
prefs
.
then
((
p
)
=>
manoDerecha
=
p
.
getBool
(
"manoDerecha"
)
??
true
);
recordTextController
.
addListener
(()
=>
setState
(()
{
jugador
=
recordTextController
.
text
;
...
...
@@ -198,9 +202,8 @@ class _PantallaJuegoState extends State<PantallaJuego>
case
OpcionPausa
.
reanudar
:
break
;
case
OpcionPausa
.
cambioMano
:
setState
(()
{
manoDerecha
=
!
manoDerecha
;
});
setState
(()
{
manoDerecha
=
!
manoDerecha
;
});
_guardarPreferenciaMano
();
break
;
case
OpcionPausa
.
nuevaPartida
:
setState
(()
{
_nuevaPartida
();});
...
...
@@ -264,13 +267,15 @@ class _PantallaJuegoState extends State<PantallaJuego>
@override
Widget
build
(
BuildContext
context
)
{
return
Consumer
<
ListaDificultad
>(
builder:
(
context
,
manager
,
child
)
{
return
OrientationBuilder
(
builder:
(
context
,
orientation
)
{
return
Scaffold
(
backgroundColor:
(
mostrarPistas
)?
Theme
.
of
(
context
).
colorScheme
.
surfaceDim
:
null
,
body:
manager
.
listo
?
_buildPaginaJuego
(
context
,
orientation
)
:
CircularProgressIndicator
()
);
return
FutureBuilder
(
future:
prefs
,
builder:
(
context
,
snapshot
)
{
return
OrientationBuilder
(
builder:
(
context
,
orientation
)
{
return
Scaffold
(
backgroundColor:
(
mostrarPistas
)?
Theme
.
of
(
context
).
colorScheme
.
surfaceDim
:
null
,
body:
manager
.
listo
?
_buildPaginaJuego
(
context
,
orientation
)
:
CircularProgressIndicator
()
);
});
});
});
}
...
...
@@ -1058,6 +1063,12 @@ class _PantallaJuegoState extends State<PantallaJuego>
await
recordsFile
.
writeAsString
(
sb
.
toString
());
}
void
_guardarPreferenciaMano
()
async
{
final
prefs
=
await
SharedPreferences
.
getInstance
();
await
prefs
.
setBool
(
"manoDerecha"
,
manoDerecha
);
}
}
enum
OpcionesFinPartida
{
...
...
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