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 _onQueryFocusRequest() => _queryBarFocusNode.requestFocus();
|
||||||
|
|
||||||
void _updateStatusBarHeight() {
|
void _updateStatusBarHeight() {
|
||||||
if (!context.mounted) {
|
if (!mounted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_statusBarHeight = MediaQuery.paddingOf(context).top;
|
_statusBarHeight = MediaQuery.paddingOf(context).top;
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:async';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:aves/app_mode.dart';
|
import 'package:aves/app_mode.dart';
|
||||||
|
import 'package:aves/model/device.dart';
|
||||||
import 'package:aves/model/entry/entry.dart';
|
import 'package:aves/model/entry/entry.dart';
|
||||||
import 'package:aves/model/entry/extensions/multipage.dart';
|
import 'package:aves/model/entry/extensions/multipage.dart';
|
||||||
import 'package:aves/model/entry/extensions/props.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);
|
static const _pipRatioMin = Rational(18, 43);
|
||||||
|
|
||||||
Future<void> updatePictureInPicture(BuildContext context) async {
|
Future<void> updatePictureInPicture(BuildContext context) async {
|
||||||
if (context.mounted) {
|
if (!device.supportPictureInPicture) return;
|
||||||
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
final viewSize = MediaQuery.sizeOf(context) * MediaQuery.devicePixelRatioOf(context);
|
if (context.mounted && settings.videoBackgroundMode == VideoBackgroundMode.pip) {
|
||||||
final fittedSize = applyBoxFit(BoxFit.contain, entrySize, viewSize).destination;
|
final playingController = context.read<VideoConductor>().getPlayingController();
|
||||||
final sourceRectHint = Rectangle<int>(
|
if (playingController != null) {
|
||||||
((viewSize.width - fittedSize.width) / 2).round(),
|
final entrySize = playingController.entry.displaySize;
|
||||||
((viewSize.height - fittedSize.height) / 2).round(),
|
final entryAspectRatio = entrySize.aspectRatio;
|
||||||
fittedSize.width.round(),
|
final Rational pipAspectRatio;
|
||||||
fittedSize.height.round(),
|
if (entryAspectRatio > _pipRatioMax.aspectRatio) {
|
||||||
);
|
pipAspectRatio = _pipRatioMax;
|
||||||
|
} else if (entryAspectRatio < _pipRatioMin.aspectRatio) {
|
||||||
|
pipAspectRatio = _pipRatioMin;
|
||||||
|
} else {
|
||||||
|
pipAspectRatio = Rational(entrySize.width.round(), entrySize.height.round());
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
final viewSize = MediaQuery.sizeOf(context) * MediaQuery.devicePixelRatioOf(context);
|
||||||
final status = await Floating().enable(OnLeavePiP(
|
final fittedSize = applyBoxFit(BoxFit.contain, entrySize, viewSize).destination;
|
||||||
aspectRatio: pipAspectRatio,
|
final sourceRectHint = Rectangle<int>(
|
||||||
sourceRectHint: sourceRectHint,
|
((viewSize.width - fittedSize.width) / 2).round(),
|
||||||
));
|
((viewSize.height - fittedSize.height) / 2).round(),
|
||||||
debugPrint('Enabled picture-in-picture with status=$status');
|
fittedSize.width.round(),
|
||||||
return;
|
fittedSize.height.round(),
|
||||||
} on PlatformException catch (e, stack) {
|
);
|
||||||
await reportService.recordError(e, stack);
|
|
||||||
}
|
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