feat: 查看up主收藏订阅
This commit is contained in:
@ -16,10 +16,16 @@ class FavController extends GetxController {
|
||||
int currentPage = 1;
|
||||
int pageSize = 60;
|
||||
RxBool hasMore = true.obs;
|
||||
late int mid;
|
||||
late int ownerMid;
|
||||
RxBool isOwner = false.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
mid = int.parse(Get.parameters['mid'] ?? '-1');
|
||||
userInfo = userInfoCache.get('userInfoCache');
|
||||
ownerMid = userInfo != null ? userInfo!.mid! : -1;
|
||||
isOwner.value = mid == -1 || mid == ownerMid;
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@ -33,7 +39,7 @@ class FavController extends GetxController {
|
||||
var res = await UserHttp.userfavFolder(
|
||||
pn: currentPage,
|
||||
ps: pageSize,
|
||||
mid: userInfo!.mid!,
|
||||
mid: isOwner.value ? ownerMid : mid,
|
||||
);
|
||||
if (res['status']) {
|
||||
if (type == 'init') {
|
||||
|
||||
@ -42,17 +42,25 @@ class _FavPageState extends State<FavPage> {
|
||||
appBar: AppBar(
|
||||
centerTitle: false,
|
||||
titleSpacing: 0,
|
||||
title: Text(
|
||||
'我的收藏',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
title: Obx(() => Text(
|
||||
'${_favController.isOwner.value ? '我' : 'Ta'}的收藏',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
)),
|
||||
actions: [
|
||||
Obx(() => !_favController.isOwner.value
|
||||
? IconButton(
|
||||
onPressed: () =>
|
||||
Get.toNamed('/subscription?mid=${_favController.mid}'),
|
||||
icon: const Icon(Icons.subscriptions_outlined, size: 21),
|
||||
tooltip: 'Ta的订阅',
|
||||
)
|
||||
: const SizedBox.shrink()),
|
||||
IconButton(
|
||||
onPressed: () => Get.toNamed(
|
||||
'/favSearch?searchType=1&mediaId=${_favController.favFolderData.value.list!.first.id}'),
|
||||
icon: const Icon(Icons.search_outlined),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
const SizedBox(width: 14),
|
||||
],
|
||||
),
|
||||
body: FutureBuilder(
|
||||
@ -67,7 +75,9 @@ class _FavPageState extends State<FavPage> {
|
||||
itemCount: _favController.favFolderList.length,
|
||||
itemBuilder: (context, index) {
|
||||
return FavItem(
|
||||
favFolderItem: _favController.favFolderList[index]);
|
||||
favFolderItem: _favController.favFolderList[index],
|
||||
isOwner: _favController.isOwner.value,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
@ -7,7 +7,9 @@ import 'package:pilipala/utils/utils.dart';
|
||||
class FavItem extends StatelessWidget {
|
||||
// ignore: prefer_typing_uninitialized_variables
|
||||
final favFolderItem;
|
||||
const FavItem({super.key, required this.favFolderItem});
|
||||
final bool isOwner;
|
||||
const FavItem(
|
||||
{super.key, required this.favFolderItem, required this.isOwner});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -20,6 +22,7 @@ class FavItem extends StatelessWidget {
|
||||
parameters: {
|
||||
'heroTag': heroTag,
|
||||
'mediaId': favFolderItem.id.toString(),
|
||||
'isOwner': isOwner ? '1' : '0',
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user