wonders/lib/ui/common/modals/fullscreen_video_viewer.dart

55 lines
1.4 KiB
Dart
Raw Normal View History

2022-08-29 20:38:28 -06:00
import 'package:wonders/common_libs.dart';
import 'package:youtube_player_iframe/youtube_player_iframe.dart';
2022-08-29 20:38:28 -06:00
class FullscreenVideoViewer extends StatefulWidget {
const FullscreenVideoViewer({Key? key, required this.id}) : super(key: key);
2022-08-29 20:38:28 -06:00
final String id;
@override
State<FullscreenVideoViewer> createState() => _FullscreenVideoViewerState();
2022-08-29 20:38:28 -06:00
}
class _FullscreenVideoViewerState extends State<FullscreenVideoViewer> {
late final _controller = YoutubePlayerController.fromVideoId(
videoId: widget.id,
params: const YoutubePlayerParams(),
);
@override
void initState() {
super.initState();
appLogic.supportedOrientationsOverride = [Axis.horizontal, Axis.vertical];
}
@override
void dispose() {
// when view closes, remove the override
appLogic.supportedOrientationsOverride = null;
super.dispose();
}
2022-08-29 20:38:28 -06:00
@override
Widget build(BuildContext context) {
double aspect = context.isLandscape ? MediaQuery.of(context).size.aspectRatio : 9 / 9;
return Scaffold(
backgroundColor: Colors.black,
body: Stack(
children: [
Center(
child: YoutubePlayer(
controller: _controller,
aspectRatio: aspect,
),
),
SafeArea(
child: Padding(
padding: EdgeInsets.all($styles.insets.md),
child: const BackBtn(),
),
),
],
),
);
}
2022-08-29 20:38:28 -06:00
}