mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-29 06:45:54 +08:00
opt: select (#937)
This commit is contained in:
committed by
GitHub
parent
afb09e8a0a
commit
01552801f2
@@ -1,6 +1,4 @@
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/skeleton/video_card_h.dart';
|
||||
import 'package:PiliPlus/common/widgets/button/icon_button.dart';
|
||||
import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
@@ -57,7 +55,6 @@ class _LaterViewChildPageState extends State<LaterViewChildPage>
|
||||
}
|
||||
|
||||
Widget _buildBody(LoadingState<List<LaterItemModel>?> loadingState) {
|
||||
final theme = Theme.of(context);
|
||||
return switch (loadingState) {
|
||||
Loading() => SliverGrid(
|
||||
gridDelegate: Grid.videoCardHDelegate(context),
|
||||
@@ -80,116 +77,42 @@ class _LaterViewChildPageState extends State<LaterViewChildPage>
|
||||
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,
|
||||
cover: videoItem.pic,
|
||||
title: videoItem.title,
|
||||
extraArguments: {
|
||||
'oid': videoItem.aid,
|
||||
'sourceType': SourceType.watchLater,
|
||||
'count': _laterController
|
||||
.baseCtr
|
||||
.counts[LaterViewType.all],
|
||||
'favTitle': '稍后再看',
|
||||
'mediaId': _laterController.accountService.mid,
|
||||
'desc': false,
|
||||
'isContinuePlaying': index != 0,
|
||||
},
|
||||
);
|
||||
return VideoCardHLater(
|
||||
videoItem: videoItem,
|
||||
onViewLater: (cid) {
|
||||
PageUtils.toVideoPage(
|
||||
bvid: videoItem.bvid,
|
||||
cid: cid,
|
||||
cover: videoItem.pic,
|
||||
title: videoItem.title,
|
||||
extraArguments: {
|
||||
'oid': videoItem.aid,
|
||||
'sourceType': 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) {
|
||||
);
|
||||
},
|
||||
onTap: !enableMultiSelect
|
||||
? null
|
||||
: () => _laterController.onSelect(videoItem),
|
||||
onLongPress: enableMultiSelect
|
||||
? null
|
||||
: () {
|
||||
_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:
|
||||
WidgetStatePropertyAll(
|
||||
theme.colorScheme.surface
|
||||
.withValues(alpha: 0.8),
|
||||
),
|
||||
),
|
||||
onPressed: null,
|
||||
icon: Icon(
|
||||
Icons.done_all_outlined,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
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,
|
||||
),
|
||||
),
|
||||
],
|
||||
},
|
||||
onRemove: () => _laterController.toViewDel(
|
||||
context,
|
||||
index,
|
||||
videoItem.aid,
|
||||
),
|
||||
);
|
||||
},
|
||||
childCount: response!.length,
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
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/image_save.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/common/widgets/progress_bar/video_progress_indicator.dart';
|
||||
import 'package:PiliPlus/common/widgets/select_mask.dart';
|
||||
import 'package:PiliPlus/common/widgets/stat/stat.dart';
|
||||
import 'package:PiliPlus/http/search.dart';
|
||||
import 'package:PiliPlus/models/common/badge_type.dart';
|
||||
@@ -22,11 +25,13 @@ class VideoCardHLater extends StatelessWidget {
|
||||
this.onTap,
|
||||
this.onLongPress,
|
||||
this.onViewLater,
|
||||
this.onRemove,
|
||||
});
|
||||
final LaterItemModel videoItem;
|
||||
final VoidCallback? onTap;
|
||||
final VoidCallback? onLongPress;
|
||||
final ValueChanged<int>? onViewLater;
|
||||
final VoidCallback? onRemove;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -152,6 +157,12 @@ class VideoCardHLater extends StatelessWidget {
|
||||
bottom: 6.0,
|
||||
type: PBadgeType.gray,
|
||||
),
|
||||
Positioned.fill(
|
||||
child: selectMask(
|
||||
Theme.of(context),
|
||||
videoItem.checked == true,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
@@ -234,6 +245,22 @@ class VideoCardHLater extends StatelessWidget {
|
||||
type: StatType.danmaku,
|
||||
value: videoItem.stat?.danmaku,
|
||||
),
|
||||
if (onRemove != null) ...[
|
||||
const Spacer(),
|
||||
iconButton(
|
||||
tooltip: '移除',
|
||||
context: context,
|
||||
onPressed: () => showConfirmDialog(
|
||||
context: context,
|
||||
title: '提示',
|
||||
content: '即将移除该视频,确定是否移除',
|
||||
onConfirm: onRemove!,
|
||||
),
|
||||
icon: Icons.clear,
|
||||
iconColor: theme.colorScheme.outline,
|
||||
bgColor: Colors.transparent,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user