hiding appbar
This commit is contained in:
parent
a92556b7fe
commit
e1be7bd5e6
@ -33,7 +33,7 @@ class _ShuffleScreenState extends State<ShuffleScreen> {
|
||||
double width = MediaQuery.of(context).size.width;
|
||||
return PreviewGrid(
|
||||
videoLoader: () {
|
||||
return loadData((isTV() ? width ~/ 200 : width ~/ 330) * 2);
|
||||
return loadData((isTV() ? width ~/ 200 : width ~/ 275) * 2);
|
||||
},
|
||||
footerBuilder: (state) => Column(
|
||||
children: [
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:math';
|
||||
|
||||
@ -10,6 +11,7 @@ import 'package:video_player/video_player.dart';
|
||||
|
||||
import 'api/api.dart';
|
||||
import 'api/token.dart';
|
||||
import 'log/log.dart';
|
||||
import 'platform.dart';
|
||||
|
||||
class VideoScreen extends StatefulWidget {
|
||||
@ -21,13 +23,14 @@ class VideoScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _VideoScreenState extends State<VideoScreen> {
|
||||
Player? _player =
|
||||
isDesktop() ? Player(id: Random().nextInt(0x7fffffff)) : null;
|
||||
Player? _player = isDesktop() ? Player(id: Random().nextInt(0x7fffffff)) : null;
|
||||
ChewieController? _chewieController;
|
||||
|
||||
bool _appBarVisible = true;
|
||||
Timer? _appBarTimer;
|
||||
|
||||
void loadData() async {
|
||||
final data =
|
||||
await API.query("video", "loadVideo", {'MovieId': widget.metaData.id});
|
||||
final data = await API.query("video", "loadVideo", {'MovieId': widget.metaData.id});
|
||||
|
||||
final d = jsonDecode(data);
|
||||
|
||||
@ -47,8 +50,7 @@ class _VideoScreenState extends State<VideoScreen> {
|
||||
autoStart: true, // default
|
||||
);
|
||||
} else {
|
||||
final VideoPlayerController _controller =
|
||||
VideoPlayerController.network(path);
|
||||
final VideoPlayerController _controller = VideoPlayerController.network(path);
|
||||
await _controller.initialize();
|
||||
|
||||
_chewieController = ChewieController(
|
||||
@ -71,18 +73,15 @@ class _VideoScreenState extends State<VideoScreen> {
|
||||
if (isDesktop()) {
|
||||
RawKeyboard.instance.addListener((value) {
|
||||
if (value.logicalKey == LogicalKeyboardKey.arrowRight) {
|
||||
_player
|
||||
?.seek(_player!.position.position! + const Duration(seconds: 5));
|
||||
_player?.seek(_player!.position.position! + const Duration(seconds: 5));
|
||||
} else if (value.logicalKey == LogicalKeyboardKey.arrowLeft) {
|
||||
_player
|
||||
?.seek(_player!.position.position! + const Duration(seconds: -5));
|
||||
_player?.seek(_player!.position.position! + const Duration(seconds: -5));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
loadData();
|
||||
|
||||
// todo hide appbar after some seonds
|
||||
_setAppBarTimer();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -96,13 +95,35 @@ class _VideoScreenState extends State<VideoScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
void _setAppBarTimer() {
|
||||
_appBarTimer?.cancel();
|
||||
_appBarTimer = Timer(
|
||||
Duration(seconds: 3),
|
||||
() {
|
||||
setState(() {
|
||||
_appBarVisible = false;
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(widget.metaData.title),
|
||||
extendBody: true,
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: _appBarVisible ? AppBar(title: Text(widget.metaData.title)) : null,
|
||||
body: MouseRegion(
|
||||
onHover: (PointerEvent event) {
|
||||
if (event.delta.dx != 0 || event.delta.dy != 0) {
|
||||
setState(() {
|
||||
_appBarVisible = true;
|
||||
});
|
||||
_setAppBarTimer();
|
||||
}
|
||||
},
|
||||
child: Center(child: isDesktop() ? videoDesktop() : videoNotDesktop()),
|
||||
),
|
||||
body: Center(child: isDesktop() ? videoDesktop() : videoNotDesktop()),
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user