diff --git a/lib/screens/dashboard/dashboard.dart b/lib/screens/dashboard/dashboard.dart index 2f2411a..658dd51 100644 --- a/lib/screens/dashboard/dashboard.dart +++ b/lib/screens/dashboard/dashboard.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:desktop_drop/desktop_drop.dart'; +import 'package:file_selector/file_selector.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:ccxgui/bloc/dashboard_bloc/dashboard_bloc.dart'; @@ -136,91 +138,103 @@ class ClearFilesButton extends StatelessWidget { class SelectedFilesContainer extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( - decoration: BoxDecoration( - color: kBgLightColor, - ), - height: MediaQuery.of(context).size.height / 2, - child: BlocConsumer( - listener: (context, state) { - if (state.alreadyPresent) { - CustomSnackBarMessage.show( - context, 'Already selected files were ignored'); - } - }, - builder: (context, state) { - return Column( - mainAxisSize: MainAxisSize.max, - children: [ - Container( - color: kBgDarkColor, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - 'Selected files', - style: TextStyle( - fontSize: 20, + return DropTarget( + onDragDone: (detail) { + List files = detail.urls.map((e) => XFile(e.path)).toList(); + context.read().add( + NewFileAdded(files), + ); + context.read().add( + ProcessFilesSubmitted(files), + ); + }, + child: Container( + decoration: BoxDecoration( + color: kBgLightColor, + ), + height: MediaQuery.of(context).size.height / 2, + child: BlocConsumer( + listener: (context, state) { + if (state.alreadyPresent) { + CustomSnackBarMessage.show( + context, 'Already selected files were ignored'); + } + }, + builder: (context, state) { + return Column( + mainAxisSize: MainAxisSize.max, + children: [ + Container( + color: kBgDarkColor, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Selected files', + style: TextStyle( + fontSize: 20, + ), ), - ), - Row( - children: [ - ClearFilesButton(), - StartStopButton(), - ], - ), - ], + Row( + children: [ + ClearFilesButton(), + StartStopButton(), + ], + ), + ], + ), ), - ), - BlocBuilder( - builder: (context, settingsState) { - if (settingsState is CurrentSettingsState) { - return Expanded( - child: state.files.isNotEmpty - ? Scrollbar( - child: ListView.builder( - shrinkWrap: true, - physics: ClampingScrollPhysics(), - itemCount: - settingsState.settingsModel.splitMode && - state.files.length > 1 - ? 1 - : state.files.length, - itemBuilder: (context, index) { - return Container( - color: kBgLightColor, - child: settingsState - .settingsModel.splitMode && - state.files.length > 1 - ? MultiProcessTile(files: state.files) - : ProcessTile(file: state.files[index]), - ); - }, - ), - ) - : Center( - child: Text( - 'No files selected', - style: TextStyle( - fontSize: 15, + BlocBuilder( + builder: (context, settingsState) { + if (settingsState is CurrentSettingsState) { + return Expanded( + child: state.files.isNotEmpty + ? Scrollbar( + child: ListView.builder( + shrinkWrap: true, + physics: ClampingScrollPhysics(), + itemCount: + settingsState.settingsModel.splitMode && + state.files.length > 1 + ? 1 + : state.files.length, + itemBuilder: (context, index) { + return Container( + color: kBgLightColor, + child: settingsState + .settingsModel.splitMode && + state.files.length > 1 + ? MultiProcessTile(files: state.files) + : ProcessTile( + file: state.files[index]), + ); + }, + ), + ) + : Center( + child: Text( + 'No files selected', + style: TextStyle( + fontSize: 15, + ), ), ), - ), - ); - } - return Center( - child: Text( - 'Loading settings, this should be super fast so if this is stuck something is broken, please open a issue on github', - style: TextStyle( - fontSize: 15, + ); + } + return Center( + child: Text( + 'Loading settings, this should be super fast so if this is stuck something is broken, please open a issue on github', + style: TextStyle( + fontSize: 15, + ), ), - ), - ); - }, - ), - ], - ); - }, + ); + }, + ), + ], + ); + }, + ), ), ); } diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 215e094..4ed69d7 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -2,13 +2,19 @@ // Generated file. Do not edit. // +// clang-format off + #include "generated_plugin_registrant.h" +#include #include #include #include void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) desktop_drop_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "DesktopDropPlugin"); + desktop_drop_plugin_register_with_registrar(desktop_drop_registrar); g_autoptr(FlPluginRegistrar) file_selector_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin"); file_selector_plugin_register_with_registrar(file_selector_linux_registrar); diff --git a/linux/flutter/generated_plugin_registrant.h b/linux/flutter/generated_plugin_registrant.h index 9bf7478..e0f0a47 100644 --- a/linux/flutter/generated_plugin_registrant.h +++ b/linux/flutter/generated_plugin_registrant.h @@ -2,6 +2,8 @@ // Generated file. Do not edit. // +// clang-format off + #ifndef GENERATED_PLUGIN_REGISTRANT_ #define GENERATED_PLUGIN_REGISTRANT_ diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 73c8db3..a52b3b0 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + desktop_drop file_selector_linux url_launcher_linux window_size diff --git a/pubspec.lock b/pubspec.lock index 1b45cb4..e611aa9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -197,6 +197,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" + desktop_drop: + dependency: "direct main" + description: + name: desktop_drop + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.2" equatable: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 26b0ab2..46ead23 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,6 +11,7 @@ dependencies: bloc: ^7.0.0 bloc_test: ^8.1.0 cupertino_icons: ^1.0.2 + desktop_drop: ^0.1.2 equatable: ^2.0.3 expandable: ^5.0.1 file_selector: ^0.8.2