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 {
|
class FollowItem extends StatelessWidget {
|
||||||
final FollowItemModel item;
|
final FollowItemModel item;
|
||||||
final FollowController? ctr;
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -41,31 +48,34 @@ class FollowItem extends StatelessWidget {
|
|||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
dense: true,
|
dense: true,
|
||||||
trailing: ctr != null && ctr!.isOwner.value
|
trailing: ctr?.isOwner.value == true
|
||||||
? SizedBox(
|
? SizedBox(
|
||||||
height: 34,
|
height: 34,
|
||||||
child: TextButton(
|
child: FilledButton.tonal(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Utils.actionRelationMod(
|
Utils.actionRelationMod(
|
||||||
context: context,
|
context: context,
|
||||||
mid: item.mid,
|
mid: item.mid,
|
||||||
isFollow: true,
|
isFollow: item.attribute != -1,
|
||||||
callback: (attribute) {},
|
callback: callback,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
style: TextButton.styleFrom(
|
style: FilledButton.styleFrom(
|
||||||
padding: const EdgeInsets.fromLTRB(15, 0, 15, 0),
|
padding: const EdgeInsets.fromLTRB(15, 0, 15, 0),
|
||||||
foregroundColor: Theme.of(context).colorScheme.outline,
|
foregroundColor: item.attribute == -1
|
||||||
backgroundColor:
|
? null
|
||||||
Theme.of(context).colorScheme.onInverseSurface,
|
: 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),
|
style: TextStyle(fontSize: 12),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: const SizedBox(),
|
: null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,11 @@ class _OwnerFollowListState extends State<OwnerFollowList>
|
|||||||
return FollowItem(
|
return FollowItem(
|
||||||
item: followList[index],
|
item: followList[index],
|
||||||
ctr: widget.ctr,
|
ctr: widget.ctr,
|
||||||
|
callback: (attr) {
|
||||||
|
followList[index].attribute =
|
||||||
|
attr == 0 ? -1 : 0;
|
||||||
|
followList.refresh();
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -638,7 +638,7 @@ class Utils {
|
|||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
required dynamic mid,
|
required dynamic mid,
|
||||||
required bool isFollow,
|
required bool isFollow,
|
||||||
required Function callback,
|
required ValueChanged? callback,
|
||||||
}) async {
|
}) async {
|
||||||
if (mid == null) {
|
if (mid == null) {
|
||||||
return;
|
return;
|
||||||
@@ -652,9 +652,7 @@ class Utils {
|
|||||||
);
|
);
|
||||||
SmartDialog.showToast(res['status'] ? "关注成功" : res['msg']);
|
SmartDialog.showToast(res['status'] ? "关注成功" : res['msg']);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
callback(1);
|
callback?.call(1);
|
||||||
// followStatus['attribute'] = 2;
|
|
||||||
// followStatus.refresh();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dynamic result = await VideoHttp.hasFollow(mid: mid);
|
dynamic result = await VideoHttp.hasFollow(mid: mid);
|
||||||
@@ -680,20 +678,11 @@ class Utils {
|
|||||||
isAdd: !isSpecialFollowed,
|
isAdd: !isSpecialFollowed,
|
||||||
);
|
);
|
||||||
if (res['status']) {
|
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成功');
|
SmartDialog.showToast('$text成功');
|
||||||
if (isSpecialFollowed) {
|
if (isSpecialFollowed) {
|
||||||
callback(1);
|
callback?.call(1);
|
||||||
} else {
|
} else {
|
||||||
callback(2);
|
callback?.call(2);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SmartDialog.showToast(res['msg']);
|
SmartDialog.showToast(res['msg']);
|
||||||
@@ -733,9 +722,9 @@ class Utils {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (result == true) {
|
if (result == true) {
|
||||||
callback(2);
|
callback?.call(2);
|
||||||
} else if (result == false) {
|
} else if (result == false) {
|
||||||
callback(1);
|
callback?.call(1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
title: const Text(
|
title: const Text(
|
||||||
@@ -755,9 +744,7 @@ class Utils {
|
|||||||
SmartDialog.showToast(
|
SmartDialog.showToast(
|
||||||
res['status'] ? "取消关注成功" : res['msg']);
|
res['status'] ? "取消关注成功" : res['msg']);
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
callback(0);
|
callback?.call(0);
|
||||||
// followStatus['attribute'] = 0;
|
|
||||||
// followStatus.refresh();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
title: const Text(
|
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) {
|
static String generateRandomString(int length) {
|
||||||
|
|||||||
Reference in New Issue
Block a user