mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
fix: follow up (#702)
This commit is contained in:
committed by
GitHub
parent
cb6ead96d1
commit
12c711424b
@@ -30,7 +30,7 @@ class FollowItemModel {
|
|||||||
});
|
});
|
||||||
|
|
||||||
int? mid;
|
int? mid;
|
||||||
int? attribute;
|
int? attribute; // 对于`/x/relation/tag`, 此处的attribute似乎恒为0
|
||||||
// int? mtime;
|
// int? mtime;
|
||||||
List? tag;
|
List? tag;
|
||||||
int? special;
|
int? special;
|
||||||
|
|||||||
@@ -27,8 +27,7 @@ class MemberControllerNew extends CommonDataController<Data, dynamic>
|
|||||||
RxBool showUname = false.obs;
|
RxBool showUname = false.obs;
|
||||||
String? username;
|
String? username;
|
||||||
int? ownerMid;
|
int? ownerMid;
|
||||||
RxBool isFollow = false.obs;
|
RxInt relation = 0.obs;
|
||||||
RxInt relation = 1.obs;
|
|
||||||
TabController? tabController;
|
TabController? tabController;
|
||||||
late List<Tab> tabs;
|
late List<Tab> tabs;
|
||||||
List<Tab2>? tab2;
|
List<Tab2>? tab2;
|
||||||
@@ -37,6 +36,8 @@ class MemberControllerNew extends CommonDataController<Data, dynamic>
|
|||||||
bool? hasSeasonOrSeries;
|
bool? hasSeasonOrSeries;
|
||||||
final fromViewAid = Get.parameters['from_view_aid'];
|
final fromViewAid = Get.parameters['from_view_aid'];
|
||||||
|
|
||||||
|
bool get isFollow => relation.value != 0 && relation.value != 128;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
@@ -61,8 +62,11 @@ class MemberControllerNew extends CommonDataController<Data, dynamic>
|
|||||||
bool customHandleResponse(bool isRefresh, Success<Data> response) {
|
bool customHandleResponse(bool isRefresh, Success<Data> response) {
|
||||||
Data data = response.response;
|
Data data = response.response;
|
||||||
username = data.card?.name ?? '';
|
username = data.card?.name ?? '';
|
||||||
isFollow.value = data.card?.relation?.isFollow == 1;
|
relation.value = data.card?.relation?.isFollow == 1
|
||||||
relation.value = data.relSpecial == 1 ? 2 : data.relation ?? 1;
|
? data.relSpecial == 1
|
||||||
|
? -10
|
||||||
|
: data.card?.relation?.status ?? 2
|
||||||
|
: 0;
|
||||||
tab2 = data.tab2;
|
tab2 = data.tab2;
|
||||||
live = data.live;
|
live = data.live;
|
||||||
silence = data.card?.silence;
|
silence = data.card?.silence;
|
||||||
@@ -153,7 +157,7 @@ class MemberControllerNew extends CommonDataController<Data, dynamic>
|
|||||||
builder: (context) {
|
builder: (context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: const Text('提示'),
|
title: const Text('提示'),
|
||||||
content: Text(relation.value != -1 ? '确定拉黑UP主?' : '从黑名单移除UP主'),
|
content: Text(relation.value != 128 ? '确定拉黑UP主?' : '从黑名单移除UP主'),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: Get.back,
|
onPressed: Get.back,
|
||||||
@@ -182,19 +186,18 @@ class MemberControllerNew extends CommonDataController<Data, dynamic>
|
|||||||
void _onBlock() async {
|
void _onBlock() async {
|
||||||
dynamic res = await VideoHttp.relationMod(
|
dynamic res = await VideoHttp.relationMod(
|
||||||
mid: mid,
|
mid: mid,
|
||||||
act: relation.value != -1 ? 5 : 6,
|
act: relation.value != 128 ? 5 : 6,
|
||||||
reSrc: 11,
|
reSrc: 11,
|
||||||
);
|
);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
relation.value = relation.value != -1 ? -1 : 1;
|
relation.value = relation.value != 128 ? 128 : 0;
|
||||||
isFollow.value = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onFollow(BuildContext context) async {
|
void onFollow(BuildContext context) async {
|
||||||
if (mid == ownerMid) {
|
if (mid == ownerMid) {
|
||||||
Get.toNamed('/editProfile');
|
Get.toNamed('/editProfile');
|
||||||
} else if (relation.value == -1) {
|
} else if (relation.value == 128) {
|
||||||
_onBlock();
|
_onBlock();
|
||||||
} else {
|
} else {
|
||||||
if (ownerMid == null) {
|
if (ownerMid == null) {
|
||||||
@@ -204,10 +207,9 @@ class MemberControllerNew extends CommonDataController<Data, dynamic>
|
|||||||
Utils.actionRelationMod(
|
Utils.actionRelationMod(
|
||||||
context: context,
|
context: context,
|
||||||
mid: mid,
|
mid: mid,
|
||||||
isFollow: isFollow.value,
|
isFollow: isFollow,
|
||||||
callback: (attribute) {
|
callback: (attribute) {
|
||||||
relation.value = attribute;
|
relation.value = attribute;
|
||||||
isFollow.value = attribute != 0;
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ class _MemberPageNewState extends State<MemberPageNew> {
|
|||||||
children: [
|
children: [
|
||||||
const Icon(Icons.block, size: 19),
|
const Icon(Icons.block, size: 19),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Text(_userController.relation.value != -1
|
Text(_userController.relation.value != 128
|
||||||
? '加入黑名单'
|
? '加入黑名单'
|
||||||
: '移除黑名单'),
|
: '移除黑名单'),
|
||||||
],
|
],
|
||||||
@@ -281,7 +281,6 @@ class _MemberPageNewState extends State<MemberPageNew> {
|
|||||||
isV: isV,
|
isV: isV,
|
||||||
isOwner: _userController.mid == _userController.ownerMid,
|
isOwner: _userController.mid == _userController.ownerMid,
|
||||||
relation: _userController.relation.value,
|
relation: _userController.relation.value,
|
||||||
isFollow: _userController.isFollow.value,
|
|
||||||
card: userState.response.card,
|
card: userState.response.card,
|
||||||
images: userState.response.images,
|
images: userState.response.images,
|
||||||
onFollow: () => _userController.onFollow(context),
|
onFollow: () => _userController.onFollow(context),
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ class UserInfoCard extends StatelessWidget {
|
|||||||
required this.card,
|
required this.card,
|
||||||
required this.images,
|
required this.images,
|
||||||
required this.relation,
|
required this.relation,
|
||||||
required this.isFollow,
|
|
||||||
required this.onFollow,
|
required this.onFollow,
|
||||||
this.live,
|
this.live,
|
||||||
this.silence,
|
this.silence,
|
||||||
@@ -29,7 +28,6 @@ class UserInfoCard extends StatelessWidget {
|
|||||||
final bool isV;
|
final bool isV;
|
||||||
final bool isOwner;
|
final bool isOwner;
|
||||||
final int relation;
|
final int relation;
|
||||||
final bool isFollow;
|
|
||||||
final space.Card card;
|
final space.Card card;
|
||||||
final space.Images images;
|
final space.Images images;
|
||||||
final VoidCallback onFollow;
|
final VoidCallback onFollow;
|
||||||
@@ -380,7 +378,7 @@ class UserInfoCard extends StatelessWidget {
|
|||||||
child: FilledButton.tonal(
|
child: FilledButton.tonal(
|
||||||
onPressed: onFollow,
|
onPressed: onFollow,
|
||||||
style: FilledButton.styleFrom(
|
style: FilledButton.styleFrom(
|
||||||
backgroundColor: relation == -1 || isFollow
|
backgroundColor: relation != 0
|
||||||
? Theme.of(context).colorScheme.onInverseSurface
|
? Theme.of(context).colorScheme.onInverseSurface
|
||||||
: null,
|
: null,
|
||||||
visualDensity: const VisualDensity(
|
visualDensity: const VisualDensity(
|
||||||
@@ -390,13 +388,13 @@ class UserInfoCard extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
child: Text.rich(
|
child: Text.rich(
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: relation == -1 || isFollow
|
color: relation != 0
|
||||||
? Theme.of(context).colorScheme.outline
|
? Theme.of(context).colorScheme.outline
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
TextSpan(
|
TextSpan(
|
||||||
children: [
|
children: [
|
||||||
if (isFollow)
|
if (relation != 0 && relation != 128)
|
||||||
WidgetSpan(
|
WidgetSpan(
|
||||||
alignment: PlaceholderAlignment.top,
|
alignment: PlaceholderAlignment.top,
|
||||||
child: Icon(
|
child: Icon(
|
||||||
@@ -406,16 +404,17 @@ class UserInfoCard extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: isOwner
|
text: isOwner
|
||||||
? '编辑资料'
|
? '编辑资料'
|
||||||
: relation == -1
|
: switch (relation) {
|
||||||
? '移除黑名单'
|
0 => '关注',
|
||||||
: relation == 2
|
1 => '悄悄关注',
|
||||||
? ' 特别关注'
|
2 => '已关注',
|
||||||
: isFollow
|
6 => '已互关',
|
||||||
? ' 已关注'
|
128 => '移除黑名单',
|
||||||
: '关注',
|
-10 => '特别关注', // 该状态码并不是官方状态码
|
||||||
),
|
_ => relation.toString(),
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -546,7 +546,9 @@ class VideoIntroController extends GetxController
|
|||||||
}
|
}
|
||||||
var result = await UserHttp.hasFollow(videoDetail.value.owner!.mid!);
|
var result = await UserHttp.hasFollow(videoDetail.value.owner!.mid!);
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
followStatus.value = result['data'];
|
Map data = result['data'];
|
||||||
|
if (data['special'] == 1) data['attribute'] = -10;
|
||||||
|
followStatus.value = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -890,6 +890,7 @@ class _VideoInfoState extends State<VideoInfo> {
|
|||||||
2 => '已关注',
|
2 => '已关注',
|
||||||
6 => '已互关',
|
6 => '已互关',
|
||||||
128 => '已拉黑',
|
128 => '已拉黑',
|
||||||
|
-10 => '特别关注',
|
||||||
_ => '关注'
|
_ => '关注'
|
||||||
},
|
},
|
||||||
style: TextStyle(fontSize: t.textTheme.labelMedium!.fontSize),
|
style: TextStyle(fontSize: t.textTheme.labelMedium!.fontSize),
|
||||||
|
|||||||
@@ -1133,7 +1133,7 @@ class Utils {
|
|||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
required dynamic mid,
|
required dynamic mid,
|
||||||
required bool isFollow,
|
required bool isFollow,
|
||||||
required ValueChanged? callback,
|
required ValueChanged<int>? callback,
|
||||||
Map? followStatus,
|
Map? followStatus,
|
||||||
}) async {
|
}) async {
|
||||||
if (mid == null) {
|
if (mid == null) {
|
||||||
@@ -1182,7 +1182,7 @@ class Utils {
|
|||||||
);
|
);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
SmartDialog.showToast('$text成功');
|
SmartDialog.showToast('$text成功');
|
||||||
callback?.call(2);
|
callback?.call(-10);
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast(res['msg']);
|
SmartDialog.showToast(res['msg']);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user