opt fab location

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-03-16 10:12:36 +08:00
parent e04affd0fe
commit ed66a4655b
18 changed files with 556 additions and 619 deletions

View File

@@ -68,13 +68,12 @@ class _ArticlePageState extends CommonDynPageState<ArticlePage> {
appBar: _buildAppBar(),
body: Padding(
padding: EdgeInsets.only(left: padding.left, right: padding.right),
child: Stack(
clipBehavior: Clip.none,
children: [
_buildPage(theme),
_buildBottom(theme),
],
),
child: _buildPage(theme),
),
floatingActionButtonLocation: floatingActionButtonLocation,
floatingActionButton: SlideTransition(
position: fabAnimation,
child: _buildBottom(theme),
),
);
}
@@ -494,177 +493,160 @@ class _ArticlePageState extends CommonDynPageState<ArticlePage> {
],
);
Widget _buildBottom(ThemeData theme) => Positioned(
left: 0,
bottom: 0,
right: 0,
child: SlideTransition(
position: fabAnim,
child: Builder(
builder: (context) {
if (!controller.showDynActionBar) {
return Align(
alignment: Alignment.bottomRight,
child: Padding(
padding: EdgeInsets.only(
right: kFloatingActionButtonMargin,
bottom: padding.bottom + kFloatingActionButtonMargin,
),
child: replyButton,
),
);
}
Widget _buildBottom(ThemeData theme) {
if (!controller.showDynActionBar) {
return fabButton;
}
late final primary = theme.colorScheme.primary;
late final outline = theme.colorScheme.outline;
late final btnStyle = TextButton.styleFrom(
tapTargetSize: .padded,
padding: const EdgeInsets.symmetric(horizontal: 15),
foregroundColor: outline,
late final primary = theme.colorScheme.primary;
late final outline = theme.colorScheme.outline;
late final btnStyle = TextButton.styleFrom(
tapTargetSize: .padded,
padding: const EdgeInsets.symmetric(horizontal: 15),
foregroundColor: outline,
);
Widget textIconButton({
required IconData icon,
required String text,
required DynamicStat? stat,
required VoidCallback onPressed,
IconData? activatedIcon,
}) {
final status = stat?.status == true;
final color = status ? primary : outline;
return TextButton.icon(
onPressed: onPressed,
icon: Icon(
status ? activatedIcon : icon,
size: 16,
color: color,
),
style: btnStyle,
label: Text(
stat?.count != null ? NumUtils.numFormat(stat!.count) : text,
style: TextStyle(color: color),
),
);
}
return Padding(
padding: .only(left: padding.left, right: padding.right),
child: Obx(() {
final stats = controller.stats.value;
Widget btn = Padding(
padding: EdgeInsets.only(
right: kFloatingActionButtonMargin,
bottom:
kFloatingActionButtonMargin +
(stats != null ? 0 : padding.bottom),
),
child: replyButton,
);
if (stats == null) {
return Align(
alignment: Alignment.bottomRight,
child: btn,
);
}
Widget textIconButton({
required IconData icon,
required String text,
required DynamicStat? stat,
required VoidCallback onPressed,
IconData? activatedIcon,
}) {
final status = stat?.status == true;
final color = status ? primary : outline;
return TextButton.icon(
onPressed: onPressed,
icon: Icon(
status ? activatedIcon : icon,
size: 16,
color: color,
),
style: btnStyle,
label: Text(
stat?.count != null ? NumUtils.numFormat(stat!.count) : text,
style: TextStyle(color: color),
),
);
}
return Obx(() {
final stats = controller.stats.value;
Widget btn = Padding(
padding: EdgeInsets.only(
right: kFloatingActionButtonMargin,
bottom:
kFloatingActionButtonMargin +
(stats != null ? 0 : padding.bottom),
),
child: replyButton,
);
if (stats == null) {
return Align(
alignment: Alignment.centerRight,
child: btn,
);
}
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
btn,
Container(
decoration: BoxDecoration(
color: theme.colorScheme.surface,
border: Border(
top: BorderSide(
color: theme.colorScheme.outline.withValues(
alpha: 0.08,
),
),
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
btn,
Container(
decoration: BoxDecoration(
color: theme.colorScheme.surface,
border: Border(
top: BorderSide(
color: theme.colorScheme.outline.withValues(
alpha: 0.08,
),
),
padding: EdgeInsets.only(bottom: padding.bottom),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Expanded(
child: Builder(
builder: (btnContext) {
final forward = stats.forward;
return textIconButton(
text: '转发',
icon: FontAwesomeIcons.shareFromSquare,
stat: forward,
onPressed: () {
if (controller.opusData == null &&
controller.articleData?.dynIdStr == null) {
SmartDialog.showToast(
'err: ${controller.id}',
);
return;
}
final summary = controller.summary;
showModalBottomSheet(
context: context,
isScrollControlled: true,
useSafeArea: true,
builder: (context) => RepostPanel(
item: controller.opusData,
dynIdStr: controller.articleData?.dynIdStr,
pic: summary.cover,
title: summary.title,
uname: summary.author?.name,
onSuccess: () {
if (forward != null) {
int count = forward.count ?? 0;
forward.count = count + 1;
if (btnContext.mounted) {
(btnContext as Element?)
?.markNeedsBuild();
}
}
},
),
);
},
),
),
padding: EdgeInsets.only(bottom: padding.bottom),
child: Row(
children: [
Expanded(
child: Builder(
builder: (btnContext) {
final forward = stats.forward;
return textIconButton(
text: '转发',
icon: FontAwesomeIcons.shareFromSquare,
stat: forward,
onPressed: () {
if (controller.opusData == null &&
controller.articleData?.dynIdStr == null) {
SmartDialog.showToast(
'err: ${controller.id}',
);
return;
}
final summary = controller.summary;
showModalBottomSheet(
context: context,
isScrollControlled: true,
useSafeArea: true,
builder: (context) => RepostPanel(
item: controller.opusData,
dynIdStr: controller.articleData?.dynIdStr,
pic: summary.cover,
title: summary.title,
uname: summary.author?.name,
onSuccess: () {
if (forward != null) {
int count = forward.count ?? 0;
forward.count = count + 1;
if (btnContext.mounted) {
(btnContext as Element?)
?.markNeedsBuild();
}
}
},
),
);
},
),
),
Expanded(
child: textIconButton(
text: '分享',
icon: CustomIcons.share_node,
stat: null,
onPressed: () => Utils.shareText(controller.url),
),
),
Expanded(
child: textIconButton(
icon: FontAwesomeIcons.star,
activatedIcon: FontAwesomeIcons.solidStar,
text: '收藏',
stat: stats.favorite,
onPressed: controller.onFav,
),
),
Expanded(
child: textIconButton(
icon: FontAwesomeIcons.thumbsUp,
activatedIcon: FontAwesomeIcons.solidThumbsUp,
text: '点赞',
stat: stats.like,
onPressed: controller.onLike,
),
),
],
);
},
),
),
),
],
);
});
},
),
),
);
Expanded(
child: textIconButton(
text: '分享',
icon: CustomIcons.share_node,
stat: null,
onPressed: () => Utils.shareText(controller.url),
),
),
Expanded(
child: textIconButton(
icon: FontAwesomeIcons.star,
activatedIcon: FontAwesomeIcons.solidStar,
text: '收藏',
stat: stats.favorite,
onPressed: controller.onFav,
),
),
Expanded(
child: textIconButton(
icon: FontAwesomeIcons.thumbsUp,
activatedIcon: FontAwesomeIcons.solidThumbsUp,
text: '点赞',
stat: stats.like,
onPressed: controller.onLike,
),
),
],
),
),
],
);
}),
);
}
}