Skip to content

Commit

Permalink
viewer: fixed video progress bar layout
Browse files Browse the repository at this point in the history
  • Loading branch information
deckerst committed Oct 7, 2024
1 parent eb68b8e commit 763eeba
Showing 1 changed file with 21 additions and 25 deletions.
46 changes: 21 additions & 25 deletions lib/widgets/viewer/overlay/video/progress_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -44,12 +45,6 @@ class _VideoProgressBarState extends State<VideoProgressBar> {
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(
Expand Down Expand Up @@ -106,18 +101,10 @@ class _VideoProgressBarState extends State<VideoProgressBar> {
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(
Expand All @@ -132,7 +119,7 @@ class _VideoProgressBarState extends State<VideoProgressBar> {
if (!progress.isFinite) progress = 0.0;
return LinearProgressIndicator(
value: progress,
backgroundColor: Theme.of(context).colorScheme.onSurface.withOpacity(.2),
backgroundColor: theme.colorScheme.onSurface.withOpacity(.2),
);
}),
),
Expand All @@ -141,12 +128,8 @@ class _VideoProgressBarState extends State<VideoProgressBar> {
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(''),
],
),
],
Expand All @@ -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) {
if (controller == null || position == null) return const SizedBox();
return Positioned(
Expand All @@ -185,7 +180,7 @@ class _VideoProgressBarState extends State<VideoProgressBar> {
return speed != 1
? Padding(
padding: const EdgeInsetsDirectional.only(end: 8),
child: Text('x$speed'),
child: _buildText('x$speed'),
)
: const SizedBox();
},
Expand All @@ -199,9 +194,10 @@ class _VideoProgressBarState extends State<VideoProgressBar> {
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();
Expand Down

0 comments on commit 763eeba

Please sign in to comment.