diff --git a/lib/fluent/app.dart b/lib/fluent/app.dart index 5fb15d2..c8659db 100644 --- a/lib/fluent/app.dart +++ b/lib/fluent/app.dart @@ -1,8 +1,11 @@ import 'package:fluent_ui/fluent_ui.dart'; + +// import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:momo/fluent/login.dart'; import 'package:momo/fluent/router.dart'; import 'package:momo/provider/token.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class MyFluentApp extends ConsumerWidget { const MyFluentApp({Key? key}) : super(key: key); @@ -10,16 +13,31 @@ class MyFluentApp extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final String token = ref.watch(tokenProvider); - return token.isNotEmpty - ? FluentApp.router( - routeInformationParser: - MyFluentRouterConfig.router.routeInformationParser, - routerDelegate: MyFluentRouterConfig.router.routerDelegate, - color: Colors.blue, - ) - : FluentApp( - color: Colors.blue, - home: LoginPage(), - ); + Future loadToken() async { + final prefs = await SharedPreferences.getInstance(); + String? tk = await prefs.getString("token"); + return tk; + } + + return FutureBuilder( + future: loadToken(), + builder: (BuildContext context, AsyncSnapshot snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + MyFluentRouterConfig myFluentRouterConfig = + MyFluentRouterConfig(snapshot.data); + return FluentApp.router( + routeInformationParser: + myFluentRouterConfig.router.routeInformationParser, + routerDelegate: myFluentRouterConfig.router.routerDelegate, + color: Colors.blue, + ); + } else { + return const FluentApp( + home: ScaffoldPage( + content: Placeholder(), + ), + ); + } + }); } } diff --git a/lib/fluent/home.dart b/lib/fluent/home.dart index a4ac757..df04215 100644 --- a/lib/fluent/home.dart +++ b/lib/fluent/home.dart @@ -1,19 +1,26 @@ import 'package:fluent_ui/fluent_ui.dart'; import 'package:fluentui_system_icons/fluentui_system_icons.dart' as fluentui_system_icons; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; +import 'package:momo/provider/token.dart'; -class HomePage extends StatefulWidget { +class HomePage extends ConsumerStatefulWidget { const HomePage({Key? key}) : super(key: key); @override - State createState() => _HomePageState(); + ConsumerState createState() => _HomePageState(); } -class _HomePageState extends State { +class _HomePageState extends ConsumerState { int _selected = 0; @override - Widget build(BuildContext context) { + Widget build( + BuildContext context, + ) { + // String token = ref.watch(tokenProvider); + return MediaQuery.of(context).size.width > 640 ? NavigationView( appBar: NavigationAppBar(title: Text('momo')), @@ -46,6 +53,15 @@ class _HomePageState extends State { header: PageHeader( title: Text("213"), ), + content: Center( + child: FilledButton( + onPressed: () { + // ref.watch(tokenProvider.notifier).removeToken(); + GoRouter.of(context).go("/login"); + }, + child: Text("退出"), + ), + ), )), PaneItem( icon: const Icon(fluentui_system_icons diff --git a/lib/fluent/login.dart b/lib/fluent/login.dart index 71271a1..3984966 100644 --- a/lib/fluent/login.dart +++ b/lib/fluent/login.dart @@ -1,4 +1,12 @@ +import 'dart:convert'; +import 'dart:io'; +import 'dart:math'; + import 'package:fluent_ui/fluent_ui.dart'; +import 'package:go_router/go_router.dart'; +import 'package:http/http.dart' as http; +import 'package:momo/models/login_resp.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class LoginPage extends StatelessWidget { const LoginPage({Key? key}) : super(key: key); @@ -8,25 +16,69 @@ class LoginPage extends StatelessWidget { return Container( // padding: EdgeInsets.all(100), color: Colors.white, - child: ScaffoldPage( + child: const ScaffoldPage( header: PageHeader( title: Text("登录"), ), - content: Container( - padding: EdgeInsets.fromLTRB(50, 0, 50, 0), - child: ListView( - children: [ - TextBox( - header: "账号", - placeholder: "请输入账号", - ), - TextBox( - header: "密码", - placeholder: "请输入密码", - ), - ], - ), - ), + content: LoginForm(), + ), + ); + } +} + +class LoginForm extends StatefulWidget { + const LoginForm({Key? key}) : super(key: key); + + @override + State createState() => _LoginFormState(); +} + +class _LoginFormState extends State { + TextEditingController usernameController = TextEditingController(); + TextEditingController passwordController = TextEditingController(); + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.fromLTRB(50, 0, 50, 0), + child: ListView( + children: [ + TextBox( + controller: usernameController, + header: "账号", + placeholder: "请输入账号", + ), + TextBox( + controller: passwordController, + header: "密码", + placeholder: "请输入密码", + ), + FilledButton( + child: Text('登录'), + onPressed: () { + if (usernameController.text.isNotEmpty && + passwordController.text.isNotEmpty) { + http + .post(Uri.parse("http://localhost:8080/user/login"), + headers: {"Content-Type": "application/json"}, + body: jsonEncode({ + "username": usernameController.text, + "password": passwordController.text + })) + .then((resp) { + if (resp.statusCode == HttpStatus.ok) { + LoginResp loginResp = + LoginResp.fromJson(jsonDecode(resp.body)); + SharedPreferences.getInstance().then((prefs) { + return prefs.setString("token", loginResp.token); + }).then((value) { + context.go("/"); + }); + } + }); + } + }) + ], ), ); } diff --git a/lib/fluent/router.dart b/lib/fluent/router.dart index 443ea51..c94c05c 100644 --- a/lib/fluent/router.dart +++ b/lib/fluent/router.dart @@ -1,26 +1,49 @@ import 'package:fluent_ui/fluent_ui.dart'; import 'package:go_router/go_router.dart'; import 'package:momo/fluent/home.dart'; -import 'package:momo/provider/token.dart'; +import 'package:momo/fluent/login.dart'; class MyFluentRouterConfig { - static GoRouter router = GoRouter( - routes: [ - GoRoute( - path: '/', - builder: (BuildContext context, GoRouterState state) { - return HomePage(); - }, - redirect: (BuildContext context, GoRouterState state) { - print(tokenProvider); - return null; - }, - ), - GoRoute( - path: "/login", + late GoRouter router; + + MyFluentRouterConfig(String? token) { + router = GoRouter( + routes: [ + GoRoute( + path: '/', builder: (BuildContext context, GoRouterState state) { - return ScaffoldPage(); - }) - ], - ); + return const HomePage(); + }, + redirect: (BuildContext context, GoRouterState state) { + if (token == null || token.isEmpty) { + return "/login"; + } + return null; + }, + ), + GoRoute( + path: "/login", + builder: (BuildContext context, GoRouterState state) { + return const LoginPage(); + }) + ], + ); + } +} + +class TextLogin extends StatelessWidget { + const TextLogin({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return ScaffoldPage( + content: Center( + child: FilledButton( + child: Text("logi"), + onPressed: () { + context.go("/"); + }), + ), + ); + } } diff --git a/lib/main.dart b/lib/main.dart index b0b1f23..2088438 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,14 +1,30 @@ import 'dart:io'; import 'package:fluent_ui/fluent_ui.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:momo/fluent/app.dart'; import 'package:momo/material/app.dart'; +import 'package:window_manager/window_manager.dart'; +import 'package:tray_manager/tray_manager.dart'; -void main() { - print(defaultTargetPlatform); - runApp(ProviderScope(child: const MyApp())); +void main() async { + if (Platform.isLinux || Platform.isWindows || Platform.isMacOS) { + WidgetsFlutterBinding.ensureInitialized(); + // Must add this line. + await windowManager.ensureInitialized(); + WindowOptions windowOptions = const WindowOptions( + size: Size(800, 600), + center: true, + minimumSize: Size(300, 400), + // backgroundColor: Colors.transparent, + // skipTaskbar: false, + // titleBarStyle: TitleBarStyle.hidden, + ); + windowManager.waitUntilReadyToShow(windowOptions, () async { + await windowManager.show(); + await windowManager.focus(); + }); + } + runApp(const ProviderScope(child: MyApp())); } class MyApp extends StatelessWidget { @@ -16,10 +32,6 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - if (Platform.isWindows) { - return const MyFluentApp(); - } else { - return const MyMaterialApp(); - } + return const MyMaterialApp(); } } diff --git a/lib/material/app.dart b/lib/material/app.dart index 2de00e6..433510d 100644 --- a/lib/material/app.dart +++ b/lib/material/app.dart @@ -1,14 +1,49 @@ import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:momo/material/router.dart'; +import 'package:momo/provider/token.dart'; +import 'package:shared_preferences/shared_preferences.dart'; -class MyMaterialApp extends StatelessWidget { +class MyMaterialApp extends ConsumerWidget { const MyMaterialApp({Key? key}) : super(key: key); + Future loadToken() async { + final prefs = await SharedPreferences.getInstance(); + String? tk = await prefs.getString("token"); + return tk; + } + @override - Widget build(BuildContext context) { - return MaterialApp.router( - routerConfig: MyMaterialRouterConfig.router, - theme: ThemeData(useMaterial3: true), - ); + Widget build(BuildContext context, WidgetRef ref) { + return FutureBuilder( + future: loadToken(), + builder: (BuildContext context, AsyncSnapshot snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + String? token = snapshot.data; + if (token != null) { + // ref + // .watch( + // tokenProvider.notifier, + // ) + // .setToken(token); + } + MyMaterialRouterConfig myMaterialRouterConfig = + MyMaterialRouterConfig(token); + + return MaterialApp.router( + routerConfig: myMaterialRouterConfig.router, + theme: ThemeData( + useMaterial3: true, scaffoldBackgroundColor: Colors.white), + ); + } else { + return MaterialApp( + theme: ThemeData( + useMaterial3: true, scaffoldBackgroundColor: Colors.white), + home: const Center( + child: CircularProgressIndicator(), + ), + ); + } + }); } } diff --git a/lib/material/gallery.dart b/lib/material/gallery.dart new file mode 100644 index 0000000..991d531 --- /dev/null +++ b/lib/material/gallery.dart @@ -0,0 +1,27 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; +import 'package:momo/provider/token.dart'; + +class Gallery extends ConsumerStatefulWidget { + const Gallery({Key? key}) : super(key: key); + + @override + ConsumerState createState() => _GalleryState(); +} + +class _GalleryState extends ConsumerState { + @override + Widget build(BuildContext context) { + String token = ref.watch(tokenProvider); + print(token); + return Center( + child: ElevatedButton( + onPressed: () { + // ref.watch(tokenProvider.notifier).removeToken(); + context.go("/login"); + }, + child: Text("exit")), + ); + } +} diff --git a/lib/material/home.dart b/lib/material/home.dart index 9e164a6..209ddb9 100644 --- a/lib/material/home.dart +++ b/lib/material/home.dart @@ -1,4 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; +import 'package:momo/material/gallery.dart'; class HomePage extends StatefulWidget { const HomePage({Key? key}) : super(key: key); @@ -14,16 +16,21 @@ class _HomePageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - backgroundColor: Colors.pinkAccent, - title: const Text("APP"), + title: const Text( + "App Header", + style: TextStyle(fontWeight: FontWeight.bold), + ), + elevation: 10, ), body: Row( children: [ MediaQuery.of(context).size.width > 640 ? NavigationRail( + elevation: 10, + backgroundColor: const Color(0xffebf6f5), leading: MediaQuery.of(context).size.width >= 1008 ? const Text( - "Header", + "Side Header", style: TextStyle( fontWeight: FontWeight.bold, fontSize: 36), ) @@ -43,11 +50,13 @@ class _HomePageState extends State { selectedIndex: selectedIndex) : const SizedBox( width: 0, - ) + ), + Expanded(child: pageList[selectedIndex]) ], ), bottomNavigationBar: MediaQuery.of(context).size.width <= 640 ? BottomNavigationBar( + elevation: 10, currentIndex: selectedIndex, onTap: (idx) { setState(() { @@ -63,3 +72,10 @@ class _HomePageState extends State { ); } } + +List pageList = [ + Gallery(), + Scaffold( + body: Placeholder(), + ) +]; diff --git a/lib/material/login.dart b/lib/material/login.dart new file mode 100644 index 0000000..3bad2f9 --- /dev/null +++ b/lib/material/login.dart @@ -0,0 +1,101 @@ +import 'dart:convert'; +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; +import 'package:http/http.dart' as http; +import 'package:momo/models/login_resp.dart'; +import 'package:momo/provider/token.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +class LoginPage extends StatelessWidget { + const LoginPage({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text("登录"), + centerTitle: true, + ), + body: const Padding( + padding: EdgeInsets.fromLTRB(20, 0, 20, 0), + child: LoginForm(), + )); + } +} + +class LoginForm extends ConsumerStatefulWidget { + const LoginForm({Key? key}) : super(key: key); + + @override + ConsumerState createState() => _LoginFormState(); +} + +class _LoginFormState extends ConsumerState { + TextEditingController usernameController = + TextEditingController(text: "kencho"); + TextEditingController passwordController = + TextEditingController(text: "169482"); + + @override + Widget build(BuildContext context) { + return ListView( + children: [ + Form( + child: Column( + children: [ + TextFormField( + controller: usernameController, + decoration: const InputDecoration( + enabledBorder: OutlineInputBorder(borderSide: BorderSide()), + focusedBorder: OutlineInputBorder(borderSide: BorderSide()), + hintText: 'Enter your username', + ), + ), + const SizedBox( + height: 20, + ), + TextFormField( + controller: passwordController, + decoration: const InputDecoration( + enabledBorder: OutlineInputBorder(borderSide: BorderSide()), + focusedBorder: OutlineInputBorder(borderSide: BorderSide()), + hintText: 'Enter your password', + ), + ), + const SizedBox( + height: 20, + ), + ], + )), + ElevatedButton( + child: const Text("登录"), + onPressed: () async { + if (usernameController.text.isNotEmpty && + passwordController.text.isNotEmpty) { + http.Response resp = await http.post( + Uri.parse("http://localhost:8080/user/login"), + headers: {"Content-Type": "application/json"}, + body: jsonEncode({ + "username": usernameController.text, + "password": passwordController.text + })); + + if (resp.statusCode == HttpStatus.ok) { + LoginResp loginResp = + LoginResp.fromJson(jsonDecode(resp.body)); + SharedPreferences prefs = + await SharedPreferences.getInstance(); + // ref.watch(tokenProvider.notifier).setToken(loginResp.token); + prefs.setString("token", loginResp.token).then((value) { + context.go("/"); + }); + } + } + }), + ], + ); + } +} diff --git a/lib/material/router.dart b/lib/material/router.dart index 23eb610..32ef214 100644 --- a/lib/material/router.dart +++ b/lib/material/router.dart @@ -1,16 +1,32 @@ import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:momo/material/home.dart'; +import 'package:momo/material/login.dart'; class MyMaterialRouterConfig { - static GoRouter router = GoRouter( - routes: [ - GoRoute( - path: '/', - builder: (BuildContext context, GoRouterState state) { - return HomePage(); - }, - ), - ], - ); + late GoRouter router; + + MyMaterialRouterConfig(String? token) { + router = GoRouter( + routes: [ + GoRoute( + path: '/', + builder: (BuildContext context, GoRouterState state) { + return const HomePage(); + }, + redirect: (BuildContext context, GoRouterState state) { + if (token == null || token.isEmpty) { + return '/login'; + } + return null; + }), + GoRoute( + path: "/login", + builder: (BuildContext context, GoRouterState state) { + return const LoginPage(); + }, + ) + ], + ); + } } diff --git a/lib/models/configs.dart b/lib/models/configs.dart deleted file mode 100644 index 4123cf5..0000000 --- a/lib/models/configs.dart +++ /dev/null @@ -1,54 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; - -/// This allows the `User` class to access private members in -/// the generated file. The value for this is *.g.dart, where -/// the star denotes the source file name. -part 'configs.g.dart'; - -/// An annotation for the code generator to know that this class needs the -/// JSON serialization logic to be generated. -@JsonSerializable() -class Configs { - Configs( - this.port, - this.socksPort, - this.tproxyPort, - this.redirPort, - this.mixedPort, - this.authentication, - this.allowLan, - this.bindAddress, - this.mode, - this.logLevel, - this.ipv6); - - int port; - @JsonKey(name: 'socks-port') - int socksPort; - @JsonKey(name: 'redir-port') - int redirPort; - @JsonKey(name: 'tproxy-port') - int tproxyPort; - @JsonKey(name: 'mixed-port') - int mixedPort; - List authentication; - @JsonKey(name: 'allow-lan') - bool allowLan; - @JsonKey(name: 'bind-address') - String bindAddress; - String mode; - @JsonKey(name: 'log-level') - String logLevel; - bool ipv6; - - /// A necessary factory constructor for creating a new Configs instance - /// from a map. Pass the map to the generated `_$ConfigsFromJson()` constructor. - /// The constructor is named after the source class, in this case, Configs. - factory Configs.fromJson(Map json) => - _$ConfigsFromJson(json); - - /// `toJson` is the convention for a class to declare support for serialization - /// to JSON. The implementation simply calls the private, generated - /// helper method `_$ConfigsToJson`. - Map toJson() => _$ConfigsToJson(this); -} diff --git a/lib/models/configs.g.dart b/lib/models/configs.g.dart deleted file mode 100644 index 1fb6dba..0000000 --- a/lib/models/configs.g.dart +++ /dev/null @@ -1,35 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'configs.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -Configs _$ConfigsFromJson(Map json) => Configs( - json['port'] as int, - json['socks-port'] as int, - json['tproxy-port'] as int, - json['redir-port'] as int, - json['mixed-port'] as int, - json['authentication'] as List, - json['allow-lan'] as bool, - json['bind-address'] as String, - json['mode'] as String, - json['log-level'] as String, - json['ipv6'] as bool, - ); - -Map _$ConfigsToJson(Configs instance) => { - 'port': instance.port, - 'socks-port': instance.socksPort, - 'redir-port': instance.redirPort, - 'tproxy-port': instance.tproxyPort, - 'mixed-port': instance.mixedPort, - 'authentication': instance.authentication, - 'allow-lan': instance.allowLan, - 'bind-address': instance.bindAddress, - 'mode': instance.mode, - 'log-level': instance.logLevel, - 'ipv6': instance.ipv6, - }; diff --git a/lib/models/login_resp.dart b/lib/models/login_resp.dart new file mode 100644 index 0000000..749e70c --- /dev/null +++ b/lib/models/login_resp.dart @@ -0,0 +1,27 @@ +import 'package:json_annotation/json_annotation.dart'; + +/// This allows the `User` class to access private members in +/// the generated file. The value for this is *.g.dart, where +/// the star denotes the source file name. +part 'login_resp.g.dart'; + +/// An annotation for the code generator to know that this class needs the +/// JSON serialization logic to be generated. +@JsonSerializable() +class LoginResp { + LoginResp(this.token, this.msg); + + String token; + String msg; + + /// A necessary factory constructor for creating a new Configs instance + /// from a map. Pass the map to the generated `_$ConfigsFromJson()` constructor. + /// The constructor is named after the source class, in this case, Configs. + factory LoginResp.fromJson(Map json) => + _$LoginRespFromJson(json); + + /// `toJson` is the convention for a class to declare support for serialization + /// to JSON. The implementation simply calls the private, generated + /// helper method `_$LoginRespToJson`. + Map toJson() => _$LoginRespToJson(this); +} diff --git a/lib/models/login_resp.g.dart b/lib/models/login_resp.g.dart new file mode 100644 index 0000000..eed6250 --- /dev/null +++ b/lib/models/login_resp.g.dart @@ -0,0 +1,17 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'login_resp.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +LoginResp _$LoginRespFromJson(Map json) => LoginResp( + json['token'] as String, + json['msg'] as String, + ); + +Map _$LoginRespToJson(LoginResp instance) => { + 'token': instance.token, + 'msg': instance.msg, + }; diff --git a/lib/provider/token.dart b/lib/provider/token.dart index 4a03f0a..942b27e 100644 --- a/lib/provider/token.dart +++ b/lib/provider/token.dart @@ -1,4 +1,5 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class TokenNotifier extends Notifier { @override @@ -8,6 +9,16 @@ class TokenNotifier extends Notifier { setToken(String token) { state = token; + SharedPreferences.getInstance().then((prefs) { + prefs.setString("token", token); + }); + } + + removeToken() { + state = ''; + SharedPreferences.getInstance().then((prefs) { + prefs.setString("token", ""); + }); } } diff --git a/lib/request/http_client.dart b/lib/request/http_client.dart new file mode 100644 index 0000000..946b3e8 --- /dev/null +++ b/lib/request/http_client.dart @@ -0,0 +1,11 @@ +import 'package:http/http.dart' as http; + +class HttpClient { + HttpClient(this.header); + + Map? header; + + Future post(Uri url) { + return http.post(url); + } +} diff --git a/lib/screens/login.dart b/lib/screens/login.dart deleted file mode 100644 index aa2f49c..0000000 --- a/lib/screens/login.dart +++ /dev/null @@ -1,15 +0,0 @@ -import 'package:fluent_ui/fluent_ui.dart'; - -class Login extends StatefulWidget { - const Login({Key? key}) : super(key: key); - - @override - State createState() => _LoginState(); -} - -class _LoginState extends State { - @override - Widget build(BuildContext context) { - return const Placeholder(); - } -} diff --git a/lib/screens/profile.dart b/lib/screens/profile.dart deleted file mode 100644 index e69de29..0000000 diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index e71a16d..35b7e69 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -6,6 +6,18 @@ #include "generated_plugin_registrant.h" +#include +#include +#include void fl_register_plugins(FlPluginRegistry* registry) { + g_autoptr(FlPluginRegistrar) screen_retriever_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin"); + screen_retriever_plugin_register_with_registrar(screen_retriever_registrar); + g_autoptr(FlPluginRegistrar) tray_manager_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "TrayManagerPlugin"); + tray_manager_plugin_register_with_registrar(tray_manager_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); } diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 2e1de87..256ffa4 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -3,6 +3,9 @@ # list(APPEND FLUTTER_PLUGIN_LIST + screen_retriever + tray_manager + window_manager ) list(APPEND FLUTTER_FFI_PLUGIN_LIST diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 724bb2a..43ea430 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,8 +5,14 @@ import FlutterMacOS import Foundation +import screen_retriever import shared_preferences_foundation +import tray_manager +import window_manager func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) + TrayManagerPlugin.register(with: registry.registrar(forPlugin: "TrayManagerPlugin")) + WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index c5cc2d3..aafbe89 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -437,6 +437,14 @@ packages: url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" source: hosted version: "0.2.0" + menu_base: + dependency: transitive + description: + name: menu_base + sha256: "820368014a171bd1241030278e6c2617354f492f5c703d7b7d4570a6b8b84405" + url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" + source: hosted + version: "0.1.1" meta: dependency: transitive description: @@ -581,6 +589,14 @@ packages: url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" source: hosted version: "2.1.3" + screen_retriever: + dependency: transitive + description: + name: screen_retriever + sha256: "4931f226ca158123ccd765325e9fbf360bfed0af9b460a10f960f9bb13d58323" + url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" + source: hosted + version: "0.1.6" scroll_pos: dependency: transitive description: @@ -661,6 +677,14 @@ packages: url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" source: hosted version: "1.0.3" + shortid: + dependency: transitive + description: + name: shortid + sha256: d0b40e3dbb50497dad107e19c54ca7de0d1a274eb9b4404991e443dadb9ebedb + url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" + source: hosted + version: "0.1.2" sky_engine: dependency: transitive description: flutter @@ -754,6 +778,14 @@ packages: url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" source: hosted version: "1.0.1" + tray_manager: + dependency: "direct main" + description: + name: tray_manager + sha256: b1975a05e0c6999e983cf9a58a6a098318c896040ccebac5398a3cc9e43b9c69 + url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" + source: hosted + version: "0.2.0" typed_data: dependency: transitive description: @@ -794,6 +826,14 @@ packages: url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" source: hosted version: "3.1.3" + window_manager: + dependency: "direct main" + description: + name: window_manager + sha256: "5bdd29dc5f1f3185fc90696373a571d77968e03e5e820fb1ecdbdade3f5d8fff" + url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" + source: hosted + version: "0.3.0" xdg_directories: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index ff97313..2eb196f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -44,6 +44,8 @@ dependencies: flutter_launcher_icons: ^0.11.0 shared_preferences: ^2.0.17 flutter_riverpod: ^2.1.3 + window_manager: ^0.3.0 + tray_manager: ^0.2.0 dev_dependencies: flutter_test: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 8b6d468..08f146e 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,6 +6,15 @@ #include "generated_plugin_registrant.h" +#include +#include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { + ScreenRetrieverPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("ScreenRetrieverPlugin")); + TrayManagerPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("TrayManagerPlugin")); + WindowManagerPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("WindowManagerPlugin")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index b93c4c3..4a31ae7 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,6 +3,9 @@ # list(APPEND FLUTTER_PLUGIN_LIST + screen_retriever + tray_manager + window_manager ) list(APPEND FLUTTER_FFI_PLUGIN_LIST