feat: fav pgc page

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-03-29 13:28:07 +08:00
parent 6ea8ffea7a
commit 72fa9c51f0
16 changed files with 884 additions and 216 deletions

View File

@@ -33,3 +33,70 @@ void showConfirmDialog({
}, },
); );
} }
void showPgcFollowDialog({
required BuildContext context,
required String type,
required int followStatus,
required ValueChanged<int> onUpdateStatus,
}) {
Widget statusItem({
required bool enabled,
required String text,
required VoidCallback onTap,
}) {
return ListTile(
dense: true,
enabled: enabled,
title: Padding(
padding: const EdgeInsets.only(left: 10),
child: Text(
'标记为 $text',
style: const TextStyle(fontSize: 14),
),
),
trailing: !enabled ? const Icon(size: 22, Icons.check) : null,
onTap: onTap,
);
}
showDialog(
context: context,
builder: (context) => AlertDialog(
clipBehavior: Clip.hardEdge,
contentPadding: const EdgeInsets.symmetric(vertical: 12),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
...[
{'followStatus': 3, 'title': '看过'},
{'followStatus': 2, 'title': '在看'},
{'followStatus': 1, 'title': '想看'},
].map(
(Map item) => statusItem(
enabled: followStatus != item['followStatus'],
text: item['title'],
onTap: () {
Get.back();
onUpdateStatus(item['followStatus']);
},
),
),
ListTile(
dense: true,
title: Padding(
padding: EdgeInsets.only(left: 10),
child: Text(
'取消$type',
style: TextStyle(fontSize: 14),
),
),
onTap: () {
Get.back();
onUpdateStatus(-1);
},
)
],
),
));
}

View File

