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
53752d51
authored
May 10, 2025
by
Rafa Castillo Passols
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Creado el dialogo para añadir dificultades
parent
8b76cee5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
37 deletions
lib/paginas/pantalla_dificultad.dart
lib/widgets/dificultad_dialog.dart
lib/paginas/pantalla_dificultad.dart
View file @
53752d51
...
...
@@ -30,19 +30,15 @@ class PantallaDificultad extends StatelessWidget {
body:
construirListaDificultad
(),
floatingActionButton:
FloatingActionButton
(
child:
const
Icon
(
Icons
.
add
),
onPressed:
()
{
Navigator
.
push
(
context
,
// TODO: MIRAR COMO MOSTRAR DIÁLOGO
MaterialPageRoute
(
builder:
(
context
)
{
return
DificultadDialog
(
crearDificultad:
(
dificultad
)
{
Navigator
.
pop
(
context
);},
editarDificultad:
(
_
)
{},
);
}
)
onPressed:
()
async
{
Dificultad
?
nuevo
=
await
showDialog
<
Dificultad
>(
context:
context
,
builder:
(
context
)
=>
DificultadDialog
()
);
if
(
nuevo
!=
null
&&
context
.
mounted
)
{
Provider
.
of
<
ListaDificultad
>(
context
,
listen:
false
).
add
(
nuevo
);
}
}
),
);
...
...
lib/widgets/dificultad_dialog.dart
View file @
53752d51
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:peponator/modelo/dificultad.dart'
;
class
DificultadDialog
extends
StatefulWidget
{
final
Dificultad
?
dificultad
;
final
Function
(
Dificultad
)
crearDificultad
;
final
Function
(
Dificultad
)
editarDificultad
;
final
bool
actualizando
;
const
DificultadDialog
({
super
.
key
,
this
.
dificultad
,
required
this
.
crearDificultad
,
required
this
.
editarDificultad
}):
actualizando
=
(
dificultad
!=
null
);
const
DificultadDialog
({
super
.
key
,
this
.
dificultad
});
@override
State
<
DificultadDialog
>
createState
()
=>
_DificultadDialogState
();
}
// TODO: HACER QUE 'HECHO' SE DESABILITE CUANDO CAMPOS VACIOS
// TODO: MEJORAR EL ASPECTO
// TODO: CAMBIAR PARA USAR IDIOMA
class
_DificultadDialogState
extends
State
<
DificultadDialog
>
{
@override
Widget
build
(
BuildContext
context
)
{
TextEditingController
limiteController
=
TextEditingController
(
text:
widget
.
dificultad
?.
limiteSuperior
.
toString
()
);
TextEditingController
intentosController
=
TextEditingController
(
text:
widget
.
dificultad
?.
intentos
.
toString
()
);
TextEditingController
nombreController
=
TextEditingController
(
text:
widget
.
dificultad
?.
nombre
.
toString
()
);
return
SimpleDialog
(
title:
Text
(
widget
.
actualizando
widget
.
dificultad
!=
null
?
"Editar dificultad"
:
"Añadir dificultad"
),
children:
[
TextField
(
),
TextField
(
),
TextField
(
SimpleDialogOption
(
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Text
(
"Limite superior"
),
TextField
(
controller:
limiteController
,
keyboardType:
TextInputType
.
number
,
inputFormatters:
[
FilteringTextInputFormatter
.
digitsOnly
],
),
const
SizedBox
(
height:
16
,),
Text
(
"Número de intentos"
),
TextField
(
controller:
intentosController
,
keyboardType:
TextInputType
.
number
,
inputFormatters:
[
FilteringTextInputFormatter
.
digitsOnly
],
),
const
SizedBox
(
height:
16
,),
Text
(
"Nombre"
),
TextField
(
controller:
nombreController
),
],
),
),
IconButton
(
onPressed:
widget
.
actualizando
?
widget
.
editarDificultad
(
widget
.
dificultad
!)
:
widget
.
crearDificultad
(
Dificultad
(
limiteInferior:
1
,
limiteSuperior:
69
,
intentos:
10
,
nombre:
"Test"
)
SimpleDialogOption
(
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
SimpleDialogOption
(
onPressed:
()
{
Navigator
.
pop
(
context
,
Dificultad
(
limiteInferior:
1
,
limiteSuperior:
int
.
parse
(
limiteController
.
text
),
intentos:
int
.
parse
(
intentosController
.
text
),
nombre:
nombreController
.
text
,
)
);
},
child:
Text
(
"Hecho"
),
),
icon:
const
Icon
(
Icons
.
check
),
SimpleDialogOption
(
onPressed:
()
=>
Navigator
.
pop
(
context
),
child:
Text
(
"Cancelar"
),
)
],
),
)
],
);
}
...
...
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