From cbc0fec0cc84ad7115fc30ea6320809d20658573 Mon Sep 17 00:00:00 2001 From: yuanzui-cf Date: Tue, 13 Aug 2024 12:42:46 +0800 Subject: [PATCH 01/22] fix: Window minimum size --- lib/main.dart | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index f45ffe2..4a1f97d 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:grassh_renew/src/ui/main.dart'; import 'package:grassh_renew/src/util/platform.dart'; +import 'package:grassh_renew/src/util/screen.dart'; import 'package:window_manager/window_manager.dart'; void main() async { @@ -10,9 +11,10 @@ void main() async { if (PlatformUtil.isPC) { await windowManager.ensureInitialized(); - WindowOptions windowOptions = const WindowOptions( - size: Size(1000, 800), - minimumSize: Size(1000, 800), + WindowOptions windowOptions = WindowOptions( + size: Size(1000, ScreenUtil.height < 800 ? ScreenUtil.height : 800), + minimumSize: + Size(1000, ScreenUtil.height < 800 ? ScreenUtil.height : 800), center: true, backgroundColor: Colors.transparent, skipTaskbar: false, From fa7205ac961c77f9b4d996f3cc2270fa2d6324ed Mon Sep 17 00:00:00 2001 From: yuanzui-cf Date: Tue, 13 Aug 2024 13:03:53 +0800 Subject: [PATCH 02/22] feat: Initial sidebar component --- lib/src/ui/component/sidebar/main.dart | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 lib/src/ui/component/sidebar/main.dart diff --git a/lib/src/ui/component/sidebar/main.dart b/lib/src/ui/component/sidebar/main.dart new file mode 100644 index 0000000..b9b068c --- /dev/null +++ b/lib/src/ui/component/sidebar/main.dart @@ -0,0 +1,16 @@ +import 'package:flutter/material.dart'; + +class SideBar extends StatelessWidget { + final Widget? child; + const SideBar({ + super.key, + this.child, + }); + + @override + Widget build(BuildContext context) { + return Container( + width: 50, + ); + } +} From 9283229f59838c18cbc12788ba78fbd739f8663f Mon Sep 17 00:00:00 2001 From: yuanzui-cf Date: Thu, 15 Aug 2024 11:26:42 +0800 Subject: [PATCH 03/22] feat: Add sidebar component --- lib/src/ui/component/sidebar/main.dart | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/src/ui/component/sidebar/main.dart b/lib/src/ui/component/sidebar/main.dart index b9b068c..f9f6de8 100644 --- a/lib/src/ui/component/sidebar/main.dart +++ b/lib/src/ui/component/sidebar/main.dart @@ -2,15 +2,22 @@ import 'package:flutter/material.dart'; class SideBar extends StatelessWidget { final Widget? child; + final double width; const SideBar({ super.key, + required this.width, this.child, }); @override Widget build(BuildContext context) { - return Container( - width: 50, + return AnimatedContainer( + duration: const Duration(milliseconds: 300), + curve: Curves.fastEaseInToSlowEaseOut, + width: width, + child: Center( + child: child, + ), ); } } From e28678bae626d28850abca91e39f778405a346ef Mon Sep 17 00:00:00 2001 From: yuanzui-cf Date: Thu, 15 Aug 2024 11:26:56 +0800 Subject: [PATCH 04/22] feat: Add SideBarTab component --- lib/src/ui/component/sidebar/tab.dart | 59 +++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 lib/src/ui/component/sidebar/tab.dart diff --git a/lib/src/ui/component/sidebar/tab.dart b/lib/src/ui/component/sidebar/tab.dart new file mode 100644 index 0000000..7a0d515 --- /dev/null +++ b/lib/src/ui/component/sidebar/tab.dart @@ -0,0 +1,59 @@ +import 'package:flutter/material.dart'; + +class SideBarTab extends StatefulWidget { + final void Function()? callback; + final IconData? icon; + final String? text; + + const SideBarTab({super.key, this.callback, this.icon, this.text}); + + @override + State createState() => _SideBarTabState(); +} + +class _SideBarTabState extends State { + bool _isHover = false; + + @override + Widget build(BuildContext context) { + return Center( + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 5), + child: GestureDetector( + onTap: () { + widget.callback?.call(); + }, + child: MouseRegion( + cursor: SystemMouseCursors.click, + onEnter: (e) { + _isHover = true; + setState(() {}); + }, + onExit: (e) { + _isHover = false; + setState(() {}); + }, + child: AnimatedContainer( + duration: const Duration(milliseconds: 100), + curve: Curves.easeInOut, + width: MediaQuery.of(context).size.width, + height: 30, + decoration: BoxDecoration( + color: _isHover ? Theme.of(context).highlightColor : null, + borderRadius: BorderRadius.circular(5), + ), + child: Row( + children: [ + Icon( + widget.icon, + size: 10, + ) + ], + ), + ), + ), + ), + ), + ); + } +} From c514c971f81d1944f2c05e9f5c464488ff791756 Mon Sep 17 00:00:00 2001 From: yuanzui-cf Date: Thu, 15 Aug 2024 11:27:23 +0800 Subject: [PATCH 05/22] feat: Add left SideBar --- lib/src/ui/component/sidebar/left.dart | 53 ++++++++++++++++++++++++++ lib/src/ui/main.dart | 13 +++++-- 2 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 lib/src/ui/component/sidebar/left.dart diff --git a/lib/src/ui/component/sidebar/left.dart b/lib/src/ui/component/sidebar/left.dart new file mode 100644 index 0000000..e618e0b --- /dev/null +++ b/lib/src/ui/component/sidebar/left.dart @@ -0,0 +1,53 @@ +import 'package:flutter/material.dart'; +import 'package:grassh_renew/src/ui/component/sidebar/main.dart'; +import 'package:grassh_renew/src/ui/component/sidebar/tab.dart'; + +class LeftSideBar extends StatefulWidget { + final LeftSideBarController controller; + const LeftSideBar({super.key, required this.controller}); + + @override + State createState() => _LeftSideBarState(); +} + +class _LeftSideBarState extends State { + @override + Widget build(BuildContext context) { + return SideBar( + width: widget.controller.isOpen ? 150 : 40, + child: Column( + children: [ + SideBarTab( + callback: () { + widget.controller.switchState(); + setState(() {}); + }, + ), + ], + ), + ); + } +} + +class LeftSideBarController { + final void Function()? callback; + + LeftSideBarController({this.callback}); + + bool _open = false; + bool get isOpen => _open; + + open() { + _open = true; + callback?.call(); + } + + close() { + _open = false; + callback?.call(); + } + + switchState() { + _open ? close() : open(); + } +} diff --git a/lib/src/ui/main.dart b/lib/src/ui/main.dart index a5e1173..6a3ab63 100644 --- a/lib/src/ui/main.dart +++ b/lib/src/ui/main.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:grassh_renew/src/ui/component/sidebar/left.dart'; import 'component/appbar/main.dart' as bar; class MainPage extends StatefulWidget { @@ -11,9 +12,15 @@ class MainPage extends StatefulWidget { class _MainPageState extends State { @override Widget build(BuildContext context) { - return const Scaffold( - appBar: bar.AppBar(), - body: Row(), + return Scaffold( + appBar: const bar.AppBar(), + body: Row( + children: [ + LeftSideBar( + controller: LeftSideBarController(), + ), + ], + ), ); } } From 3b02215bee6dda20a412b4d2828b49786de85156 Mon Sep 17 00:00:00 2001 From: yuanzui-cf Date: Thu, 15 Aug 2024 12:21:49 +0800 Subject: [PATCH 06/22] style: Rename switchState function to switchSidebar --- lib/src/ui/component/sidebar/left.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/ui/component/sidebar/left.dart b/lib/src/ui/component/sidebar/left.dart index e618e0b..6627365 100644 --- a/lib/src/ui/component/sidebar/left.dart +++ b/lib/src/ui/component/sidebar/left.dart @@ -19,7 +19,7 @@ class _LeftSideBarState extends State { children: [ SideBarTab( callback: () { - widget.controller.switchState(); + widget.controller.switchSidebar(); setState(() {}); }, ), @@ -47,7 +47,7 @@ class LeftSideBarController { callback?.call(); } - switchState() { + switchSidebar() { _open ? close() : open(); } } From 7b1ab2547bc76059f5f42df4ce92c0a1e3de004d Mon Sep 17 00:00:00 2001 From: yuanzui-cf Date: Thu, 15 Aug 2024 13:11:17 +0800 Subject: [PATCH 07/22] feat: Add icon and text on Tab component --- lib/src/ui/component/sidebar/tab.dart | 34 +++++++++++++++++++++------ 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/lib/src/ui/component/sidebar/tab.dart b/lib/src/ui/component/sidebar/tab.dart index 7a0d515..cc9b696 100644 --- a/lib/src/ui/component/sidebar/tab.dart +++ b/lib/src/ui/component/sidebar/tab.dart @@ -42,13 +42,33 @@ class _SideBarTabState extends State { color: _isHover ? Theme.of(context).highlightColor : null, borderRadius: BorderRadius.circular(5), ), - child: Row( - children: [ - Icon( - widget.icon, - size: 10, - ) - ], + child: Padding( + padding: EdgeInsets.all(8), + child: ClipRect( + child: Stack( + alignment: Alignment.centerLeft, + children: [ + Icon( + widget.icon, + size: 14, + ), + Positioned( + left: 20, + child: Container( + constraints: const BoxConstraints(maxWidth: 104), + child: Text( + widget.text ?? "", + softWrap: false, + style: const TextStyle( + fontSize: 12, + overflow: TextOverflow.fade, + ), + ), + ), + ), + ], + ), + ), ), ), ), From f56c7c00ce0c2ac3ed9f73966c2b79d4506cc515 Mon Sep 17 00:00:00 2001 From: yuanzui-cf Date: Thu, 15 Aug 2024 13:11:31 +0800 Subject: [PATCH 08/22] feat: Add menu icon --- lib/src/ui/icons/codicon.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/src/ui/icons/codicon.dart b/lib/src/ui/icons/codicon.dart index 62dd279..59084a3 100644 --- a/lib/src/ui/icons/codicon.dart +++ b/lib/src/ui/icons/codicon.dart @@ -48,4 +48,10 @@ class Codicon { fontFamily: "Codicon", matchTextDirection: true, ); + + static const IconData menu = IconData( + 0xeb94, + fontFamily: "Codicon", + matchTextDirection: true, + ); } From 410412e353ef28f5f3cd9040d4720eaa69aa3180 Mon Sep 17 00:00:00 2001 From: yuanzui-cf Date: Thu, 15 Aug 2024 13:12:00 +0800 Subject: [PATCH 09/22] feat: Add menu icon & text on LeftSideBar --- lib/src/ui/component/sidebar/left.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/src/ui/component/sidebar/left.dart b/lib/src/ui/component/sidebar/left.dart index 6627365..e508fd2 100644 --- a/lib/src/ui/component/sidebar/left.dart +++ b/lib/src/ui/component/sidebar/left.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:grassh_renew/src/ui/component/sidebar/main.dart'; import 'package:grassh_renew/src/ui/component/sidebar/tab.dart'; +import 'package:grassh_renew/src/ui/icons/codicon.dart'; class LeftSideBar extends StatefulWidget { final LeftSideBarController controller; @@ -18,6 +19,8 @@ class _LeftSideBarState extends State { child: Column( children: [ SideBarTab( + icon: Codicon.menu, + text: "Menu", callback: () { widget.controller.switchSidebar(); setState(() {}); From 989551da8e615a1aaaa0eb2db48a88c1996bf50c Mon Sep 17 00:00:00 2001 From: yuanzui-cf Date: Thu, 15 Aug 2024 14:22:02 +0800 Subject: [PATCH 10/22] feat: Add "Add terminal" button --- lib/src/ui/component/sidebar/left.dart | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/src/ui/component/sidebar/left.dart b/lib/src/ui/component/sidebar/left.dart index e508fd2..c1a80c3 100644 --- a/lib/src/ui/component/sidebar/left.dart +++ b/lib/src/ui/component/sidebar/left.dart @@ -26,6 +26,18 @@ class _LeftSideBarState extends State { setState(() {}); }, ), + // TODO: Terminal Tabs + // ListView.builder( + // itemCount: 0, + // itemBuilder: (ctx, index) { + // return Tab(); + // }, + // ), + SideBarTab( + icon: Codicon.add, + text: "Add Terminal", + callback: () {}, + ), ], ), ); From 6903c256b6336ca7b91d1be5ec57d3da06ab254b Mon Sep 17 00:00:00 2001 From: yuanzui-cf Date: Thu, 15 Aug 2024 14:22:31 +0800 Subject: [PATCH 11/22] feat: Add add icon --- lib/src/ui/icons/codicon.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/src/ui/icons/codicon.dart b/lib/src/ui/icons/codicon.dart index 59084a3..d12195f 100644 --- a/lib/src/ui/icons/codicon.dart +++ b/lib/src/ui/icons/codicon.dart @@ -54,4 +54,10 @@ class Codicon { fontFamily: "Codicon", matchTextDirection: true, ); + + static const IconData add = IconData( + 0xea60, + fontFamily: "Codicon", + matchTextDirection: true, + ); } From 7ed6e5df70f866a4c11eeb03d9eb813101273781 Mon Sep 17 00:00:00 2001 From: yuanzui-cf Date: Thu, 15 Aug 2024 14:25:07 +0800 Subject: [PATCH 12/22] fix: Tab style fine-tunning --- lib/src/ui/component/sidebar/tab.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/ui/component/sidebar/tab.dart b/lib/src/ui/component/sidebar/tab.dart index cc9b696..ef33447 100644 --- a/lib/src/ui/component/sidebar/tab.dart +++ b/lib/src/ui/component/sidebar/tab.dart @@ -18,7 +18,7 @@ class _SideBarTabState extends State { Widget build(BuildContext context) { return Center( child: Padding( - padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 5), + padding: const EdgeInsets.symmetric(vertical: 5, horizontal: 5), child: GestureDetector( onTap: () { widget.callback?.call(); From 2f1f1ba6750e69232fe5645368dd472bfd703bd9 Mon Sep 17 00:00:00 2001 From: yuanzui-cf Date: Thu, 15 Aug 2024 18:55:47 +0800 Subject: [PATCH 13/22] refactor: Optimize performance --- lib/src/ui/component/sidebar/tab.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/ui/component/sidebar/tab.dart b/lib/src/ui/component/sidebar/tab.dart index ef33447..629ac3d 100644 --- a/lib/src/ui/component/sidebar/tab.dart +++ b/lib/src/ui/component/sidebar/tab.dart @@ -43,7 +43,7 @@ class _SideBarTabState extends State { borderRadius: BorderRadius.circular(5), ), child: Padding( - padding: EdgeInsets.all(8), + padding: const EdgeInsets.all(8), child: ClipRect( child: Stack( alignment: Alignment.centerLeft, From 20d7e020e62199a0f1877d81d0049879e8dddf28 Mon Sep 17 00:00:00 2001 From: yuanzui-cf Date: Thu, 15 Aug 2024 18:56:18 +0800 Subject: [PATCH 14/22] feat: Add background color to SideBar --- lib/src/ui/component/sidebar/main.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/src/ui/component/sidebar/main.dart b/lib/src/ui/component/sidebar/main.dart index f9f6de8..c30cb11 100644 --- a/lib/src/ui/component/sidebar/main.dart +++ b/lib/src/ui/component/sidebar/main.dart @@ -16,7 +16,10 @@ class SideBar extends StatelessWidget { curve: Curves.fastEaseInToSlowEaseOut, width: width, child: Center( - child: child, + child: Container( + color: Theme.of(context).cardColor, + child: child, + ), ), ); } From d06a51d0a3d8d1d9191152ba86b9cd5550d95f8e Mon Sep 17 00:00:00 2001 From: yuanzui-cf Date: Thu, 15 Aug 2024 18:56:45 +0800 Subject: [PATCH 15/22] feat: Initial layout --- lib/src/ui/main.dart | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/src/ui/main.dart b/lib/src/ui/main.dart index 6a3ab63..b915acc 100644 --- a/lib/src/ui/main.dart +++ b/lib/src/ui/main.dart @@ -14,12 +14,19 @@ class _MainPageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: const bar.AppBar(), - body: Row( - children: [ - LeftSideBar( - controller: LeftSideBarController(), - ), - ], + body: SizedBox( + width: MediaQuery.of(context).size.width, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + LeftSideBar( + controller: LeftSideBarController(), + ), + Expanded( + child: Container(), + ) + ], + ), ), ); } From 694387d9dfdc35321933a3dfbde327866f0b9631 Mon Sep 17 00:00:00 2001 From: yuanzui-cf Date: Fri, 16 Aug 2024 12:54:15 +0800 Subject: [PATCH 16/22] fix: Remove left bar button on top bar --- lib/src/ui/component/appbar/action_button.dart | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lib/src/ui/component/appbar/action_button.dart b/lib/src/ui/component/appbar/action_button.dart index 3298192..25fd079 100644 --- a/lib/src/ui/component/appbar/action_button.dart +++ b/lib/src/ui/component/appbar/action_button.dart @@ -17,16 +17,6 @@ class _ActionButtonState extends State { Widget build(BuildContext context) { return Row( children: [ - Button( - icon: - isSidebarLeftOpen ? Codicon.sidebarLeft : Codicon.sidebarLeftOff, - callback: () { - setState(() { - isSidebarLeftOpen = !isSidebarLeftOpen; - }); - }, - ), - const SizedBox(width: 5), Button( icon: isSidebarRightOpen ? Codicon.sidebarRight From ca9eaff0a981261fde350763e17b0d4ae8c070c8 Mon Sep 17 00:00:00 2001 From: yuanzui-cf Date: Fri, 16 Aug 2024 12:57:17 +0800 Subject: [PATCH 17/22] fix: Left bar style fine-tunning --- lib/src/ui/component/sidebar/left.dart | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/src/ui/component/sidebar/left.dart b/lib/src/ui/component/sidebar/left.dart index c1a80c3..2eaaac1 100644 --- a/lib/src/ui/component/sidebar/left.dart +++ b/lib/src/ui/component/sidebar/left.dart @@ -27,12 +27,15 @@ class _LeftSideBarState extends State { }, ), // TODO: Terminal Tabs - // ListView.builder( - // itemCount: 0, - // itemBuilder: (ctx, index) { - // return Tab(); - // }, + // Expanded( + // child: ListView.builder( + // itemCount: 0, + // itemBuilder: (ctx, index) { + // return Tab(); + // }, + // ), // ), + Expanded(child: Container()), SideBarTab( icon: Codicon.add, text: "Add Terminal", From 2c80f6880db3da5c0974ebead1b21151730ae338 Mon Sep 17 00:00:00 2001 From: yuanzui-cf Date: Fri, 16 Aug 2024 13:12:07 +0800 Subject: [PATCH 18/22] chore: Update package --- macos/Flutter/GeneratedPluginRegistrant.swift | 2 + pubspec.lock | 93 +++++++++++++++++++ pubspec.yaml | 2 + 3 files changed, 97 insertions(+) diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index b622947..23ec071 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,10 +5,12 @@ import FlutterMacOS import Foundation +import package_info_plus import screen_retriever import window_manager func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { + FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin")) WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index 847bee4..76092cb 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -49,6 +49,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6" + url: "https://pub.dev" + source: hosted + version: "2.1.3" flutter: dependency: "direct main" description: flutter @@ -67,6 +75,27 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + http: + dependency: transitive + description: + name: http + sha256: b9c29a161230ee03d3ccf545097fccd9b87a5264228c5d348202e0f0c28f9010 + url: "https://pub.dev" + source: hosted + version: "1.2.2" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" leak_tracker: dependency: transitive description: @@ -123,6 +152,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.12.0" + package_info_plus: + dependency: "direct main" + description: + name: package_info_plus + sha256: a75164ade98cb7d24cfd0a13c6408927c6b217fa60dee5a7ff5c116a58f28918 + url: "https://pub.dev" + source: hosted + version: "8.0.2" + package_info_plus_platform_interface: + dependency: transitive + description: + name: package_info_plus_platform_interface + sha256: ac1f4a4847f1ade8e6a87d1f39f5d7c67490738642e2542f559ec38c37489a66 + url: "https://pub.dev" + source: hosted + version: "3.0.1" path: dependency: transitive description: @@ -131,6 +176,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.0" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 + url: "https://pub.dev" + source: hosted + version: "6.0.2" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" screen_retriever: dependency: transitive description: @@ -192,6 +253,22 @@ packages: url: "https://pub.dev" source: hosted version: "0.7.0" + toml: + dependency: "direct main" + description: + name: toml + sha256: d968d149c8bd06dc14e09ea3a140f90a3f2ba71949e7a91df4a46f3107400e71 + url: "https://pub.dev" + source: hosted + version: "0.16.0" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" + source: hosted + version: "1.3.2" vector_math: dependency: transitive description: @@ -208,6 +285,22 @@ packages: url: "https://pub.dev" source: hosted version: "14.2.1" + web: + dependency: transitive + description: + name: web + sha256: d43c1d6b787bf0afad444700ae7f4db8827f701bc61c255ac8d328c6f4d52062 + url: "https://pub.dev" + source: hosted + version: "1.0.0" + win32: + dependency: transitive + description: + name: win32 + sha256: "68d1e89a91ed61ad9c370f9f8b6effed9ae5e0ede22a270bdfa6daf79fc2290a" + url: "https://pub.dev" + source: hosted + version: "5.5.4" window_manager: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 1336336..ad87d27 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,6 +10,8 @@ environment: dependencies: flutter: sdk: flutter + package_info_plus: ^8.0.2 + toml: ^0.16.0 window_manager: ^0.4.0 dev_dependencies: From abe2988c512dfde7a4d458726a316a294ae59377 Mon Sep 17 00:00:00 2001 From: yuanzui-cf Date: Fri, 16 Aug 2024 13:12:54 +0800 Subject: [PATCH 19/22] feat: Add global config --- lib/src/config/config.dart | 56 +++++++++++++++++++++++++++++++ lib/src/config/global_config.dart | 20 +++++++++++ 2 files changed, 76 insertions(+) create mode 100644 lib/src/config/config.dart create mode 100644 lib/src/config/global_config.dart diff --git a/lib/src/config/config.dart b/lib/src/config/config.dart new file mode 100644 index 0000000..ec05164 --- /dev/null +++ b/lib/src/config/config.dart @@ -0,0 +1,56 @@ +import 'dart:io'; + +import 'package:toml/toml.dart'; + +class Config { + late Map conf; + String path; + + Config({ + required this.path, + required Map defaultConfig, + }) { + conf = defaultConfig; + init(path, defaultConfig); + } + + init(String path, Map defaultConfig) { + var f = File(path); + _configFileCheck(f); + read(); + } + + save() { + var f = File(path); + _configFileCheck(f); + try { + var config = TomlDocument.fromMap(conf).toString(); + f.writeAsStringSync(config); + } catch (e) { + rethrow; + } + } + + read() { + var f = File(path); + _configFileCheck(f); + var ctx = f.readAsStringSync(); + try { + conf = TomlDocument.parse(ctx).toMap(); + } catch (e) { + rethrow; + } + } + + _configFileCheck(File f) { + if (!f.existsSync()) { + f.createSync(); + try { + var config = TomlDocument.fromMap(conf).toString(); + f.writeAsStringSync(config); + } catch (e) { + rethrow; + } + } + } +} diff --git a/lib/src/config/global_config.dart b/lib/src/config/global_config.dart new file mode 100644 index 0000000..d87a526 --- /dev/null +++ b/lib/src/config/global_config.dart @@ -0,0 +1,20 @@ +import 'package:grassh_renew/src/config/config.dart'; +import 'package:package_info_plus/package_info_plus.dart'; + +class GlobalConfig { + static late PackageInfo packageInfo; + static late Config config; + + static init() async { + packageInfo = await PackageInfo.fromPlatform(); + // config = Config( + // path: "./config.toml", + // defaultConfig: { + // "version": 1, + // "global": { + // "language": "zh-CN", + // }, + // }, + // ); + } +} From 2055fb03a141140a4cf1b93cf2c775c0302b5e0e Mon Sep 17 00:00:00 2001 From: yuanzui-cf Date: Fri, 16 Aug 2024 20:07:56 +0800 Subject: [PATCH 20/22] feat: Add build info. --- lib/main.dart | 3 +++ lib/src/config/global_config.dart | 1 + lib/src/ui/main.dart | 42 +++++++++++++++++++++---------- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 4a1f97d..59f9f36 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:grassh_renew/src/config/global_config.dart'; import 'package:grassh_renew/src/ui/main.dart'; import 'package:grassh_renew/src/util/platform.dart'; import 'package:grassh_renew/src/util/screen.dart'; @@ -7,6 +8,8 @@ import 'package:window_manager/window_manager.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); + await GlobalConfig.init(); + // Initialize PC Window if (PlatformUtil.isPC) { await windowManager.ensureInitialized(); diff --git a/lib/src/config/global_config.dart b/lib/src/config/global_config.dart index d87a526..13f2436 100644 --- a/lib/src/config/global_config.dart +++ b/lib/src/config/global_config.dart @@ -7,6 +7,7 @@ class GlobalConfig { static init() async { packageInfo = await PackageInfo.fromPlatform(); + // config = Config( // path: "./config.toml", // defaultConfig: { diff --git a/lib/src/ui/main.dart b/lib/src/ui/main.dart index b915acc..5607c1d 100644 --- a/lib/src/ui/main.dart +++ b/lib/src/ui/main.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:grassh_renew/src/config/global_config.dart'; import 'package:grassh_renew/src/ui/component/sidebar/left.dart'; import 'component/appbar/main.dart' as bar; @@ -15,19 +16,34 @@ class _MainPageState extends State { return Scaffold( appBar: const bar.AppBar(), body: SizedBox( - width: MediaQuery.of(context).size.width, - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - LeftSideBar( - controller: LeftSideBarController(), - ), - Expanded( - child: Container(), - ) - ], - ), - ), + width: MediaQuery.of(context).size.width, + child: Stack( + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + LeftSideBar( + controller: LeftSideBarController(), + ), + Expanded( + child: Container(), + ) + ], + ), + Positioned( + right: 0, + bottom: 0, + child: Text( + "GrassH v${GlobalConfig.packageInfo.version}\nBuild ${GlobalConfig.packageInfo.buildNumber}. Not intended for external distribution.", + textAlign: TextAlign.end, + style: TextStyle( + fontSize: 10, + color: Theme.of(context).primaryColorLight, + ), + ), + ), + ], + )), ); } } From b5fe685c930136b2349cc021216e4107b652d7d6 Mon Sep 17 00:00:00 2001 From: yuanzui-cf Date: Fri, 16 Aug 2024 20:17:25 +0800 Subject: [PATCH 21/22] feat: add condition to showcase build information --- lib/src/ui/main.dart | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/src/ui/main.dart b/lib/src/ui/main.dart index 5607c1d..6c248ae 100644 --- a/lib/src/ui/main.dart +++ b/lib/src/ui/main.dart @@ -30,18 +30,20 @@ class _MainPageState extends State { ) ], ), - Positioned( - right: 0, - bottom: 0, - child: Text( - "GrassH v${GlobalConfig.packageInfo.version}\nBuild ${GlobalConfig.packageInfo.buildNumber}. Not intended for external distribution.", - textAlign: TextAlign.end, - style: TextStyle( - fontSize: 10, - color: Theme.of(context).primaryColorLight, - ), - ), - ), + GlobalConfig.packageInfo.buildNumber != "" + ? Positioned( + right: 0, + bottom: 0, + child: Text( + "GrassH v${GlobalConfig.packageInfo.version}\nBuild ${GlobalConfig.packageInfo.buildNumber}. Not intended for external distribution.", + textAlign: TextAlign.end, + style: TextStyle( + fontSize: 10, + color: Theme.of(context).primaryColorLight, + ), + ), + ) + : const SizedBox(), ], )), ); From 5c0ec196dabdc8767d7a8752ad42ff63af897e78 Mon Sep 17 00:00:00 2001 From: yuanzui-cf Date: Fri, 16 Aug 2024 21:20:09 +0800 Subject: [PATCH 22/22] chore: Add terminal package --- linux/flutter/generated_plugins.cmake | 1 + pubspec.lock | 48 +++++++++++++++++++++++++ pubspec.yaml | 2 ++ windows/flutter/generated_plugins.cmake | 1 + 4 files changed, 52 insertions(+) diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 913ac71..2e081d6 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -8,6 +8,7 @@ list(APPEND FLUTTER_PLUGIN_LIST ) list(APPEND FLUTTER_FFI_PLUGIN_LIST + flutter_pty ) set(PLUGIN_BUNDLED_LIBRARIES) diff --git a/pubspec.lock b/pubspec.lock index 76092cb..a14e040 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -41,6 +41,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.18.0" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + equatable: + dependency: transitive + description: + name: equatable + sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2 + url: "https://pub.dev" + source: hosted + version: "2.0.5" fake_async: dependency: transitive description: @@ -70,6 +86,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.2" + flutter_pty: + dependency: "direct main" + description: + name: flutter_pty + sha256: "08b6f37a4f394159e3a6adb6f07295e6fb6acb71270c87a4d0be187db34535cd" + url: "https://pub.dev" + source: hosted + version: "0.4.0" flutter_test: dependency: "direct dev" description: flutter @@ -192,6 +216,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.8" + quiver: + dependency: transitive + description: + name: quiver + sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47 + url: "https://pub.dev" + source: hosted + version: "3.2.1" screen_retriever: dependency: transitive description: @@ -309,6 +341,22 @@ packages: url: "https://pub.dev" source: hosted version: "0.4.0" + xterm: + dependency: "direct main" + description: + name: xterm + sha256: "168dfedca77cba33fdb6f52e2cd001e9fde216e398e89335c19b524bb22da3a2" + url: "https://pub.dev" + source: hosted + version: "4.0.0" + zmodem: + dependency: transitive + description: + name: zmodem + sha256: "3b7e5b29f3a7d8aee472029b05165a68438eff2f3f7766edf13daba1e297adbf" + url: "https://pub.dev" + source: hosted + version: "0.0.6" sdks: dart: ">=3.4.4 <4.0.0" flutter: ">=3.22.3" diff --git a/pubspec.yaml b/pubspec.yaml index ad87d27..0438a04 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,9 +10,11 @@ environment: dependencies: flutter: sdk: flutter + flutter_pty: ^0.4.0 package_info_plus: ^8.0.2 toml: ^0.16.0 window_manager: ^0.4.0 + xterm: ^4.0.0 dev_dependencies: flutter_test: diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index bfa52f4..07950b2 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -8,6 +8,7 @@ list(APPEND FLUTTER_PLUGIN_LIST ) list(APPEND FLUTTER_FFI_PLUGIN_LIST + flutter_pty ) set(PLUGIN_BUNDLED_LIBRARIES)