Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mobile][photos] implemeted using a root overlay for pill position in landscape mode

aaqil7fdd2530bd1f
diff --git a/mobile/apps/photos/lib/ui/viewer/file/video_control/gallery_video_controls.dart b/mobile/apps/photos/lib/ui/viewer/file/video_control/gallery_video_controls.dart
index 4982eb7fcd..7e40357759 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/video_control/gallery_video_controls.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/video_control/gallery_video_controls.dart
@@ -12,11 +12,28 @@ const kVideoCaptionLineHeight = 16.0;
const kVideoScrimTopPadding = 12.0;
const kVideoLongPressPlaybackSpeed = 2.0;
-double videoLongPressSpeedIndicatorTop(BuildContext context) {
- final screenSize = MediaQuery.sizeOf(context);
- final isLandscape = screenSize.width > screenSize.height;
- return MediaQuery.paddingOf(context).top +
- (isLandscape ? 8 : kToolbarHeight + 16);
+OverlayEntry showVideoLongPressSpeedIndicator(BuildContext context) {
+ final entry = OverlayEntry(
+ builder: (context) {
+ final screenSize = MediaQuery.sizeOf(context);
+ final isLandscape = screenSize.width > screenSize.height;
+ return Positioned(
+ top:
+ MediaQuery.paddingOf(context).top +
+ (isLandscape ? 12 : kToolbarHeight + 16),
+ left: 0,
+ right: 0,
+ child: const IgnorePointer(
+ child: Material(
+ type: MaterialType.transparency,
+ child: Center(child: VideoLongPressSpeedIndicator()),
+ ),
+ ),
+ );
+ },
+ );
+ Overlay.of(context, rootOverlay: true).insert(entry);
+ return entry;
}
class VideoLongPressSpeedIndicator extends StatelessWidget {
diff --git a/mobile/apps/photos/lib/ui/viewer/file/video_widget_media_kit_common.dart b/mobile/apps/photos/lib/ui/viewer/file/video_widget_media_kit_common.dart
index b48c4b3290..6de5a8cad4 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/video_widget_media_kit_common.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/video_widget_media_kit_common.dart
@@ -47,6 +47,7 @@ class _VideoWidgetState extends State<VideoWidget> {
final _isSeekingNotifier = ValueNotifier<bool>(false);
late final StreamSubscription<bool> _isPlayingStreamSubscription;
bool _isLongPressSpeedActive = false;
+ OverlayEntry? _longPressSpeedIndicatorEntry;
@override
void initState() {
@@ -71,6 +72,7 @@ class _VideoWidgetState extends State<VideoWidget> {
@override
void dispose() {
+ _longPressSpeedIndicatorEntry?.remove();
widget.playbackSpeed.removeListener(_onPlaybackSpeedChanged);
showControlsNotifier.dispose();
_isPlayingStreamSubscription.cancel();
@@ -86,13 +88,16 @@ class _VideoWidgetState extends State<VideoWidget> {
void _startLongPressSpeed() {
if (_isLongPressSpeedActive) return;
- setState(() => _isLongPressSpeedActive = true);
+ _isLongPressSpeedActive = true;
+ _longPressSpeedIndicatorEntry = showVideoLongPressSpeedIndicator(context);
widget.controller.player.setRate(kVideoLongPressPlaybackSpeed).ignore();
}
void _restorePlaybackSpeed() {
if (!_isLongPressSpeedActive) return;
- setState(() => _isLongPressSpeedActive = false);
+ _isLongPressSpeedActive = false;
+ _longPressSpeedIndicatorEntry?.remove();
+ _longPressSpeedIndicatorEntry = null;
widget.controller.player.setRate(widget.playbackSpeed.value).ignore();
}
@@ -240,13 +245,6 @@ class _VideoWidgetState extends State<VideoWidget> {
);
},
),
- if (_isLongPressSpeedActive)
- Positioned(
- top: videoLongPressSpeedIndicatorTop(context),
- left: 0,
- right: 0,
- child: const Center(child: VideoLongPressSpeedIndicator()),
- ),
],
);
}
diff --git a/mobile/apps/photos/lib/ui/viewer/file/video_widget_native.dart b/mobile/apps/photos/lib/ui/viewer/file/video_widget_native.dart
index b640227402..6474e490a9 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/video_widget_native.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/video_widget_native.dart
@@ -99,6 +99,7 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
final _transformationController = TransformationController();
bool _isZooming = false;
bool _isLongPressSpeedActive = false;
+ OverlayEntry? _longPressSpeedIndicatorEntry;
@override
void initState() {
@@ -256,6 +257,7 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
@override
void dispose() {
+ _longPressSpeedIndicatorEntry?.remove();
widget.playbackSpeed.removeListener(_onPlaybackSpeedChanged);
_subscription?.cancel();
_controller?.stop().ignore();
@@ -305,13 +307,16 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
void _startLongPressSpeed() {
final controller = _controller;
if (_isLongPressSpeedActive || controller == null) return;
- setState(() => _isLongPressSpeedActive = true);
+ _isLongPressSpeedActive = true;
+ _longPressSpeedIndicatorEntry = showVideoLongPressSpeedIndicator(context);
controller.setPlaybackSpeed(kVideoLongPressPlaybackSpeed).ignore();
}
void _restorePlaybackSpeed() {
if (!_isLongPressSpeedActive) return;
- setState(() => _isLongPressSpeedActive = false);
+ _isLongPressSpeedActive = false;
+ _longPressSpeedIndicatorEntry?.remove();
+ _longPressSpeedIndicatorEntry = null;
_controller?.setPlaybackSpeed(widget.playbackSpeed.value).ignore();
}
@@ -434,15 +439,6 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
constraints: const BoxConstraints.expand(),
),
),
- if (_isLongPressSpeedActive)
- Positioned(
- top: videoLongPressSpeedIndicatorTop(context),
- left: 0,
- right: 0,
- child: const Center(
- child: VideoLongPressSpeedIndicator(),
- ),
- ),
if (!widget.isFromMemories && isPlaybackReady)
Positioned.fill(
child: Center(