load illust with id; context menu

This commit is contained in:
wgh19
2024-05-14 22:15:05 +08:00
parent faa857b814
commit a8b0495fc6
6 changed files with 151 additions and 66 deletions

View File

@@ -9,6 +9,7 @@ import 'package:pixes/components/page_route.dart';
import 'package:pixes/components/title_bar.dart';
import 'package:pixes/foundation/app.dart';
import 'package:pixes/network/download.dart';
import 'package:pixes/pages/illust_page.dart';
import 'package:pixes/utils/translation.dart';
import 'package:share_plus/share_plus.dart';
import 'package:window_manager/window_manager.dart';
@@ -54,7 +55,7 @@ class _DownloadedPageState extends State<DownloadedPage> {
return GridViewWithFixedItemHeight(
itemCount: illusts.length,
itemHeight: 152,
maxCrossAxisExtent: 560,
maxCrossAxisExtent: 742,
builder: (context, index) {
return Card(
margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
@@ -113,14 +114,22 @@ class _DownloadedPageState extends State<DownloadedPage> {
child: Text("View".tl).fixWidth(42),
onPressed: () {
App.rootNavigatorKey.currentState?.push(
AppPageRoute(builder: (context) {
return _DownloadedIllustViewPage(
DownloadManager().getImagePaths(
illusts[index].illustId));
}));
AppPageRoute(builder: (context) {
return _DownloadedIllustViewPage(
DownloadManager().getImagePaths(
illusts[index].illustId));
}));
},
),
const SizedBox(width: 8),
const SizedBox(width: 6),
Button(
child: Text("Info".tl).fixWidth(42),
onPressed: () {
context.to(() => IllustPageWithId(
illusts[index].illustId.toString()));
},
),
const SizedBox(width: 6),
FlyoutTarget(
controller: flyoutControllers[index],
child: Button(

View File

@@ -887,3 +887,23 @@ class _CommentsPageState extends MultiPageLoadingState<_CommentsPage, Comment> {
}
class IllustPageWithId extends StatefulWidget {
const IllustPageWithId(this.id, {super.key});
final String id;
@override
State<IllustPageWithId> createState() => _IllustPageWithIdState();
}
class _IllustPageWithIdState extends LoadingState<IllustPageWithId, Illust> {
@override
Widget buildContent(BuildContext context, Illust data) {
return IllustPage(data);
}
@override
Future<Res<Illust>> loadData() {
return Network().getIllustByID(widget.id);
}
}

View File

@@ -2,10 +2,12 @@ import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:pixes/appdata.dart';
import 'package:pixes/components/loading.dart';
import 'package:pixes/components/message.dart';
import 'package:pixes/components/page_route.dart';
import 'package:pixes/components/user_preview.dart';
import 'package:pixes/foundation/app.dart';
import 'package:pixes/network/network.dart';
import 'package:pixes/pages/illust_page.dart';
import 'package:pixes/pages/user_info_page.dart';
import 'package:pixes/utils/translation.dart';
@@ -41,17 +43,15 @@ class _SearchPageState extends State<SearchPage> {
case 0:
context.to(() => SearchResultPage(text));
case 1:
// TODO: novel search
showToast(context, message: "Not implemented");
case 2:
context.to(() => SearchUserResultPage(text));
case 3:
// TODO: artwork id
throw UnimplementedError();
context.to(() => IllustPageWithId(text));
case 4:
context.to(() => UserInfoPage(text));
case 5:
// TODO: novel id
throw UnimplementedError();
showToast(context, message: "Not implemented");
}
}