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