From 23ba9ad8c195527d108307792192249f66cf6222 Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Tue, 24 Dec 2024 12:03:53 +0800 Subject: [PATCH] opt: expand intro panel Signed-off-by: bggRGjQaUbCoE --- lib/pages/setting/extra_setting.dart | 8 +++++++- lib/pages/video/detail/introduction/view.dart | 9 +++++---- lib/utils/storage.dart | 10 +++++++--- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/pages/setting/extra_setting.dart b/lib/pages/setting/extra_setting.dart index 35ba57d2..c501da26 100644 --- a/lib/pages/setting/extra_setting.dart +++ b/lib/pages/setting/extra_setting.dart @@ -244,7 +244,13 @@ class _ExtraSettingState extends State { SetSwitchItem( title: '默认展开视频简介', leading: Icon(Icons.expand_more), - setKey: SettingBoxKey.exapndIntroPanel, + setKey: SettingBoxKey.alwaysExapndIntroPanel, + defaultVal: false, + ), + SetSwitchItem( + title: '横屏自动展开视频简介', + leading: Icon(Icons.expand_more), + setKey: SettingBoxKey.exapndIntroPanelH, defaultVal: false, ), Obx( diff --git a/lib/pages/video/detail/introduction/view.dart b/lib/pages/video/detail/introduction/view.dart index 03cc353e..0acb68cd 100644 --- a/lib/pages/video/detail/introduction/view.dart +++ b/lib/pages/video/detail/introduction/view.dart @@ -171,15 +171,16 @@ class _VideoInfoState extends State with TickerProviderStateMixin { loadingStatus = widget.loadingStatus; enableAi = setting.get(SettingBoxKey.enableAi, defaultValue: true); - bool exapndIntroPanel = GStorage.exapndIntroPanel; + bool alwaysExapndIntroPanel = GStorage.alwaysExapndIntroPanel; _expandableCtr = ExpandableController( - initialExpanded: exapndIntroPanel, + initialExpanded: alwaysExapndIntroPanel, ); - if (exapndIntroPanel.not) { + if (alwaysExapndIntroPanel.not && GStorage.exapndIntroPanelH) { WidgetsBinding.instance.addPostFrameCallback((_) { - if (context.orientation == Orientation.landscape) { + if (context.orientation == Orientation.landscape && + _expandableCtr.expanded.not) { _expandableCtr.toggle(); } }); diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index 4be3c71f..b7fc0b74 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -122,8 +122,11 @@ class GStorage { static bool get showBangumiReply => setting.get(SettingBoxKey.showBangumiReply, defaultValue: true); - static bool get exapndIntroPanel => - setting.get(SettingBoxKey.exapndIntroPanel, defaultValue: false); + static bool get alwaysExapndIntroPanel => + setting.get(SettingBoxKey.alwaysExapndIntroPanel, defaultValue: false); + + static bool get exapndIntroPanelH => + setting.get(SettingBoxKey.exapndIntroPanelH, defaultValue: false); static List get dynamicDetailRatio => setting.get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0]); @@ -321,7 +324,8 @@ class SettingBoxKey { showRelatedVideo = 'showRelatedVideo', showVideoReply = 'showVideoReply', showBangumiReply = 'showBangumiReply', - exapndIntroPanel = 'exapndIntroPanel', + alwaysExapndIntroPanel = 'alwaysExapndIntroPanel', + exapndIntroPanelH = 'exapndIntroPanelH', // Sponsor Block enableSponsorBlock = 'enableSponsorBlock',