Skip to content

Commit

Permalink
add file drop
Browse files Browse the repository at this point in the history
  • Loading branch information
LiquidatorCoder2 committed Nov 13, 2021
1 parent f9d5dc6 commit 00bc3ab
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 7 deletions.
4 changes: 1 addition & 3 deletions lib/main.dart
Expand Up @@ -31,9 +31,7 @@ class MyApp extends StatelessWidget {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Odin',
theme: ThemeData(
primarySwatch: Colors.blue,
),
theme: ThemeData.dark(),
home: const HomePage(),
);
}
Expand Down
52 changes: 48 additions & 4 deletions lib/pages/home_page.dart
@@ -1,12 +1,21 @@
import 'package:desktop_drop/desktop_drop.dart';
import 'package:flutter/material.dart';
import 'package:odin/widgets/window_top_bar.dart';

const backgroundStartColor = Color(0x55121212);
const backgroundEndColor = Color(0x55202020);

class HomePage extends StatelessWidget {
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);

@override
State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
final List<Uri> _list = [];
bool _dragging = false;

@override
Widget build(BuildContext context) {
return Scaffold(
Expand All @@ -20,9 +29,44 @@ class HomePage extends StatelessWidget {
),
),
child: Stack(
children: const [
SizedBox.expand(),
WindowTopBar(),
children: [
DropTarget(
onDragDone: (detail) {
setState(() {
_list.addAll(detail.urls);
});
},
onDragEntered: (detail) {
setState(() {
_dragging = true;
});
},
onDragExited: (detail) {
setState(() {
_dragging = false;
});
},
child: SizedBox.expand(
child: AnimatedContainer(
duration: const Duration(milliseconds: 300),
curve: Curves.easeOut,
color: _dragging
? Colors.blue.withOpacity(0.2)
: Colors.transparent,
child: Center(
child: Text(
_list.isEmpty ? 'Drop a file to start' : _list.join("\n"),
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w100,
color: Colors.white.withOpacity(0.3),
),
),
),
),
),
),
const WindowTopBar(),
],
),
),
Expand Down
7 changes: 7 additions & 0 deletions pubspec.lock
Expand Up @@ -85,6 +85,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
desktop_drop:
dependency: "direct main"
description:
name: desktop_drop
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2"
fake_async:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Expand Up @@ -36,6 +36,7 @@ dependencies:
cupertino_icons: ^1.0.2
bitsdojo_window: ^0.1.1+1
flutter_acrylic: ^0.1.0
desktop_drop: ^0.1.2

dev_dependencies:
flutter_test:
Expand Down
3 changes: 3 additions & 0 deletions windows/flutter/generated_plugin_registrant.cc
Expand Up @@ -7,11 +7,14 @@
#include "generated_plugin_registrant.h"

#include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
#include <desktop_drop/desktop_drop_plugin.h>
#include <flutter_acrylic/flutter_acrylic_plugin.h>

void RegisterPlugins(flutter::PluginRegistry* registry) {
BitsdojoWindowPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("BitsdojoWindowPlugin"));
DesktopDropPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("DesktopDropPlugin"));
FlutterAcrylicPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterAcrylicPlugin"));
}
1 change: 1 addition & 0 deletions windows/flutter/generated_plugins.cmake
Expand Up @@ -4,6 +4,7 @@

list(APPEND FLUTTER_PLUGIN_LIST
bitsdojo_window_windows
desktop_drop
flutter_acrylic
)

Expand Down

0 comments on commit 00bc3ab

Please sign in to comment.