* opt: cache

* opt: MediaListPanel

* feat: nested replyreply panel

* tweaks

* opt: abstract class

* opt: PageStorageKey

* opt: contextExt

* opt: EpisodePanel

* opt

* opt: context instead GlobalKey

* feat: jump to reply

* refa: reply_reply

* fix: jump

* fix: index

* update

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>

* opt: keepalive

* reapply: nested replyreply

* mod: spacing

* opt: CommonSlidePageState

* fix drag bottomsheet

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>

* opt reply jump

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>

* opt reply2reply

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>

* tweaks

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>

* tweaks

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>

* reapply: jumpToReply

* fix: padding

* fix: anim

* fix some panels

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>

* opt: implements Scaffold

* opt: remove keepalive

* revert: GlobalKey

* tweaks

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>

---------

Co-authored-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
My-Responsitories
2025-09-15 18:45:28 +08:00
committed by GitHub
parent b9a55ccbce
commit 37fb63c3b1
75 changed files with 6300 additions and 1140 deletions

View File

@@ -9,21 +9,20 @@ import 'package:PiliPlus/models/common/badge_type.dart';
import 'package:PiliPlus/models/common/stat_type.dart';
import 'package:PiliPlus/models_new/media_list/media_list.dart';
import 'package:PiliPlus/models_new/video/video_detail/episode.dart';
import 'package:PiliPlus/pages/common/slide/common_collapse_slide_page.dart';
import 'package:PiliPlus/pages/common/slide/common_slide_page.dart';
import 'package:PiliPlus/utils/duration_utils.dart';
import 'package:flutter/material.dart' hide RefreshCallback;
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
class MediaListPanel extends CommonCollapseSlidePage {
class MediaListPanel extends CommonSlidePage {
const MediaListPanel({
super.key,
required this.mediaList,
required this.onChangeEpisode,
this.panelTitle,
required this.getBvId,
required this.bvid,
required this.loadMoreMedia,
required this.count,
required this.desc,
@@ -32,37 +31,33 @@ class MediaListPanel extends CommonCollapseSlidePage {
this.onDelete,
});
final List<MediaListItemModel> mediaList;
final RxList<MediaListItemModel> mediaList;
final ValueChanged<BaseEpisodeItem> onChangeEpisode;
final String? panelTitle;
final Function getBvId;
final String bvid;
final VoidCallback loadMoreMedia;
final int? count;
final bool desc;
final VoidCallback onReverse;
final RefreshCallback? loadPrevious;
final Function(MediaListItemModel item, int index)? onDelete;
final void Function(MediaListItemModel item, int index)? onDelete;
@override
State<MediaListPanel> createState() => _MediaListPanelState();
}
class _MediaListPanelState
extends CommonCollapseSlidePageState<MediaListPanel> {
final _controller = ItemScrollController();
class _MediaListPanelState extends State<MediaListPanel>
with SingleTickerProviderStateMixin, CommonSlideMixin {
late final ScrollController _controller;
@override
void init() {
final bvid = widget.getBvId();
void initState() {
super.initState();
final bvid = widget.bvid;
final bvIndex = widget.mediaList.indexWhere((item) => item.bvid == bvid);
if (bvIndex != -1) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) {
isInit = false;
_controller.jumpTo(index: bvIndex);
}
});
}
_controller = ScrollController(
initialScrollOffset: bvIndex == -1 ? 0 : bvIndex * 100.0 + 7,
);
}
@override
@@ -120,31 +115,37 @@ class _MediaListPanelState
: _buildList(theme);
}
Widget _buildList(ThemeData theme) => Obx(
() {
final showDelBtn = widget.onDelete != null && widget.mediaList.length > 1;
return ScrollablePositionedList.separated(
itemScrollController: _controller,
physics: const AlwaysScrollableScrollPhysics(),
itemCount: widget.mediaList.length,
padding: EdgeInsets.only(
top: 7,
bottom: MediaQuery.viewPaddingOf(context).bottom + 100,
Widget _buildList(ThemeData theme) {
final showDelBtn = widget.onDelete != null && widget.mediaList.length > 1;
return CustomScrollView(
controller: _controller,
physics: const AlwaysScrollableScrollPhysics(),
slivers: [
SliverPadding(
padding: EdgeInsets.only(
top: 7,
bottom: MediaQuery.viewPaddingOf(context).bottom + 100,
),
sliver: Obx(
() => SliverFixedExtentList.builder(
itemExtent: 100,
itemCount: widget.mediaList.length,
itemBuilder: (context, index) {
if (index == widget.mediaList.length - 1 &&
(widget.count == null ||
widget.mediaList.length < widget.count!)) {
widget.loadMoreMedia();
}
var item = widget.mediaList[index];
final isCurr = item.bvid == widget.bvid;
return _buildItem(theme, index, item, isCurr, showDelBtn);
},
),
),
),
itemBuilder: ((context, index) {
if (index == widget.mediaList.length - 1 &&
(widget.count == null ||
widget.mediaList.length < widget.count!)) {
widget.loadMoreMedia();
}
var item = widget.mediaList[index];
final isCurr = item.bvid == widget.getBvId();
return _buildItem(theme, index, item, isCurr, showDelBtn);
}),
separatorBuilder: (context, index) => const SizedBox(height: 2),
);
},
);
],
);
}
Widget _buildItem(
ThemeData theme,
@@ -153,146 +154,151 @@ class _MediaListPanelState
bool isCurr,
bool showDelBtn,
) {
return SizedBox(
height: 98,
child: Material(
type: MaterialType.transparency,
child: InkWell(
onTap: () {
if (item.type != 2) {
SmartDialog.showToast('不支持播放该类型视频');
return;
}
Get.back();
widget.onChangeEpisode(item);
},
onLongPress: () => imageSaveDialog(
title: item.title,
cover: item.cover,
aid: item.aid,
bvid: item.bvid,
),
child: Stack(
clipBehavior: Clip.none,
children: [
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 5,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Stack(
clipBehavior: Clip.none,
children: [
NetworkImgLayer(
src: item.cover,
width: 140.8,
height: 88,
),
if (item.badge?.isNotEmpty == true)
PBadge(
text: item.badge,
right: 6.0,
top: 6.0,
type: switch (item.badge) {
'充电专属' => PBadgeType.error,
_ => PBadgeType.primary,
},
),
PBadge(
text: DurationUtils.formatDuration(
item.duration,
),
right: 6.0,
bottom: 6.0,
type: PBadgeType.gray,
),
],
),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
return Padding(
padding: const EdgeInsets.only(bottom: 2),
child: SizedBox(
height: 98,
child: Material(
type: MaterialType.transparency,
child: InkWell(
onTap: () {
if (item.type != 2) {
SmartDialog.showToast('不支持播放该类型视频');
return;
}
Get.back();
widget.onChangeEpisode(item);
},
onLongPress: () => imageSaveDialog(
title: item.title,
cover: item.cover,
aid: item.aid,
bvid: item.bvid,
),
child: Stack(
clipBehavior: Clip.none,
children: [
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 5,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Stack(
clipBehavior: Clip.none,
children: [
Text(
item.title!,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontWeight: isCurr ? FontWeight.bold : null,
color: isCurr ? theme.colorScheme.primary : null,
),
NetworkImgLayer(
src: item.cover,
width: 140.8,
height: 88,
),
if (item.type == 24 &&
item.intro?.isNotEmpty == true) ...[
const SizedBox(height: 3),
if (item.badge?.isNotEmpty == true)
PBadge(
text: item.badge,
right: 6.0,
top: 6.0,
type: switch (item.badge) {
'充电专属' => PBadgeType.error,
_ => PBadgeType.primary,
},
),
PBadge(
text: DurationUtils.formatDuration(
item.duration,
),
right: 6.0,
bottom: 6.0,
type: PBadgeType.gray,
),
],
),
const SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
item.intro!,
item.title!,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 13,
fontWeight: isCurr ? FontWeight.bold : null,
color: isCurr
? theme.colorScheme.primary
: null,
),
),
if (item.type == 24 &&
item.intro?.isNotEmpty == true) ...[
const SizedBox(height: 3),
Text(
item.intro!,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 13,
color: theme.colorScheme.outline,
),
),
],
const Spacer(),
Text(
item.upper!.name!,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12,
color: theme.colorScheme.outline,
),
),
if (item.type == 2) ...[
const SizedBox(height: 3),
Row(
spacing: 8,
children: [
StatWidget(
type: StatType.play,
value: item.cntInfo!.play,
),
StatWidget(
type: StatType.danmaku,
value: item.cntInfo!.danmaku,
),
],
),
],
],
const Spacer(),
Text(
item.upper!.name!,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12,
color: theme.colorScheme.outline,
),
),
if (item.type == 2) ...[
const SizedBox(height: 3),
Row(
spacing: 8,
children: [
StatWidget(
type: StatType.play,
value: item.cntInfo!.play,
),
StatWidget(
type: StatType.danmaku,
value: item.cntInfo!.danmaku,
),
],
),
],
],
),
),
),
],
],
),
),
),
if (showDelBtn && !isCurr)
Positioned(
right: 12,
bottom: -6,
child: InkWell(
customBorder: const CircleBorder(),
onTap: () => showConfirmDialog(
context: context,
title: '确定移除该视频?',
onConfirm: () => widget.onDelete!(item, index),
),
onLongPress: () => widget.onDelete!(item, index),
child: Padding(
padding: const EdgeInsets.all(9),
child: Icon(
Icons.clear,
size: 18,
color: theme.colorScheme.outline,
if (showDelBtn && !isCurr)
Positioned(
right: 12,
bottom: -6,
child: InkWell(
customBorder: const CircleBorder(),
onTap: () => showConfirmDialog(
context: context,
title: '确定移除该视频?',
onConfirm: () => widget.onDelete!(item, index),
),
onLongPress: () => widget.onDelete!(item, index),
child: Padding(
padding: const EdgeInsets.all(9),
child: Icon(
Icons.clear,
size: 18,
color: theme.colorScheme.outline,
),
),
),
),
),
],
],
),
),
),
),