Skip to content

基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。

simplify time code

lauirfa362b926cd0e
diff --git a/lib/pages/timeline/timeline_controller.dart b/lib/pages/timeline/timeline_controller.dart
index 49e6342d..16883060 100644
--- a/lib/pages/timeline/timeline_controller.dart
+++ b/lib/pages/timeline/timeline_controller.dart
@@ -39,4 +39,9 @@ abstract class _TimelineController with Store {
bangumiCalendar.addAll(resBangumiCalendar);
}
}
+
+ void tryEnterSeason(DateTime date) {
+ selectedDate = date;
+ seasonString = "加载中 ٩(◦`꒳´◦)۶";
+ }
}
\ No newline at end of file
diff --git a/lib/pages/timeline/timeline_page.dart b/lib/pages/timeline/timeline_page.dart
index e883798a..686b98d5 100644
--- a/lib/pages/timeline/timeline_page.dart
+++ b/lib/pages/timeline/timeline_page.dart
@@ -82,6 +82,17 @@ class _TimelinePageState extends State<TimelinePage>
Tab(text: '日'),
];
+ final seasons = [
+ '秋',
+ '夏',
+ '春',
+ '冬'
+ ];
+
+ String getStringByDateTime(DateTime d){
+ return d.year.toString() + Utils.getSeasonStringByMonth(d.month);
+ }
+
@override
Widget build(BuildContext context) {
return OrientationBuilder(builder: (context, orientation) {
@@ -111,6 +122,15 @@ class _TimelinePageState extends State<TimelinePage>
showingTimeMachineDialog = false;
},
builder: (context) {
+ var currDate = DateTime.now();
+ final years = List.generate(20, (index) => currDate.year - index);
+ List<DateTime> buttons = [];
+ currDate = DateTime(2026);
+ for (final i in years){
+ for (final s in seasons){
+ buttons.add(generateDateTime(i, s));
+ }
+ }
return AlertDialog(
title: const Text("时间机器"),
content: SingleChildScrollView(
@@ -118,68 +138,17 @@ class _TimelinePageState extends State<TimelinePage>
spacing: 8,
runSpacing: Utils.isCompact() ? 2 : 8,
children: [
- for (final int i in List.generate(
- 20, (index) => DateTime.now().year - index))
- for (final String selectedSeason in [
- '秋',
- '夏',
- '春',
- '冬'
- ])
- DateTime.now().isAfter(
- generateDateTime(i, selectedSeason))
- ? timelineController.selectedDate ==
- generateDateTime(i, selectedSeason)
+ for (final date in buttons)
+ currDate.isAfter(date)
+ ? timelineController.selectedDate == date
? FilledButton(
- onPressed: () async {
- if (timelineController
- .selectedDate !=
- generateDateTime(
- i, selectedSeason)) {
- KazumiDialog.dismiss();
- timelineController
- .selectedDate =
- generateDateTime(
- i, selectedSeason);
- timelineController
- .seasonString =
- "加载中 ٩(◦`꒳´◦)۶";
- if (AnimeSeason(
- timelineController
- .selectedDate)
- .toString() ==
- AnimeSeason(DateTime.now())
- .toString()) {
- await timelineController
- .getSchedules();
- } else {
- await timelineController
- .getSchedulesBySeason();
- }
- timelineController
- .seasonString = AnimeSeason(
- timelineController
- .selectedDate)
- .toString();
- }
- },
- child: Text(i.toString() +
- selectedSeason.toString()),
+ onPressed: () {},
+ child: Text(getStringByDateTime(date)),
)
: FilledButton.tonal(
onPressed: () async {
- if (timelineController
- .selectedDate !=
- generateDateTime(
- i, selectedSeason)) {
- KazumiDialog.dismiss();
- timelineController
- .selectedDate =
- generateDateTime(
- i, selectedSeason);
- timelineController
- .seasonString =
- "加载中 ٩(◦`꒳´◦)۶";
+ KazumiDialog.dismiss();
+ timelineController.tryEnterSeason(date);
if (AnimeSeason(
timelineController
.selectedDate)
@@ -197,10 +166,8 @@ class _TimelinePageState extends State<TimelinePage>
timelineController
.selectedDate)
.toString();
- }
},
- child: Text(i.toString() +
- selectedSeason.toString()),
+ child: Text(getStringByDateTime(date)),
)
: Container(),
],
diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart
index 6ed59056..b90230b9 100644
--- a/lib/utils/utils.dart
+++ b/lib/utils/utils.dart
@@ -540,4 +540,17 @@ class Utils {
static Future<String> getCurrentDemux() async {
return 'MPV';
}
+
+ static String getSeasonStringByMonth(int month){
+ if (month<=3) {
+ return '冬';
+ }
+ if(month<=6){
+ return '春';
+ }
+ if (month<=9) {
+ return '夏';
+ }
+ return '秋';
+ }
}