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": "历史",
|
||||
"Ranking": "排行",
|
||||
"Settings": "设置",
|
||||
"Artworks": "插画",
|
||||
"Artworks": "作品",
|
||||
"Mangas": "漫画",
|
||||
"Users": "用户",
|
||||
"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登录. 但是, 一些浏览器可能与应用程序不兼容",
|
||||
"External browser": "外部浏览器",
|
||||
"Show comments": "显示评论",
|
||||
"Show original image": "显示原图"
|
||||
"Show original image": "显示原图",
|
||||
"Illustrations": "插画"
|
||||
},
|
||||
"zh_TW": {
|
||||
"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登錄. 但是, 一些瀏覽器可能與應用程序不兼容",
|
||||
"External browser": "外部瀏覽器",
|
||||
"Show comments": "顯示評論",
|
||||
"Show original image": "顯示原圖"
|
||||
"Show original image": "顯示原圖",
|
||||
"Illustrations": "插畫"
|
||||
}
|
||||
}
|
@@ -4,6 +4,7 @@ typedef MdIcons = md.Icons;
|
||||
typedef MdTheme = md.Theme;
|
||||
typedef MdThemeData = md.ThemeData;
|
||||
typedef MdColorScheme = md.ColorScheme;
|
||||
typedef TextField = md.TextField;
|
||||
|
||||
class ColorScheme {
|
||||
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(
|
||||
"/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) {
|
||||
return Res(
|
||||
(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",
|
||||
data: {"illust_ids": ids});
|
||||
if (res.success) {
|
||||
|
@@ -92,7 +92,7 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
||||
void showMenu() {
|
||||
menuController.showFlyout(
|
||||
barrierColor: Colors.transparent,
|
||||
position: Offset(context.size!.width, 0),
|
||||
position: App.isMobile ? Offset(context.size!.width, 0) : null,
|
||||
builder: (context) => MenuFlyout(
|
||||
items: [
|
||||
MenuFlyoutItem(
|
||||
@@ -100,10 +100,11 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
||||
onPressed: () async {
|
||||
var file = await getFile();
|
||||
if (file != null) {
|
||||
var fileName = file.path.split('/').last;
|
||||
var fileName = widget.urls[currentPage].split('/').last;
|
||||
if (!fileName.contains('.')) {
|
||||
fileName += getExtensionName();
|
||||
}
|
||||
print(fileName);
|
||||
saveFile(file, fileName);
|
||||
}
|
||||
}),
|
||||
@@ -113,7 +114,8 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
||||
onPressed: () async {
|
||||
var file = await getFile();
|
||||
if (file != null) {
|
||||
var fileName = file.path.split('/').last;
|
||||
var fileName =
|
||||
widget.urls[currentPage].split('/').last;
|
||||
if (!fileName.contains('.')) {
|
||||
fileName += getExtensionName();
|
||||
}
|
||||
@@ -130,7 +132,7 @@ class _ImagePageState extends State<ImagePage> with WindowListener {
|
||||
var file = await getFile();
|
||||
if (file != null) {
|
||||
var ext = getExtensionName();
|
||||
var fileName = file.path.split('/').last;
|
||||
var fileName = widget.urls[currentPage].split('/').last;
|
||||
if (!fileName.contains('.')) {
|
||||
fileName += ext;
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ import "dart:async";
|
||||
|
||||
import "package:fluent_ui/fluent_ui.dart";
|
||||
import "package:flutter/foundation.dart";
|
||||
import "package:flutter/services.dart";
|
||||
import "package:pixes/appdata.dart";
|
||||
import "package:pixes/components/md.dart";
|
||||
import "package:pixes/foundation/app.dart";
|
||||
@@ -64,13 +65,17 @@ class MainPage extends StatefulWidget {
|
||||
State<MainPage> createState() => _MainPageState();
|
||||
}
|
||||
|
||||
class _MainPageState extends State<MainPage> with WindowListener {
|
||||
class _MainPageState extends State<MainPage>
|
||||
with WindowListener
|
||||
implements PopEntry {
|
||||
final navigatorKey = GlobalKey<NavigatorState>();
|
||||
|
||||
int index = 4;
|
||||
|
||||
int windowButtonKey = 0;
|
||||
|
||||
ModalRoute<dynamic>? _route;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
StateController.put<TitleBarController>(TitleBarController());
|
||||
@@ -80,10 +85,22 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
||||
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
|
||||
void dispose() {
|
||||
StateController.remove<TitleBarController>();
|
||||
windowManager.removeListener(this);
|
||||
ModalRoute.of(context)!.unregisterPopEntry(this);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -151,7 +168,7 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
||||
),
|
||||
PaneItemSeparator(),
|
||||
PaneItemHeader(
|
||||
header: Text('${"Artwork".tl}/${"Manga".tl}')
|
||||
header: Text('${"Illustrations".tl}/${"Manga".tl}')
|
||||
.paddingBottom(4)
|
||||
.paddingLeft(8)),
|
||||
PaneItem(
|
||||
@@ -209,10 +226,7 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
||||
),
|
||||
],
|
||||
),
|
||||
paneBodyBuilder: (pane, child) => NavigatorPopHandler(
|
||||
key: const Key("navigator"),
|
||||
onPop: () => navigatorKey.currentState?.pop(),
|
||||
child: MediaQuery.removePadding(
|
||||
paneBodyBuilder: (pane, child) => MediaQuery.removePadding(
|
||||
context: context,
|
||||
removeTop: true,
|
||||
child: Navigator(
|
||||
@@ -220,7 +234,7 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
||||
onGenerateRoute: (settings) => AppPageRoute(
|
||||
builder: (context) => const RecommendationPage()),
|
||||
),
|
||||
))),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -315,6 +329,25 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
||||
: 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 {
|
||||
|
@@ -45,7 +45,7 @@ class _RecommendationPageState extends State<RecommendationPage> {
|
||||
title: "Explore".tl,
|
||||
action: SegmentedButton<int>(
|
||||
options: [
|
||||
SegmentedButtonOption(0, "Artworks".tl),
|
||||
SegmentedButtonOption(0, "Illustrations".tl),
|
||||
SegmentedButtonOption(1, "Mangas".tl),
|
||||
SegmentedButtonOption(2, "Users".tl),
|
||||
],
|
||||
|
@@ -63,7 +63,7 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
||||
_RelatedUsers(widget.id),
|
||||
buildInformation(),
|
||||
buildArtworkHeader(),
|
||||
if (page == 2)
|
||||
if (page == 4)
|
||||
_UserNovels(widget.id)
|
||||
else
|
||||
_UserArtworks(
|
||||
@@ -228,8 +228,10 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
||||
SegmentedButton<int>(
|
||||
options: [
|
||||
SegmentedButtonOption(0, "Artworks".tl),
|
||||
SegmentedButtonOption(1, "Bookmarks".tl),
|
||||
SegmentedButtonOption(2, "Novels".tl),
|
||||
SegmentedButtonOption(1, "Illustrations".tl),
|
||||
SegmentedButtonOption(2, "Mangas".tl),
|
||||
SegmentedButtonOption(3, "Bookmarks".tl),
|
||||
SegmentedButtonOption(4, "Novels".tl),
|
||||
],
|
||||
value: page,
|
||||
onPressed: (value) {
|
||||
@@ -239,15 +241,24 @@ class _UserInfoPageState extends LoadingState<UserInfoPage, UserDetails> {
|
||||
},
|
||||
),
|
||||
const Spacer(),
|
||||
if (page != 2)
|
||||
if (page != 4)
|
||||
BatchDownloadButton(
|
||||
request: () {
|
||||
if (page == 0) {
|
||||
return Network().getUserIllusts(data!.id.toString());
|
||||
} else {
|
||||
return Network()
|
||||
.getUserBookmarks(data!.id.toString());
|
||||
switch (page) {
|
||||
case 0:
|
||||
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()
|
||||
.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),
|
||||
padding: EdgeInsets.zero,
|
||||
child: ListTile(
|
||||
leading: icon == null
|
||||
? null
|
||||
: Icon(
|
||||
icon,
|
||||
size: 20,
|
||||
),
|
||||
title: Text(title),
|
||||
subtitle: SelectableText(content),
|
||||
title: Row(
|
||||
children: [
|
||||
Icon(icon, size: 20),
|
||||
const SizedBox(width: 8),
|
||||
Text(title)
|
||||
],
|
||||
),
|
||||
subtitle: SelectableText(content).paddingLeft(icon == null ? 0 : 28),
|
||||
trailing: trailing,
|
||||
),
|
||||
);
|
||||
@@ -409,8 +420,9 @@ class _UserArtworksState extends MultiPageLoadingState<_UserArtworks, Illust> {
|
||||
return Res.error("No more data");
|
||||
}
|
||||
var res = nextUrl == null
|
||||
? (widget.type == 0
|
||||
? await Network().getUserIllusts(widget.uid)
|
||||
? (widget.type != 3
|
||||
? await Network().getUserIllusts(
|
||||
widget.uid, [null, "illust", "manga"][widget.type])
|
||||
: await Network().getUserBookmarks(widget.uid))
|
||||
: await Network().getIllustsWithNextUrl(nextUrl!);
|
||||
if (!res.error) {
|
||||
@@ -422,7 +434,7 @@ class _UserArtworksState extends MultiPageLoadingState<_UserArtworks, Illust> {
|
||||
}
|
||||
|
||||
class _UserNovels extends StatefulWidget {
|
||||
const _UserNovels(this.uid, {super.key});
|
||||
const _UserNovels(this.uid);
|
||||
|
||||
final String uid;
|
||||
|
||||
@@ -534,7 +546,7 @@ class _RelatedUsersState
|
||||
return UserPreviewWidget(data[index]).fixWidth(342);
|
||||
},
|
||||
));
|
||||
if (MediaQuery.of(context).size.width > 500) {
|
||||
if (App.isDesktop) {
|
||||
content = ScrollbarTheme.merge(
|
||||
data: const ScrollbarThemeData(
|
||||
thickness: 6,
|
||||
@@ -542,7 +554,21 @@ class _RelatedUsersState
|
||||
mainAxisMargin: 4,
|
||||
hoveringPadding: 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);
|
||||
}
|
||||
return MediaQuery.removePadding(
|
||||
|
Reference in New Issue
Block a user