diff --git a/lib/main.dart b/lib/main.dart index 45d3416..44a577a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -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(), ); } diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index 8f41d6a..bc8e5ad 100644 --- a/lib/pages/home_page.dart +++ b/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 createState() => _HomePageState(); +} + +class _HomePageState extends State { + final List _list = []; + bool _dragging = false; + @override Widget build(BuildContext context) { return Scaffold( @@ -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(), ], ), ), diff --git a/pubspec.lock b/pubspec.lock index 0cf8e1c..86c4668 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -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: diff --git a/pubspec.yaml b/pubspec.yaml index 2eeea90..7678d6c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 70cc101..17961c3 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -7,11 +7,14 @@ #include "generated_plugin_registrant.h" #include +#include #include void RegisterPlugins(flutter::PluginRegistry* registry) { BitsdojoWindowPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("BitsdojoWindowPlugin")); + DesktopDropPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("DesktopDropPlugin")); FlutterAcrylicPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("FlutterAcrylicPlugin")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index ed0f996..7b44dfe 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -4,6 +4,7 @@ list(APPEND FLUTTER_PLUGIN_LIST bitsdojo_window_windows + desktop_drop flutter_acrylic )