Skip to content

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

fix(android): restore correct back navigation behavior

Predidit4e91d9824812
diff --git a/lib/pages/collect/collect_page.dart b/lib/pages/collect/collect_page.dart
index e9e56c10..c054d76b 100644
--- a/lib/pages/collect/collect_page.dart
+++ b/lib/pages/collect/collect_page.dart
@@ -4,7 +4,6 @@ import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:kazumi/bean/dialog/dialog_helper.dart';
import 'package:kazumi/modules/collect/collect_module.dart';
import 'package:flutter/material.dart';
-import 'package:flutter_modular/flutter_modular.dart';
import 'package:kazumi/utils/constants.dart';
import 'package:kazumi/bean/card/bangumi_card.dart';
import 'package:kazumi/pages/collect/collect_controller.dart';
@@ -134,17 +133,6 @@ class _CollectPageState extends State<CollectPage>
);
}
- void onBackPressed(BuildContext context) {
- if (syncCollectiblesing) {
- return;
- }
- if (KazumiDialog.observer.hasKazumiDialog) {
- KazumiDialog.dismiss();
- return;
- }
- context.navigate('/tab/popular/');
- }
-
@override
void initState() {
super.initState();
@@ -168,87 +156,75 @@ class _CollectPageState extends State<CollectPage>
@override
Widget build(BuildContext context) {
- return PopScope(
- canPop: false,
- onPopInvokedWithResult: (bool didPop, Object? result) {
- if (didPop) {
- return;
- }
- if (syncCollectiblesing) {
- return;
- }
- onBackPressed(context);
- },
- child: Scaffold(
- appBar: SysAppBar(
- needTopOffset: false,
- toolbarHeight: 104,
- bottom: TabBar(
- controller: tabController,
- tabs: tabs,
- indicatorColor: Theme.of(context).colorScheme.primary,
- ),
- title: const Text('追番'),
- actions: [
- IconButton(
- onPressed: () {
- setState(() {
- showDelete = !showDelete;
- });
- },
- icon: showDelete
- ? const Icon(Icons.edit_outlined)
- : const Icon(Icons.edit))
- ],
+ return Scaffold(
+ appBar: SysAppBar(
+ needTopOffset: false,
+ toolbarHeight: 104,
+ bottom: TabBar(
+ controller: tabController,
+ tabs: tabs,
+ indicatorColor: Theme.of(context).colorScheme.primary,
),
- floatingActionButton: FloatingActionButton(
- onPressed: () async {
- bool webDavenable =
- await GStorage.getSetting(SettingsKeys.webDavEnable);
- bool webDavCollectEnable =
- GStorage.getSetting(SettingsKeys.webDavEnableCollect);
- bool bgmSyncEnable =
- GStorage.getSetting(SettingsKeys.bangumiSyncEnable);
- final syncPlan = CollectSyncPlan(
- webDavEnabled: webDavenable,
- webDavCollectiblesEnabled: webDavCollectEnable,
- bangumiEnabled: bgmSyncEnable,
- );
- if (!syncPlan.canSync) {
- KazumiDialog.showToast(message: '同步功能不可用,请至少开启一个同步功能');
- return;
- }
- if (showDelete) {
- KazumiDialog.showToast(message: '编辑模式无法执行同步');
- return;
- }
- if (syncCollectiblesing) {
- return;
- }
- setState(() {
- syncCollectiblesing = true;
- });
- try {
- await _runFullSync(
- plan: syncPlan,
- );
- } finally {
- if (mounted) {
+ title: const Text('追番'),
+ actions: [
+ IconButton(
+ onPressed: () {
setState(() {
- syncCollectiblesing = false;
+ showDelete = !showDelete;
});
- }
+ },
+ icon: showDelete
+ ? const Icon(Icons.edit_outlined)
+ : const Icon(Icons.edit))
+ ],
+ ),
+ floatingActionButton: FloatingActionButton(
+ onPressed: () async {
+ bool webDavenable =
+ await GStorage.getSetting(SettingsKeys.webDavEnable);
+ bool webDavCollectEnable =
+ GStorage.getSetting(SettingsKeys.webDavEnableCollect);
+ bool bgmSyncEnable =
+ GStorage.getSetting(SettingsKeys.bangumiSyncEnable);
+ final syncPlan = CollectSyncPlan(
+ webDavEnabled: webDavenable,
+ webDavCollectiblesEnabled: webDavCollectEnable,
+ bangumiEnabled: bgmSyncEnable,
+ );
+ if (!syncPlan.canSync) {
+ KazumiDialog.showToast(message: '同步功能不可用,请至少开启一个同步功能');
+ return;
+ }
+ if (showDelete) {
+ KazumiDialog.showToast(message: '编辑模式无法执行同步');
+ return;
+ }
+ if (syncCollectiblesing) {
+ return;
+ }
+ setState(() {
+ syncCollectiblesing = true;
+ });
+ try {
+ await _runFullSync(
+ plan: syncPlan,
+ );
+ } finally {
+ if (mounted) {
+ setState(() {
+ syncCollectiblesing = false;
+ });
}
- },
- child: syncCollectiblesing
- ? const SizedBox(
- width: 32, height: 32, child: CircularProgressIndicator())
- : const Icon(Icons.sync_rounded),
- ),
- body: Observer(builder: (context) {
- return renderBody;
- }),
+ }
+ },
+ child: syncCollectiblesing
+ ? const SizedBox(
+ width: 32, height: 32, child: CircularProgressIndicator())
+ : const Icon(Icons.sync_rounded),
),
+ body: Observer(builder: (context) {
+ return renderBody;
+ }),
);
}
diff --git a/lib/pages/menu/menu.dart b/lib/pages/menu/menu.dart
index 8a3f4e2a..175d9977 100644
--- a/lib/pages/menu/menu.dart
+++ b/lib/pages/menu/menu.dart
@@ -1,5 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
+import 'package:flutter/services.dart';
+import 'package:kazumi/bean/dialog/dialog_helper.dart';
import 'package:kazumi/bean/widget/embedded_native_control_area.dart';
import 'package:kazumi/pages/router.dart';
@@ -12,8 +14,10 @@ class ScaffoldMenu extends StatefulWidget {
class _ScaffoldMenu extends State<ScaffoldMenu> {
final _outletKey = GlobalKey<RouterOutletState>();
+ DateTime? _lastExitPromptAt;
void _selectDestination(int index) {
+ _lastExitPromptAt = null;
final currentIndex =
menu.indexForPath(context.routeState(listen: false).uri.path);
if (index == currentIndex) {
@@ -22,20 +26,58 @@ class _ScaffoldMenu extends State<ScaffoldMenu> {
_outletKey.currentState?.navigate('/tab${menu.getPath(index)}/');
}
+ void _handleSystemBack(BuildContext context) {
+ if (_outletKey.currentState?.maybePop() ?? false) {
+ _lastExitPromptAt = null;
+ return;
+ }
+
+ final currentIndex =
+ menu.indexForPath(context.routeState(listen: false).uri.path);
+ if (currentIndex != 0) {
+ _selectDestination(0);
+ return;
+ }
+
+ final now = DateTime.now();
+ final lastPromptAt = _lastExitPromptAt;
+ if (lastPromptAt == null ||
+ now.difference(lastPromptAt) > const Duration(seconds: 2)) {
+ _lastExitPromptAt = now;
+ KazumiDialog.showToast(message: '再按一次退出应用', context: context);
+ return;
+ }
+
+ _lastExitPromptAt = null;
+ SystemNavigator.pop();
+ }
+
@override
Widget build(BuildContext context) {
final selectedIndex = menu.indexForPath(context.routeState().uri.path);
- return OrientationBuilder(
- builder: (context, orientation) {
- return orientation == Orientation.portrait
- ? _bottomMenu(context, selectedIndex)
- : _sideMenu(context, selectedIndex);
+ return PopScope(
+ canPop: false,
+ onPopInvokedWithResult: (didPop, _) {
+ if (!didPop) {
+ _handleSystemBack(context);
+ }
},
+ child: OrientationBuilder(
+ builder: (context, orientation) {
+ return orientation == Orientation.portrait
+ ? _bottomMenu(context, selectedIndex)
+ : _sideMenu(context, selectedIndex);
+ },
+ ),
);
}
Widget _outlet(BuildContext context, {BorderRadius? borderRadius}) {
- Widget child = RouterOutlet(key: _outletKey);
+ Widget child = NotificationListener<NavigationNotification>(
+ // A non-poppable outlet must not override the shell's PopScope state.
+ onNotification: (notification) => !notification.canHandlePop,
+ child: RouterOutlet(key: _outletKey),
+ );
if (borderRadius != null) {
child = ClipRRect(borderRadius: borderRadius, child: child);
}
diff --git a/lib/pages/my/my_page.dart b/lib/pages/my/my_page.dart
index 822af85c..1faa9ad9 100644
--- a/lib/pages/my/my_page.dart
+++ b/lib/pages/my/my_page.dart
@@ -2,168 +2,144 @@ import 'package:card_settings_ui/card_settings_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:kazumi/bean/appbar/sys_app_bar.dart';
-import 'package:kazumi/bean/dialog/dialog_helper.dart';
-class MyPage extends StatefulWidget {
+class MyPage extends StatelessWidget {
const MyPage({super.key});
-
- @override
- State<MyPage> createState() => _MyPageState();
-}
-
-class _MyPageState extends State<MyPage> {
- void onBackPressed(BuildContext context) {
- if (KazumiDialog.observer.hasKazumiDialog) {
- KazumiDialog.dismiss();
- return;
- }
- context.navigate('/tab/popular/');
- }
-
@override
Widget build(BuildContext context) {
final fontFamily = Theme.of(context).textTheme.bodyMedium?.fontFamily;
- return PopScope(
- canPop: false,
- onPopInvokedWithResult: (bool didPop, Object? result) {
- if (didPop) {
- return;
- }
- onBackPressed(context);
- },
- child: Scaffold(
- appBar: const SysAppBar(title: Text('我的'), needTopOffset: false),
- body: SettingsList(
- maxWidth: 1000,
- sections: [
- SettingsSection(
- title: Text('播放历史与视频源', style: TextStyle(fontFamily: fontFamily)),
- tiles: [
- SettingsTile.navigation(
- onPressed: (_) {
- context.pushNamed('/settings/history/');
- },
- leading: const Icon(Icons.history_rounded),
- title: Text('历史记录', style: TextStyle(fontFamily: fontFamily)),
- description: Text('查看播放历史记录',
- style: TextStyle(fontFamily: fontFamily)),
- ),
- SettingsTile.navigation(
- onPressed: (_) {
- context.pushNamed('/settings/download/');
- },
- leading: const Icon(Icons.download_rounded),
- title: Text('下载管理', style: TextStyle(fontFamily: fontFamily)),
- description: Text('查看和管理离线下载',
- style: TextStyle(fontFamily: fontFamily)),
- ),
- SettingsTile.navigation(
- onPressed: (_) {
- context.pushNamed('/settings/download-settings');
- },
- leading: const Icon(Icons.settings_rounded),
- title: Text('下载设置', style: TextStyle(fontFamily: fontFamily)),
- description: Text('配置下载并发数等参数',
- style: TextStyle(fontFamily: fontFamily)),
- ),
- SettingsTile.navigation(
- onPressed: (_) {
- context.pushNamed('/settings/plugin/');
- },
- leading: const Icon(Icons.extension),
- title: Text('规则管理', style: TextStyle(fontFamily: fontFamily)),
- description: Text('管理番剧资源规则',
- style: TextStyle(fontFamily: fontFamily)),
- ),
- ],
- ),
- SettingsSection(
- title: Text('播放器设置', style: TextStyle(fontFamily: fontFamily)),
- tiles: [
- SettingsTile.navigation(
- onPressed: (_) {
- context.pushNamed('/settings/player');
- },
- leading: const Icon(Icons.display_settings_rounded),
- title: Text('播放设置', style: TextStyle(fontFamily: fontFamily)),
- description: Text('设置播放器相关参数',
- style: TextStyle(fontFamily: fontFamily)),
- ),
- SettingsTile.navigation(
- onPressed: (_) {
- context.pushNamed('/settings/danmaku/');
- },
- leading: const Icon(Icons.subtitles_rounded),
- title: Text('弹幕设置', style: TextStyle(fontFamily: fontFamily)),
- description: Text('设置弹幕相关参数',
- style: TextStyle(fontFamily: fontFamily)),
- ),
- SettingsTile.navigation(
- onPressed: (_) {
- context.pushNamed('/settings/keyboard');
- },
- leading: const Icon(Icons.keyboard_rounded),
- title: Text('操作设置', style: TextStyle(fontFamily: fontFamily)),
- description: Text('设置播放器按键映射',
- style: TextStyle(fontFamily: fontFamily)),
- ),
- SettingsTile.navigation(
- onPressed: (_) {
- context.pushNamed('/settings/proxy');
- },
- leading: const Icon(Icons.vpn_key_rounded),
- title: Text('代理设置', style: TextStyle(fontFamily: fontFamily)),
- description: Text('配置HTTP代理',
- style: TextStyle(fontFamily: fontFamily)),
- ),
- ],
- ),
- SettingsSection(
- title: Text('应用与外观', style: TextStyle(fontFamily: fontFamily)),
- tiles: [
- SettingsTile.navigation(
- onPressed: (_) {
- context.pushNamed('/settings/theme');
- },
- leading: const Icon(Icons.palette_rounded),
- title: Text('外观设置', style: TextStyle(fontFamily: fontFamily)),
- description: Text('设置应用主题和刷新率',
- style: TextStyle(fontFamily: fontFamily)),
- ),
- SettingsTile.navigation(
- onPressed: (_) {
- context.pushNamed('/settings/interface');
- },
- leading: const Icon(Icons.pages_rounded),
- title: Text('界面设置', style: TextStyle(fontFamily: fontFamily)),
- description: Text('设置应用界面样式',
- style: TextStyle(fontFamily: fontFamily)),
- ),
- SettingsTile.navigation(
- onPressed: (_) {
- context.pushNamed('/settings/webdav/');
- },
- leading: const Icon(Icons.cloud),
- title: Text('同步设置', style: TextStyle(fontFamily: fontFamily)),
- description:
- Text('设置同步参数', style: TextStyle(fontFamily: fontFamily)),
- ),
- ],
- ),
- SettingsSection(
- title: Text('其他', style: TextStyle(fontFamily: fontFamily)),
- tiles: [
- SettingsTile.navigation(
- onPressed: (_) {
- context.pushNamed('/settings/about/');
- },
- leading: const Icon(Icons.info_outline_rounded),
- title: Text('关于', style: TextStyle(fontFamily: fontFamily)),
- ),
- ],
- ),
- ],
- ),
+ return Scaffold(
+ appBar: const SysAppBar(title: Text('我的'), needTopOffset: false),
+ body: SettingsList(
+ maxWidth: 1000,
+ sections: [
+ SettingsSection(
+ title: Text('播放历史与视频源', style: TextStyle(fontFamily: fontFamily)),
+ tiles: [
+ SettingsTile.navigation(
+ onPressed: (_) {
+ context.pushNamed('/settings/history/');
+ },
+ leading: const Icon(Icons.history_rounded),
+ title: Text('历史记录', style: TextStyle(fontFamily: fontFamily)),
+ description:
+ Text('查看播放历史记录', style: TextStyle(fontFamily: fontFamily)),
+ ),
+ SettingsTile.navigation(
+ onPressed: (_) {
+ context.pushNamed('/settings/download/');
+ },
+ leading: const Icon(Icons.download_rounded),
+ title: Text('下载管理', style: TextStyle(fontFamily: fontFamily)),
+ description:
+ Text('查看和管理离线下载', style: TextStyle(fontFamily: fontFamily)),
+ ),
+ SettingsTile.navigation(
+ onPressed: (_) {
+ context.pushNamed('/settings/download-settings');
+ },
+ leading: const Icon(Icons.settings_rounded),
+ title: Text('下载设置', style: TextStyle(fontFamily: fontFamily)),
+ description: Text('配置下载并发数等参数',
+ style: TextStyle(fontFamily: fontFamily)),
+ ),
+ SettingsTile.navigation(
+ onPressed: (_) {
+ context.pushNamed('/settings/plugin/');
+ },
+ leading: const Icon(Icons.extension),
+ title: Text('规则管理', style: TextStyle(fontFamily: fontFamily)),
+ description:
+ Text('管理番剧资源规则', style: TextStyle(fontFamily: fontFamily)),
+ ),
+ ],
+ ),
+ SettingsSection(
+ title: Text('播放器设置', style: TextStyle(fontFamily: fontFamily)),
+ tiles: [
+ SettingsTile.navigation(
+ onPressed: (_) {
+ context.pushNamed('/settings/player');
+ },
+ leading: const Icon(Icons.display_settings_rounded),
+ title: Text('播放设置', style: TextStyle(fontFamily: fontFamily)),
+ description:
+ Text('设置播放器相关参数', style: TextStyle(fontFamily: fontFamily)),
+ ),
+ SettingsTile.navigation(
+ onPressed: (_) {
+ context.pushNamed('/settings/danmaku/');
+ },
+ leading: const Icon(Icons.subtitles_rounded),
+ title: Text('弹幕设置', style: TextStyle(fontFamily: fontFamily)),
+ description:
+ Text('设置弹幕相关参数', style: TextStyle(fontFamily: fontFamily)),
+ ),
+ SettingsTile.navigation(
+ onPressed: (_) {
+ context.pushNamed('/settings/keyboard');
+ },
+ leading: const Icon(Icons.keyboard_rounded),
+ title: Text('操作设置', style: TextStyle(fontFamily: fontFamily)),
+ description:
+ Text('设置播放器按键映射', style: TextStyle(fontFamily: fontFamily)),
+ ),
+ SettingsTile.navigation(
+ onPressed: (_) {
+ context.pushNamed('/settings/proxy');
+ },
+ leading: const Icon(Icons.vpn_key_rounded),
+ title: Text('代理设置', style: TextStyle(fontFamily: fontFamily)),
+ description:
+ Text('配置HTTP代理', style: TextStyle(fontFamily: fontFamily)),
+ ),
+ ],
+ ),
+ SettingsSection(
+ title: Text('应用与外观', style: TextStyle(fontFamily: fontFamily)),
+ tiles: [
+ SettingsTile.navigation(
+ onPressed: (_) {
+ context.pushNamed('/settings/theme');
+ },
+ leading: const Icon(Icons.palette_rounded),
+ title: Text('外观设置', style: TextStyle(fontFamily: fontFamily)),
+ description: Text('设置应用主题和刷新率',
+ style: TextStyle(fontFamily: fontFamily)),
+ ),
+ SettingsTile.navigation(
+ onPressed: (_) {
+ context.pushNamed('/settings/interface');
+ },
+ leading: const Icon(Icons.pages_rounded),
+ title: Text('界面设置', style: TextStyle(fontFamily: fontFamily)),
+ description:
+ Text('设置应用界面样式', style: TextStyle(fontFamily: fontFamily)),
+ ),
+ SettingsTile.navigation(
+ onPressed: (_) {
+ context.pushNamed('/settings/webdav/');
+ },
+ leading: const Icon(Icons.cloud),
+ title: Text('同步设置', style: TextStyle(fontFamily: fontFamily)),
+ description:
+ Text('设置同步参数', style: TextStyle(fontFamily: fontFamily)),
+ ),
+ ],
+ ),
+ SettingsSection(
+ title: Text('其他', style: TextStyle(fontFamily: fontFamily)),
+ tiles: [
+ SettingsTile.navigation(
+ onPressed: (_) {
+ context.pushNamed('/settings/about/');
+ },
+ leading: const Icon(Icons.info_outline_rounded),
+ title: Text('关于', style: TextStyle(fontFamily: fontFamily)),
+ ),
+ ],
+ ),
+ ],
),
);
}
diff --git a/lib/pages/popular/popular_page.dart b/lib/pages/popular/popular_page.dart
index d84c100d..155402b3 100644
--- a/lib/pages/popular/popular_page.dart
+++ b/lib/pages/popular/popular_page.dart
@@ -1,14 +1,13 @@
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
-import 'package:kazumi/bean/dialog/dialog_helper.dart';
import 'package:kazumi/bean/widget/bangumi_mirror_error_widget.dart';
import 'package:kazumi/bean/widget/custom_dropdown_menu.dart';
+import 'package:kazumi/modules/bangumi/bangumi_item.dart';
import 'package:kazumi/pages/popular/popular_controller.dart';
import 'package:kazumi/bean/card/bangumi_card.dart';
import 'package:kazumi/utils/constants.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
-import 'package:flutter/services.dart';
import 'package:window_manager/window_manager.dart';
import 'package:kazumi/services/logging/logger.dart';
import 'package:kazumi/services/storage/storage.dart';
@@ -28,8 +27,6 @@ class PopularPage extends StatefulWidget {
}
class _PopularPageState extends State<PopularPage> {
- DateTime? _lastPressedAt;
- final FocusNode _focusNode = FocusNode();
late final ScrollController scrollController;
PopularController get popularController => widget.controller;
@@ -50,7 +47,6 @@ class _PopularPageState extends State<PopularPage> {
@override
void dispose() {
- _focusNode.dispose();
scrollController.removeListener(scrollListener);
scrollController.dispose();
super.dispose();
@@ -75,91 +71,66 @@ class _PopularPageState extends State<PopularPage> {
return GStorage.getSetting(SettingsKeys.showWindowButton);
}
- void onBackPressed(BuildContext context) {
- if (KazumiDialog.observer.hasKazumiDialog) {
- KazumiDialog.dismiss();
- return;
- }
- if (_lastPressedAt == null ||
- DateTime.now().difference(_lastPressedAt!) >
- const Duration(seconds: 2)) {
- _lastPressedAt = DateTime.now();
- KazumiDialog.showToast(message: "再按一次退出应用", context: context);
- return;
- }
- SystemNavigator.pop();
- }
-
@override
Widget build(BuildContext context) {
- return PopScope(
- canPop: false,
- onPopInvokedWithResult: (bool didPop, Object? result) {
- if (didPop) {
- return;
- }
- onBackPressed(context);
- },
- child: Scaffold(
- body: CustomScrollView(
- controller: scrollController,
- slivers: [
- buildSliverAppBar(),
- SliverToBoxAdapter(
- child: Observer(
- builder: (_) => AnimatedOpacity(
- opacity: popularController.isLoadingMore ? 1.0 : 0.0,
- duration: const Duration(milliseconds: 300),
- child: popularController.isLoadingMore
- ? const LinearProgressIndicator(minHeight: 4)
- : const SizedBox(height: 4),
- ),
+ return Scaffold(
+ body: CustomScrollView(
+ controller: scrollController,
+ slivers: [
+ buildSliverAppBar(),
+ SliverToBoxAdapter(
+ child: Observer(
+ builder: (_) => AnimatedOpacity(
+ opacity: popularController.isLoadingMore ? 1.0 : 0.0,
+ duration: const Duration(milliseconds: 300),
+ child: popularController.isLoadingMore
+ ? const LinearProgressIndicator(minHeight: 4)
+ : const SizedBox(height: 4),
),
),
- SliverPadding(
- padding: const EdgeInsets.fromLTRB(
- StyleString.cardSpace, 0, StyleString.cardSpace, 0),
- sliver: Observer(builder: (_) {
- if (popularController.isTimeOut) {
- return SliverToBoxAdapter(
- child: SizedBox(
- height: 400,
- child: BangumiMirrorErrorWidget(
- onRetry: () {
- if (popularController.trendList.isEmpty) {
- popularController.queryBangumiByTrend();
- } else {
- popularController.queryBangumiByTag();
- }
- },
- onSettingsReturned: () {
- if (mounted) {
- setState(() {});
- }
- },
- ),
+ ),
+ SliverPadding(
+ padding: const EdgeInsets.fromLTRB(
+ StyleString.cardSpace, 0, StyleString.cardSpace, 0),
+ sliver: Observer(builder: (_) {
+ if (popularController.isTimeOut) {
+ return SliverToBoxAdapter(
+ child: SizedBox(
+ height: 400,
+ child: BangumiMirrorErrorWidget(
+ onRetry: () {
+ if (popularController.trendList.isEmpty) {
+ popularController.queryBangumiByTrend();
+ } else {
+ popularController.queryBangumiByTag();
+ }
+ },
+ onSettingsReturned: () {
+ if (mounted) {
+ setState(() {});
+ }
+ },
),
- );
- }
- return contentGrid(
- (popularController.currentTag == '')
- ? popularController.trendList
- : popularController.bangumiList,
+ ),
);
- })),
- ],
- ),
- floatingActionButton: FloatingActionButton(
- onPressed: () => scrollController.animateTo(0,
- duration: const Duration(milliseconds: 350),
- curve: Curves.easeOut),
- child: const Icon(Icons.arrow_upward),
- ),
+ }
+ return contentGrid(
+ (popularController.currentTag == '')
+ ? popularController.trendList
+ : popularController.bangumiList,
+ );
+ })),
+ ],
+ ),
+ floatingActionButton: FloatingActionButton(
+ onPressed: () => scrollController.animateTo(0,
+ duration: const Duration(milliseconds: 350), curve: Curves.easeOut),
+ child: const Icon(Icons.arrow_upward),
),
);
}
- Widget contentGrid(bangumiList) {
+ Widget contentGrid(List<BangumiItem> bangumiList) {
int crossCount = 3;
if (MediaQuery.sizeOf(context).width > LayoutBreakpoint.compact['width']!) {
crossCount = 5;
@@ -183,11 +154,11 @@ class _PopularPageState extends State<PopularPage> {
),
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
- return bangumiList!.isNotEmpty
+ return bangumiList.isNotEmpty
? BangumiCardV(bangumiItem: bangumiList[index])
: null;
},
- childCount: bangumiList!.isNotEmpty ? bangumiList!.length : 10,
+ childCount: bangumiList.isNotEmpty ? bangumiList.length : 10,
),
),
);
diff --git a/lib/pages/timeline/timeline_page.dart b/lib/pages/timeline/timeline_page.dart
index 8764ec52..15fbec08 100644
--- a/lib/pages/timeline/timeline_page.dart
+++ b/lib/pages/timeline/timeline_page.dart
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
-import 'package:flutter_modular/flutter_modular.dart';
import 'package:kazumi/modules/bangumi/bangumi_item.dart';
import 'package:kazumi/pages/timeline/timeline_controller.dart';
import 'package:kazumi/bean/dialog/adaptive_bottom_sheet.dart';
@@ -51,14 +50,6 @@ class _TimelinePageState extends State<TimelinePage>
super.dispose();
}
- void onBackPressed(BuildContext context) {
- if (KazumiDialog.observer.hasKazumiDialog) {
- KazumiDialog.dismiss();
- return;
- }
- context.navigate('/tab/popular/');
- }
-
DateTime generateDateTime(int year, String season) {
switch (season) {
case '冬':
@@ -684,85 +675,76 @@ class _TimelinePageState extends State<TimelinePage>
@override
Widget build(BuildContext context) {
- return PopScope(
- canPop: false,
- onPopInvokedWithResult: (bool didPop, Object? result) {
- if (didPop) {
- return;
- }
- onBackPressed(context);
- },
- child: Scaffold(
- appBar: SysAppBar(
- needTopOffset: false,
- toolbarHeight: 104,
- bottom: TabBar(
- controller: tabController,
- tabs: tabs,
- indicatorColor: Theme.of(context).colorScheme.primary,
- ),
- title: InkWell(
- borderRadius: BorderRadius.circular(8),
- child: Observer(builder: (context) {
- return Text(timelineController.seasonString);
- }),
- onTap: () {
- showSeasonBottomSheet(context);
- },
- ),
+ return Scaffold(
+ appBar: SysAppBar(
+ needTopOffset: false,
+ toolbarHeight: 104,
+ bottom: TabBar(
+ controller: tabController,
+ tabs: tabs,
+ indicatorColor: Theme.of(context).colorScheme.primary,
),
- floatingActionButton: FloatingActionButton(
- onPressed: () {
- KazumiDialog.showBottomSheet(
- backgroundColor: Theme.of(context).colorScheme.surface,
- shape: const RoundedRectangleBorder(
- borderRadius: BorderRadius.vertical(top: Radius.circular(28)),
- ),
- isScrollControlled: true,
- constraints: buildTimelineBottomSheetConstraints(
- context,
- compactHeightFactor: 2 / 3,
- ),
- clipBehavior: Clip.antiAlias,
- useSafeArea: true,
- context: context,
- builder: (context) {
- return buildTimelineOptionsSheet(context);
- },
- );
+ title: InkWell(
+ borderRadius: BorderRadius.circular(8),
+ child: Observer(builder: (context) {
+ return Text(timelineController.seasonString);
+ }),
+ onTap: () {
+ showSeasonBottomSheet(context);
},
- child: const Icon(Icons.tune),
),
- body: Observer(builder: (context) {
- if (timelineController.isLoading &&
- timelineController.bangumiCalendar.isEmpty) {
- return const Center(
- child: CircularProgressIndicator(),
- );
- }
- if (timelineController.isTimeOut) {
- return Center(
- child: SizedBox(
- height: 400,
- child: BangumiMirrorErrorWidget(
- onRetry: () {
- onSeasonSelected(timelineController.selectedDate);
- },
- onSettingsReturned: () {
- if (mounted) {
- setState(() {});
- }
- },
- ),
- ),
- );
- }
- return TabBarView(
- controller: tabController,
- children: contentGrid(timelineController.bangumiCalendar),
+ ),
+ floatingActionButton: FloatingActionButton(
+ onPressed: () {
+ KazumiDialog.showBottomSheet(
+ backgroundColor: Theme.of(context).colorScheme.surface,
+ shape: const RoundedRectangleBorder(
+ borderRadius: BorderRadius.vertical(top: Radius.circular(28)),
+ ),
+ isScrollControlled: true,
+ constraints: buildTimelineBottomSheetConstraints(
+ context,
+ compactHeightFactor: 2 / 3,
+ ),
+ clipBehavior: Clip.antiAlias,
+ useSafeArea: true,
+ context: context,
+ builder: (context) {
+ return buildTimelineOptionsSheet(context);
+ },
);
- }),
+ },
+ child: const Icon(Icons.tune),
),
+ body: Observer(builder: (context) {
+ if (timelineController.isLoading &&
+ timelineController.bangumiCalendar.isEmpty) {
+ return const Center(
+ child: CircularProgressIndicator(),
+ );
+ }
+ if (timelineController.isTimeOut) {
+ return Center(
+ child: SizedBox(
+ height: 400,
+ child: BangumiMirrorErrorWidget(
+ onRetry: () {
+ onSeasonSelected(timelineController.selectedDate);
+ },
+ onSettingsReturned: () {
+ if (mounted) {
+ setState(() {});
+ }
+ },
+ ),
+ ),
+ );
+ }
+ return TabBarView(
+ controller: tabController,
+ children: contentGrid(timelineController.bangumiCalendar),
+ );
+ }),
);
}