viewer: fixed video progress bar layout

This commit is contained in:
Thibault Deckers 2024-10-07 23:56:48 +02:00
parent eb68b8eba6
commit 763eebac7d

View file

@ -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/blurred.dart';
import 'package:aves/widgets/common/fx/borders.dart'; import 'package:aves/widgets/common/fx/borders.dart';
import 'package:aves_video/aves_video.dart'; import 'package:aves_video/aves_video.dart';
import 'package:decorated_icon/decorated_icon.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class VideoProgressBar extends StatefulWidget { class VideoProgressBar extends StatefulWidget {
@ -44,12 +45,6 @@ class _VideoProgressBarState extends State<VideoProgressBar> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final blurred = settings.enableBlurEffect; final blurred = settings.enableBlurEffect;
final theme = Theme.of(context); final theme = Theme.of(context);
final textStyle = TextStyle(
shadows: theme.isDark ? AStyles.embossShadows : null,
);
const strutStyle = StrutStyle(
forceStrutHeight: true,
);
return SizeTransition( return SizeTransition(
sizeFactor: widget.scale, sizeFactor: widget.scale,
child: BlurredRRect.all( child: BlurredRRect.all(
@ -106,18 +101,10 @@ class _VideoProgressBarState extends State<VideoProgressBar> {
builder: (context, snapshot) { builder: (context, snapshot) {
// do not use stream snapshot because it is obsolete when switching between videos // do not use stream snapshot because it is obsolete when switching between videos
final position = controller?.currentPosition.floor() ?? 0; final position = controller?.currentPosition.floor() ?? 0;
return Text( return _buildText(formatFriendlyDuration(Duration(milliseconds: position)));
formatFriendlyDuration(Duration(milliseconds: position)),
style: textStyle,
strutStyle: strutStyle,
);
}), }),
const Spacer(), const Spacer(),
Text( _buildText(formatFriendlyDuration(Duration(milliseconds: controller?.duration ?? 0))),
formatFriendlyDuration(Duration(milliseconds: controller?.duration ?? 0)),
style: textStyle,
strutStyle: strutStyle,
),
], ],
), ),
ClipRRect( ClipRRect(
@ -132,7 +119,7 @@ class _VideoProgressBarState extends State<VideoProgressBar> {
if (!progress.isFinite) progress = 0.0; if (!progress.isFinite) progress = 0.0;
return LinearProgressIndicator( return LinearProgressIndicator(
value: progress, value: progress,
backgroundColor: Theme.of(context).colorScheme.onSurface.withOpacity(.2), backgroundColor: theme.colorScheme.onSurface.withOpacity(.2),
); );
}), }),
), ),
@ -141,12 +128,8 @@ class _VideoProgressBarState extends State<VideoProgressBar> {
children: [ children: [
_buildSpeedIndicator(), _buildSpeedIndicator(),
_buildMuteIndicator(), _buildMuteIndicator(),
Text(
// fake text below to match the height of the text above and center the whole thing // fake text below to match the height of the text above and center the whole thing
'', _buildText(''),
style: textStyle,
strutStyle: strutStyle,
),
], ],
), ),
], ],
@ -164,6 +147,18 @@ class _VideoProgressBarState extends State<VideoProgressBar> {
); );
} }
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) { Widget _buildABRepeatMark(BuildContext context, int? position) {
if (controller == null || position == null) return const SizedBox(); if (controller == null || position == null) return const SizedBox();
return Positioned( return Positioned(
@ -185,7 +180,7 @@ class _VideoProgressBarState extends State<VideoProgressBar> {
return speed != 1 return speed != 1
? Padding( ? Padding(
padding: const EdgeInsetsDirectional.only(end: 8), padding: const EdgeInsetsDirectional.only(end: 8),
child: Text('x$speed'), child: _buildText('x$speed'),
) )
: const SizedBox(); : const SizedBox();
}, },
@ -199,9 +194,10 @@ class _VideoProgressBarState extends State<VideoProgressBar> {
return isMuted return isMuted
? Padding( ? Padding(
padding: const EdgeInsetsDirectional.only(end: 8), padding: const EdgeInsetsDirectional.only(end: 8),
child: Icon( child: DecoratedIcon(
AIcons.mute, AIcons.mute,
size: textScaler.scale(16), size: textScaler.scale(16),
shadows: Theme.of(context).isDark ? AStyles.embossShadows : null,
), ),
) )
: const SizedBox(); : const SizedBox();