@@ -411,7 +411,7 @@ class Api {
'/pgc/season/index/result?st=1&order=3&season_version=-1&spoken_language_type=-1&area=-1&is_finish=-1&copyright=-1&season_status=-1&season_month=-1&year=-1&style_id=-1&sort=0&season_type=1&pagesize=20&type=1'; '/pgc/season/index/result?st=1&order=3&season_version=-1&spoken_language_type=-1&area=-1&is_finish=-1&copyright=-1&season_status=-1&season_month=-1&year=-1&style_id=-1&sort=0&season_type=1&pagesize=20&type=1';
// 我的追番/追剧 ?type=1&pn=1&ps=15 // 我的追番/追剧 ?type=1&pn=1&ps=15
static const String bangumiFollow = '/x/space/bangumi/follow/list'; static const String bangumiFollowList = '/x/space/bangumi/follow/list';
// 黑名单 // 黑名单
static const String blackLst = '/x/relation/blacks'; static const String blackLst = '/x/relation/blacks';
@@ -643,9 +643,6 @@ class Api {
/// 最近点赞的视频 /// 最近点赞的视频
static const getRecentLikeVideoApi = '/x/space/like/video'; static const getRecentLikeVideoApi = '/x/space/like/video';
/// 最近追番
static const getRecentBangumiApi = '/x/space/bangumi/follow/list';
/// 用户专栏 /// 用户专栏
static const getMemberSeasonsApi = '/x/polymer/web-space/home/seasons_series'; static const getMemberSeasonsApi = '/x/polymer/web-space/home/seasons_series';

View File

@@ -67,19 +67,24 @@ class BangumiHttp {
} }
} }
static Future<LoadingState> bangumiFollow({ static Future<LoadingState> bangumiFollowList({
dynamic mid, required dynamic mid,
required int type, required int type,
required int pn, required int pn,
int? followStatus,
}) async { }) async {
var res = await Request().get(Api.bangumiFollow, queryParameters: { var res = await Request().get(Api.bangumiFollowList, queryParameters: {
'vmid': mid, 'vmid': mid,
'type': type, 'type': type,
if (followStatus != null) 'follow_status': followStatus,
'pn': pn, 'pn': pn,
}); });
if (res.data['code'] == 0) { if (res.data['code'] == 0) {
BangumiListDataModel data = BangumiListDataModel data =
BangumiListDataModel.fromJson(res.data['data']); BangumiListDataModel.fromJson(res.data['data']);
if (followStatus != null) {
return LoadingState.success(data.list);
}
return LoadingState.success(data); return LoadingState.success(data);
} else { } else {
return LoadingState.error(res.data['message']); return LoadingState.error(res.data['message']);

View File

@@ -920,13 +920,13 @@ class VideoHttp {
} }
static Future bangumiUpdate({ static Future bangumiUpdate({
dynamic seasonId, required List seasonId,
dynamic status, required dynamic status,
}) async { }) async {
var res = await Request().post( var res = await Request().post(
Api.bangumiUpdate, Api.bangumiUpdate,
data: { data: {
'season_id': seasonId, 'season_id': seasonId.join(','),
'status': status, 'status': status,
'csrf': Accounts.main.csrf, 'csrf': Accounts.main.csrf,
}, },

View File

@@ -44,6 +44,7 @@ class BangumiListItemModel {
this.title, this.title,
this.titleIcon, this.titleIcon,
this.progress, this.progress,
this.newEp,
}); });
String? badge; String? badge;
@@ -62,9 +63,11 @@ class BangumiListItemModel {
String? subTitle; String? subTitle;
String? title; String? title;
String? titleIcon; String? titleIcon;
Map? newEp;
String? progress; String? progress;
bool? checked;
BangumiListItemModel.fromJson(Map<String, dynamic> json) { BangumiListItemModel.fromJson(Map<String, dynamic> json) {
badge = json['badge'] == '' ? null : json['badge']; badge = json['badge'] == '' ? null : json['badge'];
badgeType = json['badge_type']; badgeType = json['badge_type'];
@@ -82,7 +85,7 @@ class BangumiListItemModel {
subTitle = json['sub_title']; subTitle = json['sub_title'];
title = json['title']; title = json['title'];
titleIcon = json['title_icon']; titleIcon = json['title_icon'];
newEp = json['new_ep'];
progress = json['progress']; progress = json['progress'];
} }
} }

View File

@@ -51,7 +51,7 @@ class BangumiController extends CommonController {
return; return;
} }
followLoading = true; followLoading = true;
dynamic res = await BangumiHttp.bangumiFollow( dynamic res = await BangumiHttp.bangumiFollowList(
mid: mid, mid: mid,
type: tabType == TabType.bangumi ? 1 : 2, type: tabType == TabType.bangumi ? 1 : 2,
pn: followPage, pn: followPage,

View File

@@ -521,7 +521,7 @@ class BangumiIntroController extends CommonController {
Future bangumiUpdate(status) async { Future bangumiUpdate(status) async {
var result = await VideoHttp.bangumiUpdate( var result = await VideoHttp.bangumiUpdate(
seasonId: (loadingState.value as Success).response.seasonId, seasonId: [(loadingState.value as Success).response.seasonId],
status: status, status: status,
); );
if (result['status']) { if (result['status']) {

View File

@@ -1,5 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'package:PiliPlus/common/widgets/dialog.dart';
import 'package:PiliPlus/common/widgets/http_error.dart'; import 'package:PiliPlus/common/widgets/http_error.dart';
import 'package:PiliPlus/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart' import 'package:PiliPlus/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart'
show SourceModel; show SourceModel;
@@ -299,10 +300,24 @@ class _BangumiInfoState extends State<BangumiInfo>
: () { : () {
if (bangumiIntroController if (bangumiIntroController
.isFollowed.value) { .isFollowed.value) {
showDialog( showPgcFollowDialog(
context: context, context: context,
builder: (context) => type: bangumiIntroController
_followDialog(), .type,
followStatus:
bangumiIntroController
.followStatus.value,
onUpdateStatus:
(followStatus) {
if (followStatus == -1) {
bangumiIntroController
.bangumiDel();
} else {
bangumiIntroController
.bangumiUpdate(
followStatus);
}
},
); );
} else { } else {
bangumiIntroController bangumiIntroController
@@ -601,59 +616,6 @@ class _BangumiInfoState extends State<BangumiInfo>
text: '转发'), text: '转发'),
]); ]);
} }
Widget _followDialog() {
return AlertDialog(
clipBehavior: Clip.hardEdge,
contentPadding: const EdgeInsets.symmetric(vertical: 12),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
_followDialogItem(3, '看过'),
_followDialogItem(2, '在看'),
_followDialogItem(1, '想看'),
ListTile(
dense: true,
title: Padding(
padding: EdgeInsets.only(left: 10),
child: Text(
'取消${bangumiIntroController.type}',
style: TextStyle(fontSize: 14),
),
),
onTap: () {
Get.back();
bangumiIntroController.bangumiDel();
},
)
],
),
);
}
Widget _followDialogItem(
int followStatus,
String text,
) {
return ListTile(
dense: true,
enabled: bangumiIntroController.followStatus.value != followStatus,
title: Padding(
padding: const EdgeInsets.only(left: 10),
child: Text(
'标记为 $text',
style: const TextStyle(fontSize: 14),
),
),
trailing: bangumiIntroController.followStatus.value == followStatus
? const Icon(size: 22, Icons.check)
: null,
onTap: () {
Get.back();
bangumiIntroController.bangumiUpdate(followStatus);
},
);
}
} }
class AreasAndPubTime extends StatelessWidget { class AreasAndPubTime extends StatelessWidget {

View File

@@ -149,6 +149,9 @@ class _FavNoteChildPageState extends State<FavNoteChildPage>
), ),
delegate: SliverChildBuilderDelegate( delegate: SliverChildBuilderDelegate(
(context, index) { (context, index) {
if (index == loadingState.response.length - 1) {
_favNoteController.onLoadMore();
}
return FavNoteItem( return FavNoteItem(
item: loadingState.response[index], item: loadingState.response[index],
ctr: _favNoteController, ctr: _favNoteController,

View File

@@ -1,8 +1,5 @@
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/pages/fav/note/child_view.dart'; import 'package:PiliPlus/pages/fav/note/child_view.dart';
import 'package:PiliPlus/pages/fav/note/controller.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart';
class FavNotePage extends StatefulWidget { class FavNotePage extends StatefulWidget {
const FavNotePage({super.key}); const FavNotePage({super.key});
@@ -62,30 +59,30 @@ class _FavNotePageState extends State<FavNotePage>
], ],
), ),
), ),
TextButton( // TextButton(
style: TextButton.styleFrom( // style: TextButton.styleFrom(
foregroundColor: Theme.of(context).colorScheme.onSurfaceVariant, // foregroundColor: Theme.of(context).colorScheme.onSurfaceVariant,
visualDensity: VisualDensity(horizontal: -2, vertical: -2), // visualDensity: VisualDensity(horizontal: -2, vertical: -2),
tapTargetSize: MaterialTapTargetSize.shrinkWrap, // tapTargetSize: MaterialTapTargetSize.shrinkWrap,
), // ),
onPressed: () async { // onPressed: () async {
final favNoteController = Get.find<FavNoteController>( // final favNoteController = Get.find<FavNoteController>(
tag: _tabController.index == 0 ? 'false' : 'true'); // tag: _tabController.index == 0 ? 'false' : 'true');
if (favNoteController.enableMultiSelect.value) { // if (favNoteController.enableMultiSelect.value) {
favNoteController.onDisable(); // favNoteController.onDisable();
} else { // } else {
if (favNoteController.loadingState.value is Success && // if (favNoteController.loadingState.value is Success &&
((favNoteController.loadingState.value as Success) // ((favNoteController.loadingState.value as Success)
.response as List?) // .response as List?)
?.isNotEmpty == // ?.isNotEmpty ==
true) { // true) {
favNoteController.enableMultiSelect.value = true; // favNoteController.enableMultiSelect.value = true;
} // }
} // }
}, // },
child: const Text('管理'), // child: const Text('管理'),
), // ),
const SizedBox(width: 12), // const SizedBox(width: 12),
], ],
), ),
Expanded( Expanded(

View File

@@ -18,7 +18,9 @@ class FavNoteItem extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return InkWell( return Material(
color: Colors.transparent,
child: InkWell(
onTap: () { onTap: () {
if (ctr.enableMultiSelect.value) { if (ctr.enableMultiSelect.value) {
onSelect(); onSelect();
@@ -153,6 +155,7 @@ class FavNoteItem extends StatelessWidget {
], ],
), ),
), ),
),
); );
} }
} }

