mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-22 11:30:13 +08:00
@@ -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<String, dynamic> 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
|
||||
|
||||
@@ -38,7 +38,10 @@ class MemberController extends CommonDataController<SpaceData, SpaceData?>
|
||||
|
||||
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<SpaceTab2>? tab2;
|
||||
@@ -88,14 +91,19 @@ class MemberController extends CommonDataController<SpaceData, SpaceData?>
|
||||
|
||||
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;
|
||||
|
||||
@@ -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 => '回关',
|
||||
|
||||
@@ -37,6 +37,10 @@ abstract final class Utils {
|
||||
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) {
|
||||
return v.toString() + random.nextInt(9999).toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user