minor fixes
This commit is contained in:
parent
cb067aa1ac
commit
b8e9786f4d
2 changed files with 34 additions and 33 deletions
|
@ -626,7 +626,7 @@ class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerPr
|
|||
void _onQueryFocusRequest() => _queryBarFocusNode.requestFocus();
|
||||
|
||||
void _updateStatusBarHeight() {
|
||||
if (!context.mounted) {
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
_statusBarHeight = MediaQuery.paddingOf(context).top;
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:async';
|
|||
import 'dart:math';
|
||||
|
||||
import 'package:aves/app_mode.dart';
|
||||
import 'package:aves/model/device.dart';
|
||||
import 'package:aves/model/entry/entry.dart';
|
||||
import 'package:aves/model/entry/extensions/multipage.dart';
|
||||
import 'package:aves/model/entry/extensions/props.dart';
|
||||
|
@ -227,40 +228,40 @@ mixin EntryViewControllerMixin<T extends StatefulWidget> on State<T> {
|
|||
static const _pipRatioMin = Rational(18, 43);
|
||||
|
||||
Future<void> updatePictureInPicture(BuildContext context) async {
|
||||
if (context.mounted) {
|
||||
if (settings.videoBackgroundMode == VideoBackgroundMode.pip) {
|
||||
final playingController = context.read<VideoConductor>().getPlayingController();
|
||||
if (playingController != null) {
|
||||
final entrySize = playingController.entry.displaySize;
|
||||
final entryAspectRatio = entrySize.aspectRatio;
|
||||
final Rational pipAspectRatio;
|
||||
if (entryAspectRatio > _pipRatioMax.aspectRatio) {
|
||||
pipAspectRatio = _pipRatioMax;
|
||||
} else if (entryAspectRatio < _pipRatioMin.aspectRatio) {
|
||||
pipAspectRatio = _pipRatioMin;
|
||||
} else {
|
||||
pipAspectRatio = Rational(entrySize.width.round(), entrySize.height.round());
|
||||
}
|
||||
if (!device.supportPictureInPicture) return;
|
||||
|
||||
final viewSize = MediaQuery.sizeOf(context) * MediaQuery.devicePixelRatioOf(context);
|
||||
final fittedSize = applyBoxFit(BoxFit.contain, entrySize, viewSize).destination;
|
||||
final sourceRectHint = Rectangle<int>(
|
||||
((viewSize.width - fittedSize.width) / 2).round(),
|
||||
((viewSize.height - fittedSize.height) / 2).round(),
|
||||
fittedSize.width.round(),
|
||||
fittedSize.height.round(),
|
||||
);
|
||||
if (context.mounted && settings.videoBackgroundMode == VideoBackgroundMode.pip) {
|
||||
final playingController = context.read<VideoConductor>().getPlayingController();
|
||||
if (playingController != null) {
|
||||
final entrySize = playingController.entry.displaySize;
|
||||
final entryAspectRatio = entrySize.aspectRatio;
|
||||
final Rational pipAspectRatio;
|
||||
if (entryAspectRatio > _pipRatioMax.aspectRatio) {
|
||||
pipAspectRatio = _pipRatioMax;
|
||||
} else if (entryAspectRatio < _pipRatioMin.aspectRatio) {
|
||||
pipAspectRatio = _pipRatioMin;
|
||||
} else {
|
||||
pipAspectRatio = Rational(entrySize.width.round(), entrySize.height.round());
|
||||
}
|
||||
|
||||
try {
|
||||
final status = await Floating().enable(OnLeavePiP(
|
||||
aspectRatio: pipAspectRatio,
|
||||
sourceRectHint: sourceRectHint,
|
||||
));
|
||||
debugPrint('Enabled picture-in-picture with status=$status');
|
||||
return;
|
||||
} on PlatformException catch (e, stack) {
|
||||
await reportService.recordError(e, stack);
|
||||
}
|
||||
final viewSize = MediaQuery.sizeOf(context) * MediaQuery.devicePixelRatioOf(context);
|
||||
final fittedSize = applyBoxFit(BoxFit.contain, entrySize, viewSize).destination;
|
||||
final sourceRectHint = Rectangle<int>(
|
||||
((viewSize.width - fittedSize.width) / 2).round(),
|
||||
((viewSize.height - fittedSize.height) / 2).round(),
|
||||
fittedSize.width.round(),
|
||||
fittedSize.height.round(),
|
||||
);
|
||||
|
||||
try {
|
||||
final status = await Floating().enable(OnLeavePiP(
|
||||
aspectRatio: pipAspectRatio,
|
||||
sourceRectHint: sourceRectHint,
|
||||
));
|
||||
debugPrint('Enabled picture-in-picture with status=$status');
|
||||
return;
|
||||
} on PlatformException catch (e, stack) {
|
||||
await reportService.recordError(e, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue