Merge pull request #329 from orz12/remove_loading_on_liking_reply
opt: 移除回复点赞冗余加载提示
This commit is contained in:
@ -121,7 +121,14 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
late final BangumiInfoModel? bangumiItem;
|
late final BangumiInfoModel? bangumiItem;
|
||||||
late double sheetHeight;
|
late double sheetHeight;
|
||||||
int? cid;
|
int? cid;
|
||||||
|
bool isProcessing = false;
|
||||||
|
void Function()? handleState(Future Function() action) {
|
||||||
|
return isProcessing ? null : () async {
|
||||||
|
setState(() => isProcessing = true);
|
||||||
|
await action();
|
||||||
|
setState(() => isProcessing = false);
|
||||||
|
};
|
||||||
|
}
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -395,7 +402,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
() => ActionItem(
|
() => ActionItem(
|
||||||
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
||||||
onTap: () => bangumiIntroController.actionLikeVideo(),
|
onTap: handleState(bangumiIntroController.actionLikeVideo),
|
||||||
selectStatus: bangumiIntroController.hasLike.value,
|
selectStatus: bangumiIntroController.hasLike.value,
|
||||||
loadingStatus: false,
|
loadingStatus: false,
|
||||||
text: !widget.loadingStatus
|
text: !widget.loadingStatus
|
||||||
@ -406,7 +413,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
() => ActionItem(
|
() => ActionItem(
|
||||||
icon: const Icon(FontAwesomeIcons.b),
|
icon: const Icon(FontAwesomeIcons.b),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.b),
|
selectIcon: const Icon(FontAwesomeIcons.b),
|
||||||
onTap: () => bangumiIntroController.actionCoinVideo(),
|
onTap: handleState(bangumiIntroController.actionCoinVideo),
|
||||||
selectStatus: bangumiIntroController.hasCoin.value,
|
selectStatus: bangumiIntroController.hasCoin.value,
|
||||||
loadingStatus: false,
|
loadingStatus: false,
|
||||||
text: !widget.loadingStatus
|
text: !widget.loadingStatus
|
||||||
@ -455,7 +462,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
Obx(
|
Obx(
|
||||||
() => ActionRowItem(
|
() => ActionRowItem(
|
||||||
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
||||||
onTap: () => videoIntroController.actionLikeVideo(),
|
onTap: handleState(videoIntroController.actionLikeVideo),
|
||||||
selectStatus: videoIntroController.hasLike.value,
|
selectStatus: videoIntroController.hasLike.value,
|
||||||
loadingStatus: widget.loadingStatus,
|
loadingStatus: widget.loadingStatus,
|
||||||
text: !widget.loadingStatus
|
text: !widget.loadingStatus
|
||||||
@ -467,7 +474,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
Obx(
|
Obx(
|
||||||
() => ActionRowItem(
|
() => ActionRowItem(
|
||||||
icon: const Icon(FontAwesomeIcons.b),
|
icon: const Icon(FontAwesomeIcons.b),
|
||||||
onTap: () => videoIntroController.actionCoinVideo(),
|
onTap: handleState(videoIntroController.actionCoinVideo),
|
||||||
selectStatus: videoIntroController.hasCoin.value,
|
selectStatus: videoIntroController.hasCoin.value,
|
||||||
loadingStatus: widget.loadingStatus,
|
loadingStatus: widget.loadingStatus,
|
||||||
text: !widget.loadingStatus
|
text: !widget.loadingStatus
|
||||||
|
|||||||
@ -23,7 +23,14 @@ 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;
|
||||||
|
void Function()? handleState(Future Function() action) {
|
||||||
|
return isProcessing ? null : () async {
|
||||||
|
setState(() => isProcessing = true);
|
||||||
|
await action();
|
||||||
|
setState(() => isProcessing = false);
|
||||||
|
};
|
||||||
|
}
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -31,7 +38,7 @@ class _ActionPanelState extends State<ActionPanel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 动态点赞
|
// 动态点赞
|
||||||
onLikeDynamic() async {
|
Future onLikeDynamic() async {
|
||||||
feedBack();
|
feedBack();
|
||||||
var item = widget.item!;
|
var item = widget.item!;
|
||||||
String dynamicId = item.idStr!;
|
String dynamicId = item.idStr!;
|
||||||
@ -101,7 +108,7 @@ class _ActionPanelState extends State<ActionPanel> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: TextButton.icon(
|
child: TextButton.icon(
|
||||||
onPressed: () => onLikeDynamic(),
|
onPressed: handleState(onLikeDynamic),
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
stat.like!.status!
|
stat.like!.status!
|
||||||
? FontAwesomeIcons.solidThumbsUp
|
? FontAwesomeIcons.solidThumbsUp
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@ -134,7 +136,14 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
late int mid;
|
late int mid;
|
||||||
late String memberHeroTag;
|
late String memberHeroTag;
|
||||||
late bool enableAi;
|
late bool enableAi;
|
||||||
|
bool isProcessing = false;
|
||||||
|
void Function()? handleState(Future Function() action) {
|
||||||
|
return isProcessing ? null : () async {
|
||||||
|
setState(() => isProcessing = true);
|
||||||
|
await action();
|
||||||
|
setState(() => isProcessing = false);
|
||||||
|
};
|
||||||
|
}
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -477,7 +486,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
() => ActionItem(
|
() => ActionItem(
|
||||||
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
selectIcon: const Icon(FontAwesomeIcons.solidThumbsUp),
|
||||||
onTap: () => videoIntroController.actionLikeVideo(),
|
onTap: handleState(videoIntroController.actionLikeVideo),
|
||||||
selectStatus: videoIntroController.hasLike.value,
|
selectStatus: videoIntroController.hasLike.value,
|
||||||
loadingStatus: loadingStatus,
|
loadingStatus: loadingStatus,
|
||||||
text: !loadingStatus
|
text: !loadingStatus
|
||||||
@ -494,7 +503,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
() => ActionItem(
|
() => ActionItem(
|
||||||
icon: const Icon(FontAwesomeIcons.b),
|
icon: const Icon(FontAwesomeIcons.b),
|
||||||
selectIcon: const Icon(FontAwesomeIcons.b),
|
selectIcon: const Icon(FontAwesomeIcons.b),
|
||||||
onTap: () => videoIntroController.actionCoinVideo(),
|
onTap: handleState(videoIntroController.actionCoinVideo),
|
||||||
selectStatus: videoIntroController.hasCoin.value,
|
selectStatus: videoIntroController.hasCoin.value,
|
||||||
loadingStatus: loadingStatus,
|
loadingStatus: loadingStatus,
|
||||||
text: !loadingStatus
|
text: !loadingStatus
|
||||||
@ -538,7 +547,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
Obx(
|
Obx(
|
||||||
() => ActionRowItem(
|
() => ActionRowItem(
|
||||||
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
icon: const Icon(FontAwesomeIcons.thumbsUp),
|
||||||
onTap: () => videoIntroController.actionLikeVideo(),
|
onTap: handleState(videoIntroController.actionLikeVideo),
|
||||||
selectStatus: videoIntroController.hasLike.value,
|
selectStatus: videoIntroController.hasLike.value,
|
||||||
loadingStatus: loadingStatus,
|
loadingStatus: loadingStatus,
|
||||||
text:
|
text:
|
||||||
@ -549,7 +558,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
Obx(
|
Obx(
|
||||||
() => ActionRowItem(
|
() => ActionRowItem(
|
||||||
icon: const Icon(FontAwesomeIcons.b),
|
icon: const Icon(FontAwesomeIcons.b),
|
||||||
onTap: () => videoIntroController.actionCoinVideo(),
|
onTap: handleState(videoIntroController.actionCoinVideo),
|
||||||
selectStatus: videoIntroController.hasCoin.value,
|
selectStatus: videoIntroController.hasCoin.value,
|
||||||
loadingStatus: loadingStatus,
|
loadingStatus: loadingStatus,
|
||||||
text:
|
text:
|
||||||
|
|||||||
@ -22,9 +22,9 @@ class ZanButton extends StatefulWidget {
|
|||||||
|
|
||||||
class _ZanButtonState extends State<ZanButton> {
|
class _ZanButtonState extends State<ZanButton> {
|
||||||
// 评论点赞
|
// 评论点赞
|
||||||
onLikeReply() async {
|
Future onLikeReply() async {
|
||||||
feedBack();
|
feedBack();
|
||||||
SmartDialog.showLoading(msg: 'pilipala ...');
|
// SmartDialog.showLoading(msg: 'pilipala ...');
|
||||||
ReplyItemModel replyItem = widget.replyItem!;
|
ReplyItemModel replyItem = widget.replyItem!;
|
||||||
int oid = replyItem.oid!;
|
int oid = replyItem.oid!;
|
||||||
int rpid = replyItem.rpid!;
|
int rpid = replyItem.rpid!;
|
||||||
@ -32,7 +32,7 @@ class _ZanButtonState extends State<ZanButton> {
|
|||||||
int action = replyItem.action == 0 ? 1 : 0;
|
int action = replyItem.action == 0 ? 1 : 0;
|
||||||
var res = await ReplyHttp.likeReply(
|
var 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 == 0 ? '点赞成功 👍' : '取消赞 💔');
|
||||||
if (action == 1) {
|
if (action == 1) {
|
||||||
@ -47,6 +47,14 @@ class _ZanButtonState extends State<ZanButton> {
|
|||||||
SmartDialog.showToast(res['msg']);
|
SmartDialog.showToast(res['msg']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bool isProcessing = false;
|
||||||
|
void Function()? handleState(Future Function() action) {
|
||||||
|
return isProcessing ? null : () async {
|
||||||
|
setState(() => isProcessing = true);
|
||||||
|
await action();
|
||||||
|
setState(() => isProcessing = false);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -55,6 +63,7 @@ class _ZanButtonState extends State<ZanButton> {
|
|||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: 32,
|
height: 32,
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
|
onPressed: handleState(onLikeReply),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
@ -79,7 +88,6 @@ class _ZanButtonState extends State<ZanButton> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
onPressed: () => onLikeReply(),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user