diff --git a/lib/main.dart b/lib/main.dart index 7b7f5b6..c781996 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,122 +1,79 @@ -import 'package:flutter/material.dart'; +import "dart:io"; +import "package:window_manager/window_manager.dart"; +import "package:flutter/material.dart"; +import "package:dynamic_system_colors/dynamic_system_colors.dart"; +import "package:flutter_hooks/flutter_hooks.dart"; +import "package:window_size/window_size.dart"; -void main() { - runApp(const MyApp()); +void main() async { + WidgetsFlutterBinding.ensureInitialized(); + await windowManager.ensureInitialized(); + + await windowManager.waitUntilReadyToShow( + WindowOptions(titleBarStyle: TitleBarStyle.hidden), + ); + + setWindowMinSize(const Size.square(500)); + + runApp(const App()); } -class MyApp extends StatelessWidget { - const MyApp({super.key}); +class App extends HookWidget { + const App({super.key}); - // This widget is the root of your application. @override Widget build(BuildContext context) { - return MaterialApp( - title: 'Flutter Demo', - theme: ThemeData( - // This is the theme of your application. - // - // TRY THIS: Try running your application with "flutter run". You'll see - // the application has a purple toolbar. Then, without quitting the app, - // try changing the seedColor in the colorScheme below to Colors.green - // and then invoke "hot reload" (save your changes or press the "hot - // reload" button in a Flutter-supported IDE, or press "r" if you used - // the command line to start the app). - // - // Notice that the counter didn't reset back to zero; the application - // state is not lost during the reload. To reset the state, use hot - // restart instead. - // - // This works for code too, not just values: Most code changes can be - // tested with just a hot reload. - colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), + final index = useState(0); + final drawer = Drawer( + child: Row( + children: [ + NavigationRail( + useIndicator: false, + labelType: NavigationRailLabelType.none, + onDestinationSelected: (value) => index.value = value, + destinations: [ + NavigationRailDestination( + icon: Icon(Icons.home), + label: Text("Home"), + padding: EdgeInsets.symmetric(vertical: 8), + ), + NavigationRailDestination( + icon: Image.file(File("assets/icon.png"), width: 35), + label: Text("Space 1"), + ), + ], + selectedIndex: index.value, + ), + ], ), - home: const MyHomePage(title: 'Flutter Demo Home Page'), ); - } -} -class MyHomePage extends StatefulWidget { - const MyHomePage({super.key, required this.title}); + return DynamicColorBuilder( + builder: (lightDynamic, darkDynamic) => LayoutBuilder( + builder: (context, constraints) { + final isDesktop = constraints.maxWidth > 650; - // This widget is the home page of your application. It is stateful, meaning - // that it has a State object (defined below) that contains fields that affect - // how it looks. - - // This class is the configuration for the state. It holds the values (in this - // case the title) provided by the parent (in this case the App widget) and - // used by the build method of the State. Fields in a Widget subclass are - // always marked "final". - - final String title; - - @override - State createState() => _MyHomePageState(); -} - -class _MyHomePageState extends State { - int _counter = 0; - - void _incrementCounter() { - setState(() { - // This call to setState tells the Flutter framework that something has - // changed in this State, which causes it to rerun the build method below - // so that the display can reflect the updated values. If we changed - // _counter without calling setState(), then the build method would not be - // called again, and so nothing would appear to happen. - _counter++; - }); - } - - @override - Widget build(BuildContext context) { - // This method is rerun every time setState is called, for instance as done - // by the _incrementCounter method above. - // - // The Flutter framework has been optimized to make rerunning build methods - // fast, so that you can just rebuild anything that needs updating rather - // than having to individually change instances of widgets. - return Scaffold( - appBar: AppBar( - // TRY THIS: Try changing the color here to a specific color (to - // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar - // change color while the other colors stay the same. - backgroundColor: Theme.of(context).colorScheme.inversePrimary, - // Here we take the value from the MyHomePage object that was created by - // the App.build method, and use it to set our appbar title. - title: Text(widget.title), - ), - body: Center( - // Center is a layout widget. It takes a single child and positions it - // in the middle of the parent. - child: Column( - // Column is also a layout widget. It takes a list of children and - // arranges them vertically. By default, it sizes itself to fit its - // children horizontally, and tries to be as tall as its parent. - // - // Column has various properties to control how it sizes itself and - // how it positions its children. Here we use mainAxisAlignment to - // center the children vertically; the main axis here is the vertical - // axis because Columns are vertical (the cross axis would be - // horizontal). - // - // TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint" - // action in the IDE, or press "p" in the console), to see the - // wireframe for each widget. - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text('You have pushed the button this many times:'), - Text( - '$_counter', - style: Theme.of(context).textTheme.headlineMedium, + return MaterialApp( + debugShowCheckedModeBanner: false, + theme: ThemeData.from( + colorScheme: lightDynamic ?? ColorScheme.light(), ), - ], - ), + darkTheme: ThemeData.from( + colorScheme: darkDynamic ?? ColorScheme.dark(), + ), + home: Scaffold( + appBar: isDesktop ? null : AppBar(), + body: Row( + children: [ + if (isDesktop) drawer, + Expanded(child: Column()), + ], + ), + drawer: isDesktop ? null : drawer, + ), + ); + }, ), - floatingActionButton: FloatingActionButton( - onPressed: _incrementCounter, - tooltip: 'Increment', - child: const Icon(Icons.add), - ), // This trailing comma makes auto-formatting nicer for build methods. ); } } diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 0848572..bd68832 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -9,8 +9,10 @@ #include #include #include -#include +#include #include +#include +#include void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) dynamic_system_colors_registrar = @@ -22,10 +24,16 @@ void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) gtk_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "GtkPlugin"); gtk_plugin_register_with_registrar(gtk_registrar); - g_autoptr(FlPluginRegistrar) isar_plus_flutter_libs_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "IsarPlusFlutterLibsPlugin"); - isar_plus_flutter_libs_plugin_register_with_registrar(isar_plus_flutter_libs_registrar); + g_autoptr(FlPluginRegistrar) screen_retriever_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverLinuxPlugin"); + screen_retriever_linux_plugin_register_with_registrar(screen_retriever_linux_registrar); g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); + g_autoptr(FlPluginRegistrar) window_manager_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin"); + window_manager_plugin_register_with_registrar(window_manager_registrar); + g_autoptr(FlPluginRegistrar) window_size_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "WindowSizePlugin"); + window_size_plugin_register_with_registrar(window_size_registrar); } diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 94ab6fa..45f0cc2 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -6,8 +6,10 @@ list(APPEND FLUTTER_PLUGIN_LIST dynamic_system_colors file_selector_linux gtk - isar_plus_flutter_libs + screen_retriever_linux url_launcher_linux + window_manager + window_size ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/pubspec.lock b/pubspec.lock index c213ec6..71f6cd2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -305,22 +305,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.7.11" - device_info_plus: - dependency: "direct main" - description: - name: device_info_plus - sha256: dd0e8e02186b2196c7848c9d394a5fd6e5b57a43a546082c5820b1ec72317e33 - url: "https://pub.dev" - source: hosted - version: "12.2.0" - device_info_plus_platform_interface: - dependency: transitive - description: - name: device_info_plus_platform_interface - sha256: e1ea89119e34903dca74b883d0dd78eb762814f97fb6c76f35e9ff74d261a18f - url: "https://pub.dev" - source: hosted - version: "7.0.3" dynamic_system_colors: dependency: "direct main" description: @@ -459,14 +443,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.3" - flutter_svg: - dependency: "direct main" - description: - name: flutter_svg - sha256: "055de8921be7b8e8b98a233c7a5ef84b3a6fcc32f46f1ebf5b9bb3576d108355" - url: "https://pub.dev" - source: hosted - version: "2.2.2" flutter_test: dependency: transitive description: flutter @@ -542,7 +518,7 @@ packages: source: hosted version: "4.3.0" http: - dependency: "direct main" + dependency: transitive description: name: http sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412" @@ -653,22 +629,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.5" - isar_plus: - dependency: "direct main" - description: - name: isar_plus - sha256: "6977284cacf7744322a07ac635708f25bb33443bfff4538ee096224a15bbf6ae" - url: "https://pub.dev" - source: hosted - version: "1.0.27" - isar_plus_flutter_libs: - dependency: "direct main" - description: - name: isar_plus_flutter_libs - sha256: "2ccfac0177dcb3160f755d23ebcc46facc9738797b1c8e94174631d3c6a917d0" - url: "https://pub.dev" - source: hosted - version: "1.0.27" js: dependency: transitive description: @@ -749,15 +709,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.11.1" - media_store_plus: - dependency: "direct main" - description: - path: "." - ref: HEAD - resolved-ref: "62b22c0c9fd5719c4abf2239e630a64d7dd45adb" - url: "https://github.com/Henry-Hiles/media_store_plus" - source: git - version: "0.1.1" meta: dependency: transitive description: @@ -774,14 +725,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.0" - mobile_scanner: - dependency: "direct main" - description: - name: mobile_scanner - sha256: "023a71afb4d7cfb5529d0f2636aa8b43db66257905b9486d702085989769c5f2" - url: "https://pub.dev" - source: hosted - version: "7.1.3" node_preamble: dependency: transitive description: @@ -798,22 +741,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.2.0" - package_info_plus: - dependency: "direct main" - description: - name: package_info_plus - sha256: f69da0d3189a4b4ceaeb1a3defb0f329b3b352517f52bed4290f83d4f06bc08d - url: "https://pub.dev" - source: hosted - version: "9.0.0" - package_info_plus_platform_interface: - dependency: transitive - description: - name: package_info_plus_platform_interface - sha256: "202a487f08836a592a6bd4f901ac69b3a8f146af552bbd14407b6b41e1c3f086" - url: "https://pub.dev" - source: hosted - version: "3.2.1" path: dependency: "direct main" description: @@ -822,14 +749,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.1" - path_parsing: - dependency: transitive - description: - name: path_parsing - sha256: "883402936929eac138ee0a45da5b0f2c80f89913e6dc3bf77eb65b84b409c6ca" - url: "https://pub.dev" - source: hosted - version: "1.1.0" path_provider: dependency: "direct main" description: @@ -1014,6 +933,46 @@ packages: url: "https://pub.dev" source: hosted version: "0.28.0" + screen_retriever: + dependency: transitive + description: + name: screen_retriever + sha256: "570dbc8e4f70bac451e0efc9c9bb19fa2d6799a11e6ef04f946d7886d2e23d0c" + url: "https://pub.dev" + source: hosted + version: "0.2.0" + screen_retriever_linux: + dependency: transitive + description: + name: screen_retriever_linux + sha256: f7f8120c92ef0784e58491ab664d01efda79a922b025ff286e29aa123ea3dd18 + url: "https://pub.dev" + source: hosted + version: "0.2.0" + screen_retriever_macos: + dependency: transitive + description: + name: screen_retriever_macos + sha256: "71f956e65c97315dd661d71f828708bd97b6d358e776f1a30d5aa7d22d78a149" + url: "https://pub.dev" + source: hosted + version: "0.2.0" + screen_retriever_platform_interface: + dependency: transitive + description: + name: screen_retriever_platform_interface + sha256: ee197f4581ff0d5608587819af40490748e1e39e648d7680ecf95c05197240c0 + url: "https://pub.dev" + source: hosted + version: "0.2.0" + screen_retriever_windows: + dependency: transitive + description: + name: screen_retriever_windows + sha256: "449ee257f03ca98a57288ee526a301a430a344a161f9202b4fcc38576716fe13" + url: "https://pub.dev" + source: hosted + version: "0.2.0" shared_preferences: dependency: "direct main" description: @@ -1307,30 +1266,6 @@ packages: url: "https://pub.dev" source: hosted version: "4.5.2" - vector_graphics: - dependency: transitive - description: - name: vector_graphics - sha256: a4f059dc26fc8295b5921376600a194c4ec7d55e72f2fe4c7d2831e103d461e6 - url: "https://pub.dev" - source: hosted - version: "1.1.19" - vector_graphics_codec: - dependency: transitive - description: - name: vector_graphics_codec - sha256: "99fd9fbd34d9f9a32efd7b6a6aae14125d8237b10403b422a6a6dfeac2806146" - url: "https://pub.dev" - source: hosted - version: "1.1.13" - vector_graphics_compiler: - dependency: transitive - description: - name: vector_graphics_compiler - sha256: d354a7ec6931e6047785f4db12a1f61ec3d43b207fc0790f863818543f8ff0dc - url: "https://pub.dev" - source: hosted - version: "1.1.19" vector_math: dependency: transitive description: @@ -1387,38 +1322,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.1" - webview_flutter: - dependency: "direct main" - description: - name: webview_flutter - sha256: c3e4fe614b1c814950ad07186007eff2f2e5dd2935eba7b9a9a1af8e5885f1ba - url: "https://pub.dev" - source: hosted - version: "4.13.0" - webview_flutter_android: - dependency: transitive - description: - name: webview_flutter_android - sha256: e5201c620eb2637dca88a756961fae4a7191bb30b4f2271e08b746405ffdf3fd - url: "https://pub.dev" - source: hosted - version: "4.10.5" - webview_flutter_platform_interface: - dependency: transitive - description: - name: webview_flutter_platform_interface - sha256: "63d26ee3aca7256a83ccb576a50272edd7cfc80573a4305caa98985feb493ee0" - url: "https://pub.dev" - source: hosted - version: "2.14.0" - webview_flutter_wkwebview: - dependency: transitive - description: - name: webview_flutter_wkwebview - sha256: "5de608fdea144d4370c21d4c80f0528135529e0180aa129790064c345e457a43" - url: "https://pub.dev" - source: hosted - version: "3.23.2" win32: dependency: transitive description: @@ -1427,14 +1330,23 @@ packages: url: "https://pub.dev" source: hosted version: "5.15.0" - win32_registry: - dependency: transitive + window_manager: + dependency: "direct main" description: - name: win32_registry - sha256: "6f1b564492d0147b330dd794fee8f512cec4977957f310f9951b5f9d83618dae" + name: window_manager + sha256: "7eb6d6c4164ec08e1bf978d6e733f3cebe792e2a23fb07cbca25c2872bfdbdcd" url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "0.5.1" + window_size: + dependency: "direct main" + description: + path: "plugins/window_size" + ref: HEAD + resolved-ref: eb3964990cf19629c89ff8cb4a37640c7b3d5601 + url: "https://github.com/google/flutter-desktop-embedding" + source: git + version: "0.1.0" xdg_directories: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 34ea2db..dc83fbd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.0.0 publish_to: none flutter: - generate: true + uses-material-design: true environment: sdk: "^3.9.2" @@ -21,30 +21,24 @@ dependencies: flutter_hooks: ^0.21.2 flutter_riverpod: ^3.0.3 hooks_riverpod: ^3.0.3 - http: ^1.2.1 intl: ^0.20.1 app_links: ^6.1.1 fast_immutable_collections: ^11.0.0 - package_info_plus: ^9.0.0 path_provider: ^2.1.3 permission_handler: ^12.0.1 shared_preferences: ^2.2.3 url_launcher: ^6.2.6 - webview_flutter: ^4.8.0 - device_info_plus: ^12.1.0 - mobile_scanner: ^7.1.2 - flutter_svg: ^2.0.10+1 freezed_annotation: ^3.1.0 image_picker: ^1.1.2 file_picker: ^10.3.3 path: ^1.9.0 dynamic_system_colors: ^1.8.0 - isar_plus: 1.0.27 - isar_plus_flutter_libs: 1.0.27 - media_store_plus: - git: - url: https://github.com/Henry-Hiles/media_store_plus collection: ^1.19.1 + window_manager: ^0.5.1 + window_size: + git: + url: https://github.com/google/flutter-desktop-embedding + path: plugins/window_size dev_dependencies: build_runner: ^2.4.11