opt member relation

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-07-15 09:25:29 +08:00
parent c1aeaca09e
commit 1548624920
4 changed files with 40 additions and 15 deletions

View File

@@ -21,6 +21,7 @@ import 'package:PiliPlus/models_new/space/space/ugc_season.dart';
class SpaceData { class SpaceData {
int? relation; int? relation;
int? guestRelation;
int? medal; int? medal;
String? defaultTab; String? defaultTab;
SpaceSetting? setting; SpaceSetting? setting;
@@ -48,6 +49,7 @@ class SpaceData {
SpaceData({ SpaceData({
this.relation, this.relation,
this.guestRelation,
this.medal, this.medal,
this.defaultTab, this.defaultTab,
this.setting, this.setting,
@@ -75,6 +77,7 @@ class SpaceData {
SpaceData.fromJson(Map<String, dynamic> json) { SpaceData.fromJson(Map<String, dynamic> json) {
relation = json['relation'] as int?; relation = json['relation'] as int?;
guestRelation = json['guest_relation'] as int?;
medal = json['medal'] as int?; medal = json['medal'] as int?;
defaultTab = json['default_tab'] as String?; defaultTab = json['default_tab'] as String?;
setting = json['setting'] == null setting = json['setting'] == null

View File

@@ -38,7 +38,10 @@ class MemberController extends CommonDataController<SpaceData, SpaceData?>
int? isFollowed; // 被关注 int? isFollowed; // 被关注
RxInt relation = 0.obs; 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; SpaceSetting? spaceSetting;
List<SpaceTab2>? tab2; List<SpaceTab2>? tab2;
@@ -88,14 +91,19 @@ class MemberController extends CommonDataController<SpaceData, SpaceData?>
reserves = data.reservationCardList; reserves = data.reservationCardList;
if (data.relation == -1) { switch (data.relation) {
relation.value = 128; case -1:
} else { relation.value = 128;
relation.value = card?.relation?.isFollow == 1 case -999:
? data.relSpecial == 1 if (data.guestRelation == -1) {
? -10 relation.value = -1;
: card?.relation?.status ?? 2 }
: 0; default:
relation.value = card?.relation?.isFollow == 1
? data.relSpecial == 1
? -10
: card?.relation?.status ?? 2
: data.relation ?? 0;
} }
tab2 = data.tab2; tab2 = data.tab2;
live = data.live; live = data.live;

View File

@@ -452,7 +452,7 @@ class UserInfoCard extends StatelessWidget {
), ),
Expanded( Expanded(
child: FilledButton.tonal( child: FilledButton.tonal(
onPressed: onFollow, onPressed: !isOwner && relation == -1 ? null : onFollow,
style: FilledButton.styleFrom( style: FilledButton.styleFrom(
backgroundColor: relation != 0 backgroundColor: relation != 0
? colorScheme.onInverseSurface ? colorScheme.onInverseSurface
@@ -461,12 +461,22 @@ class UserInfoCard extends StatelessWidget {
visualDensity: const VisualDensity(vertical: -1.8), visualDensity: const VisualDensity(vertical: -1.8),
), ),
child: Text.rich( child: Text.rich(
style: TextStyle( style: relation != 0
color: relation != 0 ? colorScheme.outline : null, ? TextStyle(color: colorScheme.outline)
), : null,
TextSpan( TextSpan(
children: [ 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( WidgetSpan(
alignment: .middle, alignment: .middle,
child: Icon( child: Icon(
@@ -481,7 +491,7 @@ class UserInfoCard extends StatelessWidget {
text: isOwner text: isOwner
? '编辑资料' ? '编辑资料'
: switch (relation) { : switch (relation) {
0 => '关注', 0 || -1 => '关注',
1 => '悄悄关注', 1 => '悄悄关注',
2 => '已关注', 2 => '已关注',
// 3 => '回关', // 3 => '回关',

View File

@@ -37,6 +37,10 @@ abstract final class Utils {
return Clipboard.setData(ClipboardData(text: text)); return Clipboard.setData(ClipboardData(text: text));
} }
static Future<void> copyJson(Object? json, {String? toastText}) {
return copyText(jsonEncoder.convert(json), toastText: toastText);
}
static String makeHeroTag(dynamic v) { static String makeHeroTag(dynamic v) {
return v.toString() + random.nextInt(9999).toString(); return v.toString() + random.nextInt(9999).toString();
} }