Todo listo para añadir la funcionalidad de escoger archivo

parent 8f8b1790
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class ActionButton extends StatelessWidget { class ActionButton extends StatelessWidget {
final actionButtonTypes tipoBoton; final ActionButtonTypes tipoBoton;
final VoidCallback? onPressed; final VoidCallback? onPressed;
const ActionButton({super.key, required this.onPressed, ActionButton({super.key, required this.tipoBoton, required this.onPressed});
required this.label, required this.icon});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -14,24 +13,24 @@ class ActionButton extends StatelessWidget { ...@@ -14,24 +13,24 @@ class ActionButton extends StatelessWidget {
textDirection: TextDirection.rtl, textDirection: TextDirection.rtl,
child: FilledButton.icon( child: FilledButton.icon(
onPressed: onPressed, onPressed: onPressed,
label: Text(label, textScaler: const TextScaler.linear(1.2)), label: Text(tipoBoton.label, textScaler: const TextScaler.linear(1.2)),
icon: icon, icon: tipoBoton.icon,
), ),
); );
} }
} }
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)),
ENLACE('Enlace', Icon(Icons.link_outlined)), enlace('Enlace', Icon(Icons.link_outlined)),
COPIAR('Copiar', Icon(Icons.copy)), copiar('Copiar', Icon(Icons.copy)),
COMPRIMIR('Comprimir', Icon(Icons.splitscreen_outlined)), comprimir('Comprimir', Icon(Icons.splitscreen_outlined)),
REEMPLAZAR('Reemplazar', Icon(Icons.change_circle_outlined)); reemplazar('Reemplazar', Icon(Icons.change_circle_outlined));
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
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import './action_button.dart'; import './action_button.dart';
...@@ -51,6 +52,24 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> { ...@@ -51,6 +52,24 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> {
); );
} }
List<Widget> _loadConvertirActionButtons (BuildContext context) {
final buttons = <Widget>[
ActionButton(
tipoBoton: ActionButtonTypes.copiar,
onPressed: () {},
),
ActionButton(
tipoBoton: ActionButtonTypes.reemplazar,
onPressed: () {}
),
ActionButton(
tipoBoton: ActionButtonTypes.comprimir,
onPressed: () {}
)
];
return buttons;
}
List<Widget> _buildFABs() { List<Widget> _buildFABs() {
final toRet = <Widget>[]; final toRet = <Widget>[];
...@@ -83,13 +102,6 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> { ...@@ -83,13 +102,6 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> {
], ],
)); ));
List<Widget> _loadConvertirActionButtons(BuildContext context){
final buttons = <Widget>[];
return buttons;
}
// FAB con las opciones para agregar archivos, carpetas, enlaces... // FAB con las opciones para agregar archivos, carpetas, enlaces...
toRet.add(Stack( toRet.add(Stack(
...@@ -122,8 +134,27 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> { ...@@ -122,8 +134,27 @@ class _ConVertexFabBarState extends State<ConVertexFabBar> {
} }
List<Widget> _loadAgregarActionButtons(BuildContext context){ List<Widget> _loadAgregarActionButtons(BuildContext context){
final buttons = <Widget>[]; final buttons = <Widget>[
ActionButton(
tipoBoton: ActionButtonTypes.enlace,
onPressed: () {}
),
ActionButton(
tipoBoton: ActionButtonTypes.carpeta,
onPressed: () {}
),
ActionButton(
tipoBoton: ActionButtonTypes.archivo,
onPressed: () async {
FilePickerResult? result = await FilePicker.platform.pickFiles();
if (result != null) {
String filePath = result.files.single.path!;
} else {
//
}
},
),
];
return buttons; return buttons;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment