feat: remove fan

Closes #733

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-22 18:05:02 +08:00
parent 1f2f00d49c
commit 7856857cca
8 changed files with 139 additions and 70 deletions

View File

@@ -25,31 +25,22 @@ class MemberControllerNew extends CommonDataController<Data, dynamic>
with GetTickerProviderStateMixin {
MemberControllerNew({required this.mid});
int mid;
RxBool showUname = false.obs;
String? username;
int? ownerMid;
RxInt relation = 0.obs;
TabController? tabController;
late List<Tab> tabs;
List<Tab2>? tab2;
RxInt contributeInitialIndex = 0.obs;
bool? hasSeasonOrSeries;
final fromViewAid = Get.parameters['from_view_aid'];
bool get isFollow => relation.value != 0 && relation.value != 128;
@override
void onInit() {
super.onInit();
ownerMid = Accounts.main.mid;
queryData();
}
String? username;
RxBool showUname = false.obs;
dynamic live;
int? silence;
String? endTime;
int? isFollowed; // 被关注
RxInt relation = 0.obs;
bool get isFollow => relation.value != 0 && relation.value != 128;
List<Tab2>? tab2;
late List<Tab> tabs;
TabController? tabController;
RxInt contributeInitialIndex = 0.obs;
late final implTabs = const [
'home',
'dynamic',
@@ -58,10 +49,22 @@ class MemberControllerNew extends CommonDataController<Data, dynamic>
'bangumi',
];
bool? hasSeasonOrSeries;
final fromViewAid = Get.parameters['from_view_aid'];
@override
void onInit() {
super.onInit();
ownerMid = Accounts.main.mid;
queryData();
}
@override
bool customHandleResponse(bool isRefresh, Success<Data> response) {
Data data = response.response;
username = data.card?.name ?? '';
isFollowed = data.card?.relation?.isFollowed;
if (data.relation == -1) {
relation.value = 128;
} else {
@@ -69,7 +72,7 @@ class MemberControllerNew extends CommonDataController<Data, dynamic>
? data.relSpecial == 1
? -10
: data.card?.relation?.status ?? 2
: 0;
: data.card?.relation?.status ?? 0;
}
tab2 = data.tab2;
live = data.live;
@@ -226,4 +229,21 @@ class MemberControllerNew extends CommonDataController<Data, dynamic>
tabController?.dispose();
super.onClose();
}
Future onRemoveFan() async {
final res = await VideoHttp.relationMod(
mid: mid,
act: 7,
reSrc: 11,
);
if (res['status']) {
isFollowed = null;
if (relation.value == 4) {
relation.value = 2;
}
SmartDialog.showToast('移除成功');
} else {
SmartDialog.showToast(res['msg']);
}
}
}

View File

@@ -84,7 +84,8 @@ class _MemberPageNewState extends State<MemberPageNew> {
PopupMenuButton(
icon: const Icon(Icons.more_vert),
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
if (_userController.ownerMid != _mid) ...[
if (_userController.ownerMid != 0 &&
_userController.ownerMid != _mid) ...[
PopupMenuItem(
onTap: () => _userController.blockUser(context),
child: Row(
@@ -97,7 +98,19 @@ class _MemberPageNewState extends State<MemberPageNew> {
: '移除黑名单'),
],
),
)
),
if (_userController.isFollowed == 1)
PopupMenuItem(
onTap: _userController.onRemoveFan,
child: Row(
mainAxisSize: MainAxisSize.min,
children: const [
Icon(Icons.remove_circle_outline_outlined, size: 19),
SizedBox(width: 10),
Text('移除粉丝'),
],
),
),
],
PopupMenuItem(
onTap: () => _userController.shareUser(),

View File

@@ -375,7 +375,7 @@ class UserInfoCard extends StatelessWidget {
child: FilledButton.tonal(
onPressed: onFollow,
style: FilledButton.styleFrom(
backgroundColor: relation != 0
backgroundColor: relation != 0 && relation != 3
? Theme.of(context).colorScheme.onInverseSurface
: null,
visualDensity: const VisualDensity(
@@ -385,13 +385,13 @@ class UserInfoCard extends StatelessWidget {
),
child: Text.rich(
style: TextStyle(
color: relation != 0
color: relation != 0 && relation != 3
? Theme.of(context).colorScheme.outline
: null,
),
TextSpan(
children: [
if (relation != 0 && relation != 128)
if (relation != 0 && relation != 128 && relation != 3)
WidgetSpan(
alignment: PlaceholderAlignment.top,
child: Icon(
@@ -407,6 +407,7 @@ class UserInfoCard extends StatelessWidget {
0 => '关注',
1 => '悄悄关注',
2 => '已关注',
3 => '回关',
4 || 6 => '已互关',
128 => '移除黑名单',
-10 => '特别关注', // 该状态码并不是官方状态码