Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mobile][photos] add pill indicator for 2x

aaqil722a58f4a606
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 5ef57d5c5e..659c8c06e1 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,6 +12,30 @@ const kVideoCaptionLineHeight = 16.0;
const kVideoScrimTopPadding = 12.0;
const kVideoLongPressPlaybackSpeed = 2.0;
+class VideoLongPressSpeedIndicator extends StatelessWidget {
+ const VideoLongPressSpeedIndicator({super.key});
+
+ @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),
+ ),
+ ),
+ ),
+ );
+ }
+}
+
class EqualHeightSliderTrackShape extends RoundedRectSliderTrackShape {
const EqualHeightSliderTrackShape();
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 14717a32a4..80f28b3a56 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
@@ -86,13 +86,13 @@ class _VideoWidgetState extends State<VideoWidget> {
void _startLongPressSpeed() {
if (_isLongPressSpeedActive) return;
- _isLongPressSpeedActive = true;
+ setState(() => _isLongPressSpeedActive = true);
widget.controller.player.setRate(kVideoLongPressPlaybackSpeed).ignore();
}
void _restorePlaybackSpeed() {
if (!_isLongPressSpeedActive) return;
- _isLongPressSpeedActive = false;
+ setState(() => _isLongPressSpeedActive = false);
widget.controller.player.setRate(widget.playbackSpeed.value).ignore();
}
@@ -240,6 +240,13 @@ class _VideoWidgetState extends State<VideoWidget> {
);
},
),
+ if (_isLongPressSpeedActive)
+ Positioned(
+ top: MediaQuery.paddingOf(context).top + kToolbarHeight + 16,
+ 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 59f620caf0..dd0e21af52 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
@@ -303,14 +303,15 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
}
void _startLongPressSpeed() {
- if (_isLongPressSpeedActive) return;
- _isLongPressSpeedActive = true;
- _controller?.setPlaybackSpeed(kVideoLongPressPlaybackSpeed).ignore();
+ final controller = _controller;
+ if (_isLongPressSpeedActive || controller == null) return;
+ setState(() => _isLongPressSpeedActive = true);
+ controller.setPlaybackSpeed(kVideoLongPressPlaybackSpeed).ignore();
}
void _restorePlaybackSpeed() {
if (!_isLongPressSpeedActive) return;
- _isLongPressSpeedActive = false;
+ setState(() => _isLongPressSpeedActive = false);
_controller?.setPlaybackSpeed(widget.playbackSpeed.value).ignore();
}
@@ -433,6 +434,18 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
constraints: const BoxConstraints.expand(),
),
),
+ if (_isLongPressSpeedActive)
+ Positioned(
+ top:
+ MediaQuery.paddingOf(context).top +
+ kToolbarHeight +
+ 16,
+ left: 0,
+ right: 0,
+ child: const Center(
+ child: VideoLongPressSpeedIndicator(),
+ ),
+ ),
if (!widget.isFromMemories && isPlaybackReady)
Positioned.fill(
child: Center(