Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Rafa Castillo Passols
/
Prototipo-Multimedia
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
3d96b3bf
authored
Apr 24, 2025
by
Rafa Castillo Passols
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Refactor ya terminado
parent
08a7cf84
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
99 deletions
lib/modelo/carpeta.dart
lib/paginas/pagina_configuracion_carpeta.dart
lib/paginas/pagina_conversion.dart
lib/widgets/carpeta_widget.dart
lib/modelo/carpeta.dart
View file @
3d96b3bf
...
...
@@ -35,8 +35,8 @@ class Carpeta extends ElementoSeleccionable {
*/
_formatos
.
add
(
InfoFormato
(
carpeta:
this
,
formato:
f
,
nombreCarpeta:
directory
.
path
.
split
(
'/'
).
last
,
subCarpeta:
false
)
);
...
...
@@ -90,39 +90,21 @@ class Carpeta extends ElementoSeleccionable {
}
/**
* Creo que es una clase que ha creado para poder manejar las entidades
* que pueden haber dentro de una carpeta (podría ser Seleccionable)
*/
class
InfoFormato
{
final
bool
_subcarpeta
;
bool
seleccionado
;
final
Convertible
_conversion
;
bool
get
subcarpeta
=>
_subcarpeta
;
Convertible
get
conversion
=>
_conversion
;
Formato
get
formatoOriginal
=>
_conversion
.
formatoOriginal
;
Formato
?
get
formatoDestino
=>
_conversion
.
formatoDestino
;
class
InfoFormato
extends
Convertible
{
final
Carpeta
_carpeta
;
bool
seleccionado
;
set
formatoDestino
(
Formato
?
destino
)
=>
_conversion
.
formatoDestino
=
destino
;
Carpeta
get
carpeta
=>
_carpeta
;
InfoFormato
({
required
Formato
formato
,
required
String
nombreCarpeta
,
required
bool
subCarpeta
,
InfoFormato
({
required
Formato
formato
,
required
Carpeta
carpeta
,
bool
?
seleccionado
}):
_subcarpeta
=
subCarpeta
,
seleccionado
=
seleccionado
??
!
subCarpeta
,
_conversion
=
Convertible
(
id:
const
Uuid
().
v1
(),
nombre:
'
$nombreCarpeta
>
${formato.name}
'
,
icon:
Icon
(
Icons
.
find_in_page_outlined
),
formatoOriginal:
formato
);
void
convertir
(){
if
(
_conversion
.
formatoDestino
!=
null
){
// TODO: <implement>
}
}
@override
bool
operator
==(
Object
other
)
{
if
(
other
is
InfoFormato
)
return
formatoOriginal
==
other
.
formatoOriginal
;
return
super
==
other
;
}
_carpeta
=
carpeta
,
seleccionado
=
seleccionado
??
false
,
super
(
id:
const
Uuid
().
v1
(),
nombre:
'
${carpeta.nombre}
>
${formato.name}
'
,
icon:
const
Icon
(
Icons
.
find_in_page_outlined
),
formatoOriginal:
formato
);
}
\ No newline at end of file
lib/paginas/pagina_configuracion_carpeta.dart
View file @
3d96b3bf
...
...
@@ -158,7 +158,6 @@ class _PaginaConfiguracionCarpetaState extends State<PaginaConfiguracionCarpeta>
]
)
),
/*
Checkbox
(
tristate:
true
,
value:
_allOfType
[
t
],
...
...
@@ -167,14 +166,15 @@ class _PaginaConfiguracionCarpetaState extends State<PaginaConfiguracionCarpeta>
_allOfType
[
t
]
=
value
??
((
_allOfType
[
t
]
==
null
)?
true
:
!(
_allOfType
[
t
]!));
for
(
InfoFormato
i
in
widget
.
_formatosCarpeta
){
if(_formatos[t]!.contains(i.formatoOriginal) && !(!_incluirSubcarpetas && i.subcarpeta)){
if
(
_formatos
[
t
]!.
contains
(
i
.
formatoOriginal
)
&&
!(!
_incluirSubcarpetas
&&
i
.
carpeta
.
incluyeSubcarpetas
)){
_seleccionados
[
i
.
formatoOriginal
]
=
_allOfType
[
t
]!;
widget
.
_carpeta
.
pressAltSeleccionado
(
widget
.
_carpeta
.
formatos
.
indexOf
(
i
));
}
}
widget
.
_lista
.
actualizaSeleccionable
(
widget
.
_indice
,
widget
.
_carpeta
);
});
})
*/
})
],
));
}
...
...
@@ -213,11 +213,10 @@ class _PaginaConfiguracionCarpetaState extends State<PaginaConfiguracionCarpeta>
),
Wrap
(
children:
[
/*
Material
(
child:
Checkbox
(
value:
_seleccionados
[
i
.
formatoOriginal
]!,
onChanged: (i.
subcarpeta
&& !_incluirSubcarpetas)? null :
onChanged:
(
i
.
carpeta
.
incluyeSubcarpetas
&&
!
_incluirSubcarpetas
)?
null
:
(
bool
?
value
)
{
setState
(()
{
_seleccionados
[
i
.
formatoOriginal
]
=
value
!;
...
...
@@ -227,17 +226,20 @@ class _PaginaConfiguracionCarpetaState extends State<PaginaConfiguracionCarpeta>
widget
.
_lista
.
actualizaSeleccionable
(
widget
.
_indice
,
widget
.
_carpeta
);
});
}),
),
*/
),
IconButton
(
icon:
const
Icon
(
Icons
.
edit
),
onPressed:
((
i
.
subcarpeta
&&
!
_incluirSubcarpetas
)
||
!
_seleccionados
[
i
.
formatoOriginal
]!)?
null
:
onPressed:
((
i
.
carpeta
.
incluyeSubcarpetas
&&
!
_incluirSubcarpetas
)
||
!
_seleccionados
[
i
.
formatoOriginal
]!)
?
null
:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
{
return
PaginaConfiguracion
(
indice:
widget
.
_indice
,
elemento:
i
.
conversion
,
lista:
widget
.
_lista
,
return
PaginaConversion
.
carpeta
(
formatoOriginal:
i
.
formatoOriginal
,
indiceArchivo:
widget
.
_indice
,
carpeta:
widget
.
_carpeta
,
infoFormato:
i
,
lista:
widget
.
_lista
);
}
));
...
...
@@ -248,7 +250,7 @@ class _PaginaConfiguracionCarpetaState extends State<PaginaConfiguracionCarpeta>
],
);
if
(
i
.
subcarpeta
)
{
if
(
i
.
carpeta
.
incluyeSubcarpetas
)
{
listaSubcarpeta
.
add
(
fila
);
}
else
{
listaCarpeta
.
add
(
fila
);
...
...
lib/paginas/pagina_conversion.dart
View file @
3d96b3bf
...
...
@@ -62,32 +62,36 @@ class _PaginaConversionState extends State<PaginaConversion>
@override
Widget
build
(
BuildContext
context
)
{
return
Column
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
Padding
(
padding:
const
EdgeInsets
.
all
(
15.0
),
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
children:
[
SizedBox
(
height:
8.0
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
_createFormatBox
(
true
),
const
SizedBox
(
width:
10.0
),
Icon
(
Icons
.
chevron_right
),
const
SizedBox
(
width:
10.0
),
_createFormatBox
(
false
)
],
),
SizedBox
(
height:
20.0
),
_createCalidadSelectionPanel
()
],
// TODO: HECHO PARA QUE NO PETE PERO HABRÁ QUE REVISAR.
// PONER UN SCAFOLD Y FACOTIRZAR
return
Material
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
Padding
(
padding:
const
EdgeInsets
.
all
(
15.0
),
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
children:
[
const
SizedBox
(
height:
8.0
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
_createFormatBox
(
true
),
const
SizedBox
(
width:
10.0
),
const
Icon
(
Icons
.
chevron_right
),
const
SizedBox
(
width:
10.0
),
_createFormatBox
(
false
)
],
),
const
SizedBox
(
height:
20.0
),
_createCalidadSelectionPanel
()
],
),
),
),
_createConversionSelectionPanel
()
]
,
_createConversionSelectionPanel
()
],
)
,
);
}
...
...
lib/widgets/carpeta_widget.dart
View file @
3d96b3bf
...
...
@@ -27,8 +27,7 @@ class _CarpetaWidgetState extends State<CarpetaWidget>
late
final
AnimationController
_controller
;
/// Archivos (o carpetas si es recursivo) que el usuario no ha eliminado
/// de la lista y que coinciden con los formatos elegidos
// TODO: REFECATORIZAR USANDO List<ElementoSeleccionable>
List
<
ElementoSeleccionable
>
seleccionados
=
[];
List
<
InfoFormato
>
seleccionados
=
[];
bool
open
=
false
;
double
rotAngle
=
0
;
double
height
=
0
;
...
...
@@ -51,25 +50,10 @@ class _CarpetaWidgetState extends State<CarpetaWidget>
@override
Widget
build
(
BuildContext
context
)
{
seleccionados
=
[];
/*
* TODO: POR AHORA COMO ESTOY REFACTORIZANDO NO VOY A FILTRAR POR FORMATO
* El objetivo es que se muestren solo los archivos de los formatos indicados
* en la pagina de configuración de la carpeta. Como estoy refactorizando
* el InfoFormato y este widget ahora utiliza los ElementoSeleccionable
* POR AHORA no voy a filtrar por formatos, PERO LO PONDRÉ CUANDO ACABE
*/
for
(
var
fse
in
widget
.
carpeta
.
elementos
)
{
/*
if(i.seleccionado && (widget.carpeta.incluyeSubcarpetas || !i.subcarpeta)){
for
(
var
i
in
widget
.
carpeta
.
formatos
)
{
if
(
i
.
seleccionado
&&
i
.
carpeta
.
incluyeSubcarpetas
){
seleccionados
.
add
(
i
);
}
*/
// Luego aplicar filtros de formatos aqui
if
(
fse
is
Directory
&&
widget
.
carpeta
.
incluyeSubcarpetas
)
{
seleccionados
.
add
(
Carpeta
(
id:
const
Uuid
().
v1
(),
directory:
fse
));
}
else
{
seleccionados
.
add
(
Archivo
(
id:
const
Uuid
().
v1
(),
file:
fse
as
File
));
}
}
if
(
seleccionados
.
isEmpty
){
_controller
.
reset
();
...
...
@@ -184,11 +168,9 @@ class _CarpetaWidgetState extends State<CarpetaWidget>
return
seleccionados
.
map
((
elemento
)
{
index
++;
String
?
formatoOrigenYDestino
;
if
(
elemento
is
Convertible
)
{
formatoOrigenYDestino
=
elemento
.
formatoOriginal
.
name
.
toUpperCase
();
if
(
elemento
.
formatoDestino
!=
null
)
{
formatoOrigenYDestino
+=
" >
${elemento.formatoDestino!.name.toUpperCase()}
"
;
}
formatoOrigenYDestino
=
elemento
.
formatoOriginal
.
name
.
toUpperCase
();
if
(
elemento
.
formatoDestino
!=
null
)
{
formatoOrigenYDestino
+=
" >
${elemento.formatoDestino!.name.toUpperCase()}
"
;
}
return
Positioned
(
...
...
@@ -230,7 +212,6 @@ class _CarpetaWidgetState extends State<CarpetaWidget>
'excluido de
${carpeta.nombre}
'
),
action:
SnackBarAction
(
// TODO: HABRÍA QUE ACTUALIZAR EL ESTADO ?
label:
'Deshacer'
,
onPressed:
()
{
seleccionados
.
insert
(
index
-
1
,
elemento
);
}
),
...
...
@@ -247,7 +228,7 @@ class _CarpetaWidgetState extends State<CarpetaWidget>
child:
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
<
Widget
>[
Flexible
(
flex:
1
,
child:
Icon
(
Icons
.
find_in_page_outlined
)),
const
Flexible
(
flex:
1
,
child:
Icon
(
Icons
.
find_in_page_outlined
)),
const
Flexible
(
flex:
1
,
child:
SizedBox
(
width:
10
)),
Flexible
(
flex:
13
,
...
...
@@ -286,10 +267,12 @@ class _CarpetaWidgetState extends State<CarpetaWidget>
onPressed:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
{
return
PaginaConfiguracion
(
indice:
widget
.
indice
,
elemento:
elemento
as
Convertible
,
lista:
widget
.
lista
,
return
PaginaConversion
.
carpeta
(
formatoOriginal:
elemento
.
formatoOriginal
,
indiceArchivo:
index
-
1
,
carpeta:
carpeta
,
infoFormato:
elemento
,
lista:
widget
.
lista
);
}
));
...
...
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