From 38f57584b64fd3303041778e0955a179c7571242 Mon Sep 17 00:00:00 2001 From: wgh19 Date: Fri, 17 May 2024 09:43:00 +0800 Subject: [PATCH] improve ui --- lib/components/md.dart | 3 + lib/main.dart | 17 +++- lib/network/models.dart | 4 +- lib/pages/illust_page.dart | 7 +- lib/pages/main_page.dart | 162 +++++++++++++++++------------------ lib/pages/settings_page.dart | 2 +- 6 files changed, 105 insertions(+), 90 deletions(-) diff --git a/lib/components/md.dart b/lib/components/md.dart index 34147d4..fe12845 100644 --- a/lib/components/md.dart +++ b/lib/components/md.dart @@ -1,6 +1,9 @@ import 'package:flutter/material.dart' as md; typedef MdIcons = md.Icons; +typedef MdTheme = md.Theme; +typedef MdThemeData = md.ThemeData; +typedef MdColorScheme = md.ColorScheme; class ColorScheme { static md.ColorScheme of(md.BuildContext context) { diff --git a/lib/main.dart b/lib/main.dart index 4bd853d..3e89003 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -3,6 +3,7 @@ import "dart:ui"; import "package:fluent_ui/fluent_ui.dart"; import "package:flutter/services.dart"; import "package:pixes/appdata.dart"; +import "package:pixes/components/md.dart"; import "package:pixes/components/message.dart"; import "package:pixes/foundation/app.dart"; import "package:pixes/foundation/log.dart"; @@ -99,7 +100,21 @@ class MyApp extends StatelessWidget { throw "widget is null"; } - return OverlayWidget(child); + return MdTheme( + data: MdThemeData.from( + colorScheme: MdColorScheme.fromSeed( + seedColor: FluentTheme.of(context).accentColor, + brightness: FluentTheme.of(context).brightness, + ), + useMaterial3: true + ), + child: DefaultTextStyle.merge( + style: TextStyle( + fontFamily: App.isWindows ? 'font' : null, + ), + child: OverlayWidget(child), + ), + ); }), ); }); diff --git a/lib/network/models.dart b/lib/network/models.dart index 3e42d59..d0b784c 100644 --- a/lib/network/models.dart +++ b/lib/network/models.dart @@ -173,7 +173,7 @@ class Illust { final int restrict; final IllustAuthor author; final List tags; - final String createDate; + final DateTime createDate; final int pageCount; final int width; final int height; @@ -220,7 +220,7 @@ class Illust { tags = (json['tags'] as List) .map((e) => Tag(e['name'], e['translated_name'])) .toList(), - createDate = json['create_date'], + createDate = DateTime.parse(json['create_date']), pageCount = json['page_count'], width = json['width'], height = json['height'], diff --git a/lib/pages/illust_page.dart b/lib/pages/illust_page.dart index 7843425..8795b28 100644 --- a/lib/pages/illust_page.dart +++ b/lib/pages/illust_page.dart @@ -314,7 +314,12 @@ class _BottomBarState extends State<_BottomBar> with TickerProviderStateMixin{ buildStats(), buildTags(), buildMoreActions(), - SelectableText("${"Artwork ID".tl}: ${widget.illust.id}\n${"Artist ID".tl}: ${widget.illust.author.id}", style: TextStyle(color: ColorScheme.of(context).outline),).paddingLeft(4), + SelectableText( + "${"Artwork ID".tl}: ${widget.illust.id}\n" + "${"Artist ID".tl}: ${widget.illust.author.id}\n" + "${widget.illust.createDate.toString().split('.').first}", + style: TextStyle(color: ColorScheme.of(context).outline),) + .paddingLeft(4), SizedBox(height: 8 + context.padding.bottom,) ], ), diff --git a/lib/pages/main_page.dart b/lib/pages/main_page.dart index 7c81a57..ff8864f 100644 --- a/lib/pages/main_page.dart +++ b/lib/pages/main_page.dart @@ -2,7 +2,6 @@ import "dart:async"; import "package:fluent_ui/fluent_ui.dart"; import "package:flutter/foundation.dart"; -import "package:flutter/material.dart" as md; import "package:pixes/appdata.dart"; import "package:pixes/components/md.dart"; import "package:pixes/foundation/app.dart"; @@ -79,91 +78,84 @@ class _MainPageState extends State with WindowListener { content: LoginPage(() => setState(() {})), ); } - return md.Theme( - data: md.ThemeData.from( - useMaterial3: true, - colorScheme: md.ColorScheme.fromSeed( - seedColor: FluentTheme.of(context).accentColor.withOpacity(1), - brightness: FluentTheme.of(context).brightness, - )), - child: DefaultSelectionStyle.merge( - selectionColor: FluentTheme.of(context).selectionColor.withOpacity(0.4), - child: NavigationView( - appBar: buildAppBar(context, navigatorKey), - pane: NavigationPane( - selected: index, - onChanged: (value) { - setState(() { - index = value; - }); - navigate(value); - }, - items: [ - UserPane(), - PaneItem( - icon: const Icon(MdIcons.search, size: 20,), - title: Text('Search'.tl), - body: const SizedBox.shrink(), - ), - PaneItem( - icon: const Icon(MdIcons.downloading, size: 20,), - title: Text('Downloading'.tl), - body: const SizedBox.shrink(), - ), - PaneItem( - icon: const Icon(MdIcons.download, size: 20,), - title: Text('Downloaded'.tl), - body: const SizedBox.shrink(), - ), - PaneItemSeparator(), - PaneItemHeader(header: Text("Artwork".tl).paddingBottom(4).paddingLeft(8)), - PaneItem( - icon: const Icon(MdIcons.explore_outlined, size: 20,), - title: Text('Explore'.tl), - body: const SizedBox.shrink(), - ), - PaneItem( - icon: const Icon(MdIcons.bookmark_outline, size: 20), - title: Text('Bookmarks'.tl), - body: const SizedBox.shrink(), - ), - PaneItem( - icon: const Icon(MdIcons.interests_outlined, size: 20), - title: Text('Following'.tl), - body: const SizedBox.shrink(), - ), - PaneItem( - icon: const Icon(MdIcons.history, size: 20), - title: Text('History'.tl), - body: const SizedBox.shrink(), - ), - PaneItem( - icon: const Icon(MdIcons.leaderboard_outlined, size: 20), - title: Text('Ranking'.tl), - body: const SizedBox.shrink(), - ), - ], - footerItems: [ - PaneItem( - icon: const Icon(MdIcons.settings_outlined, size: 20), - title: Text('Settings'.tl), - body: const SizedBox.shrink(), - ), - ], + return DefaultSelectionStyle.merge( + selectionColor: FluentTheme.of(context).selectionColor.withOpacity(0.4), + child: NavigationView( + appBar: buildAppBar(context, navigatorKey), + pane: NavigationPane( + selected: index, + onChanged: (value) { + setState(() { + index = value; + }); + navigate(value); + }, + items: [ + UserPane(), + PaneItem( + icon: const Icon(MdIcons.search, size: 20,), + title: Text('Search'.tl), + body: const SizedBox.shrink(), ), - paneBodyBuilder: (pane, child) => NavigatorPopHandler( - key: const Key("navigator"), - onPop: () => navigatorKey.currentState?.pop(), - child: MediaQuery.removePadding( - context: context, - removeTop: true, - child: Navigator( - key: navigatorKey, - onGenerateRoute: (settings) => AppPageRoute( - builder: (context) => const RecommendationPage()), - ), - ))), - )); + PaneItem( + icon: const Icon(MdIcons.downloading, size: 20,), + title: Text('Downloading'.tl), + body: const SizedBox.shrink(), + ), + PaneItem( + icon: const Icon(MdIcons.download, size: 20,), + title: Text('Downloaded'.tl), + body: const SizedBox.shrink(), + ), + PaneItemSeparator(), + PaneItemHeader(header: Text("Artwork".tl).paddingBottom(4).paddingLeft(8)), + PaneItem( + icon: const Icon(MdIcons.explore_outlined, size: 20,), + title: Text('Explore'.tl), + body: const SizedBox.shrink(), + ), + PaneItem( + icon: const Icon(MdIcons.bookmark_outline, size: 20), + title: Text('Bookmarks'.tl), + body: const SizedBox.shrink(), + ), + PaneItem( + icon: const Icon(MdIcons.interests_outlined, size: 20), + title: Text('Following'.tl), + body: const SizedBox.shrink(), + ), + PaneItem( + icon: const Icon(MdIcons.history, size: 20), + title: Text('History'.tl), + body: const SizedBox.shrink(), + ), + PaneItem( + icon: const Icon(MdIcons.leaderboard_outlined, size: 20), + title: Text('Ranking'.tl), + body: const SizedBox.shrink(), + ), + ], + footerItems: [ + PaneItem( + icon: const Icon(MdIcons.settings_outlined, size: 20), + title: Text('Settings'.tl), + body: const SizedBox.shrink(), + ), + ], + ), + paneBodyBuilder: (pane, child) => NavigatorPopHandler( + key: const Key("navigator"), + onPop: () => navigatorKey.currentState?.pop(), + child: MediaQuery.removePadding( + context: context, + removeTop: true, + child: Navigator( + key: navigatorKey, + onGenerateRoute: (settings) => AppPageRoute( + builder: (context) => const RecommendationPage()), + ), + ))), + ); } static final pageBuilders = [ diff --git a/lib/pages/settings_page.dart b/lib/pages/settings_page.dart index 81bdbfb..ec266ed 100644 --- a/lib/pages/settings_page.dart +++ b/lib/pages/settings_page.dart @@ -410,7 +410,7 @@ ${"Some keywords will be replaced by the following rule:".tl} \${index} -> ${"Index of the image in the artwork".tl} \${ext} -> ${"File extension".tl} \${AI} -> ${"Replace with 'AI' if the work was generated by AI, otherwise replace with blank".tl} - \${tag{*}} -> ${"Replace with * if the work have tag *, otherwise replace with blank.".tl} + \${tag(*)} -> ${"Replace with * if the work have tag *, otherwise replace with blank.".tl} ${"Multiple path separators will be automatically replaced with a single".tl} """;