mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-13 21:00:12 +08:00
@@ -5,6 +5,7 @@ class LaterBaseController extends GetxController {
|
||||
RxBool enableMultiSelect = false.obs;
|
||||
RxInt checkedCount = 0.obs;
|
||||
|
||||
RxMap<LaterViewType, int> counts =
|
||||
{for (final item in LaterViewType.values) item: -1}.obs;
|
||||
RxMap<LaterViewType, int> counts = {
|
||||
for (final item in LaterViewType.values) item: -1,
|
||||
}.obs;
|
||||
}
|
||||
|
||||
@@ -60,100 +60,109 @@ class _LaterViewChildPageState extends State<LaterViewChildPage>
|
||||
final theme = Theme.of(context);
|
||||
return switch (loadingState) {
|
||||
Loading() => SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
return const VideoCardHSkeleton();
|
||||
},
|
||||
childCount: 10,
|
||||
),
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
return const VideoCardHSkeleton();
|
||||
},
|
||||
childCount: 10,
|
||||
),
|
||||
Success(:var response) => response?.isNotEmpty == true
|
||||
? SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if (index == response.length - 1) {
|
||||
_laterController.onLoadMore();
|
||||
}
|
||||
var videoItem = response[index];
|
||||
final enableMultiSelect =
|
||||
_laterController.baseCtr.enableMultiSelect.value;
|
||||
return Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
VideoCardHLater(
|
||||
videoItem: videoItem,
|
||||
onViewLater: (cid) {
|
||||
PageUtils.toVideoPage(
|
||||
'bvid=${videoItem.bvid}&cid=$cid',
|
||||
arguments: {
|
||||
'videoItem': videoItem,
|
||||
'oid': videoItem.aid,
|
||||
'heroTag': Utils.makeHeroTag(videoItem.bvid),
|
||||
'sourceType': 'watchLater',
|
||||
'count': _laterController
|
||||
.baseCtr.counts[LaterViewType.all],
|
||||
'favTitle': '稍后再看',
|
||||
'mediaId': _laterController.accountService.mid,
|
||||
'desc': false,
|
||||
'isContinuePlaying': index != 0,
|
||||
},
|
||||
);
|
||||
},
|
||||
onTap: !enableMultiSelect
|
||||
? null
|
||||
: () => _laterController.onSelect(videoItem),
|
||||
onLongPress: () {
|
||||
if (!enableMultiSelect) {
|
||||
_laterController.baseCtr.enableMultiSelect.value =
|
||||
true;
|
||||
_laterController.onSelect(videoItem);
|
||||
}
|
||||
},
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
left: 12,
|
||||
bottom: 5,
|
||||
child: IgnorePointer(
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) => AnimatedOpacity(
|
||||
opacity: videoItem.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: StyleString.mdRadius,
|
||||
color: Colors.black.withValues(alpha: 0.6),
|
||||
),
|
||||
child: SizedBox(
|
||||
width: 34,
|
||||
height: 34,
|
||||
child: AnimatedScale(
|
||||
scale: videoItem.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.colorScheme.surface
|
||||
.withValues(alpha: 0.8);
|
||||
},
|
||||
),
|
||||
),
|
||||
Success(:var response) =>
|
||||
response?.isNotEmpty == true
|
||||
? SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
if (index == response.length - 1) {
|
||||
_laterController.onLoadMore();
|
||||
}
|
||||
var videoItem = response[index];
|
||||
final enableMultiSelect =
|
||||
_laterController.baseCtr.enableMultiSelect.value;
|
||||
return Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
VideoCardHLater(
|
||||
videoItem: videoItem,
|
||||
onViewLater: (cid) {
|
||||
PageUtils.toVideoPage(
|
||||
'bvid=${videoItem.bvid}&cid=$cid',
|
||||
arguments: {
|
||||
'videoItem': videoItem,
|
||||
'oid': videoItem.aid,
|
||||
'heroTag': Utils.makeHeroTag(videoItem.bvid),
|
||||
'sourceType': 'watchLater',
|
||||
'count': _laterController
|
||||
.baseCtr
|
||||
.counts[LaterViewType.all],
|
||||
'favTitle': '稍后再看',
|
||||
'mediaId': _laterController.accountService.mid,
|
||||
'desc': false,
|
||||
'isContinuePlaying': index != 0,
|
||||
},
|
||||
);
|
||||
},
|
||||
onTap: !enableMultiSelect
|
||||
? null
|
||||
: () => _laterController.onSelect(videoItem),
|
||||
onLongPress: () {
|
||||
if (!enableMultiSelect) {
|
||||
_laterController.baseCtr.enableMultiSelect.value =
|
||||
true;
|
||||
_laterController.onSelect(videoItem);
|
||||
}
|
||||
},
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
left: 12,
|
||||
bottom: 5,
|
||||
child: IgnorePointer(
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) => AnimatedOpacity(
|
||||
opacity: videoItem.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: StyleString.mdRadius,
|
||||
color: Colors.black.withValues(alpha: 0.6),
|
||||
),
|
||||
child: SizedBox(
|
||||
width: 34,
|
||||
height: 34,
|
||||
child: AnimatedScale(
|
||||
scale: videoItem.checked == true ? 1 : 0,
|
||||
duration: const Duration(
|
||||
milliseconds: 250,
|
||||
),
|
||||
onPressed: null,
|
||||
icon: Icon(
|
||||
Icons.done_all_outlined,
|
||||
color: theme.colorScheme.primary,
|
||||
curve: Curves.easeInOut,
|
||||
child: IconButton(
|
||||
tooltip: '取消选择',
|
||||
style: ButtonStyle(
|
||||
padding: WidgetStateProperty.all(
|
||||
EdgeInsets.zero,
|
||||
),
|
||||
backgroundColor:
|
||||
WidgetStateProperty.resolveWith(
|
||||
(states) {
|
||||
return theme
|
||||
.colorScheme
|
||||
.surface
|
||||
.withValues(alpha: 0.8);
|
||||
},
|
||||
),
|
||||
),
|
||||
onPressed: null,
|
||||
icon: Icon(
|
||||
Icons.done_all_outlined,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -162,36 +171,35 @@ class _LaterViewChildPageState extends State<LaterViewChildPage>
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 12,
|
||||
bottom: 0,
|
||||
child: iconButton(
|
||||
tooltip: '移除',
|
||||
context: context,
|
||||
onPressed: () => _laterController.toViewDel(
|
||||
context,
|
||||
index,
|
||||
videoItem.aid,
|
||||
Positioned(
|
||||
right: 12,
|
||||
bottom: 0,
|
||||
child: iconButton(
|
||||
tooltip: '移除',
|
||||
context: context,
|
||||
onPressed: () => _laterController.toViewDel(
|
||||
context,
|
||||
index,
|
||||
videoItem.aid,
|
||||
),
|
||||
icon: Icons.clear,
|
||||
iconColor: theme.colorScheme.outline,
|
||||
bgColor: Colors.transparent,
|
||||
),
|
||||
icon: Icons.clear,
|
||||
iconColor: theme.colorScheme.outline,
|
||||
bgColor: Colors.transparent,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
childCount: response!.length,
|
||||
],
|
||||
);
|
||||
},
|
||||
childCount: response!.length,
|
||||
),
|
||||
)
|
||||
: HttpError(
|
||||
onReload: _laterController.onReload,
|
||||
),
|
||||
)
|
||||
: HttpError(
|
||||
onReload: _laterController.onReload,
|
||||
),
|
||||
Error(:var errMsg) => HttpError(
|
||||
errMsg: errMsg,
|
||||
onReload: _laterController.onReload,
|
||||
),
|
||||
errMsg: errMsg,
|
||||
onReload: _laterController.onReload,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -28,17 +28,18 @@ class LaterController extends MultiSelectController<LaterData, LaterItemModel> {
|
||||
|
||||
@override
|
||||
Future<LoadingState<LaterData>> customGetData() => UserHttp.seeYouLater(
|
||||
page: page,
|
||||
viewed: laterViewType.type,
|
||||
asc: asc.value,
|
||||
);
|
||||
page: page,
|
||||
viewed: laterViewType.type,
|
||||
asc: asc.value,
|
||||
);
|
||||
|
||||
@override
|
||||
void onSelect(LaterItemModel item, [bool disableSelect = true]) {
|
||||
List<LaterItemModel> list = loadingState.value.data!;
|
||||
item.checked = !(item.checked ?? false);
|
||||
baseCtr.checkedCount.value =
|
||||
list.where((item) => item.checked == true).length;
|
||||
baseCtr.checkedCount.value = list
|
||||
.where((item) => item.checked == true)
|
||||
.length;
|
||||
loadingState.refresh();
|
||||
if (baseCtr.checkedCount.value == 0) {
|
||||
baseCtr.enableMultiSelect.value = false;
|
||||
@@ -111,7 +112,7 @@ class LaterController extends MultiSelectController<LaterData, LaterItemModel> {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
},
|
||||
child: const Text('确认移除'),
|
||||
)
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
@@ -166,12 +167,14 @@ class LaterController extends MultiSelectController<LaterData, LaterItemModel> {
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
_onDelete(loadingState.value.data!
|
||||
.where((e) => e.checked == true)
|
||||
.toList());
|
||||
_onDelete(
|
||||
loadingState.value.data!
|
||||
.where((e) => e.checked == true)
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
child: const Text('确认'),
|
||||
)
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
@@ -183,8 +186,9 @@ class LaterController extends MultiSelectController<LaterData, LaterItemModel> {
|
||||
List<int?> aids = result.map((item) => item.aid).toList();
|
||||
var res = await UserHttp.toViewDel(aids: aids);
|
||||
if (res['status']) {
|
||||
Set<LaterItemModel> remainList =
|
||||
loadingState.value.data!.toSet().difference(result.toSet());
|
||||
Set<LaterItemModel> remainList = loadingState.value.data!
|
||||
.toSet()
|
||||
.difference(result.toSet());
|
||||
baseCtr.counts[laterViewType] =
|
||||
baseCtr.counts[laterViewType]! - aids.length;
|
||||
loadingState.value = Success(remainList.toList());
|
||||
|
||||
@@ -91,8 +91,8 @@ class _LaterPageState extends State<LaterPage>
|
||||
tabs: LaterViewType.values.map((item) {
|
||||
final count = _baseCtr.counts[item];
|
||||
return Tab(
|
||||
text:
|
||||
'${item.title}${count != -1 ? '($count)' : ''}');
|
||||
text: '${item.title}${count != -1 ? '($count)' : ''}',
|
||||
);
|
||||
}).toList(),
|
||||
onTap: (_) {
|
||||
if (!_tabController.indexIsChanging) {
|
||||
@@ -167,8 +167,10 @@ class _LaterPageState extends State<LaterPage>
|
||||
..onReload();
|
||||
},
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 6,
|
||||
),
|
||||
child: Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
@@ -208,8 +210,10 @@ class _LaterPageState extends State<LaterPage>
|
||||
child: PopupMenuButton(
|
||||
tooltip: '清空',
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 6,
|
||||
),
|
||||
child: Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
|
||||
@@ -40,13 +40,15 @@ class VideoCardHLater extends StatelessWidget {
|
||||
return Material(
|
||||
type: MaterialType.transparency,
|
||||
child: InkWell(
|
||||
onLongPress: onLongPress ??
|
||||
onLongPress:
|
||||
onLongPress ??
|
||||
() => imageSaveDialog(
|
||||
title: videoItem.title,
|
||||
cover: videoItem.pic,
|
||||
bvid: videoItem.bvid,
|
||||
),
|
||||
onTap: onTap ??
|
||||
title: videoItem.title,
|
||||
cover: videoItem.pic,
|
||||
bvid: videoItem.bvid,
|
||||
),
|
||||
onTap:
|
||||
onTap ??
|
||||
() async {
|
||||
if (type == 'ketang') {
|
||||
SmartDialog.showToast('课堂视频暂不支持播放');
|
||||
@@ -61,9 +63,12 @@ class VideoCardHLater extends StatelessWidget {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final int? cid = videoItem.cid ??
|
||||
final int? cid =
|
||||
videoItem.cid ??
|
||||
await SearchHttp.ab2c(
|
||||
aid: videoItem.aid, bvid: videoItem.bvid);
|
||||
aid: videoItem.aid,
|
||||
bvid: videoItem.bvid,
|
||||
);
|
||||
if (cid != null) {
|
||||
onViewLater!(cid);
|
||||
}
|
||||
@@ -131,11 +136,12 @@ class VideoCardHLater extends StatelessWidget {
|
||||
? 1
|
||||
: progress / videoItem.duration!,
|
||||
),
|
||||
)
|
||||
),
|
||||
] else if (videoItem.duration! > 0)
|
||||
PBadge(
|
||||
text:
|
||||
DurationUtil.formatDuration(videoItem.duration),
|
||||
text: DurationUtil.formatDuration(
|
||||
videoItem.duration,
|
||||
),
|
||||
right: 6.0,
|
||||
bottom: 6.0,
|
||||
type: PBadgeType.gray,
|
||||
@@ -231,7 +237,7 @@ class VideoCardHLater extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
]
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user