fix: 番剧记忆播放
This commit is contained in:
@ -22,7 +22,11 @@ import 'controller.dart';
|
|||||||
import 'widgets/intro_detail.dart';
|
import 'widgets/intro_detail.dart';
|
||||||
|
|
||||||
class BangumiIntroPanel extends StatefulWidget {
|
class BangumiIntroPanel extends StatefulWidget {
|
||||||
const BangumiIntroPanel({super.key});
|
final int? cid;
|
||||||
|
const BangumiIntroPanel({
|
||||||
|
Key? key,
|
||||||
|
this.cid,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<BangumiIntroPanel> createState() => _BangumiIntroPanelState();
|
State<BangumiIntroPanel> createState() => _BangumiIntroPanelState();
|
||||||
@ -69,7 +73,11 @@ class _BangumiIntroPanelState extends State<BangumiIntroPanel>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return BangumiInfo(loadingStatus: true, bangumiDetail: bangumiDetail);
|
return BangumiInfo(
|
||||||
|
loadingStatus: true,
|
||||||
|
bangumiDetail: bangumiDetail,
|
||||||
|
cid: widget.cid,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -79,11 +87,13 @@ class _BangumiIntroPanelState extends State<BangumiIntroPanel>
|
|||||||
class BangumiInfo extends StatefulWidget {
|
class BangumiInfo extends StatefulWidget {
|
||||||
final bool loadingStatus;
|
final bool loadingStatus;
|
||||||
final BangumiInfoModel? bangumiDetail;
|
final BangumiInfoModel? bangumiDetail;
|
||||||
|
final int? cid;
|
||||||
|
|
||||||
const BangumiInfo({
|
const BangumiInfo({
|
||||||
Key? key,
|
Key? key,
|
||||||
this.loadingStatus = false,
|
this.loadingStatus = false,
|
||||||
this.bangumiDetail,
|
this.bangumiDetail,
|
||||||
|
this.cid,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -97,6 +107,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
Box localCache = GStrorage.localCache;
|
Box localCache = GStrorage.localCache;
|
||||||
late final BangumiInfoModel? bangumiItem;
|
late final BangumiInfoModel? bangumiItem;
|
||||||
late double sheetHeight;
|
late double sheetHeight;
|
||||||
|
int? cid;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -105,6 +116,7 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
videoDetailCtr = Get.find<VideoDetailController>(tag: heroTag);
|
videoDetailCtr = Get.find<VideoDetailController>(tag: heroTag);
|
||||||
bangumiItem = bangumiIntroController.bangumiItem;
|
bangumiItem = bangumiIntroController.bangumiItem;
|
||||||
sheetHeight = localCache.get('sheetHeight');
|
sheetHeight = localCache.get('sheetHeight');
|
||||||
|
cid = widget.cid!;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 收藏
|
// 收藏
|
||||||
@ -320,9 +332,10 @@ class _BangumiInfoState extends State<BangumiInfo> {
|
|||||||
pages: bangumiItem != null
|
pages: bangumiItem != null
|
||||||
? bangumiItem!.episodes!
|
? bangumiItem!.episodes!
|
||||||
: widget.bangumiDetail!.episodes!,
|
: widget.bangumiDetail!.episodes!,
|
||||||
cid: bangumiItem != null
|
cid: cid ??
|
||||||
? bangumiItem!.episodes!.first.cid
|
(bangumiItem != null
|
||||||
: widget.bangumiDetail!.episodes!.first.cid,
|
? bangumiItem!.episodes!.first.cid
|
||||||
|
: widget.bangumiDetail!.episodes!.first.cid),
|
||||||
sheetHeight: sheetHeight,
|
sheetHeight: sheetHeight,
|
||||||
changeFuc: (bvid, cid, aid) => bangumiIntroController
|
changeFuc: (bvid, cid, aid) => bangumiIntroController
|
||||||
.changeSeasonOrbangu(bvid, cid, aid),
|
.changeSeasonOrbangu(bvid, cid, aid),
|
||||||
|
@ -22,77 +22,106 @@ class BangumiPanel extends StatefulWidget {
|
|||||||
|
|
||||||
class _BangumiPanelState extends State<BangumiPanel> {
|
class _BangumiPanelState extends State<BangumiPanel> {
|
||||||
late int currentIndex;
|
late int currentIndex;
|
||||||
|
final ScrollController listViewScrollCtr = ScrollController();
|
||||||
|
final ScrollController listViewScrollCtr_2 = ScrollController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
currentIndex = widget.pages.indexWhere((e) => e.cid == widget.cid!);
|
currentIndex = widget.pages.indexWhere((e) => e.cid == widget.cid!);
|
||||||
|
scrollToIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
listViewScrollCtr.dispose();
|
||||||
|
listViewScrollCtr_2.dispose();
|
||||||
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void showBangumiPanel() {
|
void showBangumiPanel() {
|
||||||
showBottomSheet(
|
showBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (_) => Container(
|
builder: (BuildContext context) {
|
||||||
height: widget.sheetHeight,
|
return StatefulBuilder(
|
||||||
color: Theme.of(context).colorScheme.background,
|
builder: (BuildContext context, StateSetter setState) {
|
||||||
child: Column(
|
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||||
children: [
|
await Future.delayed(const Duration(milliseconds: 200));
|
||||||
AppBar(
|
listViewScrollCtr_2.animateTo(currentIndex * 56,
|
||||||
toolbarHeight: 45,
|
duration: const Duration(milliseconds: 500),
|
||||||
automaticallyImplyLeading: false,
|
curve: Curves.easeInOut);
|
||||||
title: Row(
|
});
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
// 在这里使用 setState 更新状态
|
||||||
|
return Container(
|
||||||
|
height: widget.sheetHeight,
|
||||||
|
color: Theme.of(context).colorScheme.background,
|
||||||
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
AppBar(
|
||||||
'合集(${widget.pages.length})',
|
toolbarHeight: 45,
|
||||||
style: Theme.of(context).textTheme.titleMedium,
|
automaticallyImplyLeading: false,
|
||||||
|
title: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'合集(${widget.pages.length})',
|
||||||
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.close),
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
titleSpacing: 10,
|
||||||
),
|
),
|
||||||
IconButton(
|
Expanded(
|
||||||
icon: const Icon(Icons.close),
|
child: Material(
|
||||||
onPressed: () => Navigator.pop(context),
|
child: ListView.builder(
|
||||||
|
controller: listViewScrollCtr_2,
|
||||||
|
itemCount: widget.pages.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return ListTile(
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
changeFucCall(widget.pages[index], index);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
dense: false,
|
||||||
|
leading: index == currentIndex
|
||||||
|
? Image.asset(
|
||||||
|
'assets/images/live.gif',
|
||||||
|
color:
|
||||||
|
Theme.of(context).colorScheme.primary,
|
||||||
|
height: 12,
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
title: Text(
|
||||||
|
'第${index + 1}话 ${widget.pages[index].longTitle!}',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: index == currentIndex
|
||||||
|
? Theme.of(context).colorScheme.primary
|
||||||
|
: Theme.of(context).colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
trailing: widget.pages[index].badge != null
|
||||||
|
? Image.asset(
|
||||||
|
'assets/images/big-vip.png',
|
||||||
|
height: 20,
|
||||||
|
)
|
||||||
|
: const SizedBox(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
titleSpacing: 10,
|
);
|
||||||
),
|
},
|
||||||
Expanded(
|
);
|
||||||
child: Material(
|
},
|
||||||
child: ListView.builder(
|
|
||||||
itemCount: widget.pages.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
return ListTile(
|
|
||||||
onTap: () => changeFucCall(widget.pages[index], index),
|
|
||||||
dense: false,
|
|
||||||
leading: index == currentIndex
|
|
||||||
? Image.asset(
|
|
||||||
'assets/images/live.gif',
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
height: 12,
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
title: Text(
|
|
||||||
'第${index + 1}话 ${widget.pages[index].longTitle!}',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 14,
|
|
||||||
color: index == currentIndex
|
|
||||||
? Theme.of(context).colorScheme.primary
|
|
||||||
: Theme.of(context).colorScheme.onSurface,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
trailing: widget.pages[index].badge != null
|
|
||||||
? Image.asset(
|
|
||||||
'assets/images/big-vip.png',
|
|
||||||
height: 20,
|
|
||||||
)
|
|
||||||
: const SizedBox(),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,6 +137,15 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
|||||||
);
|
);
|
||||||
currentIndex = i;
|
currentIndex = i;
|
||||||
setState(() {});
|
setState(() {});
|
||||||
|
scrollToIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
void scrollToIndex() {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
// 在回调函数中获取更新后的状态
|
||||||
|
listViewScrollCtr.animateTo(currentIndex * 150,
|
||||||
|
duration: const Duration(milliseconds: 500), curve: Curves.easeInOut);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -150,6 +188,7 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
height: 60,
|
height: 60,
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
|
controller: listViewScrollCtr,
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
itemCount: widget.pages.length,
|
itemCount: widget.pages.length,
|
||||||
itemExtent: 150,
|
itemExtent: 150,
|
||||||
@ -222,87 +261,6 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
|||||||
);
|
);
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
// SingleChildScrollView(
|
|
||||||
// padding: const EdgeInsets.only(top: 7, bottom: 7),
|
|
||||||
// scrollDirection: Axis.horizontal,
|
|
||||||
// child: ConstrainedBox(
|
|
||||||
// constraints: BoxConstraints(
|
|
||||||
// minWidth: MediaQuery.of(context).size.width,
|
|
||||||
// ),
|
|
||||||
// child: Row(
|
|
||||||
// children: [
|
|
||||||
// for (int i = 0; i < widget.pages.length; i++) ...[
|
|
||||||
// Container(
|
|
||||||
// width: 150,
|
|
||||||
// margin: const EdgeInsets.only(right: 10),
|
|
||||||
// child: Material(
|
|
||||||
// color: Theme.of(context).colorScheme.onInverseSurface,
|
|
||||||
// borderRadius: BorderRadius.circular(6),
|
|
||||||
// clipBehavior: Clip.hardEdge,
|
|
||||||
// child: InkWell(
|
|
||||||
// onTap: () => changeFucCall(widget.pages[i], i),
|
|
||||||
// child: Padding(
|
|
||||||
// padding: const EdgeInsets.symmetric(
|
|
||||||
// vertical: 8, horizontal: 10),
|
|
||||||
// child: Column(
|
|
||||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
// children: [
|
|
||||||
// Row(
|
|
||||||
// children: [
|
|
||||||
// if (i == currentIndex) ...[
|
|
||||||
// Image.asset(
|
|
||||||
// 'assets/images/live.gif',
|
|
||||||
// color:
|
|
||||||
// Theme.of(context).colorScheme.primary,
|
|
||||||
// height: 12,
|
|
||||||
// ),
|
|
||||||
// const SizedBox(width: 6)
|
|
||||||
// ],
|
|
||||||
// Text(
|
|
||||||
// '第${i + 1}话',
|
|
||||||
// style: TextStyle(
|
|
||||||
// fontSize: 13,
|
|
||||||
// color: i == currentIndex
|
|
||||||
// ? Theme.of(context)
|
|
||||||
// .colorScheme
|
|
||||||
// .primary
|
|
||||||
// : Theme.of(context)
|
|
||||||
// .colorScheme
|
|
||||||
// .onSurface),
|
|
||||||
// ),
|
|
||||||
// const SizedBox(width: 2),
|
|
||||||
// if (widget.pages[i].badge != null) ...[
|
|
||||||
// Image.asset(
|
|
||||||
// 'assets/images/big-vip.png',
|
|
||||||
// height: 16,
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// const SizedBox(height: 3),
|
|
||||||
// Text(
|
|
||||||
// widget.pages[i].longTitle!,
|
|
||||||
// maxLines: 1,
|
|
||||||
// style: TextStyle(
|
|
||||||
// fontSize: 13,
|
|
||||||
// color: i == currentIndex
|
|
||||||
// ? Theme.of(context).colorScheme.primary
|
|
||||||
// : Theme.of(context)
|
|
||||||
// .colorScheme
|
|
||||||
// .onSurface),
|
|
||||||
// overflow: TextOverflow.ellipsis,
|
|
||||||
// )
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ]
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// )
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -322,7 +322,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
const VideoIntroPanel(),
|
const VideoIntroPanel(),
|
||||||
] else if (videoDetailController.videoType ==
|
] else if (videoDetailController.videoType ==
|
||||||
SearchType.media_bangumi) ...[
|
SearchType.media_bangumi) ...[
|
||||||
const BangumiIntroPanel()
|
BangumiIntroPanel(
|
||||||
|
cid: videoDetailController.cid)
|
||||||
],
|
],
|
||||||
// if (videoDetailController.videoType ==
|
// if (videoDetailController.videoType ==
|
||||||
// SearchType.video) ...[
|
// SearchType.video) ...[
|
||||||
|
Reference in New Issue
Block a user