opt: up主页布局

This commit is contained in:
guozhigq
2024-10-13 01:11:48 +08:00
parent 85f77ed933
commit c1cd024db6
4 changed files with 601 additions and 668 deletions

View File

@ -49,6 +49,8 @@ class MemberController extends GetxController {
if (res['status']) {
memberInfo.value = res['data'];
face.value = res['data'].face;
} else {
SmartDialog.showToast('用户信息请求异常:${res['msg']}');
}
return res;
}
@ -78,42 +80,10 @@ class MemberController extends GetxController {
return;
}
if (attribute.value == 128) {
blockUser();
return;
modifyRelation('block');
} else {
modifyRelation('follow');
}
SmartDialog.show(
useSystem: true,
animationType: SmartAnimationType.centerFade_otherSlide,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('提示'),
content: Text(memberInfo.value.isFollowed! ? '取消关注UP主?' : '关注UP主?'),
actions: [
TextButton(
onPressed: () => SmartDialog.dismiss(),
child: Text(
'点错了',
style: TextStyle(color: Theme.of(context).colorScheme.outline),
),
),
TextButton(
onPressed: () async {
await VideoHttp.relationMod(
mid: mid,
act: memberInfo.value.isFollowed! ? 2 : 1,
reSrc: 11,
);
memberInfo.value.isFollowed = !memberInfo.value.isFollowed!;
relationSearch();
SmartDialog.dismiss();
memberInfo.update((val) {});
},
child: const Text('确认'),
)
],
);
},
);
}
// 关系查询
@ -123,24 +93,15 @@ class MemberController extends GetxController {
var res = await UserHttp.hasFollow(mid);
if (res['status']) {
attribute.value = res['data']['attribute'];
switch (attribute.value) {
case 1:
attributeText.value = '悄悄关注';
break;
case 2:
attributeText.value = '已关注';
break;
case 6:
attributeText.value = '已互关';
break;
case 128:
attributeText.value = '已拉黑';
break;
default:
attributeText.value = '关注';
}
final Map<int, String> attributeTextMap = {
1: '悄悄关注',
2: '关注',
6: '已互关',
128: '已拉黑',
};
attributeText.value = attributeTextMap[attribute.value] ?? '关注';
if (res['data']['special'] == 1) {
attributeText.value += 'SP';
attributeText.value = '特别关注';
}
}
}
@ -151,16 +112,37 @@ class MemberController extends GetxController {
SmartDialog.showToast('账号未登录');
return;
}
SmartDialog.show(
useSystem: true,
animationType: SmartAnimationType.centerFade_otherSlide,
modifyRelation('block');
}
// 合并关注/取关和拉黑逻辑
Future modifyRelation(String actionType) async {
if (userInfo == null) {
SmartDialog.showToast('账号未登录');
return;
}
String contentText;
int act;
if (actionType == 'follow') {
contentText = memberInfo.value.isFollowed! ? '确定取消关注UP主?' : '确定关注UP主?';
act = memberInfo.value.isFollowed! ? 2 : 1;
} else if (actionType == 'block') {
contentText = attribute.value != 128 ? '确定拉黑UP主?' : '确定从黑名单移除UP主';
act = attribute.value != 128 ? 5 : 6;
} else {
return;
}
showDialog(
context: Get.context!,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('提示'),
content: Text(attribute.value != 128 ? '确定拉黑UP主?' : '从黑名单移除UP主'),
content: Text(contentText),
actions: [
TextButton(
onPressed: () => SmartDialog.dismiss(),
onPressed: () => Navigator.of(context).pop(),
child: Text(
'点错了',
style: TextStyle(color: Theme.of(context).colorScheme.outline),
@ -170,19 +152,26 @@ class MemberController extends GetxController {
onPressed: () async {
var res = await VideoHttp.relationMod(
mid: mid,
act: attribute.value != 128 ? 5 : 6,
act: act,
reSrc: 11,
);
SmartDialog.dismiss();
if (res['status']) {
attribute.value = attribute.value != 128 ? 128 : 0;
attributeText.value = attribute.value == 128 ? '已拉黑' : '关注';
memberInfo.value.isFollowed = false;
if (actionType == 'follow') {
memberInfo.value.isFollowed = !memberInfo.value.isFollowed!;
} else if (actionType == 'block') {
attribute.value = attribute.value != 128 ? 128 : 0;
attributeText.value = attribute.value == 128 ? '已拉黑' : '关注';
memberInfo.value.isFollowed = false;
}
relationSearch();
if (context.mounted) {
Navigator.of(context).pop();
}
memberInfo.update((val) {});
}
},
child: const Text(''),
child: const Text(''),
)
],
);
@ -228,17 +217,14 @@ class MemberController extends GetxController {
// 跳转查看动态
void pushDynamicsPage() => Get.toNamed('/memberDynamics?mid=$mid');
// 跳转查看投稿
void pushArchivesPage() => Get.toNamed('/memberArchive?mid=$mid');
// 跳转查看专栏
void pushSeasonsPage() {}
// 跳转查看最近投币
void pushRecentCoinsPage() async {
if (recentCoinsList.isNotEmpty) {}
}
// 跳转查看收藏夹
void pushfavPage() => Get.toNamed('/fav?mid=$mid');
// 跳转图文专栏
void pushArticlePage() => Get.toNamed('/memberArticle?mid=$mid');