improve ui

This commit is contained in:
wgh19
2024-05-17 09:43:00 +08:00
parent 8ff269c8a8
commit 38f57584b6
6 changed files with 105 additions and 90 deletions

View File

@@ -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) {

View File

@@ -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),
),
);
}),
);
});

View File

@@ -173,7 +173,7 @@ class Illust {
final int restrict;
final IllustAuthor author;
final List<Tag> 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'],

View File

@@ -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,)
],
),

View File

@@ -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<MainPage> 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 = <Widget Function()>[

View File

@@ -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}
""";