View File

@@ -0,0 +1,217 @@
import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/common/skeleton/video_card_h.dart';
import 'package:PiliPlus/common/widgets/dialog.dart';
import 'package:PiliPlus/common/widgets/http_error.dart';
import 'package:PiliPlus/common/widgets/icon_button.dart';
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/pages/fav/pgc/controller.dart';
import 'package:PiliPlus/pages/fav/pgc/widget/item.dart';
import 'package:PiliPlus/utils/grid.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class FavPgcChildPage extends StatefulWidget {
const FavPgcChildPage({
super.key,
required this.type,
required this.followStatus,
});
final int type;
final int followStatus;
@override
State<FavPgcChildPage> createState() => _FavPgcChildPageState();
}
class _FavPgcChildPageState extends State<FavPgcChildPage>
with AutomaticKeepAliveClientMixin {
late final FavPgcController _favPgcController = Get.put(
FavPgcController(widget.type, widget.followStatus),
tag: '${widget.type}${widget.followStatus}',
);
@override
Widget build(BuildContext context) {
super.build(context);
return LayoutBuilder(
builder: (context, constraints) => Stack(
clipBehavior: Clip.none,
children: [
refreshIndicator(
onRefresh: () async {
await _favPgcController.onRefresh();
},
child: CustomScrollView(
slivers: [
Obx(() => _buildBody(_favPgcController.loadingState.value)),
],
),
),
Positioned(
top: constraints.maxHeight,
left: 0,
right: 0,
child: Obx(
() => AnimatedSlide(
offset: _favPgcController.enableMultiSelect.value
? Offset(0, -1)
: Offset.zero,
duration: const Duration(milliseconds: 150),
child: Container(
padding: MediaQuery.paddingOf(context),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.onInverseSurface,
border: Border(
top: BorderSide(
width: 0.5,
color: Theme.of(context)
.colorScheme
.outline
.withOpacity(0.5),
),
),
),
width: double.infinity,
child: Row(
children: [
const SizedBox(width: 16),
iconButton(
size: 32,
tooltip: '取消',
context: context,
icon: Icons.clear,
onPressed: _favPgcController.onDisable,
),
const SizedBox(width: 12),
Obx(
() => Checkbox(
value: _favPgcController.allSelected.value,
onChanged: (value) {
_favPgcController.handleSelect(
!_favPgcController.allSelected.value);
},
),
),
GestureDetector(
onTap: () {
_favPgcController.handleSelect(
!_favPgcController.allSelected.value);
},
child: const Text('全选'),
),
const Spacer(),
...[
{'followStatus': 1, 'title': '想看'},
{'followStatus': 2, 'title': '在看'},
{'followStatus': 3, 'title': '看过'},
]
.where((item) =>
item['followStatus'] != widget.followStatus)
.map(
(Map item) => Padding(
padding: const EdgeInsets.only(left: 25),
child: GestureDetector(
onTap: () {
_favPgcController
.onUpdate(item['followStatus']);
},
child: Text(
'标记为${item['title']}',
style: TextStyle(
color: Theme.of(context)
.colorScheme
.onSurfaceVariant,
),
),
),
),
),
const SizedBox(width: 20),
],
),
),
),
),
),
],
),
);
}
Widget _buildBody(LoadingState loadingState) {
return switch (loadingState) {
Loading() => SliverGrid(
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
mainAxisSpacing: 2,
maxCrossAxisExtent: Grid.mediumCardWidth * 2,
childAspectRatio: StyleString.aspectRatio * 2.2,
),
delegate: SliverChildBuilderDelegate(
(context, index) {
return const VideoCardHSkeleton();
},
childCount: 10,
),
),
Success() => (loadingState.response as List?)?.isNotEmpty == true
? SliverPadding(
padding: EdgeInsets.only(
bottom: MediaQuery.paddingOf(context).bottom + 80),
sliver: SliverGrid(
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
mainAxisSpacing: 2,
maxCrossAxisExtent: Grid.mediumCardWidth * 2,
childAspectRatio: StyleString.aspectRatio * 2.6,
),
delegate: SliverChildBuilderDelegate(
(context, index) {
if (index == loadingState.response.length - 1) {
_favPgcController.onLoadMore();
}
return FavPgcItem(
item: loadingState.response[index],
ctr: _favPgcController,
onSelect: () {
_favPgcController.onSelect(index);
},
onUpdateStatus: () {
showPgcFollowDialog(
context: context,
type: widget.type == 0 ? '追番' : '追剧',
followStatus: widget.followStatus,
onUpdateStatus: (followStatus) {
if (followStatus == -1) {
_favPgcController.bangumiDel(
index,
loadingState.response[index].seasonId,
);
} else {
_favPgcController.bangumiUpdate(
index,
followStatus,
loadingState.response[index].seasonId,
);
}
},
);
},
);
},
childCount: loadingState.response.length,
),
),
)
: HttpError(callback: _favPgcController.onReload),
Error() => HttpError(
errMsg: loadingState.errMsg,
callback: _favPgcController.onReload,
),
LoadingState() => throw UnimplementedError(),
};
}
@override
bool get wantKeepAlive => true;
}

