mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 12:57:24 +00:00
history feature
This commit is contained in:
@@ -418,4 +418,18 @@ class Network {
|
|||||||
return Res.error(res.errorMessage);
|
return Res.error(res.errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Res<List<Illust>>> getHistory(int page) async {
|
||||||
|
String param = "";
|
||||||
|
if(page > 1) {
|
||||||
|
param = "?offset=${30*(page-1)}";
|
||||||
|
}
|
||||||
|
var res = await apiGet("/v1/user/browsing-history/illusts$param");
|
||||||
|
if (res.success) {
|
||||||
|
return Res((res.data["illusts"] as List)
|
||||||
|
.map((e) => Illust.fromJson(e)).toList());
|
||||||
|
} else {
|
||||||
|
return Res.error(res.errorMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
55
lib/pages/history.dart
Normal file
55
lib/pages/history.dart
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
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/title_bar.dart';
|
||||||
|
import 'package:pixes/foundation/app.dart';
|
||||||
|
import 'package:pixes/network/models.dart';
|
||||||
|
import 'package:pixes/network/network.dart';
|
||||||
|
import 'package:pixes/utils/translation.dart';
|
||||||
|
|
||||||
|
import '../components/illust_widget.dart';
|
||||||
|
|
||||||
|
class HistoryPage extends StatefulWidget {
|
||||||
|
const HistoryPage({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<HistoryPage> createState() => _HistoryPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _HistoryPageState extends MultiPageLoadingState<HistoryPage, Illust> {
|
||||||
|
@override
|
||||||
|
Widget buildContent(BuildContext context, final List<Illust> data) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
TitleBar(title: "History".tl),
|
||||||
|
Expanded(
|
||||||
|
child: LayoutBuilder(builder: (context, constrains){
|
||||||
|
return MasonryGridView.builder(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8)
|
||||||
|
+ EdgeInsets.only(bottom: context.padding.bottom),
|
||||||
|
gridDelegate: const SliverSimpleGridDelegateWithMaxCrossAxisExtent(
|
||||||
|
maxCrossAxisExtent: 240,
|
||||||
|
),
|
||||||
|
itemCount: data.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
if(index == data.length - 1){
|
||||||
|
nextPage();
|
||||||
|
}
|
||||||
|
return IllustWidget(data[index]);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<Res<List<Illust>>> loadData(page) {
|
||||||
|
if(appdata.account?.user.isPremium != true) {
|
||||||
|
return Future.value(Res.error("Premium Required".tl));
|
||||||
|
}
|
||||||
|
return Network().getHistory(page);
|
||||||
|
}
|
||||||
|
}
|
@@ -10,6 +10,7 @@ import "package:pixes/network/network.dart";
|
|||||||
import "package:pixes/pages/bookmarks.dart";
|
import "package:pixes/pages/bookmarks.dart";
|
||||||
import "package:pixes/pages/downloaded_page.dart";
|
import "package:pixes/pages/downloaded_page.dart";
|
||||||
import "package:pixes/pages/following_artworks.dart";
|
import "package:pixes/pages/following_artworks.dart";
|
||||||
|
import "package:pixes/pages/history.dart";
|
||||||
import "package:pixes/pages/ranking.dart";
|
import "package:pixes/pages/ranking.dart";
|
||||||
import "package:pixes/pages/recommendation_page.dart";
|
import "package:pixes/pages/recommendation_page.dart";
|
||||||
import "package:pixes/pages/login_page.dart";
|
import "package:pixes/pages/login_page.dart";
|
||||||
@@ -129,6 +130,11 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
title: Text('Following'.tl),
|
title: Text('Following'.tl),
|
||||||
body: const SizedBox.shrink(),
|
body: const SizedBox.shrink(),
|
||||||
),
|
),
|
||||||
|
PaneItem(
|
||||||
|
icon: const Icon(MdIcons.history, size: 20),
|
||||||
|
title: Text('History'.tl),
|
||||||
|
body: const SizedBox.shrink(),
|
||||||
|
),
|
||||||
PaneItem(
|
PaneItem(
|
||||||
icon: const Icon(MdIcons.leaderboard_outlined, size: 20),
|
icon: const Icon(MdIcons.leaderboard_outlined, size: 20),
|
||||||
title: Text('Ranking'.tl),
|
title: Text('Ranking'.tl),
|
||||||
@@ -166,6 +172,7 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
|||||||
() => const RecommendationPage(),
|
() => const RecommendationPage(),
|
||||||
() => const BookMarkedArtworkPage(),
|
() => const BookMarkedArtworkPage(),
|
||||||
() => const FollowingArtworksPage(),
|
() => const FollowingArtworksPage(),
|
||||||
|
() => const HistoryPage(),
|
||||||
() => const RankingPage(),
|
() => const RankingPage(),
|
||||||
() => const SettingsPage(),
|
() => const SettingsPage(),
|
||||||
];
|
];
|
||||||
|
Reference in New Issue
Block a user