diff --git a/lib/models/follow/result.dart b/lib/models/follow/result.dart index de9614e8..24ff29d1 100644 --- a/lib/models/follow/result.dart +++ b/lib/models/follow/result.dart @@ -30,7 +30,7 @@ class FollowItemModel { }); int? mid; - int? attribute; + int? attribute; // 对于`/x/relation/tag`, 此处的attribute似乎恒为0 // int? mtime; List? tag; int? special; diff --git a/lib/pages/member/controller.dart b/lib/pages/member/controller.dart index dc6f5320..6e95bbda 100644 --- a/lib/pages/member/controller.dart +++ b/lib/pages/member/controller.dart @@ -27,8 +27,7 @@ class MemberControllerNew extends CommonDataController RxBool showUname = false.obs; String? username; int? ownerMid; - RxBool isFollow = false.obs; - RxInt relation = 1.obs; + RxInt relation = 0.obs; TabController? tabController; late List tabs; List? tab2; @@ -37,6 +36,8 @@ class MemberControllerNew extends CommonDataController bool? hasSeasonOrSeries; final fromViewAid = Get.parameters['from_view_aid']; + bool get isFollow => relation.value != 0 && relation.value != 128; + @override void onInit() { super.onInit(); @@ -61,8 +62,11 @@ class MemberControllerNew extends CommonDataController bool customHandleResponse(bool isRefresh, Success response) { Data data = response.response; username = data.card?.name ?? ''; - isFollow.value = data.card?.relation?.isFollow == 1; - relation.value = data.relSpecial == 1 ? 2 : data.relation ?? 1; + relation.value = data.card?.relation?.isFollow == 1 + ? data.relSpecial == 1 + ? -10 + : data.card?.relation?.status ?? 2 + : 0; tab2 = data.tab2; live = data.live; silence = data.card?.silence; @@ -153,7 +157,7 @@ class MemberControllerNew extends CommonDataController builder: (context) { return AlertDialog( title: const Text('提示'), - content: Text(relation.value != -1 ? '确定拉黑UP主?' : '从黑名单移除UP主'), + content: Text(relation.value != 128 ? '确定拉黑UP主?' : '从黑名单移除UP主'), actions: [ TextButton( onPressed: Get.back, @@ -182,19 +186,18 @@ class MemberControllerNew extends CommonDataController void _onBlock() async { dynamic res = await VideoHttp.relationMod( mid: mid, - act: relation.value != -1 ? 5 : 6, + act: relation.value != 128 ? 5 : 6, reSrc: 11, ); if (res['status']) { - relation.value = relation.value != -1 ? -1 : 1; - isFollow.value = false; + relation.value = relation.value != 128 ? 128 : 0; } } void onFollow(BuildContext context) async { if (mid == ownerMid) { Get.toNamed('/editProfile'); - } else if (relation.value == -1) { + } else if (relation.value == 128) { _onBlock(); } else { if (ownerMid == null) { @@ -204,10 +207,9 @@ class MemberControllerNew extends CommonDataController Utils.actionRelationMod( context: context, mid: mid, - isFollow: isFollow.value, + isFollow: isFollow, callback: (attribute) { relation.value = attribute; - isFollow.value = attribute != 0; }, ); } diff --git a/lib/pages/member/member_page.dart b/lib/pages/member/member_page.dart index c3fbc252..dd215474 100644 --- a/lib/pages/member/member_page.dart +++ b/lib/pages/member/member_page.dart @@ -200,7 +200,7 @@ class _MemberPageNewState extends State { children: [ const Icon(Icons.block, size: 19), const SizedBox(width: 10), - Text(_userController.relation.value != -1 + Text(_userController.relation.value != 128 ? '加入黑名单' : '移除黑名单'), ], @@ -281,7 +281,6 @@ class _MemberPageNewState extends State { isV: isV, isOwner: _userController.mid == _userController.ownerMid, relation: _userController.relation.value, - isFollow: _userController.isFollow.value, card: userState.response.card, images: userState.response.images, onFollow: () => _userController.onFollow(context), diff --git a/lib/pages/member/widget/user_info_card.dart b/lib/pages/member/widget/user_info_card.dart index f3e79524..0a0ea9ed 100644 --- a/lib/pages/member/widget/user_info_card.dart +++ b/lib/pages/member/widget/user_info_card.dart @@ -19,7 +19,6 @@ class UserInfoCard extends StatelessWidget { required this.card, required this.images, required this.relation, - required this.isFollow, required this.onFollow, this.live, this.silence, @@ -29,7 +28,6 @@ class UserInfoCard extends StatelessWidget { final bool isV; final bool isOwner; final int relation; - final bool isFollow; final space.Card card; final space.Images images; final VoidCallback onFollow; @@ -380,7 +378,7 @@ class UserInfoCard extends StatelessWidget { child: FilledButton.tonal( onPressed: onFollow, style: FilledButton.styleFrom( - backgroundColor: relation == -1 || isFollow + backgroundColor: relation != 0 ? Theme.of(context).colorScheme.onInverseSurface : null, visualDensity: const VisualDensity( @@ -390,13 +388,13 @@ class UserInfoCard extends StatelessWidget { ), child: Text.rich( style: TextStyle( - color: relation == -1 || isFollow + color: relation != 0 ? Theme.of(context).colorScheme.outline : null, ), TextSpan( children: [ - if (isFollow) + if (relation != 0 && relation != 128) WidgetSpan( alignment: PlaceholderAlignment.top, child: Icon( @@ -406,16 +404,17 @@ class UserInfoCard extends StatelessWidget { ), ), TextSpan( - text: isOwner - ? '编辑资料' - : relation == -1 - ? '移除黑名单' - : relation == 2 - ? ' 特别关注' - : isFollow - ? ' 已关注' - : '关注', - ), + text: isOwner + ? '编辑资料' + : switch (relation) { + 0 => '关注', + 1 => '悄悄关注', + 2 => '已关注', + 6 => '已互关', + 128 => '移除黑名单', + -10 => '特别关注', // 该状态码并不是官方状态码 + _ => relation.toString(), + }), ], ), ), diff --git a/lib/pages/video/detail/introduction/controller.dart b/lib/pages/video/detail/introduction/controller.dart index 40c2edd2..d1b93665 100644 --- a/lib/pages/video/detail/introduction/controller.dart +++ b/lib/pages/video/detail/introduction/controller.dart @@ -546,7 +546,9 @@ class VideoIntroController extends GetxController } var result = await UserHttp.hasFollow(videoDetail.value.owner!.mid!); if (result['status']) { - followStatus.value = result['data']; + Map data = result['data']; + if (data['special'] == 1) data['attribute'] = -10; + followStatus.value = data; } } diff --git a/lib/pages/video/detail/introduction/view.dart b/lib/pages/video/detail/introduction/view.dart index 873da1f1..465291ff 100644 --- a/lib/pages/video/detail/introduction/view.dart +++ b/lib/pages/video/detail/introduction/view.dart @@ -890,6 +890,7 @@ class _VideoInfoState extends State { 2 => '已关注', 6 => '已互关', 128 => '已拉黑', + -10 => '特别关注', _ => '关注' }, style: TextStyle(fontSize: t.textTheme.labelMedium!.fontSize), diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index ae442fd1..d60b3393 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -1133,7 +1133,7 @@ class Utils { required BuildContext context, required dynamic mid, required bool isFollow, - required ValueChanged? callback, + required ValueChanged? callback, Map? followStatus, }) async { if (mid == null) { @@ -1182,7 +1182,7 @@ class Utils { ); if (res['status']) { SmartDialog.showToast('$text成功'); - callback?.call(2); + callback?.call(-10); } else { SmartDialog.showToast(res['msg']); }