View File

@@ -0,0 +1,134 @@
import 'package:PiliPlus/http/bangumi.dart';
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/http/video.dart';
import 'package:PiliPlus/models/bangumi/list.dart';
import 'package:PiliPlus/pages/common/multi_select_controller.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
class FavPgcController extends MultiSelectController {
final int type;
final int followStatus;
FavPgcController(this.type, this.followStatus);
late final allSelected = false.obs;
@override
void onInit() {
super.onInit();
queryData();
}
@override
onSelect(int index) {
List<BangumiListItemModel> list = (loadingState.value as Success).response;
list[index].checked = !(list[index].checked ?? false);
checkedCount.value = list.where((item) => item.checked == true).length;
loadingState.value = LoadingState.success(list);
allSelected.value = checkedCount.value == list.length;
if (checkedCount.value == 0) {
enableMultiSelect.value = false;
}
}
@override
void handleSelect([bool checked = false]) {
allSelected.value = checked;
if (loadingState.value is Success) {
List<BangumiListItemModel> list =
(loadingState.value as Success).response;
if (list.isNotEmpty) {
loadingState.value = LoadingState.success(list
.map<BangumiListItemModel>((item) => item..checked = checked)
.toList());
checkedCount.value = checked ? list.length : 0;
}
}
}
@override
Future<LoadingState> customGetData() => BangumiHttp.bangumiFollowList(
mid: Accounts.main.mid,
type: type,
followStatus: followStatus,
pn: currentPage,
);
void onDisable() {
if (checkedCount.value != 0) {
handleSelect();
}
enableMultiSelect.value = false;
}
// 取消追番
Future bangumiDel(index, seasonId) async {
var result = await VideoHttp.bangumiDel(seasonId: seasonId);
if (result['status']) {
List<BangumiListItemModel> list =
(loadingState.value as Success).response;
list.removeAt(index);
loadingState.value = LoadingState.success(list);
}
SmartDialog.showToast(result['msg']);
}
Future onUpdate(followStatus) async {
List<BangumiListItemModel> dataList =
(loadingState.value as Success).response as List<BangumiListItemModel>;
Set<BangumiListItemModel> updateList =
dataList.where((item) => item.checked == true).toSet();
final res = await VideoHttp.bangumiUpdate(
seasonId: updateList.map((item) => item.seasonId).toList(),
status: followStatus,
);
if (res['status']) {
List<BangumiListItemModel> remainList =
dataList.toSet().difference(updateList).toList();
loadingState.value = LoadingState.success(remainList);
enableMultiSelect.value = false;
try {
final ctr = Get.find<FavPgcController>(tag: '$type$followStatus');
if (ctr.loadingState.value is Success) {
List<BangumiListItemModel> list =
(ctr.loadingState.value as Success).response;
list.insertAll(0, updateList.map((item) => item..checked = null));
ctr.loadingState.value = LoadingState.success(list);
ctr.allSelected.value = false;
}
} catch (e) {
debugPrint('fav pgc onUpdate: $e');
}
}
SmartDialog.showToast(res['msg']);
}
Future bangumiUpdate(index, followStatus, seasonId) async {
var result = await VideoHttp.bangumiUpdate(
seasonId: [seasonId],
status: followStatus,
);
if (result['status']) {
List<BangumiListItemModel> list =
(loadingState.value as Success).response;
final item = list.removeAt(index);
loadingState.value = LoadingState.success(list);
try {
final ctr = Get.find<FavPgcController>(tag: '$type$followStatus');
if (ctr.loadingState.value is Success) {
List<BangumiListItemModel> list =
(ctr.loadingState.value as Success).response;
list.insert(0, item);
ctr.loadingState.value = LoadingState.success(list);
ctr.allSelected.value = false;
}
} catch (e) {
debugPrint('fav pgc bangumiUpdate: $e');
}
}
SmartDialog.showToast(result['msg']);
}
}

