Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mobile][photos] simplify the long press states

aaqil095e033a61bb
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 7e40357759..49efe3d17b 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
@@ -42,18 +42,16 @@ class VideoLongPressSpeedIndicator extends StatelessWidget {
@override
Widget build(BuildContext context) {
final textTheme = getEnteTextTheme(context);
- return IgnorePointer(
- child: DecoratedBox(
- decoration: BoxDecoration(
- color: Colors.black.withValues(alpha: 0.72),
- borderRadius: BorderRadius.circular(16),
- ),
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
- child: Text(
- "2x",
- style: textTheme.smallBold.copyWith(color: textBaseDark),
- ),
+ return DecoratedBox(
+ decoration: BoxDecoration(
+ color: Colors.black.withValues(alpha: 0.72),
+ borderRadius: BorderRadius.circular(16),
+ ),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
+ child: Text(
+ "2x",
+ style: textTheme.smallBold.copyWith(color: textBaseDark),
),
),
);
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 11c8b68e0f..5815e3c4ba 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
@@ -51,7 +51,6 @@ class _VideoWidgetState extends State<VideoWidget> {
late final VideoSeekController _seekController;
bool _isSeekInteractionActive = false;
late final StreamSubscription<bool> _isPlayingStreamSubscription;
- bool _isLongPressSpeedActive = false;
OverlayEntry? _longPressSpeedIndicatorEntry;
late final StreamSubscription<bool> _completedStreamSubscription;
@@ -112,15 +111,13 @@ class _VideoWidgetState extends State<VideoWidget> {
}
void _startLongPressSpeed() {
- if (_isLongPressSpeedActive) return;
- _isLongPressSpeedActive = true;
+ if (_longPressSpeedIndicatorEntry != null) return;
_longPressSpeedIndicatorEntry = showVideoLongPressSpeedIndicator(context);
widget.controller.player.setRate(kVideoLongPressPlaybackSpeed).ignore();
}
void _restorePlaybackSpeed() {
- if (!_isLongPressSpeedActive) return;
- _isLongPressSpeedActive = false;
+ if (_longPressSpeedIndicatorEntry == null) return;
_longPressSpeedIndicatorEntry?.remove();
_longPressSpeedIndicatorEntry = null;
widget.controller.player.setRate(widget.playbackSpeed.value).ignore();
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 a038d28fc8..142039107f 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
@@ -101,7 +101,6 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
StreamSubscription<DownloadTask>? downloadTaskSubscription;
final _transformationController = TransformationController();
bool _isZooming = false;
- bool _isLongPressSpeedActive = false;
OverlayEntry? _longPressSpeedIndicatorEntry;
@override
@@ -331,15 +330,13 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
void _startLongPressSpeed() {
final controller = _controller;
- if (_isLongPressSpeedActive || controller == null) return;
- _isLongPressSpeedActive = true;
+ if (_longPressSpeedIndicatorEntry != null || controller == null) return;
_longPressSpeedIndicatorEntry = showVideoLongPressSpeedIndicator(context);
controller.setPlaybackSpeed(kVideoLongPressPlaybackSpeed).ignore();
}
void _restorePlaybackSpeed() {
- if (!_isLongPressSpeedActive) return;
- _isLongPressSpeedActive = false;
+ if (_longPressSpeedIndicatorEntry == null) return;
_longPressSpeedIndicatorEntry?.remove();
_longPressSpeedIndicatorEntry = null;
_controller?.setPlaybackSpeed(widget.playbackSpeed.value).ignore();