mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: action panel
This commit is contained in:
@@ -26,7 +26,7 @@ class ActionPanel extends StatefulWidget {
|
|||||||
|
|
||||||
class _ActionPanelState extends State<ActionPanel> {
|
class _ActionPanelState extends State<ActionPanel> {
|
||||||
final DynamicsController _dynamicsController = Get.put(DynamicsController());
|
final DynamicsController _dynamicsController = Get.put(DynamicsController());
|
||||||
late ModuleStatModel stat;
|
// late ModuleStatModel stat;
|
||||||
bool isProcessing = false;
|
bool isProcessing = false;
|
||||||
void Function()? handleState(Future Function() action) {
|
void Function()? handleState(Future Function() action) {
|
||||||
return isProcessing
|
return isProcessing
|
||||||
@@ -38,11 +38,11 @@ class _ActionPanelState extends State<ActionPanel> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
// @override
|
||||||
void initState() {
|
// void initState() {
|
||||||
super.initState();
|
// super.initState();
|
||||||
stat = widget.item!.modules.moduleStat;
|
// stat = widget.item!.modules.moduleStat;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 动态点赞
|
// 动态点赞
|
||||||
Future onLikeDynamic() async {
|
Future onLikeDynamic() async {
|
||||||
@@ -89,7 +89,18 @@ class _ActionPanelState extends State<ActionPanel> {
|
|||||||
context: context,
|
context: context,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
useSafeArea: true,
|
useSafeArea: true,
|
||||||
builder: (_) => RepostPanel(item: widget.item),
|
builder: (_) => RepostPanel(
|
||||||
|
item: widget.item,
|
||||||
|
callback: () {
|
||||||
|
int count = int.tryParse(
|
||||||
|
widget.item!.modules.moduleStat.forward?.count ??
|
||||||
|
'0') ??
|
||||||
|
0;
|
||||||
|
widget.item!.modules.moduleStat.forward!.count =
|
||||||
|
(count + 1).toString();
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
@@ -101,7 +112,7 @@ class _ActionPanelState extends State<ActionPanel> {
|
|||||||
padding: const EdgeInsets.fromLTRB(15, 0, 15, 0),
|
padding: const EdgeInsets.fromLTRB(15, 0, 15, 0),
|
||||||
foregroundColor: Theme.of(context).colorScheme.outline,
|
foregroundColor: Theme.of(context).colorScheme.outline,
|
||||||
),
|
),
|
||||||
label: Text(stat.forward!.count ?? ''),
|
label: Text(widget.item!.modules.moduleStat.forward!.count ?? '转发'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -118,7 +129,7 @@ class _ActionPanelState extends State<ActionPanel> {
|
|||||||
padding: const EdgeInsets.fromLTRB(15, 0, 15, 0),
|
padding: const EdgeInsets.fromLTRB(15, 0, 15, 0),
|
||||||
foregroundColor: Theme.of(context).colorScheme.outline,
|
foregroundColor: Theme.of(context).colorScheme.outline,
|
||||||
),
|
),
|
||||||
label: Text(stat.comment!.count ?? ''),
|
label: Text(widget.item!.modules.moduleStat.comment!.count ?? '评论'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@@ -126,12 +137,15 @@ class _ActionPanelState extends State<ActionPanel> {
|
|||||||
child: TextButton.icon(
|
child: TextButton.icon(
|
||||||
onPressed: handleState(onLikeDynamic),
|
onPressed: handleState(onLikeDynamic),
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
stat.like!.status!
|
widget.item!.modules.moduleStat.like!.status!
|
||||||
? FontAwesomeIcons.solidThumbsUp
|
? FontAwesomeIcons.solidThumbsUp
|
||||||
: FontAwesomeIcons.thumbsUp,
|
: FontAwesomeIcons.thumbsUp,
|
||||||
size: 16,
|
size: 16,
|
||||||
color: stat.like!.status! ? primary : color,
|
color: widget.item!.modules.moduleStat.like!.status!
|
||||||
semanticLabel: stat.like!.status! ? "已赞" : "点赞",
|
? primary
|
||||||
|
: color,
|
||||||
|
semanticLabel:
|
||||||
|
widget.item!.modules.moduleStat.like!.status! ? "已赞" : "点赞",
|
||||||
),
|
),
|
||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
padding: const EdgeInsets.fromLTRB(15, 0, 15, 0),
|
padding: const EdgeInsets.fromLTRB(15, 0, 15, 0),
|
||||||
@@ -143,10 +157,13 @@ class _ActionPanelState extends State<ActionPanel> {
|
|||||||
return ScaleTransition(scale: animation, child: child);
|
return ScaleTransition(scale: animation, child: child);
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
stat.like!.count ?? '',
|
widget.item!.modules.moduleStat.like!.count ?? '点赞',
|
||||||
key: ValueKey<String>(stat.like!.count ?? '点赞'),
|
key: ValueKey<String>(
|
||||||
|
widget.item!.modules.moduleStat.like!.count ?? '点赞'),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: stat.like!.status! ? primary : color,
|
color: widget.item!.modules.moduleStat.like!.status!
|
||||||
|
? primary
|
||||||
|
: color,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -158,9 +175,15 @@ class _ActionPanelState extends State<ActionPanel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class RepostPanel extends StatefulWidget {
|
class RepostPanel extends StatefulWidget {
|
||||||
const RepostPanel({super.key, required this.item});
|
const RepostPanel({
|
||||||
|
super.key,
|
||||||
|
required this.item,
|
||||||
|
required this.callback,
|
||||||
|
});
|
||||||
|
|
||||||
final dynamic item;
|
final dynamic item;
|
||||||
|
final Function callback;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<RepostPanel> createState() => _RepostPanelState();
|
State<RepostPanel> createState() => _RepostPanelState();
|
||||||
}
|
}
|
||||||
@@ -180,6 +203,7 @@ class _RepostPanelState extends State<RepostPanel> {
|
|||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
Get.back();
|
Get.back();
|
||||||
SmartDialog.showToast('转发成功');
|
SmartDialog.showToast('转发成功');
|
||||||
|
widget.callback();
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast(result['msg']);
|
SmartDialog.showToast(result['msg']);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user