mirror of
https://github.com/immich-app/immich.git
synced 2025-01-07 20:36:48 +01:00
e1feba2198
* refactor video controls * inline * make mute icon const * move placeholder to private widget * adjust text width, move volume button slightly right
34 lines
1 KiB
Dart
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,
|
|
),
|
|
);
|
|
}
|
|
}
|