View File

@@ -0,0 +1,93 @@
import 'package:PiliPlus/pages/fav/pgc/child_view.dart';
import 'package:flutter/material.dart';
class FavPgcPage extends StatefulWidget {
const FavPgcPage({super.key, required this.type});
final int type;
@override
State<FavPgcPage> createState() => _FavPgcPageState();
}
class _FavPgcPageState extends State<FavPgcPage>
with AutomaticKeepAliveClientMixin, SingleTickerProviderStateMixin {
late final TabController _tabController =
TabController(length: 3, vsync: this, initialIndex: 1);
@override
bool get wantKeepAlive => true;
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
super.build(context);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Expanded(
child: TabBar(
overlayColor: WidgetStateProperty.all(Colors.transparent),
splashFactory: NoSplash.splashFactory,
isScrollable: true,
tabAlignment: TabAlignment.start,
controller: _tabController,
padding: const EdgeInsets.symmetric(horizontal: 8),
dividerHeight: 0,
indicatorWeight: 0,
indicatorPadding:
const EdgeInsets.symmetric(horizontal: 3, vertical: 8),
indicator: BoxDecoration(
color: Theme.of(context).colorScheme.secondaryContainer,
borderRadius: BorderRadius.circular(20),
),
indicatorSize: TabBarIndicatorSize.tab,
labelStyle: TabBarTheme.of(context)
.labelStyle
?.copyWith(fontSize: 14) ??
const TextStyle(fontSize: 14),
labelColor: Theme.of(context).colorScheme.onSecondaryContainer,
unselectedLabelColor: Theme.of(context).colorScheme.outline,
tabs: const [
Tab(text: '想看'),
Tab(text: '在看'),
Tab(text: '看过'),
],
),
),
// TextButton(
// style: TextButton.styleFrom(
// foregroundColor: Theme.of(context).colorScheme.onSurfaceVariant,
// visualDensity: VisualDensity(horizontal: -2, vertical: -2),
// tapTargetSize: MaterialTapTargetSize.shrinkWrap,
// ),
// onPressed: () {},
// child: const Text('管理'),
// ),
// const SizedBox(width: 12),
],
),
Expanded(
child: TabBarView(
controller: _tabController,
physics: const NeverScrollableScrollPhysics(),
children: List.generate(
3,
(index) => FavPgcChildPage(
type: widget.type,
followStatus: index + 1,
),
),
),
),
],
);
}
}

View File

@@ -0,0 +1,186 @@
import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/common/widgets/badge.dart';
import 'package:PiliPlus/common/widgets/icon_button.dart';
import 'package:PiliPlus/common/widgets/network_img_layer.dart';
import 'package:PiliPlus/models/bangumi/list.dart';
import 'package:PiliPlus/pages/common/multi_select_controller.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:flutter/material.dart';
class FavPgcItem extends StatelessWidget {
const FavPgcItem({
super.key,
required this.item,
required this.ctr,
required this.onSelect,
required this.onUpdateStatus,
});
final BangumiListItemModel item;
final MultiSelectController ctr;
final VoidCallback onSelect;
final VoidCallback onUpdateStatus;
@override
Widget build(BuildContext context) {
return Material(
color: Colors.transparent,
child: Stack(
clipBehavior: Clip.none,
children: [
InkWell(
onTap: () {
if (ctr.enableMultiSelect.value) {
onSelect();
return;
}
Utils.viewBangumi(seasonId: item.seasonId);
},
onLongPress: () {
if (!ctr.enableMultiSelect.value) {
ctr.enableMultiSelect.value = true;
onSelect();
}
},
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: StyleString.safeSpace,
vertical: 5,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AspectRatio(
aspectRatio: 3 / 4,
child: LayoutBuilder(
builder: (BuildContext context,
BoxConstraints boxConstraints) {
return Stack(
clipBehavior: Clip.none,
children: [
NetworkImgLayer(
radius: 4,
src: item.cover,
width: boxConstraints.maxWidth,
height: boxConstraints.maxHeight,
),
if (item.badge?.isNotEmpty == true)
PBadge(
right: 4,
top: 4,
text: item.badge,
),
Positioned.fill(
child: IgnorePointer(
child: LayoutBuilder(
builder: (context, constraints) =>
AnimatedOpacity(
opacity: item.checked == true ? 1 : 0,
duration: const Duration(milliseconds: 200),
child: Container(
alignment: Alignment.center,
height: constraints.maxHeight,
width: constraints.maxHeight *
StyleString.aspectRatio,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
color: Colors.black.withOpacity(0.6),
),
child: SizedBox(
width: 34,
height: 34,
child: AnimatedScale(
scale: item.checked == true ? 1 : 0,
duration:
const Duration(milliseconds: 250),
curve: Curves.easeInOut,
child: IconButton(
tooltip: '取消选择',
style: ButtonStyle(
padding: WidgetStateProperty.all(
EdgeInsets.zero),
backgroundColor:
WidgetStateProperty
.resolveWith(
(states) {
return Theme.of(context)
.colorScheme
.surface
.withOpacity(0.8);
},
),
),
onPressed: null,
icon: Icon(
Icons.done_all_outlined,
color: Theme.of(context)
.colorScheme
.primary,
),
),
),
),
),
),
),
),
),
],
);
},
),
),
const SizedBox(width: 10),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(item.title!),
if (item.newEp?['index_show'] != null) ...[
const SizedBox(height: 6),
Text(
'${item.newEp?['index_show']}',
style: TextStyle(
fontSize: 13,
color: Theme.of(context).colorScheme.outline,
),
),
],
if (item.progress != null) ...[
SizedBox(
height:
item.newEp?['index_show'] != null ? 2 : 6),
Text(
item.progress!,
style: TextStyle(
fontSize: 13,
color: Theme.of(context).colorScheme.outline,
),
),
],
],
),
),
],
),
),
),
Positioned(
right: 12,
bottom: 0,
child: iconButton(
iconSize: 22,
context: context,
onPressed: onUpdateStatus,
icon: Icons.more_vert,
iconColor: Theme.of(context).colorScheme.onSurfaceVariant,
bgColor: Colors.transparent,
),
),
],
),
);
}
}

View File

@@ -1,5 +1,6 @@
import 'package:PiliPlus/http/loading_state.dart'; import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/pages/fav/note/view.dart'; import 'package:PiliPlus/pages/fav/note/view.dart';
import 'package:PiliPlus/pages/fav/pgc/view.dart';
import 'package:PiliPlus/pages/fav/video/index.dart'; import 'package:PiliPlus/pages/fav/video/index.dart';
import 'package:PiliPlus/pages/fav_search/view.dart'; import 'package:PiliPlus/pages/fav_search/view.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -93,8 +94,8 @@ class _FavPageState extends State<FavPage> with SingleTickerProviderStateMixin {
.map( .map(
(item) => switch (item) { (item) => switch (item) {
_FavType.video => const FavVideoPage(), _FavType.video => const FavVideoPage(),
_FavType.bangumi => Center(child: Text(item.title)), _FavType.bangumi => const FavPgcPage(type: 1),
_FavType.cinema => Center(child: Text(item.title)), _FavType.cinema => const FavPgcPage(type: 2),
_FavType.article => Center(child: Text(item.title)), _FavType.article => Center(child: Text(item.title)),
_FavType.note => const FavNotePage(), _FavType.note => const FavNotePage(),
}, },