pikapika/lib/screens/RankingsScreen.dart

79 lines
2.0 KiB
Dart
Raw Normal View History

2021-09-29 23:57:09 +00:00
import 'package:flutter/material.dart';
import 'package:pikapi/basic/Entities.dart';
import 'package:pikapi/basic/Method.dart';
import 'package:pikapi/basic/config/ListLayout.dart';
import 'package:pikapi/basic/config/ShadowCategories.dart';
2021-09-29 23:57:09 +00:00
import 'components/ComicListBuilder.dart';
2021-10-26 11:04:23 +00:00
// 排行榜
2021-09-29 23:57:09 +00:00
class RankingsScreen extends StatelessWidget {
2021-09-29 23:57:09 +00:00
@override
Widget build(BuildContext context) {
var theme = Theme.of(context);
return Scaffold(
appBar: AppBar(
title: Text('排行榜'),
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,
tabs: [
Tab(text: ''),
Tab(text: ''),
Tab(text: ''),
],
),
),
Expanded(
child: TabBarView(
children: [
_Leaderboard("H24"),
_Leaderboard("D7"),
_Leaderboard("D30"),
],
),
),
],
),
),
);
}
}
class _Leaderboard extends StatefulWidget {
final String type;
_Leaderboard(this.type);
@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);
}
}