screensaver: fixed autopilot when device orientation changes
This commit is contained in:
parent
bf88e2d816
commit
36d92aaf38
2 changed files with 23 additions and 10 deletions
|
@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
## <a id="unreleased"></a>[Unreleased]
|
## <a id="unreleased"></a>[Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- screensaver stopping when device orientation changes
|
||||||
|
|
||||||
## <a id="v1.6.12"></a>[v1.6.12] - 2022-08-27
|
## <a id="v1.6.12"></a>[v1.6.12] - 2022-08-27
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -29,7 +29,7 @@ class ScreenSaverPage extends StatefulWidget {
|
||||||
State<ScreenSaverPage> createState() => _ScreenSaverPageState();
|
State<ScreenSaverPage> createState() => _ScreenSaverPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ScreenSaverPageState extends State<ScreenSaverPage> {
|
class _ScreenSaverPageState extends State<ScreenSaverPage> with WidgetsBindingObserver {
|
||||||
late final ViewerController _viewerController;
|
late final ViewerController _viewerController;
|
||||||
CollectionLens? _slideshowCollection;
|
CollectionLens? _slideshowCollection;
|
||||||
|
|
||||||
|
@ -47,24 +47,24 @@ class _ScreenSaverPageState extends State<ScreenSaverPage> {
|
||||||
);
|
);
|
||||||
source.stateNotifier.addListener(_onSourceStateChanged);
|
source.stateNotifier.addListener(_onSourceStateChanged);
|
||||||
_initSlideshowCollection();
|
_initSlideshowCollection();
|
||||||
}
|
WidgetsBinding.instance.addObserver(this);
|
||||||
|
|
||||||
void _onSourceStateChanged() {
|
|
||||||
if (_slideshowCollection == null) {
|
|
||||||
_initSlideshowCollection();
|
|
||||||
if (_slideshowCollection != null) {
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
source.stateNotifier.removeListener(_onSourceStateChanged);
|
source.stateNotifier.removeListener(_onSourceStateChanged);
|
||||||
_viewerController.dispose();
|
_viewerController.dispose();
|
||||||
|
WidgetsBinding.instance.removeObserver(this);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||||
|
if (state == AppLifecycleState.resumed) {
|
||||||
|
_viewerController.autopilot = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Widget child;
|
Widget child;
|
||||||
|
@ -102,6 +102,15 @@ class _ScreenSaverPageState extends State<ScreenSaverPage> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _onSourceStateChanged() {
|
||||||
|
if (_slideshowCollection == null) {
|
||||||
|
_initSlideshowCollection();
|
||||||
|
if (_slideshowCollection != null) {
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _initSlideshowCollection() {
|
void _initSlideshowCollection() {
|
||||||
if (source.stateNotifier.value != SourceState.ready || _slideshowCollection != null) return;
|
if (source.stateNotifier.value != SourceState.ready || _slideshowCollection != null) return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue