feat: member cheese

feat: fav pugv

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-08-07 11:19:59 +08:00
parent 26a5b7b7a7
commit 6d55321699
22 changed files with 634 additions and 17 deletions

View File

@@ -5,6 +5,7 @@ import 'package:PiliPlus/grpc/bilibili/app/viewunite/pgcanymodel.pb.dart'
show ViewPgcAny;
import 'package:PiliPlus/grpc/view.dart';
import 'package:PiliPlus/http/constants.dart';
import 'package:PiliPlus/http/fav.dart';
import 'package:PiliPlus/http/search.dart';
import 'package:PiliPlus/http/video.dart';
import 'package:PiliPlus/models/common/video/source_type.dart';
@@ -51,6 +52,7 @@ class PgcIntroController extends CommonIntroController {
late final RxBool isFollowed = false.obs;
late final RxInt followStatus = (-1).obs;
late final RxBool isFav = (pgcItem.userStatus?.favored == 1).obs;
@override
void onInit() {
@@ -479,4 +481,16 @@ class PgcIntroController extends CommonIntroController {
artist: pgcItem.title,
);
}
Future<void> onFavPugv(bool isFav) async {
final res = isFav
? await FavHttp.delFavPugv(seasonId)
: await FavHttp.addFavPugv(seasonId);
if (res['status']) {
this.isFav.value = !isFav;
SmartDialog.showToast('${isFav ? '取消' : ''}收藏成功');
} else {
SmartDialog.showToast(res['msg']);
}
}
}

View File

@@ -3,6 +3,7 @@ import 'dart:math';
import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/common/widgets/badge.dart';
import 'package:PiliPlus/common/widgets/button/icon_button.dart';
import 'package:PiliPlus/common/widgets/dialog/dialog.dart';
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
import 'package:PiliPlus/common/widgets/stat/stat.dart';
@@ -80,7 +81,7 @@ class _PgcIntroPageState extends State<PgcIntroPage>
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 10,
children: [
_buildCover(isLandscape, item),
_buildCover(theme, isLandscape, item),
Expanded(child: _buildInfoPanel(isLandscape, theme, item)),
],
),
@@ -142,6 +143,7 @@ class _PgcIntroPageState extends State<PgcIntroPage>
radius: 0,
src: e.url,
width: imgWidth,
height: imgWidth * e.aspectRatio,
),
);
}).toList(),
@@ -153,7 +155,7 @@ class _PgcIntroPageState extends State<PgcIntroPage>
return null;
}
Widget _buildCover(bool isLandscape, PgcInfoModel item) {
Widget _buildCover(ThemeData theme, bool isLandscape, PgcInfoModel item) {
return Stack(
clipBehavior: Clip.none,
children: [
@@ -183,6 +185,24 @@ class _PgcIntroPageState extends State<PgcIntroPage>
bottom: 6,
left: null,
),
if (!pgcIntroController.isPgc)
Positioned(
right: 6,
bottom: 6,
child: Obx(() {
final isFav = pgcIntroController.isFav.value;
return iconButton(
context: context,
size: 28,
iconSize: 26,
tooltip: '${isFav ? '取消' : ''}收藏',
onPressed: () => pgcIntroController.onFavPugv(isFav),
icon: isFav ? Icons.star_rounded : Icons.star_border_rounded,
bgColor: isFav ? null : theme.colorScheme.onInverseSurface,
iconColor: isFav ? null : theme.colorScheme.onSurfaceVariant,
);
}),
),
],
);
}
@@ -374,7 +394,7 @@ class _PgcIntroPageState extends State<PgcIntroPage>
item.upInfo!.avatar!,
item.upInfo!.uname!,
),
const SizedBox(height: 8),
const SizedBox(height: 6),
],
Text(
item.title!,