127 lines
3.3 KiB
Dart
127 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:skywood/global/client/play_client.dart';
|
|
import 'package:skywood/main/lib_file.dart';
|
|
import 'package:skywood/pages/home/players/widget/sky_player_view.dart';
|
|
import 'package:skywood/utils/models/drama/skywood_detail.dart';
|
|
import 'package:skywood/utils/models/drama/skywood_drama.dart';
|
|
import 'package:skywood/utils/models/drama/skywood_episode.dart';
|
|
import 'package:skywood/utils/tools/app_toast.dart';
|
|
import 'package:skywood/utils/tools/widgets/sky_common_widget.dart';
|
|
|
|
class DramaDetailPage extends StatefulWidget {
|
|
const DramaDetailPage({super.key, required this.dramaBean});
|
|
|
|
final SkywoodDrama dramaBean;
|
|
|
|
@override
|
|
State<StatefulWidget> createState() {
|
|
return _DramaDetailPageState();
|
|
}
|
|
}
|
|
|
|
class _DramaDetailPageState extends State<DramaDetailPage> {
|
|
SkywoodDetail? _detailBean;
|
|
SkywoodEpisode? _selectedEpisode;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
|
|
_getDetailDrama(
|
|
shortPlayId: widget.dramaBean.shortPlayId ?? 0,
|
|
shortPlayVideoId: widget.dramaBean.shortPlayVideoId ?? 0,
|
|
);
|
|
}
|
|
|
|
void _getDetailDrama({
|
|
required int shortPlayId,
|
|
required int shortPlayVideoId,
|
|
}) {
|
|
AppToast.showLottieLoading();
|
|
PlayClient.getVideoDetail(
|
|
shortPlayId: shortPlayId,
|
|
shortPlayVideoId: shortPlayVideoId,
|
|
).then((value) {
|
|
AppToast.dismiss();
|
|
if (!mounted) return;
|
|
setState(() {
|
|
_detailBean = value;
|
|
});
|
|
});
|
|
}
|
|
|
|
void _onSelectedEpisode(SkywoodEpisode episode) {
|
|
setState(() {
|
|
_selectedEpisode = episode;
|
|
});
|
|
_getDetailDrama(
|
|
shortPlayId: episode.shortPlayId,
|
|
shortPlayVideoId: episode.shortPlayVideoId,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(backgroundColor: Colors.black, body: _bodyWidget());
|
|
}
|
|
|
|
Widget _bodyWidget() {
|
|
return Stack(
|
|
children: [
|
|
SizedBox(width: double.infinity, height: double.infinity),
|
|
|
|
if (_detailBean != null)
|
|
Positioned(
|
|
bottom: 0,
|
|
left: 0,
|
|
right: 0,
|
|
top: 0,
|
|
child: SkyPlayerView(
|
|
key: ValueKey(
|
|
_selectedEpisode?.shortPlayVideoId ??
|
|
_detailBean?.videoInfo?.shortPlayVideoId ??
|
|
widget.dramaBean.shortPlayVideoId,
|
|
),
|
|
detailBean: _detailBean,
|
|
dramaBean: widget.dramaBean,
|
|
currentEpisode: _selectedEpisode?.episode,
|
|
onSelectedEpisode: _onSelectedEpisode,
|
|
),
|
|
),
|
|
|
|
Positioned(
|
|
top: AppScreen.statusBarHeight + 5,
|
|
left: 0,
|
|
right: 0,
|
|
child: _headerWidget(),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _headerWidget() {
|
|
return Container(
|
|
height: 40,
|
|
padding: const EdgeInsets.only(right: 15, left: 5),
|
|
child: Row(
|
|
children: [
|
|
IconButton(
|
|
icon: HelpImg.asset(ConstImg.back, width: 32),
|
|
onPressed: () => HelpNav.back(),
|
|
),
|
|
Expanded(
|
|
child: SkyText(
|
|
text: widget.dramaBean.name,
|
|
color: Colors.white,
|
|
fontSize: 16,
|
|
textAlign: TextAlign.center,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
SizedBox(width: 40),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|