From 9e5b7a405f60a5b53cda2abf84366d7c375cebdc Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 26 Jul 2023 00:16:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=82=B9=E8=B5=9E=E6=8A=95=E5=B8=81?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/http/video.dart | 2 +- .../video/detail/introduction/controller.dart | 8 +++++-- .../introduction/widgets/action_row_item.dart | 24 ++++++++++++------- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/lib/http/video.dart b/lib/http/video.dart index 37522d4f..1de728cb 100644 --- a/lib/http/video.dart +++ b/lib/http/video.dart @@ -199,7 +199,7 @@ class VideoHttp { if (res.data['code'] == 0) { return {'status': true, 'data': res.data['data']}; } else { - return {'status': true, 'data': [], 'msg': ''}; + return {'status': false, 'data': [], 'msg': res.data['message']}; } } diff --git a/lib/pages/video/detail/introduction/controller.dart b/lib/pages/video/detail/introduction/controller.dart index ffc13d7c..bb208b3b 100644 --- a/lib/pages/video/detail/introduction/controller.dart +++ b/lib/pages/video/detail/introduction/controller.dart @@ -184,9 +184,11 @@ class VideoIntroController extends GetxController { if (!hasLike.value) { SmartDialog.showToast('į‚ščĩžæˆåŠŸ 👍'); hasLike.value = true; + videoDetail.value.stat!.like = videoDetail.value.stat!.like! + 1; } else if (hasLike.value) { SmartDialog.showToast('取æļˆčĩž'); hasLike.value = false; + videoDetail.value.stat!.like = videoDetail.value.stat!.like! - 1; } hasLike.refresh(); } else { @@ -238,12 +240,14 @@ class VideoIntroController extends GetxController { var res = await VideoHttp.coinVideo( bvid: bvid, multiply: _tempThemeValue); if (res['status']) { - SmartDialog.showToast('投币成功'); + SmartDialog.showToast('投币成功 👏'); + hasCoin.value = true; + videoDetail.value.stat!.coin = + videoDetail.value.stat!.coin! + _tempThemeValue; } else { SmartDialog.showToast(res['msg']); } Get.back(); - queryHasCoinVideo(); }, child: const Text('įĄŽåŽš')) ], diff --git a/lib/pages/video/detail/introduction/widgets/action_row_item.dart b/lib/pages/video/detail/introduction/widgets/action_row_item.dart index 0d3f2bd7..254d7bcd 100644 --- a/lib/pages/video/detail/introduction/widgets/action_row_item.dart +++ b/lib/pages/video/detail/introduction/widgets/action_row_item.dart @@ -44,14 +44,22 @@ class ActionRowItem extends StatelessWidget { AnimatedOpacity( opacity: loadingStatus! ? 0 : 1, duration: const Duration(milliseconds: 200), - child: Text( - text ?? '', - style: TextStyle( - color: selectStatus - ? Theme.of(context).colorScheme.primary - : null, - fontSize: - Theme.of(context).textTheme.labelMedium?.fontSize), + child: AnimatedSwitcher( + duration: const Duration(milliseconds: 300), + transitionBuilder: + (Widget child, Animation animation) { + return ScaleTransition(scale: animation, child: child); + }, + child: Text( + text ?? '', + key: ValueKey(text ?? ''), + style: TextStyle( + color: selectStatus + ? Theme.of(context).colorScheme.primary + : null, + fontSize: + Theme.of(context).textTheme.labelSmall!.fontSize), + ), ), ), ],