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
e0ac6390
authored
Mar 27, 2025
by
Tecnicos
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
En proceso de terminar con las acciones básicas de conversión
parent
c322e542
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
64 deletions
lib/modelo/conversor.dart
lib/widgets/action_button.dart
lib/widgets/convertex_fab_bar.dart
lib/modelo/conversor.dart
View file @
e0ac6390
import
'dart:io'
;
import
'package:ffmpeg_kit_flutter/ffmpeg_kit.dart'
;
import
'package:ffmpeg_kit_flutter/ffmpeg_kit.dart'
;
import
'package:ffmpeg_kit_flutter/ffmpeg_session.dart'
;
import
'package:ffmpeg_kit_flutter/ffmpeg_session.dart'
;
import
'package:ffmpeg_kit_flutter/return_code.dart'
;
import
'package:ffmpeg_kit_flutter/return_code.dart'
;
...
@@ -7,10 +9,9 @@ import 'package:prueba_multimedia/modelo/modelo.dart';
...
@@ -7,10 +9,9 @@ import 'package:prueba_multimedia/modelo/modelo.dart';
abstract
class
Conversor
{
abstract
class
Conversor
{
/// Se llama una vez el usuario pulsa convertir
/// Se llama una vez el usuario pulsa convertir
static
Future
<
ReturnCode
?>
convertir
(
Archivo
archivo
)
async
{
static
Future
<
ReturnCode
?>
convertir
(
Archivo
archivo
,
String
pathSalida
)
async
{
archivo
.
formatoDestino
=
Formato
.
jpg
;
String
path
=
archivo
.
file
.
path
;
String
path
=
archivo
.
file
.
path
;
String
nuevoPath
=
"
/storage/emulated/0/Documents/
${archivo.nombre}
.
${archivo.formatoDestino!.name}
"
;
String
nuevoPath
=
"
$pathSalida
${archivo.nombre}
.
${archivo.formatoDestino!.name}
"
;
String
comando
=
"-i
$path
$nuevoPath
"
;
String
comando
=
"-i
$path
$nuevoPath
"
;
FFmpegSession
session
=
await
FFmpegKit
.
execute
(
comando
);
FFmpegSession
session
=
await
FFmpegKit
.
execute
(
comando
);
...
...
lib/widgets/action_button.dart
View file @
e0ac6390
import
'dart:io'
;
import
'package:ffmpeg_kit_flutter/return_code.dart'
;
import
'package:file_picker/file_picker.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:prueba_multimedia/modelo/modelo.dart'
;
class
ActionButton
extends
StatelessWidget
{
class
ActionButton
extends
StatelessWidget
{
final
ActionButtonTypes
tipoBoton
;
final
ActionButtonTypes
tipoBoton
;
final
VoidCallback
?
onPressed
;
final
ListaSeleccionables
manager
;
const
ActionButton
({
super
.
key
,
required
this
.
tipoBoton
,
required
this
.
manager
});
void
Function
()
getCallback
()
{
const
ActionButton
({
super
.
key
,
required
this
.
tipoBoton
,
required
this
.
onPressed
});
return
switch
(
tipoBoton
)
{
ActionButtonTypes
.
archivo
=>
archivoAction
,
ActionButtonTypes
.
carpeta
=>
carpetaAction
,
ActionButtonTypes
.
enlace
=>
enlaceAction
,
ActionButtonTypes
.
copiar
=>
copiarAction
,
ActionButtonTypes
.
comprimir
=>
comprimirAction
,
ActionButtonTypes
.
reemplazar
=>
reemplazarAction
,
};
}
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Directionality
(
return
Directionality
(
textDirection:
TextDirection
.
rtl
,
textDirection:
TextDirection
.
rtl
,
child:
FilledButton
.
icon
(
child:
FilledButton
.
icon
(
onPressed:
onPressed
,
onPressed:
getCallback
()
,
label:
Text
(
tipoBoton
.
label
,
textScaler:
const
TextScaler
.
linear
(
1.2
)),
label:
Text
(
tipoBoton
.
label
,
textScaler:
const
TextScaler
.
linear
(
1.2
)),
icon:
tipoBoton
.
icon
,
icon:
tipoBoton
.
icon
,
),
),
);
);
}
}
}
void
archivoAction
()
async
{
FilePickerResult
?
result
=
await
FilePicker
.
platform
.
pickFiles
();
if
(
result
!=
null
)
{
File
file
=
File
(
result
.
files
.
first
.
path
!);
manager
.
addArchivo
(
file
);
}
// Mensaje indicando que se seleccione un archivo
else
{
//
}
}
void
carpetaAction
()
async
{
String
?
path
=
await
FilePicker
.
platform
.
getDirectoryPath
();
if
(
path
!=
null
)
{
var
directory
=
Directory
(
path
);
manager
.
addCarpeta
(
directory
);
}
// Mensaje indicando que se seleccione una carpeta
else
{
ScaffoldMessenger
.
of
().
showSnackBar
(
)
}
}
void
enlaceAction
()
{
}
void
copiarAction
()
async
{
// Averiguamos donde colocar los archivos de salida
String
?
directorioSalida
;
while
(
directorioSalida
==
null
)
{
directorioSalida
=
await
FilePicker
.
platform
.
getDirectoryPath
();
}
// Convertimos los archivos como tal
List
<
Archivo
>
archivos
=
manager
.
seleccionables
.
whereType
<
Archivo
>().
toList
();
for
(
var
archivo
in
archivos
)
{
Conversor
.
convertir
(
archivo
,
directorioSalida
);
}
}
void
comprimirAction
()
{
}
void
reemplazarAction
()
{
}
}
enum
ActionButtonTypes
{
enum
ActionButtonTypes
{
archivo
(
'Archivo'
,
Icon
(
Icons
.
description_outlined
)),
archivo
(
'Archivo'
,
Icon
(
Icons
.
description_outlined
)),
carpeta
(
'Carpeta'
,
Icon
(
Icons
.
folder_outlined
)),
carpeta
(
'Carpeta'
,
Icon
(
Icons
.
folder_outlined
)),
...
@@ -31,6 +95,6 @@ enum ActionButtonTypes {
...
@@ -31,6 +95,6 @@ enum ActionButtonTypes {
final
String
label
;
final
String
label
;
final
Icon
icon
;
final
Icon
icon
;
const
ActionButtonTypes
(
this
.
label
,
this
.
icon
);
const
ActionButtonTypes
(
this
.
label
,
this
.
icon
);
}
}
\ No newline at end of file
lib/widgets/convertex_fab_bar.dart
View file @
e0ac6390
...
@@ -19,6 +19,18 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> {
...
@@ -19,6 +19,18 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> {
final
_agregarKey
=
GlobalKey
<
ExpandableFabState
>();
final
_agregarKey
=
GlobalKey
<
ExpandableFabState
>();
final
_convertirKey
=
GlobalKey
<
ExpandableFabState
>();
final
_convertirKey
=
GlobalKey
<
ExpandableFabState
>();
static
const
agregarButtonTypes
=
<
ActionButtonTypes
>[
ActionButtonTypes
.
archivo
,
ActionButtonTypes
.
carpeta
,
ActionButtonTypes
.
enlace
];
static
const
convertirButtonTypes
=
<
ActionButtonTypes
>[
ActionButtonTypes
.
copiar
,
ActionButtonTypes
.
comprimir
,
ActionButtonTypes
.
reemplazar
];
@override
@override
void
initState
()
{
void
initState
()
{
super
.
initState
();
super
.
initState
();
...
@@ -59,28 +71,9 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> {
...
@@ -59,28 +71,9 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> {
List
<
Widget
>
_loadConvertirActionButtons
(
BuildContext
context
,
List
<
Widget
>
_loadConvertirActionButtons
(
BuildContext
context
,
ListaSeleccionables
manager
)
ListaSeleccionables
manager
)
{
{
final
buttons
=
<
Widget
>[
return
convertirButtonTypes
.
map
((
type
)
{
ActionButton
(
return
ActionButton
(
tipoBoton:
type
,
manager:
manager
);
tipoBoton:
ActionButtonTypes
.
copiar
,
}).
toList
();
onPressed:
()
{
List
<
Archivo
>
archivos
=
manager
.
seleccionables
.
whereType
<
Archivo
>().
toList
();
var
results
=
<
Future
<
ReturnCode
?>>[];
for
(
var
archivo
in
archivos
)
{
results
.
add
(
Conversor
.
convertir
(
archivo
));
}
}
),
ActionButton
(
tipoBoton:
ActionButtonTypes
.
reemplazar
,
onPressed:
()
{}
),
ActionButton
(
tipoBoton:
ActionButtonTypes
.
comprimir
,
onPressed:
()
{}
)
];
return
buttons
;
}
}
List
<
Widget
>
_buildFABs
(
ListaSeleccionables
manager
)
{
List
<
Widget
>
_buildFABs
(
ListaSeleccionables
manager
)
{
...
@@ -146,39 +139,11 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> {
...
@@ -146,39 +139,11 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> {
return
toRet
;
return
toRet
;
}
}
// TODO: TERMINAR MÉTODOS
List
<
Widget
>
_loadAgregarActionButtons
(
BuildContext
context
,
List
<
Widget
>
_loadAgregarActionButtons
(
BuildContext
context
,
ListaSeleccionables
manager
)
ListaSeleccionables
manager
)
{
{
final
buttons
=
<
Widget
>[
return
agregarButtonTypes
.
map
(
(
type
)
{
ActionButton
(
return
ActionButton
(
tipoBoton:
type
,
manager:
manager
);
tipoBoton:
ActionButtonTypes
.
enlace
,
}).
toList
();
onPressed:
()
{}
),
ActionButton
(
tipoBoton:
ActionButtonTypes
.
carpeta
,
onPressed:
()
async
{
String
?
path
=
await
FilePicker
.
platform
.
getDirectoryPath
();
if
(
path
!=
null
)
{
// TODO: AÑADIR POSIBILIDAD RECURSIVIDAD
var
directory
=
Directory
(
path
);
manager
.
addCarpeta
(
directory
);
}
}
),
ActionButton
(
tipoBoton:
ActionButtonTypes
.
archivo
,
onPressed:
()
async
{
FilePickerResult
?
result
=
await
FilePicker
.
platform
.
pickFiles
();
if
(
result
!=
null
)
{
File
file
=
File
(
result
.
files
.
first
.
path
!);
manager
.
addArchivo
(
file
);
}
else
{
//
}
},
),
];
return
buttons
;
}
}
}
}
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