mod: option show dyn actionbar

Closes #412

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-03-09 21:12:16 +08:00
parent 35a53bc8ac
commit 95e50e436b
6 changed files with 556 additions and 431 deletions

View File

@@ -19,6 +19,7 @@ class DynamicDetailController extends ReplyController {
int? floor; int? floor;
late final horizontalPreview = GStorage.horizontalPreview; late final horizontalPreview = GStorage.horizontalPreview;
late final showDynActionBar = GStorage.showDynActionBar;
@override @override
dynamic get sourceId => dynamic get sourceId =>

View File

@@ -458,13 +458,9 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
parent: _fabAnimationCtr!, parent: _fabAnimationCtr!,
curve: Curves.easeInOut, curve: Curves.easeInOut,
)), )),
child: Column( child: Builder(
mainAxisSize: MainAxisSize.min, builder: (context) {
crossAxisAlignment: CrossAxisAlignment.end, Widget button() => FloatingActionButton(
children: [
Padding(
padding: const EdgeInsets.only(right: 14, bottom: 14),
child: FloatingActionButton(
heroTag: null, heroTag: null,
onPressed: () { onPressed: () {
feedBack(); feedBack();
@@ -476,7 +472,27 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
}, },
tooltip: '评论动态', tooltip: '评论动态',
child: const Icon(Icons.reply), child: const Icon(Icons.reply),
);
return _dynamicDetailController.showDynActionBar.not
? Align(
alignment: Alignment.bottomRight,
child: Padding(
padding: EdgeInsets.only(
right: 14,
bottom:
MediaQuery.paddingOf(context).bottom + 14,
), ),
child: button(),
),
)
: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Padding(
padding: const EdgeInsets.only(
right: 14, bottom: 14),
child: button(),
), ),
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
@@ -491,20 +507,24 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
), ),
), ),
padding: EdgeInsets.only( padding: EdgeInsets.only(
bottom: MediaQuery.paddingOf(context).bottom), bottom:
MediaQuery.paddingOf(context).bottom),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [ children: [
Expanded( Expanded(
child: Builder( child: Builder(
builder: (btnContext) => TextButton.icon( builder: (btnContext) =>
TextButton.icon(
onPressed: () { onPressed: () {
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
isScrollControlled: true, isScrollControlled: true,
useSafeArea: true, useSafeArea: true,
builder: (context) => RepostPanel( builder: (context) => RepostPanel(
item: _dynamicDetailController.item, item: _dynamicDetailController
.item,
callback: () { callback: () {
int count = int.tryParse( int count = int.tryParse(
_dynamicDetailController _dynamicDetailController
@@ -515,16 +535,23 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
?.count ?? ?.count ??
'0') ?? '0') ??
0; 0;
_dynamicDetailController.item.modules _dynamicDetailController
?.moduleStat ??= ModuleStatModel(); .item
_dynamicDetailController.item.modules! .modules
.moduleStat?.forward ??= ForWard(); ?.moduleStat ??=
ModuleStatModel();
_dynamicDetailController
.item
.modules!
.moduleStat
?.forward ??= ForWard();
_dynamicDetailController _dynamicDetailController
.item .item
.modules! .modules!
.moduleStat! .moduleStat!
.forward! .forward!
.count = (count + 1).toString(); .count =
(count + 1).toString();
if (btnContext.mounted) { if (btnContext.mounted) {
(btnContext as Element?) (btnContext as Element?)
?.markNeedsBuild(); ?.markNeedsBuild();
@@ -536,20 +563,28 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
icon: Icon( icon: Icon(
FontAwesomeIcons.shareFromSquare, FontAwesomeIcons.shareFromSquare,
size: 16, size: 16,
color: Theme.of(context).colorScheme.outline, color: Theme.of(context)
.colorScheme
.outline,
semanticLabel: "转发", semanticLabel: "转发",
), ),
style: TextButton.styleFrom( style: TextButton.styleFrom(
padding: padding: const EdgeInsets.fromLTRB(
const EdgeInsets.fromLTRB(15, 0, 15, 0), 15, 0, 15, 0),
foregroundColor: foregroundColor: Theme.of(context)
Theme.of(context).colorScheme.outline, .colorScheme
.outline,
), ),
label: Text( label: Text(
_dynamicDetailController.item.modules _dynamicDetailController
?.moduleStat?.forward?.count != .item
.modules
?.moduleStat
?.forward
?.count !=
null null
? Utils.numFormat(_dynamicDetailController ? Utils.numFormat(
_dynamicDetailController
.item .item
.modules! .modules!
.moduleStat! .moduleStat!
@@ -569,14 +604,17 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
icon: Icon( icon: Icon(
FontAwesomeIcons.shareNodes, FontAwesomeIcons.shareNodes,
size: 16, size: 16,
color: Theme.of(context).colorScheme.outline, color: Theme.of(context)
.colorScheme
.outline,
semanticLabel: "分享", semanticLabel: "分享",
), ),
style: TextButton.styleFrom( style: TextButton.styleFrom(
padding: padding: const EdgeInsets.fromLTRB(
const EdgeInsets.fromLTRB(15, 0, 15, 0), 15, 0, 15, 0),
foregroundColor: foregroundColor: Theme.of(context)
Theme.of(context).colorScheme.outline, .colorScheme
.outline,
), ),
label: const Text('分享'), label: const Text('分享'),
), ),
@@ -588,23 +626,37 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
_dynamicDetailController.item, _dynamicDetailController.item,
() { () {
if (context.mounted) { if (context.mounted) {
(context as Element?)?.markNeedsBuild(); (context as Element?)
?.markNeedsBuild();
} }
}, },
), ),
icon: Icon( icon: Icon(
_dynamicDetailController.item.modules _dynamicDetailController
?.moduleStat?.like?.status == .item
.modules
?.moduleStat
?.like
?.status ==
true true
? FontAwesomeIcons.solidThumbsUp ? FontAwesomeIcons.solidThumbsUp
: FontAwesomeIcons.thumbsUp, : FontAwesomeIcons.thumbsUp,
size: 16, size: 16,
color: _dynamicDetailController.item.modules color: _dynamicDetailController
?.moduleStat?.like?.status == .item
.modules
?.moduleStat
?.like
?.status ==
true true
? Theme.of(context).colorScheme.primary ? Theme.of(context)
: Theme.of(context).colorScheme.outline, .colorScheme
semanticLabel: _dynamicDetailController .primary
: Theme.of(context)
.colorScheme
.outline,
semanticLabel:
_dynamicDetailController
.item .item
.modules .modules
?.moduleStat ?.moduleStat
@@ -615,21 +667,28 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
: "点赞", : "点赞",
), ),
style: TextButton.styleFrom( style: TextButton.styleFrom(
padding: padding: const EdgeInsets.fromLTRB(
const EdgeInsets.fromLTRB(15, 0, 15, 0), 15, 0, 15, 0),
foregroundColor: foregroundColor: Theme.of(context)
Theme.of(context).colorScheme.outline, .colorScheme
.outline,
), ),
label: AnimatedSwitcher( label: AnimatedSwitcher(
duration: const Duration(milliseconds: 400), duration: const Duration(
milliseconds: 400),
transitionBuilder: (Widget child, transitionBuilder: (Widget child,
Animation<double> animation) { Animation<double> animation) {
return ScaleTransition( return ScaleTransition(
scale: animation, child: child); scale: animation,
child: child);
}, },
child: Text( child: Text(
_dynamicDetailController.item.modules _dynamicDetailController
?.moduleStat?.like?.count != .item
.modules
?.moduleStat
?.like
?.count !=
null null
? Utils.numFormat( ? Utils.numFormat(
_dynamicDetailController _dynamicDetailController
@@ -663,6 +722,8 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
), ),
), ),
], ],
);
},
), ),
), ),
), ),

View File

@@ -25,6 +25,7 @@ class HtmlRenderController extends ReplyController {
RxBool loaded = false.obs; RxBool loaded = false.obs;
late final horizontalPreview = GStorage.horizontalPreview; late final horizontalPreview = GStorage.horizontalPreview;
late final showDynActionBar = GStorage.showDynActionBar;
@override @override
dynamic get sourceId => id; dynamic get sourceId => id;
@@ -35,6 +36,8 @@ class HtmlRenderController extends ReplyController {
id = Get.parameters['id']!; id = Get.parameters['id']!;
dynamicType = Get.parameters['dynamicType']!; dynamicType = Get.parameters['dynamicType']!;
type = dynamicType == 'picture' ? 11 : 12; type = dynamicType == 'picture' ? 11 : 12;
if (showDynActionBar) {
if (RegExp(r'^cv', caseSensitive: false).hasMatch(id)) { if (RegExp(r'^cv', caseSensitive: false).hasMatch(id)) {
UrlUtils.parseRedirectUrl('https://www.bilibili.com/read/$id/') UrlUtils.parseRedirectUrl('https://www.bilibili.com/read/$id/')
.then((url) { .then((url) {
@@ -45,6 +48,8 @@ class HtmlRenderController extends ReplyController {
} else { } else {
_queryDyn(id); _queryDyn(id);
} }
}
reqHtml(); reqHtml();
} }

View File

@@ -448,20 +448,9 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
parent: fabAnimationCtr, parent: fabAnimationCtr,
curve: Curves.easeInOut, curve: Curves.easeInOut,
)), )),
child: Obx( child: Builder(
() => Column( builder: (context) {
mainAxisSize: MainAxisSize.min, Widget button() => FloatingActionButton(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Padding(
padding: EdgeInsets.only(
right: 14,
bottom: 14 +
(_htmlRenderCtr.item.value.idStr != null
? 0
: MediaQuery.of(context).padding.bottom),
),
child: FloatingActionButton(
heroTag: null, heroTag: null,
onPressed: () { onPressed: () {
feedBack(); feedBack();
@@ -473,12 +462,42 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
}, },
tooltip: '评论动态', tooltip: '评论动态',
child: const Icon(Icons.reply), child: const Icon(Icons.reply),
);
return _htmlRenderCtr.showDynActionBar.not
? Align(
alignment: Alignment.bottomRight,
child: Padding(
padding: EdgeInsets.only(
right: 14,
bottom:
MediaQuery.of(context).padding.bottom + 14,
), ),
child: button(),
),
)
: Obx(
() => Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Padding(
padding: EdgeInsets.only(
right: 14,
bottom: 14 +
(_htmlRenderCtr.item.value.idStr != null
? 0
: MediaQuery.of(context)
.padding
.bottom),
),
child: button(),
), ),
_htmlRenderCtr.item.value.idStr != null _htmlRenderCtr.item.value.idStr != null
? Container( ? Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface, color: Theme.of(context)
.colorScheme
.surface,
border: Border( border: Border(
top: BorderSide( top: BorderSide(
color: Theme.of(context) color: Theme.of(context)
@@ -489,20 +508,25 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
), ),
), ),
padding: EdgeInsets.only( padding: EdgeInsets.only(
bottom: MediaQuery.paddingOf(context).bottom), bottom: MediaQuery.paddingOf(context)
.bottom),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [ children: [
Expanded( Expanded(
child: Builder( child: Builder(
builder: (btnContext) => TextButton.icon( builder: (btnContext) =>
TextButton.icon(
onPressed: () { onPressed: () {
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
isScrollControlled: true, isScrollControlled: true,
useSafeArea: true, useSafeArea: true,
builder: (context) => RepostPanel( builder: (context) =>
item: _htmlRenderCtr.item.value, RepostPanel(
item: _htmlRenderCtr
.item.value,
callback: () { callback: () {
int count = int.tryParse( int count = int.tryParse(
_htmlRenderCtr _htmlRenderCtr
@@ -521,9 +545,12 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
?.moduleStat ?.moduleStat
?.forward! ?.forward!
.count = .count =
(count + 1).toString(); (count + 1)
if (btnContext.mounted) { .toString();
(btnContext as Element?) if (btnContext
.mounted) {
(btnContext
as Element?)
?.markNeedsBuild(); ?.markNeedsBuild();
} }
}, },
@@ -531,7 +558,8 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
); );
}, },
icon: Icon( icon: Icon(
FontAwesomeIcons.shareFromSquare, FontAwesomeIcons
.shareFromSquare,
size: 16, size: 16,
color: Theme.of(context) color: Theme.of(context)
.colorScheme .colorScheme
@@ -539,9 +567,11 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
semanticLabel: "转发", semanticLabel: "转发",
), ),
style: TextButton.styleFrom( style: TextButton.styleFrom(
padding: const EdgeInsets.fromLTRB( padding:
const EdgeInsets.fromLTRB(
15, 0, 15, 0), 15, 0, 15, 0),
foregroundColor: Theme.of(context) foregroundColor:
Theme.of(context)
.colorScheme .colorScheme
.outline, .outline,
), ),
@@ -554,7 +584,8 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
?.forward! ?.forward!
.count != .count !=
null null
? Utils.numFormat(_htmlRenderCtr ? Utils.numFormat(
_htmlRenderCtr
.item .item
.value .value
.modules .modules
@@ -575,23 +606,29 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
icon: Icon( icon: Icon(
FontAwesomeIcons.shareNodes, FontAwesomeIcons.shareNodes,
size: 16, size: 16,
color: color: Theme.of(context)
Theme.of(context).colorScheme.outline, .colorScheme
.outline,
semanticLabel: "分享", semanticLabel: "分享",
), ),
style: TextButton.styleFrom( style: TextButton.styleFrom(
padding: const EdgeInsets.fromLTRB( padding:
const EdgeInsets.fromLTRB(
15, 0, 15, 0), 15, 0, 15, 0),
foregroundColor: foregroundColor:
Theme.of(context).colorScheme.outline, Theme.of(context)
.colorScheme
.outline,
), ),
label: const Text('分享'), label: const Text('分享'),
), ),
), ),
Expanded( Expanded(
child: Builder( child: Builder(
builder: (context) => TextButton.icon( builder: (context) =>
onPressed: () => Utils.onLikeDynamic( TextButton.icon(
onPressed: () =>
Utils.onLikeDynamic(
_htmlRenderCtr.item.value, _htmlRenderCtr.item.value,
() { () {
if (context.mounted) { if (context.mounted) {
@@ -609,8 +646,10 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
?.like ?.like
?.status == ?.status ==
true true
? FontAwesomeIcons.solidThumbsUp ? FontAwesomeIcons
: FontAwesomeIcons.thumbsUp, .solidThumbsUp
: FontAwesomeIcons
.thumbsUp,
size: 16, size: 16,
color: _htmlRenderCtr color: _htmlRenderCtr
.item .item
@@ -638,19 +677,24 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
: "点赞", : "点赞",
), ),
style: TextButton.styleFrom( style: TextButton.styleFrom(
padding: const EdgeInsets.fromLTRB( padding:
const EdgeInsets.fromLTRB(
15, 0, 15, 0), 15, 0, 15, 0),
foregroundColor: Theme.of(context) foregroundColor:
Theme.of(context)
.colorScheme .colorScheme
.outline, .outline,
), ),
label: AnimatedSwitcher( label: AnimatedSwitcher(
duration: duration: const Duration(
const Duration(milliseconds: 400), milliseconds: 400),
transitionBuilder: (Widget child, transitionBuilder:
Animation<double> animation) { (Widget child,
Animation<double>
animation) {
return ScaleTransition( return ScaleTransition(
scale: animation, child: child); scale: animation,
child: child);
}, },
child: Text( child: Text(
_htmlRenderCtr _htmlRenderCtr
@@ -661,7 +705,8 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
?.like ?.like
?.count != ?.count !=
null null
? Utils.numFormat(_htmlRenderCtr ? Utils.numFormat(
_htmlRenderCtr
.item .item
.value .value
.modules! .modules!
@@ -696,6 +741,8 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
: const SizedBox.shrink(), : const SizedBox.shrink(),
], ],
), ),
);
},
), ),
), ),
), ),

View File

@@ -2137,6 +2137,13 @@ List<SettingsModel> get extraSettings => [
setKey: SettingBoxKey.enableShrinkVideoSize, setKey: SettingBoxKey.enableShrinkVideoSize,
defaultVal: true, defaultVal: true,
), ),
SettingsModel(
settingsType: SettingsType.sw1tch,
title: '动态/专栏详情页展示底部操作栏',
leading: const Icon(Icons.more_horiz),
setKey: SettingBoxKey.showDynActionBar,
defaultVal: true,
),
SettingsModel( SettingsModel(
settingsType: SettingsType.sw1tch, settingsType: SettingsType.sw1tch,
enableFeedback: true, enableFeedback: true,

View File

@@ -400,6 +400,9 @@ class GStorage {
static bool get enableShrinkVideoSize => GStorage.setting static bool get enableShrinkVideoSize => GStorage.setting
.get(SettingBoxKey.enableShrinkVideoSize, defaultValue: true); .get(SettingBoxKey.enableShrinkVideoSize, defaultValue: true);
static bool get showDynActionBar =>
GStorage.setting.get(SettingBoxKey.showDynActionBar, defaultValue: true);
static List<double> get dynamicDetailRatio => List<double>.from(setting static List<double> get dynamicDetailRatio => List<double>.from(setting
.get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0])); .get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0]));
@@ -657,6 +660,7 @@ class SettingBoxKey {
slideDismissReplyPage = 'slideDismissReplyPage', slideDismissReplyPage = 'slideDismissReplyPage',
showFSActionItem = 'showFSActionItem', showFSActionItem = 'showFSActionItem',
enableShrinkVideoSize = 'enableShrinkVideoSize', enableShrinkVideoSize = 'enableShrinkVideoSize',
showDynActionBar = 'showDynActionBar',
// Sponsor Block // Sponsor Block
enableSponsorBlock = 'enableSponsorBlock', enableSponsorBlock = 'enableSponsorBlock',