From 763eebac7d23946d78aaefcd3c7c91ab82dc36e4 Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Mon, 7 Oct 2024 23:56:48 +0200 Subject: [PATCH] viewer: fixed video progress bar layout --- .../viewer/overlay/video/progress_bar.dart | 46 +++++++++---------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/lib/widgets/viewer/overlay/video/progress_bar.dart b/lib/widgets/viewer/overlay/video/progress_bar.dart index 1c71ad503..3d746c3e0 100644 --- a/lib/widgets/viewer/overlay/video/progress_bar.dart +++ b/lib/widgets/viewer/overlay/video/progress_bar.dart @@ -10,6 +10,7 @@ import 'package:aves/widgets/common/extensions/theme.dart'; import 'package:aves/widgets/common/fx/blurred.dart'; import 'package:aves/widgets/common/fx/borders.dart'; import 'package:aves_video/aves_video.dart'; +import 'package:decorated_icon/decorated_icon.dart'; import 'package:flutter/material.dart'; class VideoProgressBar extends StatefulWidget { @@ -44,12 +45,6 @@ class _VideoProgressBarState extends State { Widget build(BuildContext context) { final blurred = settings.enableBlurEffect; final theme = Theme.of(context); - final textStyle = TextStyle( - shadows: theme.isDark ? AStyles.embossShadows : null, - ); - const strutStyle = StrutStyle( - forceStrutHeight: true, - ); return SizeTransition( sizeFactor: widget.scale, child: BlurredRRect.all( @@ -106,18 +101,10 @@ class _VideoProgressBarState extends State { builder: (context, snapshot) { // do not use stream snapshot because it is obsolete when switching between videos final position = controller?.currentPosition.floor() ?? 0; - return Text( - formatFriendlyDuration(Duration(milliseconds: position)), - style: textStyle, - strutStyle: strutStyle, - ); + return _buildText(formatFriendlyDuration(Duration(milliseconds: position))); }), const Spacer(), - Text( - formatFriendlyDuration(Duration(milliseconds: controller?.duration ?? 0)), - style: textStyle, - strutStyle: strutStyle, - ), + _buildText(formatFriendlyDuration(Duration(milliseconds: controller?.duration ?? 0))), ], ), ClipRRect( @@ -132,7 +119,7 @@ class _VideoProgressBarState extends State { if (!progress.isFinite) progress = 0.0; return LinearProgressIndicator( value: progress, - backgroundColor: Theme.of(context).colorScheme.onSurface.withOpacity(.2), + backgroundColor: theme.colorScheme.onSurface.withOpacity(.2), ); }), ), @@ -141,12 +128,8 @@ class _VideoProgressBarState extends State { children: [ _buildSpeedIndicator(), _buildMuteIndicator(), - Text( - // fake text below to match the height of the text above and center the whole thing - '', - style: textStyle, - strutStyle: strutStyle, - ), + // fake text below to match the height of the text above and center the whole thing + _buildText(''), ], ), ], @@ -164,6 +147,18 @@ class _VideoProgressBarState extends State { ); } + Widget _buildText(String text) { + return Text( + text, + style: TextStyle( + shadows: Theme.of(context).isDark ? AStyles.embossShadows : null, + ), + strutStyle: const StrutStyle( + forceStrutHeight: true, + ), + ); + } + Widget _buildABRepeatMark(BuildContext context, int? position) { if (controller == null || position == null) return const SizedBox(); return Positioned( @@ -185,7 +180,7 @@ class _VideoProgressBarState extends State { return speed != 1 ? Padding( padding: const EdgeInsetsDirectional.only(end: 8), - child: Text('x$speed'), + child: _buildText('x$speed'), ) : const SizedBox(); }, @@ -199,9 +194,10 @@ class _VideoProgressBarState extends State { return isMuted ? Padding( padding: const EdgeInsetsDirectional.only(end: 8), - child: Icon( + child: DecoratedIcon( AIcons.mute, size: textScaler.scale(16), + shadows: Theme.of(context).isDark ? AStyles.embossShadows : null, ), ) : const SizedBox();