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
86fb3301
authored
Apr 04, 2025
by
Tecnicos
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Carpeta widget finalizado, siguiente objetivo evitar los desbordamientos
parent
af477fbf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
150 additions
and
65 deletions
lib/modelo/carpeta.dart
lib/modelo/lista_seleccionables.dart
lib/paginas/pagina_configuracion_carpeta.dart
lib/widgets/carpeta_widget.dart
lib/modelo/carpeta.dart
View file @
86fb3301
import
'dart:io'
;
import
'package:flutter/material.dart'
;
import
'package:uuid/uuid.dart'
;
import
'archivo.dart'
;
import
'convertible.dart'
;
import
'elemento_seleccionable.dart'
;
...
...
@@ -7,13 +8,14 @@ import 'formato.dart';
class
Carpeta
extends
ElementoSeleccionable
{
final
Directory
_directory
;
final
bool
_incluirSubcarpetas
=
false
;
bool
_incluirSubcarpetas
=
false
;
bool
_open
=
false
;
late
final
List
<
InfoFormato
>
_formatos
;
Directory
get
directory
=>
_directory
;
List
<
InfoFormato
>
get
formatos
=>
List
.
unmodifiable
(
_formatos
);
bool
get
isOpen
=>
_open
;
bool
get
incluyeSubcarpetas
=>
_incluirSubcarpetas
;
Carpeta
({
required
super
.
id
,
required
Directory
directory
,
required
Map
<
Formato
,
bool
>
formatos
}):
_directory
=
directory
,
...
...
@@ -54,6 +56,14 @@ class Carpeta extends ElementoSeleccionable{
_open
=
!
_open
;
}
void
pressIncluirSubcarpetas
(){
_incluirSubcarpetas
=
!
_incluirSubcarpetas
;
}
void
pressAltSeleccionado
(
int
index
){
_formatos
[
index
].
seleccionado
=
!
_formatos
[
index
].
seleccionado
;
}
@override
void
convertir
()
{
// TODO: <implement>
...
...
@@ -62,24 +72,22 @@ class Carpeta extends ElementoSeleccionable{
class
InfoFormato
{
final
bool
_subcarpeta
;
bool
_
seleccionado
;
bool
seleccionado
;
final
Convertible
_conversion
;
bool
get
subcarpeta
=>
_subcarpeta
;
bool
get
seleccionado
=>
_seleccionado
;
Convertible
get
conversion
=>
_conversion
;
Formato
get
formatoOriginal
=>
_conversion
.
formatoOriginal
;
Formato
?
get
formatoDestino
=>
_conversion
.
formatoDestino
;
set
seleccionado
(
bool
value
)
=>
_seleccionado
=
value
;
set
formatoDestino
(
Formato
?
destino
)
=>
_conversion
.
formatoDestino
=
destino
;
InfoFormato
({
required
Formato
formato
,
required
String
nombreCarpeta
,
required
bool
subCarpeta
,
bool
?
seleccionado
}):
_subcarpeta
=
subCarpeta
,
_
seleccionado
=
seleccionado
??
!
subCarpeta
,
_conversion
=
Convertible
(
id:
"null"
,
nombre:
'
$nombreCarpeta
>
${formato.name}
'
,
_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
(){
...
...
lib/modelo/lista_seleccionables.dart
View file @
86fb3301
...
...
@@ -21,7 +21,7 @@ class ListaSeleccionables extends ChangeNotifier {
}
void
addArchivo
(
File
file
)
{
_seleccionables
.
add
(
Archivo
(
id:
"Archivo"
,
_seleccionables
.
add
(
Archivo
(
id:
const
Uuid
().
v1
()
,
file:
file
));
notifyListeners
();
}
...
...
lib/paginas/pagina_configuracion_carpeta.dart
View file @
86fb3301
...
...
@@ -32,7 +32,7 @@ class _PaginaConfiguracionCarpetaState extends State<PaginaConfiguracionCarpeta>
@override
void
initState
()
{
super
.
initState
();
_incluirSubcarpetas
=
false
;
_incluirSubcarpetas
=
widget
.
_carpeta
.
incluyeSubcarpetas
;
for
(
TipoMultimedia
t
in
TipoMultimedia
.
values
){
_formatos
[
t
]
=
[];
...
...
@@ -94,6 +94,7 @@ class _PaginaConfiguracionCarpetaState extends State<PaginaConfiguracionCarpeta>
onChanged:
(
bool
?
value
)
{
setState
(()
{
_incluirSubcarpetas
=
value
!;
widget
.
_carpeta
.
pressIncluirSubcarpetas
();
widget
.
_lista
.
actualizaSeleccionable
(
widget
.
_indice
,
widget
.
_carpeta
);
});
})
...
...
@@ -148,8 +149,10 @@ class _PaginaConfiguracionCarpetaState extends State<PaginaConfiguracionCarpeta>
for
(
InfoFormato
i
in
widget
.
_formatosCarpeta
){
if
(
_formatos
[
t
]!.
contains
(
i
.
formatoOriginal
)
&&
!(!
_incluirSubcarpetas
&&
i
.
subcarpeta
)){
_seleccionados
[
i
.
formatoOriginal
]
=
_allOfType
[
t
]!;
widget
.
_carpeta
.
pressAltSeleccionado
(
widget
.
_carpeta
.
formatos
.
indexOf
(
i
));
}
}
widget
.
_lista
.
actualizaSeleccionable
(
widget
.
_indice
,
widget
.
_carpeta
);
});
})
],
...
...
@@ -198,6 +201,8 @@ class _PaginaConfiguracionCarpetaState extends State<PaginaConfiguracionCarpeta>
_seleccionados
[
i
.
formatoOriginal
]
=
value
!;
_allOfType
[
i
.
formatoOriginal
.
tipoMultimedia
]
=
_actualizarCheckboxTipo
(
i
.
formatoOriginal
.
tipoMultimedia
);
widget
.
_carpeta
.
pressAltSeleccionado
(
widget
.
_carpeta
.
formatos
.
indexOf
(
i
));
widget
.
_lista
.
actualizaSeleccionable
(
widget
.
_indice
,
widget
.
_carpeta
);
});
}),
IconButton
(
...
...
lib/widgets/carpeta_widget.dart
View file @
86fb3301
...
...
@@ -16,11 +16,12 @@ class CarpetaWidget extends StatefulWidget {
class
_CarpetaWidgetState
extends
State
<
CarpetaWidget
>
with
SingleTickerProviderStateMixin
{
static
double
MAX_HEIGHT
=
50
;
late
final
AnimationController
_controller
;
late
final
numChild
=
widget
.
carpeta
.
formatos
.
length
;
List
<
InfoFormato
>
seleccionados
=
[]
;
bool
open
=
false
;
double
rotAngle
=
0
;
double
height
=
2
0
;
double
height
=
0
;
@override
void
initState
()
{
...
...
@@ -31,7 +32,7 @@ class _CarpetaWidgetState extends State<CarpetaWidget>
_controller
.
addListener
(()
{
setState
(()
{
rotAngle
=
pi
*
_controller
.
value
;
height
=
40
*
_controller
.
value
;
height
=
MAX_HEIGHT
*
_controller
.
value
;
});
});
super
.
initState
();
...
...
@@ -39,8 +40,17 @@ class _CarpetaWidgetState extends State<CarpetaWidget>
@override
Widget
build
(
BuildContext
context
)
{
seleccionados
=
[];
for
(
var
i
in
widget
.
carpeta
.
formatos
){
if
(
i
.
seleccionado
&&
(
widget
.
carpeta
.
incluyeSubcarpetas
||
!
i
.
subcarpeta
)){
seleccionados
.
add
(
i
);
}
}
if
(
seleccionados
.
length
<=
0
){
_controller
.
reset
();
}
return
SizedBox
(
height:
60
+
(
numChild
*
height
),
height:
(
height
<=
0
)?
60
:
60
+
(
seleccionados
.
length
*(
height
+
10
)
),
width:
MediaQuery
.
of
(
context
).
size
.
width
,
child:
Stack
(
children:
[
...
...
@@ -55,6 +65,9 @@ class _CarpetaWidgetState extends State<CarpetaWidget>
}
Widget
buildMainContainer
(){
String
s
=
""
;
if
(
seleccionados
.
length
>
1
)
s
=
"s"
;
return
SizedBox
(
height:
60
,
width:
MediaQuery
.
of
(
context
).
size
.
width
-
10
,
...
...
@@ -74,14 +87,25 @@ class _CarpetaWidgetState extends State<CarpetaWidget>
fontWeight:
FontWeight
.
bold
)
),
Text
(
(
seleccionados
.
length
>
0
)?
'
${seleccionados.length}
formato
$s
seleccionado
$s
'
:
'Ningún formato seleccionado'
,
style:
Theme
.
of
(
context
).
textTheme
.
bodyLarge
?.
copyWith
(
color:
(
seleccionados
.
length
>
0
)?
null
:
Colors
.
red
)
),
],
)
),
Transform
.
rotate
(
angle:
rotAngle
,
child:
IconButton
(
icon:
Icon
(
Icons
.
arrow_drop_down
),
onPressed:
()
{
icon:
Icon
(
Icons
.
arrow_drop_down
,
color:
(
seleccionados
.
length
>
0
)?
null
:
Theme
.
of
(
context
).
disabledColor
,
),
onPressed:
(
seleccionados
.
length
<=
0
)?
null
:
()
{
setState
(()
{
open
=
!
open
;
});
...
...
@@ -110,62 +134,110 @@ class _CarpetaWidgetState extends State<CarpetaWidget>
}
List
<
Widget
>
buildSecondaryContainers
(){
return
widget
.
carpeta
.
formatos
.
map
((
elemento
)
{
int
index
=
0
;
return
seleccionados
.
map
((
elemento
)
{
index
++;
String
texto
=
elemento
.
formatoOriginal
.
name
.
toUpperCase
();
if
(
elemento
.
formatoDestino
!=
null
)
texto
+=
" >
${elemento.formatoDestino!.name.toUpperCase()}
"
;
return
ClipRect
(
clipper:
_MyRectClipper
(
_controller
),
child:
SizedBox
(
height:
40
,
width:
MediaQuery
.
of
(
context
).
size
.
width
-
10
,
child:
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
24.0
),
child:
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
<
Widget
>[
Icon
(
Icons
.
find_in_page_outlined
),
const
SizedBox
(
width:
10
),
Expanded
(
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
Text
(
widget
.
carpeta
.
nombre
,
style:
Theme
.
of
(
context
).
textTheme
.
bodyLarge
?.
copyWith
(
fontWeight:
FontWeight
.
bold
)
),
Text
(
texto
,
style:
Theme
.
of
(
context
).
textTheme
.
bodyLarge
?.
copyWith
(
fontWeight:
FontWeight
.
bold
)
),
],
)
),
IconButton
(
icon:
const
Icon
(
Icons
.
edit
),
onPressed:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
{
return
PaginaConfiguracion
(
indice:
widget
.
indice
,
elemento:
elemento
.
conversion
,
lista:
widget
.
lista
,
carpeta:
widget
.
carpeta
);
}
));
},
return
Positioned
(
top:
(
height
+
10
)*
index
,
child:
ClipRect
(
clipper:
_MyRectClipper
(
_controller
),
child:
Dismissible
(
key:
Key
(
elemento
.
conversion
.
id
),
background:
Container
(
color:
Colors
.
red
,
alignment:
Alignment
.
centerLeft
,
child:
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
4.0
),
child:
Icon
(
Icons
.
check_box_outline_blank
,
color:
Colors
.
white
,
size:
31.0
),
),
),
secondaryBackground:
Container
(
color:
Colors
.
red
,
alignment:
Alignment
.
centerRight
,
child:
Padding
(
padding:
const
EdgeInsets
.
only
(
right:
14.0
),
child:
Icon
(
Icons
.
check_box_outline_blank
,
color:
Colors
.
white
,
size:
31.0
),
),
),
onDismissed:
(
direction
)
{
seleccionados
.
remove
(
elemento
);
widget
.
carpeta
.
pressAltSeleccionado
(
widget
.
carpeta
.
formatos
.
indexOf
(
elemento
));
widget
.
lista
.
actualizaSeleccionable
(
widget
.
indice
,
widget
.
carpeta
);
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
'
${elemento.formatoOriginal.name.toUpperCase()}
excluido de
${widget.carpeta}
'
),
action:
SnackBarAction
(
label:
'Deshacer'
,
onPressed:
()
{
seleccionados
.
add
(
elemento
);
widget
.
carpeta
.
pressAltSeleccionado
(
widget
.
carpeta
.
formatos
.
indexOf
(
elemento
));
widget
.
lista
.
actualizaSeleccionable
(
widget
.
indice
,
widget
.
carpeta
);
}
),
)
]
);
},
child:
SizedBox
(
height:
50
,
width:
MediaQuery
.
of
(
context
).
size
.
width
-
10
,
child:
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
24.0
),
child:
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
<
Widget
>[
Icon
(
Icons
.
find_in_page_outlined
),
const
SizedBox
(
width:
10
),
Expanded
(
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
Text
(
widget
.
carpeta
.
nombre
,
style:
Theme
.
of
(
context
).
textTheme
.
bodyLarge
?.
copyWith
(
fontWeight:
FontWeight
.
bold
)
),
Text
(
texto
,
style:
Theme
.
of
(
context
).
textTheme
.
bodyLarge
?.
copyWith
(
fontWeight:
FontWeight
.
bold
)
),
],
)
),
IconButton
(
icon:
const
Icon
(
Icons
.
edit
),
onPressed:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
{
return
PaginaConfiguracion
(
indice:
widget
.
indice
,
elemento:
elemento
.
conversion
,
lista:
widget
.
lista
,
carpeta:
widget
.
carpeta
);
}
));
},
)
]
),
),
),
),
),
);
;
);
}).
toList
();
}
}
...
...
@@ -177,8 +249,8 @@ class _MyRectClipper extends CustomClipper<Rect> {
@override
Rect
getClip
(
Size
size
)
{
double
value
=
(
1
-
_controller
.
value
)*
40
;
return
Rect
.
fromLTWH
(
0
,
value
,
1000
,
40
);
double
value
=
(
1
-
_controller
.
value
)*
_CarpetaWidgetState
.
MAX_HEIGHT
;
return
Rect
.
fromLTWH
(
0
,
value
,
1000
,
_CarpetaWidgetState
.
MAX_HEIGHT
);
}
@override
...
...
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