diff --git a/lib/models_new/space/space/data.dart b/lib/models_new/space/space/data.dart index 4155dc4be..e19104738 100644 --- a/lib/models_new/space/space/data.dart +++ b/lib/models_new/space/space/data.dart @@ -21,6 +21,7 @@ import 'package:PiliPlus/models_new/space/space/ugc_season.dart'; class SpaceData { int? relation; + int? guestRelation; int? medal; String? defaultTab; SpaceSetting? setting; @@ -48,6 +49,7 @@ class SpaceData { SpaceData({ this.relation, + this.guestRelation, this.medal, this.defaultTab, this.setting, @@ -75,6 +77,7 @@ class SpaceData { SpaceData.fromJson(Map json) { relation = json['relation'] as int?; + guestRelation = json['guest_relation'] as int?; medal = json['medal'] as int?; defaultTab = json['default_tab'] as String?; setting = json['setting'] == null diff --git a/lib/pages/member/controller.dart b/lib/pages/member/controller.dart index fd4653878..97ae2544d 100644 --- a/lib/pages/member/controller.dart +++ b/lib/pages/member/controller.dart @@ -38,7 +38,10 @@ class MemberController extends CommonDataController int? isFollowed; // 被关注 RxInt relation = 0.obs; - bool get isFollow => relation.value != 0 && relation.value != 128; + bool get isFollow { + final relation = this.relation.value; + return relation != 0 && relation != 128 && relation != -1; + } SpaceSetting? spaceSetting; List? tab2; @@ -88,14 +91,19 @@ class MemberController extends CommonDataController reserves = data.reservationCardList; - if (data.relation == -1) { - relation.value = 128; - } else { - relation.value = card?.relation?.isFollow == 1 - ? data.relSpecial == 1 - ? -10 - : card?.relation?.status ?? 2 - : 0; + switch (data.relation) { + case -1: + relation.value = 128; + case -999: + if (data.guestRelation == -1) { + relation.value = -1; + } + default: + relation.value = card?.relation?.isFollow == 1 + ? data.relSpecial == 1 + ? -10 + : card?.relation?.status ?? 2 + : data.relation ?? 0; } tab2 = data.tab2; live = data.live; diff --git a/lib/pages/member/widget/user_info_card.dart b/lib/pages/member/widget/user_info_card.dart index cfc366cb2..477793eb6 100644 --- a/lib/pages/member/widget/user_info_card.dart +++ b/lib/pages/member/widget/user_info_card.dart @@ -452,7 +452,7 @@ class UserInfoCard extends StatelessWidget { ), Expanded( child: FilledButton.tonal( - onPressed: onFollow, + onPressed: !isOwner && relation == -1 ? null : onFollow, style: FilledButton.styleFrom( backgroundColor: relation != 0 ? colorScheme.onInverseSurface @@ -461,12 +461,22 @@ class UserInfoCard extends StatelessWidget { visualDensity: const VisualDensity(vertical: -1.8), ), child: Text.rich( - style: TextStyle( - color: relation != 0 ? colorScheme.outline : null, - ), + style: relation != 0 + ? TextStyle(color: colorScheme.outline) + : null, TextSpan( children: [ - if (relation != 0 && relation != 128) ...[ + if (relation == -1) ...[ + WidgetSpan( + alignment: .middle, + child: Icon( + Icons.block, + size: 16, + color: colorScheme.outline, + ), + ), + const TextSpan(text: ' '), + ] else if (relation != 0 && relation != 128) ...[ WidgetSpan( alignment: .middle, child: Icon( @@ -481,7 +491,7 @@ class UserInfoCard extends StatelessWidget { text: isOwner ? '编辑资料' : switch (relation) { - 0 => '关注', + 0 || -1 => '关注', 1 => '悄悄关注', 2 => '已关注', // 3 => '回关', diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index c6fcf584e..3caf14de6 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -37,6 +37,10 @@ abstract final class Utils { return Clipboard.setData(ClipboardData(text: text)); } + static Future copyJson(Object? json, {String? toastText}) { + return copyText(jsonEncoder.convert(json), toastText: toastText); + } + static String makeHeroTag(dynamic v) { return v.toString() + random.nextInt(9999).toString(); }