mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 12:57:24 +00:00
improve ui
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
"History": "历史",
|
"History": "历史",
|
||||||
"Ranking": "排行",
|
"Ranking": "排行",
|
||||||
"Settings": "设置",
|
"Settings": "设置",
|
||||||
"Artworks": "插画",
|
"Artworks": "作品",
|
||||||
"Mangas": "漫画",
|
"Mangas": "漫画",
|
||||||
"Users": "用户",
|
"Users": "用户",
|
||||||
"Search artwork": "搜索作品",
|
"Search artwork": "搜索作品",
|
||||||
@@ -173,7 +173,8 @@
|
|||||||
"Use an external browser: You can sign in using Google. However, some browsers may not be compatible with the application": "使用外部浏览器: 可以使用Google登录. 但是, 一些浏览器可能与应用程序不兼容",
|
"Use an external browser: You can sign in using Google. However, some browsers may not be compatible with the application": "使用外部浏览器: 可以使用Google登录. 但是, 一些浏览器可能与应用程序不兼容",
|
||||||
"External browser": "外部浏览器",
|
"External browser": "外部浏览器",
|
||||||
"Show comments": "显示评论",
|
"Show comments": "显示评论",
|
||||||
"Show original image": "显示原图"
|
"Show original image": "显示原图",
|
||||||
|
"Illustrations": "插画"
|
||||||
},
|
},
|
||||||
"zh_TW": {
|
"zh_TW": {
|
||||||
"Search": "搜索",
|
"Search": "搜索",
|
||||||
@@ -349,6 +350,7 @@
|
|||||||
"Use an external browser: You can sign in using Google. However, some browsers may not be compatible with the application": "使用外部瀏覽器: 可以使用Google登錄. 但是, 一些瀏覽器可能與應用程序不兼容",
|
"Use an external browser: You can sign in using Google. However, some browsers may not be compatible with the application": "使用外部瀏覽器: 可以使用Google登錄. 但是, 一些瀏覽器可能與應用程序不兼容",
|
||||||
"External browser": "外部瀏覽器",
|
"External browser": "外部瀏覽器",
|
||||||
"Show comments": "顯示評論",
|
"Show comments": "顯示評論",
|
||||||
"Show original image": "顯示原圖"
|
"Show original image": "顯示原圖",
|
||||||
|
"Illustrations": "插畫"
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -4,6 +4,7 @@ typedef MdIcons = md.Icons;
|
|||||||
typedef MdTheme = md.Theme;
|
typedef MdTheme = md.Theme;
|
||||||
typedef MdThemeData = md.ThemeData;
|
typedef MdThemeData = md.ThemeData;
|
||||||
typedef MdColorScheme = md.ColorScheme;
|
typedef MdColorScheme = md.ColorScheme;
|
||||||
|
typedef TextField = md.TextField;
|
||||||
|
|
||||||
class ColorScheme {
|
class ColorScheme {
|
||||||
static md.ColorScheme of(md.BuildContext context) {
|
static md.ColorScheme of(md.BuildContext context) {
|
||||||
|
@@ -387,9 +387,9 @@ class Network {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Res<List<Illust>>> getUserIllusts(String uid) async {
|
Future<Res<List<Illust>>> getUserIllusts(String uid, String? type) async {
|
||||||
var res = await apiGet(
|
var res = await apiGet(
|
||||||
"/v1/user/illusts?filter=for_android&user_id=$uid&type=illust");
|
"/v1/user/illusts?filter=for_android&user_id=$uid${type != null ? "&type=$type" : ""}");
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
return Res(
|
return Res(
|
||||||
(res.data["illusts"] as List).map((e) => Illust.fromJson(e)).toList(),
|
(res.data["illusts"] as List).map((e) => Illust.fromJson(e)).toList(),
|
||||||
@@ -574,7 +574,7 @@ class Network {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Res<bool>> sendHistory(List<int> ids) async{
|
Future<Res<bool>> sendHistory(List<int> ids) async {
|
||||||
var res = await apiPost("/v2/user/browsing-history/illust/add",
|
var res = await apiPost("/v2/user/browsing-history/illust/add",
|
||||||
data: {"illust_ids": ids});
|
data: {"illust_ids": ids});
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
|
@@ -92,7 +92,7 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
|||||||
void showMenu() {
|
void showMenu() {
|
||||||
menuController.showFlyout(
|
menuController.showFlyout(
|
||||||
barrierColor: Colors.transparent,
|
barrierColor: Colors.transparent,
|
||||||
position: Offset(context.size!.width, 0),
|
position: App.isMobile ? Offset(context.size!.width, 0) : null,
|
||||||
builder: (context) => MenuFlyout(
|
builder: (context) => MenuFlyout(
|
||||||
items: [
|
items: [
|
||||||
MenuFlyoutItem(
|
MenuFlyoutItem(
|
||||||
@@ -100,10 +100,11 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
|||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
var file = await getFile();
|
var file = await getFile();
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
var fileName = file.path.split('/').last;
|
var fileName = widget.urls[currentPage].split('/').last;
|
||||||
if (!fileName.contains('.')) {
|
if (!fileName.contains('.')) {
|
||||||
fileName += getExtensionName();
|
fileName += getExtensionName();
|
||||||
}
|
}
|
||||||
|
print(fileName);
|
||||||
saveFile(file, fileName);
|
saveFile(file, fileName);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
@@ -113,7 +114,8 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
|||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
var file = await getFile();
|
var file = await getFile();
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
var fileName = file.path.split('/').last;
|
var fileName =
|
||||||
|
widget.urls[currentPage].split('/').last;
|
||||||
if (!fileName.contains('.')) {
|
if (!fileName.contains('.')) {
|
||||||
fileName += getExtensionName();
|
fileName += getExtensionName();
|
||||||
}
|
}
|
||||||
@@ -130,7 +132,7 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
|||||||
var file = await getFile();
|
var file = await getFile();
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
var ext = getExtensionName();
|
var ext = getExtensionName();
|
||||||
var fileName = file.path.split('/').last;
|
var fileName = widget.urls[currentPage].split('/').last;
|
||||||
if (!fileName.contains('.')) {
|
if (!fileName.contains('.')) {
|
||||||
fileName += ext;
|
fileName += ext;
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,7 @@ import "dart:async";
|
|||||||
|
|
||||||
import "package:fluent_ui/fluent_ui.dart";
|
import "package:fluent_ui/fluent_ui.dart";
|
||||||
import "package:flutter/foundation.dart";
|
import "package:flutter/foundation.dart";
|
||||||
|
import "package:flutter/services.dart";
|
||||||
import "package:pixes/appdata.dart";
|
import "package:pixes/appdata.dart";
|
||||||
import "package:pixes/components/md.dart";
|
import "package:pixes/components/md.dart";
|
||||||
import "package:pixes/foundation/app.dart";
|
import "package:pixes/foundation/app.dart";
|
||||||
@@ -64,13 +65,17 @@ class MainPage extends StatefulWidget {
|
|||||||
State<MainPage> createState() => _MainPageState();
|
State<MainPage> createState() => _MainPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MainPageState extends State<MainPage> with WindowListener {
|
class _MainPageState extends State<MainPage>
|
||||||
|
with WindowListener
|
||||||
|
implements PopEntry {
|
||||||
final navigatorKey = GlobalKey<NavigatorState>();
|
final navigatorKey = GlobalKey<NavigatorState>();
|
||||||
|
|
||||||
int index = 4;
|
int index = 4;
|
||||||
|
|
||||||
int windowButtonKey = 0;
|
int windowButtonKey = 0;
|
||||||
|
|
||||||
|
ModalRoute<dynamic>? _route;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
StateController.put<TitleBarController>(TitleBarController());
|
StateController.put<TitleBarController>(TitleBarController());
|
||||||
@@ -80,10 +85,22 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeDependencies() {
|
||||||
|
super.didChangeDependencies();
|
||||||
|
final ModalRoute<dynamic>? nextRoute = ModalRoute.of(context);
|
||||||
|
if (nextRoute != _route) {
|
||||||
|
_route?.unregisterPopEntry(this);
|
||||||
|
_route = nextRoute;
|
||||||
|
_route?.registerPopEntry(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
StateController.remove<TitleBarController>();
|
StateController.remove<TitleBarController>();
|
||||||
windowManager.removeListener(this);
|
windowManager.removeListener(this);
|
||||||
|
ModalRoute.of(context)!.unregisterPopEntry(this);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +168,7 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
),
|
),
|
||||||
PaneItemSeparator(),
|
PaneItemSeparator(),
|
||||||
PaneItemHeader(
|
PaneItemHeader(
|
||||||
header: Text('${"Artwork".tl}/${"Manga".tl}')
|
header: Text('${"Illustrations".tl}/${"Manga".tl}')
|
||||||
.paddingBottom(4)
|
.paddingBottom(4)
|
||||||
.paddingLeft(8)),
|
.paddingLeft(8)),
|
||||||
PaneItem(
|
PaneItem(
|
||||||
@@ -209,10 +226,7 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
paneBodyBuilder: (pane, child) => NavigatorPopHandler(
|
paneBodyBuilder: (pane, child) => MediaQuery.removePadding(
|
||||||
key: const Key("navigator"),
|
|
||||||
onPop: () => navigatorKey.currentState?.pop(),
|
|
||||||
child: MediaQuery.removePadding(
|
|
||||||
context: context,
|
context: context,
|
||||||
removeTop: true,
|
removeTop: true,
|
||||||
child: Navigator(
|
child: Navigator(
|
||||||
@@ -220,7 +234,7 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
onGenerateRoute: (settings) => AppPageRoute(
|
onGenerateRoute: (settings) => AppPageRoute(
|
||||||
builder: (context) => const RecommendationPage()),
|
builder: (context) => const RecommendationPage()),
|
||||||
),
|
),
|
||||||
))),
|
)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,6 +329,25 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
: null,
|
: null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final popValue = ValueNotifier(false);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ValueListenable<bool> get canPopNotifier => popValue;
|
||||||
|
|
||||||
|
@override
|
||||||
|
PopInvokedCallback? get onPopInvoked => onPop;
|
||||||
|
|
||||||
|
void onPop(bool value) {
|
||||||
|
print("ok");
|
||||||
|
if (App.rootNavigatorKey.currentState?.canPop() ?? false) {
|
||||||
|
App.rootNavigatorKey.currentState?.pop();
|
||||||
|
} else if (App.mainNavigatorKey?.currentState?.canPop() ?? false) {
|
||||||
|
App.mainNavigatorKey?.currentState?.pop();
|
||||||
|
} else {
|
||||||
|
SystemNavigator.pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _BackButton extends StatefulWidget {
|
class _BackButton extends StatefulWidget {
|
||||||
|
@@ -45,7 +45,7 @@ class _RecommendationPageState extends State<RecommendationPage> {
|
|||||||
title: "Explore".tl,
|
title: "Explore".tl,
|
||||||
action: SegmentedButton<int>(
|
action: SegmentedButton<int>(
|
||||||
options: [
|
options: [
|
||||||
SegmentedButtonOption(0, "Artworks".tl),
|
SegmentedButtonOption(0, "Illustrations".tl),
|
||||||
SegmentedButtonOption(1, "Mangas".tl),
|
SegmentedButtonOption(1, "Mangas".tl),
|
||||||
SegmentedButtonOption(2, "Users".tl),
|
SegmentedButtonOption(2, "Users".tl),
|
||||||
],
|
],
|
||||||
|
@@ -63,7 +63,7 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
|||||||
_RelatedUsers(widget.id),
|
_RelatedUsers(widget.id),
|
||||||
buildInformation(),
|
buildInformation(),
|
||||||
buildArtworkHeader(),
|
buildArtworkHeader(),
|
||||||
if (page == 2)
|
if (page == 4)
|
||||||
_UserNovels(widget.id)
|
_UserNovels(widget.id)
|
||||||
else
|
else
|
||||||
_UserArtworks(
|
_UserArtworks(
|
||||||
@@ -228,8 +228,10 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
|||||||
SegmentedButton<int>(
|
SegmentedButton<int>(
|
||||||
options: [
|
options: [
|
||||||
SegmentedButtonOption(0, "Artworks".tl),
|
SegmentedButtonOption(0, "Artworks".tl),
|
||||||
SegmentedButtonOption(1, "Bookmarks".tl),
|
SegmentedButtonOption(1, "Illustrations".tl),
|
||||||
SegmentedButtonOption(2, "Novels".tl),
|
SegmentedButtonOption(2, "Mangas".tl),
|
||||||
|
SegmentedButtonOption(3, "Bookmarks".tl),
|
||||||
|
SegmentedButtonOption(4, "Novels".tl),
|
||||||
],
|
],
|
||||||
value: page,
|
value: page,
|
||||||
onPressed: (value) {
|
onPressed: (value) {
|
||||||
@@ -239,15 +241,24 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
if (page != 2)
|
if (page != 4)
|
||||||
BatchDownloadButton(
|
BatchDownloadButton(
|
||||||
request: () {
|
request: () {
|
||||||
if (page == 0) {
|
switch (page) {
|
||||||
return Network().getUserIllusts(data!.id.toString());
|
case 0:
|
||||||
} else {
|
return Network()
|
||||||
|
.getUserIllusts(data!.id.toString(), null);
|
||||||
|
case 1:
|
||||||
|
return Network()
|
||||||
|
.getUserIllusts(data!.id.toString(), "illust");
|
||||||
|
case 2:
|
||||||
|
return Network()
|
||||||
|
.getUserIllusts(data!.id.toString(), "manga");
|
||||||
|
case 3:
|
||||||
return Network()
|
return Network()
|
||||||
.getUserBookmarks(data!.id.toString());
|
.getUserBookmarks(data!.id.toString());
|
||||||
}
|
}
|
||||||
|
throw "Invalid page";
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -269,14 +280,14 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
|||||||
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 2),
|
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 2),
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: icon == null
|
title: Row(
|
||||||
? null
|
children: [
|
||||||
: Icon(
|
Icon(icon, size: 20),
|
||||||
icon,
|
const SizedBox(width: 8),
|
||||||
size: 20,
|
Text(title)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
title: Text(title),
|
subtitle: SelectableText(content).paddingLeft(icon == null ? 0 : 28),
|
||||||
subtitle: SelectableText(content),
|
|
||||||
trailing: trailing,
|
trailing: trailing,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -409,8 +420,9 @@ class _UserArtworksState extends MultiPageLoadingState<_UserArtworks, Illust> {
|
|||||||
return Res.error("No more data");
|
return Res.error("No more data");
|
||||||
}
|
}
|
||||||
var res = nextUrl == null
|
var res = nextUrl == null
|
||||||
? (widget.type == 0
|
? (widget.type != 3
|
||||||
? await Network().getUserIllusts(widget.uid)
|
? await Network().getUserIllusts(
|
||||||
|
widget.uid, [null, "illust", "manga"][widget.type])
|
||||||
: await Network().getUserBookmarks(widget.uid))
|
: await Network().getUserBookmarks(widget.uid))
|
||||||
: await Network().getIllustsWithNextUrl(nextUrl!);
|
: await Network().getIllustsWithNextUrl(nextUrl!);
|
||||||
if (!res.error) {
|
if (!res.error) {
|
||||||
@@ -422,7 +434,7 @@ class _UserArtworksState extends MultiPageLoadingState<_UserArtworks, Illust> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _UserNovels extends StatefulWidget {
|
class _UserNovels extends StatefulWidget {
|
||||||
const _UserNovels(this.uid, {super.key});
|
const _UserNovels(this.uid);
|
||||||
|
|
||||||
final String uid;
|
final String uid;
|
||||||
|
|
||||||
@@ -534,7 +546,7 @@ class _RelatedUsersState
|
|||||||
return UserPreviewWidget(data[index]).fixWidth(342);
|
return UserPreviewWidget(data[index]).fixWidth(342);
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
if (MediaQuery.of(context).size.width > 500) {
|
if (App.isDesktop) {
|
||||||
content = ScrollbarTheme.merge(
|
content = ScrollbarTheme.merge(
|
||||||
data: const ScrollbarThemeData(
|
data: const ScrollbarThemeData(
|
||||||
thickness: 6,
|
thickness: 6,
|
||||||
@@ -542,7 +554,21 @@ class _RelatedUsersState
|
|||||||
mainAxisMargin: 4,
|
mainAxisMargin: 4,
|
||||||
hoveringPadding: EdgeInsets.zero,
|
hoveringPadding: EdgeInsets.zero,
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
hoveringMainAxisMargin: 4),
|
hoveringMainAxisMargin: 4,
|
||||||
|
crossAxisMargin: 0,
|
||||||
|
hoveringCrossAxisMargin: 0),
|
||||||
|
child: content);
|
||||||
|
} else {
|
||||||
|
content = ScrollbarTheme.merge(
|
||||||
|
data: const ScrollbarThemeData(
|
||||||
|
thickness: 4,
|
||||||
|
hoveringThickness: 4,
|
||||||
|
mainAxisMargin: 4,
|
||||||
|
hoveringPadding: EdgeInsets.zero,
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
hoveringMainAxisMargin: 4,
|
||||||
|
crossAxisMargin: 0,
|
||||||
|
hoveringCrossAxisMargin: 0),
|
||||||
child: content);
|
child: content);
|
||||||
}
|
}
|
||||||
return MediaQuery.removePadding(
|
return MediaQuery.removePadding(
|
||||||
|
Reference in New Issue
Block a user