mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: thumbsdown reply
This commit is contained in:
@@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
## feat
|
## feat
|
||||||
|
|
||||||
|
- [x] 评论点踩
|
||||||
- [x] 显示ops专栏
|
- [x] 显示ops专栏
|
||||||
- [x] 私信发图
|
- [x] 私信发图
|
||||||
- [x] 投币动画
|
- [x] 投币动画
|
||||||
|
|||||||
@@ -143,6 +143,8 @@ class Api {
|
|||||||
// 评论点赞
|
// 评论点赞
|
||||||
static const String likeReply = '/x/v2/reply/action';
|
static const String likeReply = '/x/v2/reply/action';
|
||||||
|
|
||||||
|
static const String hateReply = '/x/v2/reply/hate';
|
||||||
|
|
||||||
// 发表评论
|
// 发表评论
|
||||||
// https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/comment/action.md
|
// https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/comment/action.md
|
||||||
static const String replyAdd = '/x/v2/reply/add';
|
static const String replyAdd = '/x/v2/reply/add';
|
||||||
|
|||||||
@@ -83,6 +83,36 @@ class ReplyHttp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future hateReply({
|
||||||
|
required int type,
|
||||||
|
required int action,
|
||||||
|
required int oid,
|
||||||
|
required int rpid,
|
||||||
|
}) async {
|
||||||
|
var res = await Request().post(
|
||||||
|
Api.hateReply,
|
||||||
|
data: {
|
||||||
|
'type': type,
|
||||||
|
'oid': oid,
|
||||||
|
'rpid': rpid,
|
||||||
|
'action': action,
|
||||||
|
'csrf': await Request.getCsrf(),
|
||||||
|
},
|
||||||
|
options: Options(
|
||||||
|
contentType: Headers.formUrlEncodedContentType,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (res.data['code'] == 0) {
|
||||||
|
return {'status': true, 'data': res.data['data']};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
'status': false,
|
||||||
|
'date': [],
|
||||||
|
'msg': res.data['message'],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 评论点赞
|
// 评论点赞
|
||||||
static Future likeReply({
|
static Future likeReply({
|
||||||
required int type,
|
required int type,
|
||||||
|
|||||||
@@ -364,11 +364,19 @@ class ReplyItem extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(width: 2),
|
const SizedBox(width: 2),
|
||||||
if (replyItem!.upAction!.like!) ...[
|
if (replyItem!.upAction!.like!) ...[
|
||||||
Text(
|
SizedBox(
|
||||||
'UP主觉得很赞',
|
height: 32,
|
||||||
style: TextStyle(
|
child: TextButton(
|
||||||
color: Theme.of(context).colorScheme.primary,
|
onPressed: null,
|
||||||
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize),
|
child: Text(
|
||||||
|
'UP主觉得很赞',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
fontSize: Theme.of(context).textTheme.labelMedium!.fontSize,
|
||||||
|
fontWeight: FontWeight.normal,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 2),
|
const SizedBox(width: 2),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -21,6 +21,38 @@ class ZanButton extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ZanButtonState extends State<ZanButton> {
|
class _ZanButtonState extends State<ZanButton> {
|
||||||
|
Future onHateReply() async {
|
||||||
|
feedBack();
|
||||||
|
// SmartDialog.showLoading(msg: 'pilipala ...');
|
||||||
|
final ReplyItemModel replyItem = widget.replyItem!;
|
||||||
|
final int oid = replyItem.oid!;
|
||||||
|
final int rpid = replyItem.rpid!;
|
||||||
|
// 1 已点赞 2 不喜欢 0 未操作
|
||||||
|
final int action = replyItem.action != 2 ? 2 : 0;
|
||||||
|
final res = await ReplyHttp.hateReply(
|
||||||
|
type: widget.replyType!.index,
|
||||||
|
action: action == 2 ? 1 : 0,
|
||||||
|
oid: oid,
|
||||||
|
rpid: rpid,
|
||||||
|
);
|
||||||
|
// SmartDialog.dismiss();
|
||||||
|
if (res['status']) {
|
||||||
|
SmartDialog.showToast(replyItem.action != 2 ? '点踩成功' : '取消踩');
|
||||||
|
if (action == 2) {
|
||||||
|
if (replyItem.action == 1) {
|
||||||
|
replyItem.like = replyItem.like! - 1;
|
||||||
|
}
|
||||||
|
replyItem.action = 2;
|
||||||
|
} else {
|
||||||
|
// replyItem.like = replyItem.like! - 1;
|
||||||
|
replyItem.action = 0;
|
||||||
|
}
|
||||||
|
setState(() {});
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast(res['msg']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 评论点赞
|
// 评论点赞
|
||||||
Future onLikeReply() async {
|
Future onLikeReply() async {
|
||||||
feedBack();
|
feedBack();
|
||||||
@@ -29,12 +61,12 @@ class _ZanButtonState extends State<ZanButton> {
|
|||||||
final int oid = replyItem.oid!;
|
final int oid = replyItem.oid!;
|
||||||
final int rpid = replyItem.rpid!;
|
final int rpid = replyItem.rpid!;
|
||||||
// 1 已点赞 2 不喜欢 0 未操作
|
// 1 已点赞 2 不喜欢 0 未操作
|
||||||
final int action = replyItem.action == 0 ? 1 : 0;
|
final int action = replyItem.action != 1 ? 1 : 0;
|
||||||
final res = await ReplyHttp.likeReply(
|
final res = await ReplyHttp.likeReply(
|
||||||
type: widget.replyType!.index, oid: oid, rpid: rpid, action: action);
|
type: widget.replyType!.index, oid: oid, rpid: rpid, action: action);
|
||||||
// SmartDialog.dismiss();
|
// SmartDialog.dismiss();
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
SmartDialog.showToast(replyItem.action == 0 ? '点赞成功' : '取消赞');
|
SmartDialog.showToast(replyItem.action != 1 ? '点赞成功' : '取消赞');
|
||||||
if (action == 1) {
|
if (action == 1) {
|
||||||
replyItem.like = replyItem.like! + 1;
|
replyItem.like = replyItem.like! + 1;
|
||||||
replyItem.action = 1;
|
replyItem.action = 1;
|
||||||
@@ -64,38 +96,58 @@ class _ZanButtonState extends State<ZanButton> {
|
|||||||
final ThemeData t = Theme.of(context);
|
final ThemeData t = Theme.of(context);
|
||||||
final Color color = t.colorScheme.outline;
|
final Color color = t.colorScheme.outline;
|
||||||
final Color primary = t.colorScheme.primary;
|
final Color primary = t.colorScheme.primary;
|
||||||
return SizedBox(
|
return Row(
|
||||||
height: 32,
|
mainAxisSize: MainAxisSize.min,
|
||||||
child: TextButton(
|
children: [
|
||||||
onPressed: handleState(onLikeReply),
|
SizedBox(
|
||||||
child: Row(
|
height: 32,
|
||||||
children: [
|
child: TextButton(
|
||||||
Icon(
|
onPressed: handleState(onHateReply),
|
||||||
widget.replyItem!.action == 1
|
child: Icon(
|
||||||
? FontAwesomeIcons.solidThumbsUp
|
widget.replyItem!.action == 2
|
||||||
: FontAwesomeIcons.thumbsUp,
|
? FontAwesomeIcons.solidThumbsDown
|
||||||
|
: FontAwesomeIcons.thumbsDown,
|
||||||
size: 16,
|
size: 16,
|
||||||
color: widget.replyItem!.action == 1 ? primary : color,
|
color: widget.replyItem!.action == 2 ? primary : color,
|
||||||
semanticLabel: widget.replyItem!.action == 1 ? '已赞' : '点赞',
|
semanticLabel: widget.replyItem!.action == 2 ? '已踩' : '点踩',
|
||||||
),
|
),
|
||||||
const SizedBox(width: 4),
|
),
|
||||||
AnimatedSwitcher(
|
|
||||||
duration: const Duration(milliseconds: 400),
|
|
||||||
transitionBuilder: (Widget child, Animation<double> animation) {
|
|
||||||
return ScaleTransition(scale: animation, child: child);
|
|
||||||
},
|
|
||||||
child: Text(
|
|
||||||
widget.replyItem!.like.toString(),
|
|
||||||
key: ValueKey<int>(widget.replyItem!.like!),
|
|
||||||
style: TextStyle(
|
|
||||||
color: widget.replyItem!.action == 1 ? primary : color,
|
|
||||||
fontSize: t.textTheme.labelSmall!.fontSize,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
SizedBox(
|
||||||
|
height: 32,
|
||||||
|
child: TextButton(
|
||||||
|
onPressed: handleState(onLikeReply),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
widget.replyItem!.action == 1
|
||||||
|
? FontAwesomeIcons.solidThumbsUp
|
||||||
|
: FontAwesomeIcons.thumbsUp,
|
||||||
|
size: 16,
|
||||||
|
color: widget.replyItem!.action == 1 ? primary : color,
|
||||||
|
semanticLabel: widget.replyItem!.action == 1 ? '已赞' : '点赞',
|
||||||
|
),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
AnimatedSwitcher(
|
||||||
|
duration: const Duration(milliseconds: 400),
|
||||||
|
transitionBuilder:
|
||||||
|
(Widget child, Animation<double> animation) {
|
||||||
|
return ScaleTransition(scale: animation, child: child);
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
widget.replyItem!.like.toString(),
|
||||||
|
key: ValueKey<int>(widget.replyItem!.like!),
|
||||||
|
style: TextStyle(
|
||||||
|
color: widget.replyItem!.action == 1 ? primary : color,
|
||||||
|
fontSize: t.textTheme.labelSmall!.fontSize,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user