pikapika/lib/screens/RankingsScreen.dart

89 lines
2.2 KiB
Dart
Raw Normal View History

2021-09-29 23:57:09 +00:00
import 'package:flutter/material.dart';
2021-11-11 03:00:38 +00:00
import 'package:pikapika/basic/Entities.dart';
import 'package:pikapika/basic/Method.dart';
import 'package:pikapika/basic/config/ListLayout.dart';
import 'package:pikapika/basic/config/ShadowCategories.dart';
2021-09-29 23:57:09 +00:00
import 'components/ComicListBuilder.dart';
2022-03-19 04:12:27 +00:00
import 'components/RightClickPop.dart';
2021-09-29 23:57:09 +00:00
2021-10-26 11:04:23 +00:00
// 排行榜
2021-09-29 23:57:09 +00:00
class RankingsScreen extends StatelessWidget {
2022-03-19 04:12:27 +00:00
const RankingsScreen({Key? key}) : super(key: key);
2021-09-29 23:57:09 +00:00
@override
Widget build(BuildContext context) {
2022-03-25 14:57:30 +00:00
return rightClickPop(
child: buildScreen(context),
context: context,
canPop: true,
);
2022-03-19 04:12:27 +00:00
}
Widget buildScreen(BuildContext context) {
2021-09-29 23:57:09 +00:00
var theme = Theme.of(context);
return Scaffold(
appBar: AppBar(
2022-03-19 04:12:27 +00:00
title: const Text('排行榜'),
2021-09-29 23:57:09 +00:00
actions: [
shadowCategoriesActionButton(context),
2021-11-04 05:56:25 +00:00
chooseLayoutActionButton(context),
2021-09-29 23:57:09 +00:00
],
),
body: DefaultTabController(
length: 3,
child: Column(
children: [
Container(
height: 40,
color: theme.colorScheme.secondary.withOpacity(.025),
child: TabBar(
indicatorColor: theme.colorScheme.secondary,
labelColor: theme.colorScheme.secondary,
2022-03-19 04:12:27 +00:00
tabs: const [
2021-09-29 23:57:09 +00:00
Tab(text: ''),
Tab(text: ''),
Tab(text: ''),
],
),
),
2022-03-19 04:12:27 +00:00
const Expanded(
2021-09-29 23:57:09 +00:00
child: TabBarView(
children: [
_Leaderboard("H24"),
_Leaderboard("D7"),
_Leaderboard("D30"),
],
),
),
],
),
),
);
}
}
class _Leaderboard extends StatefulWidget {
final String type;
2022-03-19 04:12:27 +00:00
const _Leaderboard(this.type);
2021-09-29 23:57:09 +00:00
@override
State<StatefulWidget> createState() => _LeaderboardState();
}
class _LeaderboardState extends State<_Leaderboard> {
late Future<List<ComicSimple>> _future = method.leaderboard(widget.type);
Future<void> _reload() async {
setState(() {
_future = method.leaderboard(widget.type);
});
}
@override
Widget build(BuildContext context) {
return ComicListBuilder(_future, _reload);
}
}