Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Refresh gallery video controls

ashilkn48469e047154
diff --git a/mobile/apps/photos/changes/gallery-video-controls.md b/mobile/apps/photos/changes/gallery-video-controls.md
new file mode 100644
index 0000000000..dedbcd61b2
--- /dev/null
+++ b/mobile/apps/photos/changes/gallery-video-controls.md
@@ -0,0 +1 @@
+- Refresh the gallery video caption and playback controls.
diff --git a/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart b/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart
index a0d91e460f..a917f0db16 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart
@@ -40,6 +40,7 @@ import "package:photos/ui/viewer/file/inline_text_detection.dart";
import "package:photos/ui/viewer/file/panorama_viewer_screen.dart";
import "package:photos/ui/viewer/file/qr_code_detection_helper.dart";
import "package:photos/ui/viewer/file/qr_code_highlight_overlay.dart";
+import "package:photos/ui/viewer/file/video_control/gallery_video_controls.dart";
import 'package:photos/ui/viewer/gallery/gallery.dart';
import 'package:photos/utils/dialog_util.dart';
@@ -696,14 +697,13 @@ class _GalleryBottomOverlay extends StatelessWidget {
@override
Widget build(BuildContext context) {
- final supportsCaption =
- file.fileType == FileType.image || file.fileType == FileType.livePhoto;
- final caption = supportsCaption ? file.caption : null;
+ final isVideo = file.fileType == FileType.video;
+ final caption = file.caption;
final captionText = caption == null || caption.isEmpty
? null
: '"$caption"';
final hasBottomBar = mode != DetailPageMode.minimalistic && !isGuestView;
- if (captionText == null && !hasBottomBar) {
+ if (captionText == null && (isVideo || !hasBottomBar)) {
return const SizedBox.shrink();
}
@@ -718,44 +718,48 @@ class _GalleryBottomOverlay extends StatelessWidget {
duration: const Duration(milliseconds: 200),
child: Stack(
children: [
- Align(
- alignment: Alignment.bottomCenter,
- child: IgnorePointer(
- child: SizedBox(
- width: double.infinity,
- height:
- safePadding.bottom +
- _galleryBottomBarHeight +
- (captionText == null
- ? 0
- : _galleryCaptionGap +
- _galleryCaptionLineHeight +
- _galleryCaptionScrimTopPadding),
- child: DecoratedBox(
- decoration: BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- colors: [
- Colors.transparent,
- Colors.black.withValues(alpha: 0.6),
- Colors.black.withValues(alpha: 0.72),
- ],
- stops: const [0, 0.8, 1],
+ if (!isVideo)
+ Align(
+ alignment: Alignment.bottomCenter,
+ child: IgnorePointer(
+ child: SizedBox(
+ width: double.infinity,
+ height:
+ safePadding.bottom +
+ _galleryBottomBarHeight +
+ (captionText == null
+ ? 0
+ : _galleryCaptionGap +
+ _galleryCaptionLineHeight +
+ _galleryCaptionScrimTopPadding),
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ gradient: LinearGradient(
+ begin: Alignment.topCenter,
+ end: Alignment.bottomCenter,
+ colors: [
+ Colors.transparent,
+ Colors.black.withValues(alpha: 0.6),
+ Colors.black.withValues(alpha: 0.72),
+ ],
+ stops: const [0, 0.8, 1],
+ ),
),
),
),
),
),
- ),
if (captionText != null)
Positioned(
left: safePadding.left + 16,
right: safePadding.right + 16,
bottom:
safePadding.bottom +
- _galleryBottomBarHeight +
- _galleryCaptionGap,
+ (isVideo
+ ? kGalleryVideoProgressBottom +
+ kGalleryVideoProgressHeight +
+ kGalleryVideoCaptionGap
+ : _galleryBottomBarHeight + _galleryCaptionGap),
child: Align(
alignment: Alignment.centerLeft,
child: GestureDetector(
diff --git a/mobile/apps/photos/lib/ui/viewer/file/native_video_player_controls/seek_bar.dart b/mobile/apps/photos/lib/ui/viewer/file/native_video_player_controls/seek_bar.dart
index 99856b2eb3..b0fb7e0cc7 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/native_video_player_controls/seek_bar.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/native_video_player_controls/seek_bar.dart
@@ -6,6 +6,7 @@ import "package:native_video_player/native_video_player.dart";
import "package:photos/core/event_bus.dart";
import "package:photos/events/seekbar_triggered_event.dart";
import "package:photos/theme/colors.dart";
+import "package:photos/ui/viewer/file/video_control/gallery_video_controls.dart";
class SeekBar extends StatefulWidget {
final NativeVideoPlayerController controller;
@@ -68,12 +69,14 @@ class _SeekBarState extends State<SeekBar> with SingleTickerProviderStateMixin {
builder: (_, _) {
return SliderTheme(
data: SliderTheme.of(context).copyWith(
- trackHeight: 1.0,
+ trackHeight: 3.0,
+ trackShape: const GalleryVideoSliderTrackShape(),
tickMarkShape: SliderTickMarkShape.noTickMark,
thumbShape: const RoundSliderThumbShape(enabledThumbRadius: 6.0),
overlayShape: const RoundSliderOverlayShape(overlayRadius: 12.0),
+ padding: EdgeInsets.zero,
activeTrackColor: backgroundElevatedLight,
- inactiveTrackColor: fillMutedDark,
+ inactiveTrackColor: textBaseDark.withValues(alpha: 0.3),
thumbColor: backgroundElevatedLight,
overlayColor: fillMutedDark,
),
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
new file mode 100644
index 0000000000..48f1f3288d
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/viewer/file/video_control/gallery_video_controls.dart
@@ -0,0 +1,134 @@
+import "package:flutter/material.dart";
+import "package:photos/theme/colors.dart";
+import "package:photos/theme/ente_theme.dart";
+import "package:photos/ui/viewer/file/video_control/mute_button.dart";
+
+const kGalleryVideoProgressBottom = 64.0;
+const kGalleryVideoProgressHeight = 16.0;
+const kGalleryVideoCaptionGap = 6.0;
+const kGalleryVideoCaptionLineHeight = 16.0;
+const kGalleryVideoScrimTopPadding = 12.0;
+
+class GalleryVideoSliderTrackShape extends RoundedRectSliderTrackShape {
+ const GalleryVideoSliderTrackShape();
+
+ @override
+ void paint(
+ PaintingContext context,
+ Offset offset, {
+ required RenderBox parentBox,
+ required SliderThemeData sliderTheme,
+ required Animation<double> enableAnimation,
+ required TextDirection textDirection,
+ required Offset thumbCenter,
+ Offset? secondaryOffset,
+ bool isDiscrete = false,
+ bool isEnabled = false,
+ double additionalActiveTrackHeight = 2,
+ }) {
+ super.paint(
+ context,
+ offset,
+ parentBox: parentBox,
+ sliderTheme: sliderTheme,
+ enableAnimation: enableAnimation,
+ textDirection: textDirection,
+ thumbCenter: thumbCenter,
+ secondaryOffset: secondaryOffset,
+ isDiscrete: isDiscrete,
+ isEnabled: isEnabled,
+ additionalActiveTrackHeight: 0,
+ );
+ }
+}
+
+class GalleryVideoControlScrim extends StatelessWidget {
+ final bool hasCaption;
+
+ const GalleryVideoControlScrim({required this.hasCaption, super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ return IgnorePointer(
+ child: Align(
+ alignment: Alignment.bottomCenter,
+ child: SizedBox(
+ width: double.infinity,
+ height:
+ MediaQuery.paddingOf(context).bottom +
+ kGalleryVideoProgressBottom +
+ kGalleryVideoProgressHeight +
+ (hasCaption
+ ? kGalleryVideoCaptionGap + kGalleryVideoCaptionLineHeight
+ : 0) +
+ kGalleryVideoScrimTopPadding,
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ gradient: LinearGradient(
+ begin: Alignment.topCenter,
+ end: Alignment.bottomCenter,
+ colors: [
+ Colors.transparent,
+ Colors.black.withValues(alpha: 0.6),
+ Colors.black.withValues(alpha: 0.72),
+ ],
+ stops: const [0, 0.8, 1],
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+class GalleryVideoProgressRow extends StatelessWidget {
+ final Widget seekBar;
+ final String duration;
+
+ const GalleryVideoProgressRow({
+ required this.seekBar,
+ required this.duration,
+ super.key,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ final safePadding = MediaQuery.paddingOf(context);
+ return Padding(
+ padding: EdgeInsets.only(
+ left: safePadding.left + 16,
+ right: safePadding.right + 16,
+ ),
+ child: SizedBox(
+ height: kGalleryVideoProgressHeight,
+ child: Row(
+ children: [
+ Expanded(child: seekBar),
+ const SizedBox(width: 16),
+ Transform.translate(
+ offset: const Offset(0, -1),
+ child: Text(
+ duration,
+ style: getEnteTextTheme(
+ context,
+ ).mini.copyWith(color: textBaseDark.withValues(alpha: 0.85)),
+ ),
+ ),
+ const SizedBox(width: 8),
+ const VideoMuteButton(),
+ ],
+ ),
+ ),
+ );
+ }
+}
+
+double galleryVideoStreamControlBottom(bool hasCaption) {
+ return kGalleryVideoProgressBottom +
+ kGalleryVideoProgressHeight +
+ (hasCaption
+ ? kGalleryVideoCaptionGap + kGalleryVideoCaptionLineHeight
+ : 0) +
+ 8;
+}
diff --git a/mobile/apps/photos/lib/ui/viewer/file/video_control/mute_button.dart b/mobile/apps/photos/lib/ui/viewer/file/video_control/mute_button.dart
index e5bb5a1eaf..f0ed55ff3b 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/video_control/mute_button.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/video_control/mute_button.dart
@@ -38,28 +38,38 @@ class _VideoMuteButtonState extends State<VideoMuteButton> {
@override
Widget build(BuildContext context) {
- return IconButton(
- icon: AnimatedSwitcher(
- duration: const Duration(milliseconds: 250),
- transitionBuilder: (Widget child, Animation<double> animation) {
- return ScaleTransition(scale: animation, child: child);
- },
- switchInCurve: Curves.easeInOutQuart,
- switchOutCurve: Curves.easeInOutQuart,
- child: HugeIcon(
- key: ValueKey(_isMuted),
- icon: _isMuted
- ? HugeIcons.strokeRoundedVolumeOff
- : HugeIcons.strokeRoundedVolumeHigh,
- color: Colors.white,
- size: 20,
+ return SizedBox(
+ width: 32,
+ height: 16,
+ child: IconButton(
+ padding: EdgeInsets.zero,
+ constraints: const BoxConstraints(),
+ style: IconButton.styleFrom(
+ minimumSize: Size.zero,
+ tapTargetSize: MaterialTapTargetSize.shrinkWrap,
+ ),
+ icon: AnimatedSwitcher(
+ duration: const Duration(milliseconds: 250),
+ transitionBuilder: (Widget child, Animation<double> animation) {
+ return ScaleTransition(scale: animation, child: child);
+ },
+ switchInCurve: Curves.easeInOutQuart,
+ switchOutCurve: Curves.easeInOutQuart,
+ child: HugeIcon(
+ key: ValueKey(_isMuted),
+ icon: _isMuted
+ ? HugeIcons.strokeRoundedVolumeOff
+ : HugeIcons.strokeRoundedVolumeHigh,
+ color: Colors.white,
+ size: 20,
+ ),
),
+ onPressed: () async {
+ final newValue = !_isMuted;
+ await localSettings.setIsMuted(newValue);
+ Bus.instance.fire(VideoMuteChangedEvent(newValue));
+ },
),
- onPressed: () async {
- final newValue = !_isMuted;
- await localSettings.setIsMuted(newValue);
- Bus.instance.fire(VideoMuteChangedEvent(newValue));
- },
);
}
}
diff --git a/mobile/apps/photos/lib/ui/viewer/file/video_widget_media_kit.dart b/mobile/apps/photos/lib/ui/viewer/file/video_widget_media_kit.dart
index b6f3ac3030..f5dbcc8d31 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/video_widget_media_kit.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/video_widget_media_kit.dart
@@ -8,7 +8,6 @@ import "package:media_kit/media_kit.dart";
import "package:media_kit_video/media_kit_video.dart";
import "package:photos/core/constants.dart";
import "package:photos/core/event_bus.dart";
-import "package:photos/events/file_caption_updated_event.dart";
import "package:photos/events/guest_view_event.dart";
import "package:photos/events/pause_video_event.dart";
import "package:photos/events/resume_video_event.dart";
@@ -74,8 +73,6 @@ class _VideoWidgetMediaKitState extends State<VideoWidgetMediaKit>
bool _isGuestView = false;
StreamSubscription<StreamSwitchedEvent>? _streamSwitchedSubscription;
StreamSubscription<DownloadTask>? _downloadTaskSubscription;
- late final StreamSubscription<FileCaptionUpdatedEvent>
- _captionUpdatedSubscription;
final _transformationController = TransformationController();
bool _isZooming = false;
@@ -138,15 +135,6 @@ class _VideoWidgetMediaKitState extends State<VideoWidgetMediaKit>
},
);
- _captionUpdatedSubscription = Bus.instance
- .on<FileCaptionUpdatedEvent>()
- .listen((event) {
- if (event.fileGeneratedID == widget.file.generatedID) {
- if (mounted) {
- setState(() {});
- }
- }
- });
wakeLockService.updateWakeLock(
enable: true,
wakeLockFor: WakeLockFor.videoPlayback,
@@ -211,7 +199,6 @@ class _VideoWidgetMediaKitState extends State<VideoWidgetMediaKit>
downloadManager.pause(widget.file.uploadedFileID!).ignore();
}
player.dispose();
- _captionUpdatedSubscription.cancel();
_transformationController.dispose();
if (wakeLockService.shouldKeepAppAwakeAcrossSessions) {
wakeLockService.updateWakeLock(
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 7b7593da97..40a461d01a 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
@@ -6,10 +6,8 @@ import "package:media_kit_video/media_kit_video.dart";
import "package:photos/models/file/file.dart";
import "package:photos/states/detail_page_state.dart";
import "package:photos/theme/colors.dart";
-import "package:photos/theme/ente_theme.dart";
-import "package:photos/ui/actions/file/file_actions.dart";
import "package:photos/ui/common/loading_widget.dart";
-import "package:photos/ui/viewer/file/video_control/mute_button.dart";
+import "package:photos/ui/viewer/file/video_control/gallery_video_controls.dart";
import "package:photos/ui/viewer/file/video_stream_change.dart";
import "package:photos/ui/viewer/file/zoomable_video_viewer.dart";
@@ -42,7 +40,6 @@ class VideoWidget extends StatefulWidget {
class _VideoWidgetState extends State<VideoWidget> {
final showControlsNotifier = ValueNotifier<bool>(true);
- static const double verticalMargin = 64;
final _hideControlsDebouncer = Debouncer(const Duration(milliseconds: 2000));
final _isSeekingNotifier = ValueNotifier<bool>(false);
late final StreamSubscription<bool> _isPlayingStreamSubscription;
@@ -121,6 +118,10 @@ class _VideoWidgetState extends State<VideoWidget> {
child: Stack(
alignment: Alignment.center,
children: [
+ if (!widget.isFromMemories)
+ GalleryVideoControlScrim(
+ hasCaption: widget.file.caption?.isNotEmpty ?? false,
+ ),
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: widget.isFromMemories
@@ -170,7 +171,7 @@ class _VideoWidgetState extends State<VideoWidget> {
widget.isFromMemories
? const SizedBox.shrink()
: Positioned(
- bottom: verticalMargin,
+ bottom: kGalleryVideoProgressBottom,
right: 0,
left: 0,
child: IgnorePointer(
@@ -179,30 +180,33 @@ class _VideoWidgetState extends State<VideoWidget> {
top: false,
left: false,
right: false,
- child: Padding(
- padding: EdgeInsets.only(
- bottom: widget.isFromMemories ? 32 : 0,
- ),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- VideoStreamChangeWidget(
- showControls: value,
- file: widget.file,
- isPreviewPlayer: widget.isPreviewPlayer,
- onStreamChange: widget.onStreamChange,
- ),
- SeekBarAndDuration(
- controller: widget.controller,
- isSeekingNotifier: _isSeekingNotifier,
- file: widget.file,
- ),
- ],
- ),
+ child: SeekBarAndDuration(
+ controller: widget.controller,
+ isSeekingNotifier: _isSeekingNotifier,
),
),
),
),
+ widget.isFromMemories
+ ? const SizedBox.shrink()
+ : Positioned(
+ bottom: galleryVideoStreamControlBottom(
+ widget.file.caption?.isNotEmpty ?? false,
+ ),
+ right: 0,
+ left: 0,
+ child: SafeArea(
+ top: false,
+ left: false,
+ right: false,
+ child: VideoStreamChangeWidget(
+ showControls: value,
+ file: widget.file,
+ isPreviewPlayer: widget.isPreviewPlayer,
+ onStreamChange: widget.onStreamChange,
+ ),
+ ),
+ ),
],
),
);
@@ -297,83 +301,20 @@ class _PlayPauseButtonState extends State<PlayPauseButtonMediaKit> {
}
class SeekBarAndDuration extends StatelessWidget {
- final VideoController? controller;
+ final VideoController controller;
final ValueNotifier<bool> isSeekingNotifier;
- final EnteFile file;
const SeekBarAndDuration({
super.key,
required this.controller,
required this.isSeekingNotifier,
- required this.file,
});
@override
Widget build(BuildContext context) {
- final caption = file.caption;
- final textStyle = getEnteTextTheme(
- context,
- ).mini.copyWith(color: textBaseDark);
- return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8),
- child: Container(
- decoration: BoxDecoration(
- color: Colors.black.withValues(alpha: 0.3),
- borderRadius: const BorderRadius.all(Radius.circular(8)),
- border: Border.all(color: strokeFaintDark, width: 1),
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- if (caption != null && caption.isNotEmpty)
- Padding(
- padding: const EdgeInsets.fromLTRB(8, 4, 8, 4),
- child: GestureDetector(
- onTap: () => showDetailsSheet(context, file),
- child: Row(
- children: [
- Text('"', style: textStyle),
- Flexible(
- child: Text(
- caption,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: textStyle,
- ),
- ),
- Text('"', style: textStyle),
- ],
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Row(
- children: [
- StreamBuilder(
- stream: controller?.player.stream.position,
- builder: (context, snapshot) => Text(
- snapshot.data == null
- ? "0:00"
- : secondsToDuration(snapshot.data!.inSeconds),
- style: textStyle,
- ),
- ),
- Expanded(child: SeekBar(controller!, isSeekingNotifier)),
- Text(
- _secondsToDuration(
- controller!.player.state.duration.inSeconds,
- ),
- style: textStyle,
- ),
- const SizedBox(width: 8),
- const VideoMuteButton(),
- ],
- ),
- ),
- ],
- ),
- ),
+ return GalleryVideoProgressRow(
+ seekBar: SeekBar(controller, isSeekingNotifier),
+ duration: _secondsToDuration(controller.player.state.duration.inSeconds),
);
}
@@ -443,11 +384,14 @@ class _SeekBarState extends State<SeekBar> {
Widget build(BuildContext context) {
return SliderTheme(
data: SliderTheme.of(context).copyWith(
- trackHeight: 1.0,
+ trackHeight: 3.0,
+ trackShape: const GalleryVideoSliderTrackShape(),
+ tickMarkShape: SliderTickMarkShape.noTickMark,
thumbShape: const RoundSliderThumbShape(enabledThumbRadius: 6.0),
overlayShape: const RoundSliderOverlayShape(overlayRadius: 12.0),
+ padding: EdgeInsets.zero,
activeTrackColor: backgroundElevatedLight,
- inactiveTrackColor: fillMutedDark,
+ inactiveTrackColor: textBaseDark.withValues(alpha: 0.3),
thumbColor: backgroundElevatedLight,
overlayColor: fillMutedDark,
),
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 3d1f0004f9..a0cfd51a35 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
@@ -8,7 +8,6 @@ import "package:logging/logging.dart";
import "package:native_video_player/native_video_player.dart";
import "package:photos/core/constants.dart";
import "package:photos/core/event_bus.dart";
-import "package:photos/events/file_caption_updated_event.dart";
import "package:photos/events/guest_view_event.dart";
import "package:photos/events/pause_video_event.dart";
import "package:photos/events/resume_video_event.dart";
@@ -34,7 +33,7 @@ import "package:photos/ui/notification/toast.dart";
import "package:photos/ui/viewer/file/native_video_player_controls/play_pause_button.dart";
import "package:photos/ui/viewer/file/native_video_player_controls/seek_bar.dart";
import "package:photos/ui/viewer/file/thumbnail_widget.dart";
-import "package:photos/ui/viewer/file/video_control/mute_button.dart";
+import "package:photos/ui/viewer/file/video_control/gallery_video_controls.dart";
import "package:photos/ui/viewer/file/video_stream_change.dart";
import "package:photos/ui/viewer/file/zoomable_video_viewer.dart";
import "package:photos/utils/dialog_util.dart";
@@ -72,7 +71,6 @@ class VideoWidgetNative extends StatefulWidget {
class _VideoWidgetNativeState extends State<VideoWidgetNative>
with WidgetsBindingObserver {
final Logger _logger = Logger("VideoWidgetNative");
- static const verticalMargin = 64.0;
final _progressNotifier = ValueNotifier<double?>(null);
late StreamSubscription<PauseVideoEvent> pauseVideoSubscription;
late StreamSubscription<ResumeVideoEvent> resumeVideoSubscription;
@@ -92,9 +90,6 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
StreamSubscription<PlaybackEvent>? _subscription;
StreamSubscription<StreamSwitchedEvent>? _streamSwitchedSubscription;
StreamSubscription<DownloadTask>? downloadTaskSubscription;
- late final StreamSubscription<FileCaptionUpdatedEvent>
- _captionUpdatedSubscription;
- int position = 0;
final _transformationController = TransformationController();
bool _isZooming = false;
@@ -149,15 +144,6 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
},
);
- _captionUpdatedSubscription = Bus.instance
- .on<FileCaptionUpdatedEvent>()
- .listen((event) {
- if (event.fileGeneratedID == widget.file.generatedID) {
- if (mounted) {
- setState(() {});
- }
- }
- });
if (widget.file.isUploaded) {
downloadTaskSubscription = downloadManager
.watchDownload(widget.file.uploadedFileID!)
@@ -284,7 +270,6 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
_isSeeking.removeListener(_seekListener);
_isSeeking.dispose();
_debouncer.cancelDebounceTimer();
- _captionUpdatedSubscription.cancel();
_transformationController.dispose();
wakeLockService.updateWakeLock(
enable: false,
@@ -355,6 +340,22 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
),
),
),
+ if (!widget.isFromMemories)
+ ValueListenableBuilder(
+ valueListenable: _showControls,
+ builder: (context, showControls, child) {
+ return AnimatedOpacity(
+ duration: const Duration(milliseconds: 200),
+ opacity: showControls ? 1 : 0,
+ curve: Curves.easeInOutQuad,
+ child: child,
+ );
+ },
+ child: GalleryVideoControlScrim(
+ hasCaption:
+ widget.file.caption?.isNotEmpty ?? false,
+ ),
+ ),
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: widget.isFromMemories
@@ -416,45 +417,46 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
widget.isFromMemories
? const SizedBox.shrink()
: Positioned(
- bottom: verticalMargin,
+ bottom: kGalleryVideoProgressBottom,
right: 0,
left: 0,
child: SafeArea(
top: false,
left: false,
right: false,
- child: Padding(
- padding: EdgeInsets.only(
- bottom: widget.isFromMemories ? 32 : 0,
- ),
- child: Column(
- crossAxisAlignment:
- CrossAxisAlignment.center,
- children: [
- ValueListenableBuilder(
- valueListenable: _showControls,
- builder: (context, value, _) {
- return VideoStreamChangeWidget(
- showControls: value,
- file: widget.file,
- isPreviewPlayer:
- widget.selectedPreview,
- onStreamChange:
- widget.onStreamChange,
- );
- },
- ),
- if (isPlaybackReady)
- _SeekBarAndDuration(
- controller: _controller,
- duration: duration,
- showControls: _showControls,
- isSeeking: _isSeeking,
- position: position,
- file: widget.file,
- ),
- ],
- ),
+ child: isPlaybackReady
+ ? _SeekBarAndDuration(
+ controller: _controller!,
+ duration: duration,
+ showControls: _showControls,
+ isSeeking: _isSeeking,
+ )
+ : const SizedBox.shrink(),
+ ),
+ ),
+ widget.isFromMemories
+ ? const SizedBox.shrink()
+ : Positioned(
+ bottom: galleryVideoStreamControlBottom(
+ widget.file.caption?.isNotEmpty ?? false,
+ ),
+ right: 0,
+ left: 0,
+ child: SafeArea(
+ top: false,
+ left: false,
+ right: false,
+ child: ValueListenableBuilder(
+ valueListenable: _showControls,
+ builder: (context, value, _) {
+ return VideoStreamChangeWidget(
+ showControls: value,
+ file: widget.file,
+ isPreviewPlayer:
+ widget.selectedPreview,
+ onStreamChange: widget.onStreamChange,
+ );
+ },
),
),
),
@@ -506,12 +508,6 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
case PlaybackReadyEvent():
_onPlaybackReady();
break;
- case PlaybackPositionChangedEvent():
- position = event.positionInMilliseconds;
- if (mounted) {
- setState(() {});
- }
- break;
case PlaybackEndedEvent():
_onPlaybackEnded();
break;
@@ -855,28 +851,20 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
}
class _SeekBarAndDuration extends StatelessWidget {
- final NativeVideoPlayerController? controller;
+ final NativeVideoPlayerController controller;
final String? duration;
final ValueNotifier<bool> showControls;
final ValueNotifier<bool> isSeeking;
- final int position;
- final EnteFile file;
const _SeekBarAndDuration({
required this.controller,
required this.duration,
required this.showControls,
required this.isSeeking,
- required this.position,
- required this.file,
});
@override
Widget build(BuildContext context) {
- final caption = file.caption;
- final textStyle = getEnteTextTheme(
- context,
- ).mini.copyWith(color: textBaseDark);
return ValueListenableBuilder(
valueListenable: showControls,
builder: (BuildContext context, bool value, _) {
@@ -886,66 +874,13 @@ class _SeekBarAndDuration extends StatelessWidget {
opacity: value ? 1 : 0,
child: IgnorePointer(
ignoring: !value,
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 8),
- child: Container(
- decoration: BoxDecoration(
- color: Colors.black.withValues(alpha: 0.3),
- borderRadius: const BorderRadius.all(Radius.circular(8)),
- border: Border.all(color: strokeFaintDark, width: 1),
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- if (caption != null && caption.isNotEmpty)
- Padding(
- padding: const EdgeInsets.fromLTRB(8, 4, 8, 4),
- child: GestureDetector(
- onTap: () => showDetailsSheet(context, file),
- child: Row(
- children: [
- Text('"', style: textStyle),
- Flexible(
- child: Text(
- caption,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: textStyle,
- ),
- ),
- Text('"', style: textStyle),
- ],
- ),
- ),
- ),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Row(
- children: [
- AnimatedSize(
- duration: const Duration(seconds: 5),
- curve: Curves.easeInOut,
- child: Text(
- secondsToDuration(position ~/ 1000),
- style: textStyle,
- ),
- ),
- Expanded(
- child: SeekBar(
- controller!,
- durationToSeconds(duration),
- isSeeking,
- ),
- ),
- Text(duration ?? "0:00", style: textStyle),
- const SizedBox(width: 8),
- const VideoMuteButton(),
- ],
- ),
- ),
- ],
- ),
+ child: GalleryVideoProgressRow(
+ seekBar: SeekBar(
+ controller,
+ durationToSeconds(duration),
+ isSeeking,
),
+ duration: duration ?? "0:00",
),
),
);