1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-07 20:36:48 +01:00
immich/mobile/lib/widgets/asset_viewer/formatted_duration.dart
Mert e1feba2198
refactor(mobile): video controls (#14086)
* refactor video controls

* inline

* make mute icon const

* move placeholder to private widget

* adjust text width, move volume button slightly right
2024-11-13 01:13:21 -05:00

34 lines
1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:immich_mobile/constants/immich_colors.dart';
@pragma('vm:prefer-inline')
String _formatDuration(Duration position) {
final seconds = position.inSeconds.remainder(60).toString().padLeft(2, "0");
final minutes = position.inMinutes.remainder(60).toString().padLeft(2, "0");
if (position.inHours == 0) {
return "$minutes:$seconds";
}
final hours = position.inHours.toString().padLeft(2, '0');
return "$hours:$minutes:$seconds";
}
class FormattedDuration extends StatelessWidget {
final Duration data;
const FormattedDuration(this.data, {super.key});
@override
Widget build(BuildContext context) {
return SizedBox(
width: data.inHours > 0 ? 64 : 43, // use a fixed width to prevent jitter
child: Text(
_formatDuration(data),
style: const TextStyle(
fontSize: 14.0,
color: whiteOpacity75,
fontWeight: FontWeight.normal,
),
textAlign: TextAlign.center,
),
);
}
}