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
07ea6d37
authored
May 08, 2025
by
Diego Pérez Peña
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Agregada la función de cerrar botones del FAB tras agregar un archivo o carpeta
parent
94520476
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
88 additions
and
48 deletions
lib/modelo/archivo.dart
lib/modelo/convertible.dart
lib/modelo/lista_seleccionables.dart
lib/paginas/pagina_configuracion.dart
lib/widgets/action_button.dart
lib/widgets/convertex_fab_bar.dart
lib/modelo/archivo.dart
View file @
07ea6d37
...
@@ -4,20 +4,17 @@ import 'package:prueba_multimedia/modelo/conversor.dart';
...
@@ -4,20 +4,17 @@ import 'package:prueba_multimedia/modelo/conversor.dart';
import
'convertible.dart'
;
import
'convertible.dart'
;
import
'formato.dart'
;
import
'formato.dart'
;
// TODO: QUE PASA SI NO RECONOCEMOS EL FORMATO?
// TODO: MIRAR DE CREAR UN MIXIN TIPO ELEMENTOLOCAL O ALGO ASÍ (Archivo y Carpeta)
class
Archivo
extends
Convertible
{
class
Archivo
extends
Convertible
{
final
File
file
;
final
File
file
;
late
final
Future
<
List
<
Metadato
>>
metadatos
;
late
final
Future
<
List
<
Metadato
>>
metadatos
;
Archivo
({
required
super
.
id
,
required
this
.
file
}):
Archivo
({
required
super
.
id
,
required
this
.
file
}):
super
(
super
(
nombre:
file
.
path
.
split
(
'/'
).
last
,
nombre:
file
.
path
.
split
(
'/'
).
last
,
// TODO: POR AHORA USAMOS (!) PERO HAY QUE TENERLO EN CUENTA
formatoOriginal:
Formato
.
fromExtension
(
file
.
path
.
split
(
'.'
).
last
)!,
formatoOriginal:
Formato
.
fromExtension
(
file
.
path
.
split
(
'.'
).
last
)!,
icon:
Formato
.
fromExtension
(
file
.
path
.
split
(
'.'
).
last
)!.
tipoMultimedia
.
icono
icon:
Formato
.
fromExtension
(
file
.
path
.
split
(
'.'
).
last
)!.
tipoMultimedia
.
icono
)
)
{
{
metadatos
=
Conversor
.
getMetadatos
(
this
);
metadatos
=
Conversor
.
getMetadatos
(
this
);
}
}
}
}
\ No newline at end of file
lib/modelo/convertible.dart
View file @
07ea6d37
import
'elemento_seleccionable.dart'
;
import
'elemento_seleccionable.dart'
;
import
'formato.dart'
;
import
'formato.dart'
;
// TODO: QUE PASA SI NO RECONOCEMOS EL FORMATO?
class
Convertible
extends
ElementoSeleccionable
{
class
Convertible
extends
ElementoSeleccionable
{
final
Formato
_formatoOriginal
;
final
Formato
_formatoOriginal
;
Formato
?
formatoDestino
;
Formato
?
formatoDestino
;
...
...
lib/modelo/lista_seleccionables.dart
View file @
07ea6d37
...
@@ -4,6 +4,7 @@ import 'package:uuid/uuid.dart';
...
@@ -4,6 +4,7 @@ import 'package:uuid/uuid.dart';
import
'carpeta.dart'
;
import
'carpeta.dart'
;
import
'elemento_seleccionable.dart'
;
import
'elemento_seleccionable.dart'
;
import
'archivo.dart'
;
import
'archivo.dart'
;
import
'formato.dart'
;
class
ListaSeleccionables
extends
ChangeNotifier
{
class
ListaSeleccionables
extends
ChangeNotifier
{
final
_seleccionables
=
<
ElementoSeleccionable
>[];
final
_seleccionables
=
<
ElementoSeleccionable
>[];
...
@@ -19,18 +20,23 @@ class ListaSeleccionables extends ChangeNotifier {
...
@@ -19,18 +20,23 @@ class ListaSeleccionables extends ChangeNotifier {
notifyListeners
();
notifyListeners
();
}
}
void
addArchivo
(
File
file
)
{
bool
addArchivo
(
File
file
)
{
_seleccionables
.
add
(
Archivo
(
id:
const
Uuid
().
v1
(),
if
(
Formato
.
fromExtension
(
file
.
path
.
split
(
'.'
).
last
)
!=
null
){
file:
file
));
_seleccionables
.
add
(
Archivo
(
id:
const
Uuid
().
v1
(),
notifyListeners
();
file:
file
));
notifyListeners
();
return
true
;
}
return
false
;
}
}
void
addCarpeta
(
Directory
directory
){
bool
addCarpeta
(
Directory
directory
){
final
newCarpeta
=
Carpeta
(
final
newCarpeta
=
Carpeta
(
id:
const
Uuid
().
v1
(),
id:
const
Uuid
().
v1
(),
directory:
directory
directory:
directory
);
);
//if(newCarpeta.formatos.isNotEmpty){
if
(
newCarpeta
.
formatos
.
isNotEmpty
){
_seleccionables
.
add
(
_seleccionables
.
add
(
Carpeta
(
Carpeta
(
id:
const
Uuid
().
v1
(),
id:
const
Uuid
().
v1
(),
...
@@ -38,7 +44,10 @@ class ListaSeleccionables extends ChangeNotifier {
...
@@ -38,7 +44,10 @@ class ListaSeleccionables extends ChangeNotifier {
)
)
);
);
notifyListeners
();
notifyListeners
();
//}
return
true
;
}
return
false
;
}
}
void
reinsertar
(
int
index
,
ElementoSeleccionable
element
){
void
reinsertar
(
int
index
,
ElementoSeleccionable
element
){
...
...
lib/paginas/pagina_configuracion.dart
View file @
07ea6d37
...
@@ -25,31 +25,31 @@ class _PaginaConfiguracionState extends State<PaginaConfiguracion> {
...
@@ -25,31 +25,31 @@ class _PaginaConfiguracionState extends State<PaginaConfiguracion> {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
return
Scaffold
(
appBar:
AppBar
(
appBar:
AppBar
(
title:
RichText
(
title:
RichText
(
maxLines:
1
,
maxLines:
1
,
overflow:
TextOverflow
.
ellipsis
,
overflow:
TextOverflow
.
ellipsis
,
text:
TextSpan
(
text:
TextSpan
(
children:
[
children:
[
WidgetSpan
(
WidgetSpan
(
child:
widget
.
_elementoAsociado
.
icono
child:
widget
.
_elementoAsociado
.
icono
),
),
TextSpan
(
TextSpan
(
text:
"
${widget._elementoAsociado.nombre}
"
,
text:
"
${widget._elementoAsociado.nombre}
"
,
style:
Theme
.
of
(
context
).
textTheme
.
titleLarge
,
style:
Theme
.
of
(
context
).
textTheme
.
titleLarge
,
)
)
]
]
)
)
),
),
),
),
body:
_construirCuerpo
(),
body:
_construirCuerpo
(),
bottomNavigationBar:
widget
.
_elementoAsociado
is
Archivo
bottomNavigationBar:
widget
.
_elementoAsociado
is
Archivo
?
BottomNavigationBar
(
?
BottomNavigationBar
(
currentIndex:
_categoriaActiva
,
currentIndex:
_categoriaActiva
,
onTap:
(
int
indice
)
=>
setState
(()
{
_categoriaActiva
=
indice
;
}),
onTap:
(
int
indice
)
=>
setState
(()
{
_categoriaActiva
=
indice
;
}),
items:
_construirElementosBarraNavegacion
()
items:
_construirElementosBarraNavegacion
()
)
)
:
null
:
null
);
);
}
}
...
@@ -119,3 +119,4 @@ class _PaginaConfiguracionState extends State<PaginaConfiguracion> {
...
@@ -119,3 +119,4 @@ class _PaginaConfiguracionState extends State<PaginaConfiguracion> {
}
}
}
}
lib/widgets/action_button.dart
View file @
07ea6d37
...
@@ -8,8 +8,10 @@ class ActionButton extends StatelessWidget {
...
@@ -8,8 +8,10 @@ class ActionButton extends StatelessWidget {
final
ActionButtonTypes
tipoBoton
;
final
ActionButtonTypes
tipoBoton
;
final
ListaSeleccionables
manager
;
final
ListaSeleccionables
manager
;
final
BuildContext
context
;
final
BuildContext
context
;
final
VoidCallback
?
onSuccess
;
const
ActionButton
({
super
.
key
,
required
this
.
tipoBoton
,
const
ActionButton
({
super
.
key
,
required
this
.
tipoBoton
,
required
this
.
manager
,
required
this
.
context
});
required
this
.
manager
,
required
this
.
context
,
this
.
onSuccess
});
void
Function
()
getCallback
()
{
void
Function
()
getCallback
()
{
return
switch
(
tipoBoton
)
{
return
switch
(
tipoBoton
)
{
...
@@ -41,14 +43,23 @@ class ActionButton extends StatelessWidget {
...
@@ -41,14 +43,23 @@ class ActionButton extends StatelessWidget {
FilePickerResult
?
result
=
await
FilePicker
.
platform
.
pickFiles
();
FilePickerResult
?
result
=
await
FilePicker
.
platform
.
pickFiles
();
if
(
result
!=
null
)
{
if
(
result
!=
null
)
{
File
file
=
File
(
result
.
files
.
first
.
path
!);
File
file
=
File
(
result
.
files
.
first
.
path
!);
manager
.
addArchivo
(
file
);
final
res
=
manager
.
addArchivo
(
file
);
if
(
res
){
if
(
context
.
mounted
&&
onSuccess
!=
null
){
onSuccess
!();
}
}
else
{
if
(
context
.
mounted
)
{
_mostrarSnackBar
(
'El archivo seleccionado no es de un formato multimedia conocido'
);
}
}
}
// Mensaje indicando que se seleccione un archivo
}
// Mensaje indicando que se seleccione un archivo
else
{
else
{
// Comprobar que el widget no ha sido destruido por ser asíncrono
// Comprobar que el widget no ha sido destruido por ser asíncrono
if
(
context
.
mounted
)
{
if
(
context
.
mounted
)
{
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
_mostrarSnackBar
(
'No se ha seleccionado ningún archivo'
);
SnackBar
(
content:
Text
(
"Selecciona una archivo"
))
);
}
}
}
}
}
}
...
@@ -76,14 +87,22 @@ class ActionButton extends StatelessWidget {
...
@@ -76,14 +87,22 @@ class ActionButton extends StatelessWidget {
FilePicker
.
platform
.
getDirectoryPath
().
then
(
(
path
)
{
FilePicker
.
platform
.
getDirectoryPath
().
then
(
(
path
)
{
if
(
path
!=
null
)
{
if
(
path
!=
null
)
{
var
directory
=
Directory
(
path
);
var
directory
=
Directory
(
path
);
manager
.
addCarpeta
(
directory
);
final
res
=
manager
.
addCarpeta
(
directory
);
if
(
res
){
if
(
context
.
mounted
&&
onSuccess
!=
null
){
onSuccess
!();
}
}
else
{
if
(
context
.
mounted
)
{
_mostrarSnackBar
(
'La carpeta seleccionada no contiene archivos de formatos multimedia conoocidos'
);
}
}
}
// Mensaje indicando que se seleccione una carpeta
}
// Mensaje indicando que se seleccione una carpeta
else
{
else
{
// Comprobar que el widget no ha sido destruido por ser asíncrono
// Comprobar que el widget no ha sido destruido por ser asíncrono
if
(
context
.
mounted
)
{
if
(
context
.
mounted
)
{
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
_mostrarSnackBar
(
'No se ha seleccionado ninguna carpeta'
);
SnackBar
(
content:
Text
(
"Selecciona una carpeta"
))
);
}
}
}
}
});
});
...
@@ -143,6 +162,13 @@ class ActionButton extends StatelessWidget {
...
@@ -143,6 +162,13 @@ class ActionButton extends StatelessWidget {
);
);
}
}
void
_mostrarSnackBar
(
String
text
)
{
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
text
)
));
}
}
}
enum
ActionButtonTypes
{
enum
ActionButtonTypes
{
...
...
lib/widgets/convertex_fab_bar.dart
View file @
07ea6d37
...
@@ -139,8 +139,17 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> {
...
@@ -139,8 +139,17 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> {
List
<
Widget
>
_loadAgregarActionButtons
(
BuildContext
context
,
List
<
Widget
>
_loadAgregarActionButtons
(
BuildContext
context
,
ListaSeleccionables
manager
)
ListaSeleccionables
manager
)
{
{
final
VoidCallback
closeButtons
=
()
{
setState
(()
{
_convertirOpen
=
false
;
_agregarOpen
=
false
;
});
_convertirKey
.
currentState
?.
close
();
_agregarKey
.
currentState
?.
close
();
};
return
agregarButtonTypes
.
map
(
(
type
)
{
return
agregarButtonTypes
.
map
(
(
type
)
{
return
ActionButton
(
tipoBoton:
type
,
manager:
manager
,
context:
context
,);
return
ActionButton
(
tipoBoton:
type
,
manager:
manager
,
context:
context
,
onSuccess:
closeButtons
,
);
}).
toList
();
}).
toList
();
}
}
}
}
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