Skip to content

added drag and drop to selected files container #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions lib/bloc_observer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,14 @@ class SimpleBlocObserver extends BlocObserver {
// @override
// void onEvent(Bloc bloc, Object? event) {
// super.onEvent(bloc, event);

// if ({ProcessFileExtractorOutput, ProcessFileExtractorProgress}
// .contains(event)) print('onEvent -- ${bloc.runtimeType}, $event');
// print('onEvent -- ${bloc.runtimeType}, $event');
// }

// @override
// void onTransition(Bloc bloc, Transition transition) {
// // CurrentSettingsState and ProcessState have a lot of spam
// if ({transition.nextState, transition.nextState}
// .contains(CurrentSettingsState) ||
// {transition.nextState, transition.nextState}.contains(ProcessState)) {
// print(transition);
// }
// super.onTransition(bloc, transition);
// }
@override
void onTransition(Bloc bloc, Transition transition) {
print(transition);
super.onTransition(bloc, transition);
}

@override
void onError(BlocBase bloc, Object error, StackTrace stackTrace) {
Expand Down
174 changes: 94 additions & 80 deletions lib/screens/dashboard/dashboard.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:desktop_drop/desktop_drop.dart';
import 'package:file_selector/file_selector.dart';
import 'package:flutter/material.dart';

import 'package:flutter_bloc/flutter_bloc.dart';
Expand Down Expand Up @@ -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<DashboardBloc, DashboardState>(
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<XFile> files = detail.urls.map((e) => XFile(e.path)).toList();
context.read<DashboardBloc>().add(
NewFileAdded(files),
);
context.read<ProcessBloc>().add(
ProcessFilesSubmitted(files),
);
},
child: Container(
decoration: BoxDecoration(
color: kBgLightColor,
),
height: MediaQuery.of(context).size.height / 2,
child: BlocConsumer<DashboardBloc, DashboardState>(
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<SettingsBloc, SettingsState>(
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<SettingsBloc, SettingsState>(
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,
),
),
),
);
},
),
],
);
},
);
},
),
],
);
},
),
),
);
}
Expand Down
6 changes: 6 additions & 0 deletions linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@
// Generated file. Do not edit.
//

// clang-format off

#include "generated_plugin_registrant.h"

#include <desktop_drop/desktop_drop_plugin.h>
#include <file_selector_linux/file_selector_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>
#include <window_size/window_size_plugin.h>

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);
Expand Down
2 changes: 2 additions & 0 deletions linux/flutter/generated_plugin_registrant.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Generated file. Do not edit.
//

// clang-format off

#ifndef GENERATED_PLUGIN_REGISTRANT_
#define GENERATED_PLUGIN_REGISTRANT_

Expand Down
1 change: 1 addition & 0 deletions linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#

list(APPEND FLUTTER_PLUGIN_LIST
desktop_drop
file_selector_linux
url_launcher_linux
window_size
Expand Down
7 changes: 7 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down