mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 12:57:24 +00:00
history feature
This commit is contained in:
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/downloaded_page.dart";
|
||||
import "package:pixes/pages/following_artworks.dart";
|
||||
import "package:pixes/pages/history.dart";
|
||||
import "package:pixes/pages/ranking.dart";
|
||||
import "package:pixes/pages/recommendation_page.dart";
|
||||
import "package:pixes/pages/login_page.dart";
|
||||
@@ -129,6 +130,11 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
||||
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),
|
||||
@@ -166,6 +172,7 @@ class _MainPageState extends State<MainPage> with WindowListener {
|
||||
() => const RecommendationPage(),
|
||||
() => const BookMarkedArtworkPage(),
|
||||
() => const FollowingArtworksPage(),
|
||||
() => const HistoryPage(),
|
||||
() => const RankingPage(),
|
||||
() => const SettingsPage(),
|
||||
];
|
||||
|
Reference in New Issue
Block a user