From 4431ed09c0b7d81dd4fb8d033acb2d0c8689ea0d Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Thu, 24 Oct 2024 10:37:13 +0800 Subject: [PATCH] fix: member status on video intro --- .../video/detail/introduction/controller.dart | 31 ++++++++++---- lib/pages/video/detail/introduction/view.dart | 42 ++++++++++--------- 2 files changed, 45 insertions(+), 28 deletions(-) diff --git a/lib/pages/video/detail/introduction/controller.dart b/lib/pages/video/detail/introduction/controller.dart index bfb6c573..ae48ca69 100644 --- a/lib/pages/video/detail/introduction/controller.dart +++ b/lib/pages/video/detail/introduction/controller.dart @@ -507,15 +507,30 @@ class VideoIntroController extends GetxController SmartDialog.showToast('账号未登录'); return; } - Utils.actionRelationMod( - context: context, - mid: videoDetail.value.owner?.mid, - isFollow: (followStatus['attribute'] ?? 0) != 0, - callback: (attribute) { - followStatus['attribute'] = attribute; + int attr = followStatus['attribute'] ?? 0; + if (attr == 128) { + dynamic res = await VideoHttp.relationMod( + mid: videoDetail.value.owner?.mid ?? -1, + act: attr != 128 ? 5 : 6, + reSrc: 11, + ); + if (res['status']) { + followStatus['attribute'] = 0; followStatus.refresh(); - }, - ); + } + return; + } + if (context.mounted) { + Utils.actionRelationMod( + context: context, + mid: videoDetail.value.owner?.mid, + isFollow: (followStatus['attribute'] ?? 0) != 0, + callback: (attribute) { + followStatus['attribute'] = attribute; + followStatus.refresh(); + }, + ); + } // MemberController _ = Get.put(MemberController(mid: mid), // tag: mid.toString()); diff --git a/lib/pages/video/detail/introduction/view.dart b/lib/pages/video/detail/introduction/view.dart index a73ff61b..c4d0bea8 100644 --- a/lib/pages/video/detail/introduction/view.dart +++ b/lib/pages/video/detail/introduction/view.dart @@ -545,26 +545,28 @@ class _VideoInfoState extends State with TickerProviderStateMixin { Obx followButton(BuildContext context, ThemeData t) { return Obx( - () => TextButton( - onPressed: () => videoIntroController.actionRelationMod(context), - style: TextButton.styleFrom( - visualDensity: const VisualDensity(horizontal: -2, vertical: -3), - foregroundColor: - (videoIntroController.followStatus['attribute'] ?? 0) != 0 - ? t.colorScheme.outline - : t.colorScheme.onPrimary, - backgroundColor: - (videoIntroController.followStatus['attribute'] ?? 0) != 0 - ? t.colorScheme.onInverseSurface - : t.colorScheme.primary, // 设置按钮背景色 - ), - child: Text( - ((videoIntroController.followStatus['attribute'] ?? 0) != 0) - ? '已关注' - : '关注', - style: TextStyle(fontSize: t.textTheme.labelMedium!.fontSize), - ), - ), + () { + int attr = videoIntroController.followStatus['attribute'] ?? 0; + return TextButton( + onPressed: () => videoIntroController.actionRelationMod(context), + style: TextButton.styleFrom( + visualDensity: const VisualDensity(horizontal: -2, vertical: -3), + foregroundColor: + attr != 0 ? t.colorScheme.outline : t.colorScheme.onPrimary, + backgroundColor: attr != 0 + ? t.colorScheme.onInverseSurface + : t.colorScheme.primary, // 设置按钮背景色 + ), + child: Text( + attr == 128 + ? '已拉黑' + : attr != 0 + ? '已关注' + : '关注', + style: TextStyle(fontSize: t.textTheme.labelMedium!.fontSize), + ), + ); + }, ); }