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
498b1565
authored
May 25, 2025
by
Diego Pérez Peña
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Terminada la implementación de los ajustes
parent
aa6c8045
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
156 additions
and
63 deletions
lib/modelo/provider_ajustes.dart
lib/paginas/pagina_principal.dart
lib/widgets/action_button.dart
lib/widgets/convertex_fab_bar.dart
lib/modelo/provider_ajustes.dart
View file @
498b1565
...
...
@@ -18,7 +18,7 @@ class ProviderAjustes extends ChangeNotifier {
String
get
carpetaSalida
=>
_carpetaSalida
;
bool
get
cargando
=>
_cargando
;
bool
get
expand
=>
_cargando
||
_modoConversion
!
=
0
;
bool
get
expand
Convert
=>
_cargando
||
_modoConversion
=
=
0
;
ProviderAjustes
()
{
_cargarValoresAnteriores
();
...
...
lib/paginas/pagina_principal.dart
View file @
498b1565
...
...
@@ -16,13 +16,7 @@ class PaginaPrincipal extends StatelessWidget {
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
'¡Conversión de archivos completada!'
),
action:
SnackBarAction
(
label:
'VER'
,
onPressed:
()
async
{
await
OpenFile
.
open
(
'/storage/emulated/0/Pictures/Screenshots'
);
},
),
)
));
};
...
...
lib/widgets/action_button.dart
View file @
498b1565
...
...
@@ -109,36 +109,45 @@ class ActionButton extends StatelessWidget {
void
copiarAction
()
async
{
if
(
await
_comprobacionesPreviasConversion
(
context
)){
actualizadorProgreso
();
// Averiguamos donde colocar los archivos de salida
String
?
directorioSalida
;
while
(
directorioSalida
==
null
)
{
if
(
providerAjustes
.
carpetaSalida
.
isNotEmpty
){
directorioSalida
=
providerAjustes
.
carpetaSalida
;
}
else
{
directorioSalida
=
await
FilePicker
.
platform
.
getDirectoryPath
();
if
(
directorioSalida
!=
null
){
providerAjustes
.
setCarpetaSalidaTemporal
(
directorioSalida
);
}
}
// Convertimos los archivos como tal
List
<
Archivo
>
archivos
=
manager
.
seleccionables
.
whereType
<
Archivo
>().
toList
();
for
(
var
archivo
in
archivos
)
{
Conversor
.
convertir
(
archivo
,
directorioSalida
);
}
if
(
directorioSalida
!=
null
){
actualizadorProgreso
();
// Convertimos las carpetas
List
<
Carpeta
>
carpetas
=
manager
.
seleccionables
.
whereType
<
Carpeta
>().
toList
();
for
(
var
carpeta
in
carpetas
)
{
for
(
var
archivo
in
carpeta
.
elementosSeleccionados
)
{
Directory
d
=
await
Directory
(
"
$directorioSalida
/
${carpeta.nombre}
"
).
create
();
Conversor
.
convertir
(
archivo
,
d
.
path
);
// Convertimos los archivos como tal
List
<
Archivo
>
archivos
=
manager
.
seleccionables
.
whereType
<
Archivo
>().
toList
();
while
(
manager
.
seleccionables
.
isNotEmpty
){
ElementoSeleccionable
sel
=
manager
.
seleccionables
.
first
;
if
(
sel
is
Carpeta
){
for
(
var
archivo
in
sel
.
elementosSeleccionados
)
{
Directory
d
=
await
Directory
(
"
$directorioSalida
/
${sel.nombre}
"
).
create
();
Conversor
.
convertir
(
archivo
,
d
.
path
);
}
}
else
if
(
sel
is
Archivo
){
Conversor
.
convertir
(
sel
,
directorioSalida
);
}
manager
.
borraSeleccionable
(
0
);
}
}
manager
.
finalizarConversion
();
}
}
void
comprimirAction
()
async
{
if
(
await
_comprobacionesPreviasConversion
(
context
)){
actualizadorProgreso
();
//
actualizadorProgreso();
// TODO: Código de compresión
}
...
...
@@ -188,7 +197,7 @@ class ActionButton extends StatelessWidget {
static
Future
<
bool
>
comprobacionPermisoArchivos
(
BuildContext
context
)
async
{
final
granted
=
await
Permission
.
manageExternalStorage
.
isGranted
;
if
(!
granted
){
if
(!
granted
)
{
final
permanently
=
await
Permission
.
manageExternalStorage
.
isPermanentlyDenied
;
if
(
permanently
)
{
_mostrarNotificacion
(
context
,
'El acceso al almacenamiento del dispositivo ha sido denegado permanentemente.
\n
'
...
...
@@ -258,7 +267,6 @@ enum ActionButtonTypes {
case
ActionButtonTypes
.
comprimir
:
case
ActionButtonTypes
.
reemplazar
:
return
true
;
default
:
return
false
;
}
...
...
lib/widgets/convertex_fab_bar.dart
View file @
498b1565
import
'dart:io'
;
import
'package:file_picker/file_picker.dart'
;
import
'package:flutter/material.dart'
;
import
'package:provider/provider.dart'
;
import
'package:prueba_multimedia/modelo/modelo.dart'
;
...
...
@@ -39,11 +42,6 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> {
];
@override
void
initState
()
{
super
.
initState
();
}
@override
Widget
build
(
BuildContext
context
)
{
final
manager
=
Provider
.
of
<
ListaSeleccionables
>(
context
,
listen:
false
);
...
...
@@ -59,7 +57,9 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> {
_convertirOpen
=
false
;
});
_agregarKey
.
currentState
?.
close
();
_convertirKey
.
currentState
?.
close
();
if
(
widget
.
providerAjustes
.
expandConvert
){
_convertirKey
.
currentState
?.
close
();
}
},
),
Align
(
...
...
@@ -83,7 +83,7 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> {
tipoBoton:
type
,
manager:
manager
,
context:
context
,
disabled:
!
widget
.
allowConversion
&&
type
.
isConvertir
(),
disabled:
!
(
widget
.
allowConversion
)
&&
type
.
isConvertir
(),
onSuccess:
widget
.
onConvertSuccess
,
providerAjustes:
widget
.
providerAjustes
,
);
...
...
@@ -94,34 +94,61 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> {
final
toRet
=
<
Widget
>[];
// FAB con las opciones para convertir
toRet
.
add
(
Stack
(
alignment:
Alignment
.
bottomLeft
,
children:
[
ExpandableFab
(
invert:
true
,
distance:
60
,
icon:
Icon
(
Icons
.
label_important_outline
),
label:
'Convertir'
,
key:
_convertirKey
,
children:
_loadConvertirActionButtons
(
context
,
manager
)
),
SizedBox
(
width:
130
,
height:
56
,
child:
GestureDetector
(
onTap:
()
{
setState
(()
{
_agregarOpen
=
false
;
_convertirOpen
=
!
_convertirOpen
;
});
_agregarKey
.
currentState
?.
close
();
_convertirKey
.
currentState
?.
tap
();
},
if
(
widget
.
providerAjustes
.
expandConvert
)
{
toRet
.
add
(
Stack
(
alignment:
Alignment
.
bottomLeft
,
children:
[
ExpandableFab
(
invert:
true
,
distance:
60
,
icon:
Icon
(
Icons
.
label_important_outline
),
label:
'Convertir'
,
key:
_convertirKey
,
children:
_loadConvertirActionButtons
(
context
,
manager
)
),
)
],
));
SizedBox
(
width:
130
,
height:
56
,
child:
GestureDetector
(
onTap:
()
{
setState
(()
{
_agregarOpen
=
false
;
_convertirOpen
=
!
_convertirOpen
;
});
_agregarKey
.
currentState
?.
close
();
if
(
widget
.
providerAjustes
.
expandConvert
){
_convertirKey
.
currentState
?.
tap
();
}
},
),
)
],
));
}
else
{
toRet
.
add
(
FloatingActionButton
.
extended
(
heroTag:
'btn1'
,
icon:
Icon
(
Icons
.
label_important_outline
),
label:
Text
(
'Convertir'
,
textScaler:
TextScaler
.
linear
(
1.2
)
),
foregroundColor:
(!
widget
.
allowConversion
)?
Colors
.
grey
.
shade800
:
null
,
backgroundColor:
(!
widget
.
allowConversion
)?
Colors
.
grey
.
shade200
:
null
,
disabledElevation:
0
,
onPressed:
(!
widget
.
allowConversion
)?
null
:
()
{
switch
(
widget
.
providerAjustes
.
modoConversion
){
case
1
:
convertirCopiar
(
manager
);
break
;
case
2
:
convertirComprimir
();
break
;
}
},
));
}
// FAB con las opciones para agregar archivos, carpetas, enlaces...
toRet
.
add
(
Stack
(
...
...
@@ -142,7 +169,9 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> {
_convertirOpen
=
false
;
_agregarOpen
=
!
_agregarOpen
;
});
_convertirKey
.
currentState
?.
close
();
if
(
widget
.
providerAjustes
.
expandConvert
){
_convertirKey
.
currentState
?.
close
();
}
_agregarKey
.
currentState
?.
tap
();
},
),
...
...
@@ -161,7 +190,9 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> {
_convertirOpen
=
false
;
_agregarOpen
=
false
;
});
_convertirKey
.
currentState
?.
close
();
if
(
widget
.
providerAjustes
.
expandConvert
){
_convertirKey
.
currentState
?.
close
();
}
_agregarKey
.
currentState
?.
close
();
};
...
...
@@ -176,4 +207,64 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> {
);
}).
toList
();
}
Future
<
void
>
convertirCopiar
(
ListaSeleccionables
manager
)
async
{
if
(
await
ActionButton
.
comprobacionPermisoArchivos
(
context
)){
String
?
directorioSalida
;
if
(
widget
.
providerAjustes
.
carpetaSalida
.
isNotEmpty
){
directorioSalida
=
widget
.
providerAjustes
.
carpetaSalida
;
}
else
{
directorioSalida
=
await
FilePicker
.
platform
.
getDirectoryPath
();
}
if
(
directorioSalida
!=
null
){
listenerActualizar
(
manager
);
// Convertimos los archivos como tal
List
<
Archivo
>
archivos
=
manager
.
seleccionables
.
whereType
<
Archivo
>().
toList
();
while
(
manager
.
seleccionables
.
isNotEmpty
){
ElementoSeleccionable
sel
=
manager
.
seleccionables
.
first
;
if
(
sel
is
Carpeta
){
for
(
var
archivo
in
sel
.
elementosSeleccionados
)
{
Directory
d
=
await
Directory
(
"
$directorioSalida
/
${sel.nombre}
"
).
create
();
Conversor
.
convertir
(
archivo
,
d
.
path
);
}
}
else
if
(
sel
is
Archivo
){
Conversor
.
convertir
(
sel
,
directorioSalida
);
}
manager
.
borraSeleccionable
(
0
);
}
}
}
}
Future
<
void
>
convertirComprimir
()
async
{
if
(
await
ActionButton
.
comprobacionPermisoArchivos
(
context
)){
print
(
'Hola'
);
}
}
Future
<
void
>
listenerActualizar
(
ListaSeleccionables
manager
)
async
{
manager
.
iniciarConversion
();
int
initialSize
=
manager
.
seleccionables
.
length
;
await
Future
.
delayed
(
Duration
(
milliseconds:
200
));
while
(
manager
.
seleccionables
.
isNotEmpty
){
manager
.
actualizarProgreso
(
initialSize
);
await
Future
.
delayed
(
Duration
(
milliseconds:
200
));
}
if
(
manager
.
progress
<
100
){
manager
.
actualizarProgreso
(
initialSize
);
await
Future
.
delayed
(
Duration
(
milliseconds:
200
));
}
manager
.
finalizarConversion
();
widget
.
onConvertSuccess
();
}
}
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