mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: follow page
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -9,7 +9,14 @@ import 'package:PiliPlus/utils/utils.dart';
|
||||
class FollowItem extends StatelessWidget {
|
||||
final FollowItemModel item;
|
||||
final FollowController? ctr;
|
||||
const FollowItem({super.key, required this.item, this.ctr});
|
||||
final ValueChanged? callback;
|
||||
|
||||
const FollowItem({
|
||||
super.key,
|
||||
required this.item,
|
||||
this.callback,
|
||||
this.ctr,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -41,31 +48,34 @@ class FollowItem extends StatelessWidget {
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
dense: true,
|
||||
trailing: ctr != null && ctr!.isOwner.value
|
||||
trailing: ctr?.isOwner.value == true
|
||||
? SizedBox(
|
||||
height: 34,
|
||||
child: TextButton(
|
||||
child: FilledButton.tonal(
|
||||
onPressed: () {
|
||||
Utils.actionRelationMod(
|
||||
context: context,
|
||||
mid: item.mid,
|
||||
isFollow: true,
|
||||
callback: (attribute) {},
|
||||
isFollow: item.attribute != -1,
|
||||
callback: callback,
|
||||
);
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
style: FilledButton.styleFrom(
|
||||
padding: const EdgeInsets.fromLTRB(15, 0, 15, 0),
|
||||
foregroundColor: Theme.of(context).colorScheme.outline,
|
||||
backgroundColor:
|
||||
Theme.of(context).colorScheme.onInverseSurface,
|
||||
foregroundColor: item.attribute == -1
|
||||
? null
|
||||
: Theme.of(context).colorScheme.outline,
|
||||
backgroundColor: item.attribute == -1
|
||||
? null
|
||||
: Theme.of(context).colorScheme.onInverseSurface,
|
||||
),
|
||||
child: const Text(
|
||||
'已关注',
|
||||
child: Text(
|
||||
'${item.attribute == -1 ? '' : '已'}关注',
|
||||
style: TextStyle(fontSize: 12),
|
||||
),
|
||||
),
|
||||
)
|
||||
: const SizedBox(),
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,6 +105,11 @@ class _OwnerFollowListState extends State<OwnerFollowList>
|
||||
return FollowItem(
|
||||
item: followList[index],
|
||||
ctr: widget.ctr,
|
||||
callback: (attr) {
|
||||
followList[index].attribute =
|
||||
attr == 0 ? -1 : 0;
|
||||
followList.refresh();
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -638,7 +638,7 @@ class Utils {
|
||||
required BuildContext context,
|
||||
required dynamic mid,
|
||||
required bool isFollow,
|
||||
required Function callback,
|
||||
required ValueChanged? callback,
|
||||
}) async {
|
||||
if (mid == null) {
|
||||
return;
|
||||
@@ -652,9 +652,7 @@ class Utils {
|
||||
);
|
||||
SmartDialog.showToast(res['status'] ? "关注成功" : res['msg']);
|
||||
if (res['status']) {
|
||||
callback(1);
|
||||
// followStatus['attribute'] = 2;
|
||||
// followStatus.refresh();
|
||||
callback?.call(1);
|
||||
}
|
||||
} else {
|
||||
dynamic result = await VideoHttp.hasFollow(mid: mid);
|
||||
@@ -680,20 +678,11 @@ class Utils {
|
||||
isAdd: !isSpecialFollowed,
|
||||
);
|
||||
if (res['status']) {
|
||||
// followStatus['special'] = isSpecialFollowed ? 0 : 1;
|
||||
// List tags = followStatus['tag'] ?? [];
|
||||
// if (isSpecialFollowed) {
|
||||
// tags.remove(-10);
|
||||
// } else {
|
||||
// tags.add(-10);
|
||||
// }
|
||||
// followStatus['tag'] = tags;
|
||||
// followStatus.refresh();
|
||||
SmartDialog.showToast('$text成功');
|
||||
if (isSpecialFollowed) {
|
||||
callback(1);
|
||||
callback?.call(1);
|
||||
} else {
|
||||
callback(2);
|
||||
callback?.call(2);
|
||||
}
|
||||
} else {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
@@ -733,9 +722,9 @@ class Utils {
|
||||
},
|
||||
);
|
||||
if (result == true) {
|
||||
callback(2);
|
||||
callback?.call(2);
|
||||
} else if (result == false) {
|
||||
callback(1);
|
||||
callback?.call(1);
|
||||
}
|
||||
},
|
||||
title: const Text(
|
||||
@@ -755,9 +744,7 @@ class Utils {
|
||||
SmartDialog.showToast(
|
||||
res['status'] ? "取消关注成功" : res['msg']);
|
||||
if (res['status']) {
|
||||
callback(0);
|
||||
// followStatus['attribute'] = 0;
|
||||
// followStatus.refresh();
|
||||
callback?.call(0);
|
||||
}
|
||||
},
|
||||
title: const Text(
|
||||
@@ -772,14 +759,6 @@ class Utils {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// MemberController _ = Get.put<MemberController>(MemberController(mid: mid),
|
||||
// tag: mid.toString());
|
||||
// await _.getInfo();
|
||||
// if (context.mounted) await _.actionRelationMod(context);
|
||||
// followStatus['attribute'] = _.attribute.value;
|
||||
// followStatus.refresh();
|
||||
// Get.delete<MemberController>(tag: mid.toString());
|
||||
}
|
||||
|
||||
static String generateRandomString(int length) {
|
||||
|
||||
Reference in New Issue
Block a user