Skip to content

Commit 349b2be

Browse files
lightbox [nfc]: Factor out VideoDurationLabel for testing visibility
1 parent e85d6c5 commit 349b2be

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

lib/widgets/lightbox.dart

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,25 @@ class _ImageLightboxPageState extends State<_ImageLightboxPage> {
248248
}
249249
}
250250

251+
class VideoDurationLabel extends StatelessWidget {
252+
const VideoDurationLabel(this.duration, {super.key});
253+
254+
final Duration duration;
255+
256+
static String _formatDuration(Duration value) {
257+
final hours = value.inHours.toString().padLeft(2, '0');
258+
final minutes = value.inMinutes.remainder(60).toString().padLeft(2, '0');
259+
final seconds = value.inSeconds.remainder(60).toString().padLeft(2, '0');
260+
return '${hours == '00' ? '' : '$hours:'}$minutes:$seconds';
261+
}
262+
263+
@override
264+
Widget build(BuildContext context) {
265+
return Text(_formatDuration(duration),
266+
style: const TextStyle(color: Colors.white));
267+
}
268+
}
269+
251270
class _VideoPositionSliderControl extends StatefulWidget {
252271
final VideoPlayerController controller;
253272

@@ -293,22 +312,14 @@ class _VideoPositionSliderControlState extends State<_VideoPositionSliderControl
293312
});
294313
}
295314

296-
static String _formatDuration(Duration value) {
297-
final hours = value.inHours.toString().padLeft(2, '0');
298-
final minutes = value.inMinutes.remainder(60).toString().padLeft(2, '0');
299-
final seconds = value.inSeconds.remainder(60).toString().padLeft(2, '0');
300-
return '${hours == '00' ? '' : '$hours:'}$minutes:$seconds';
301-
}
302-
303315
@override
304316
Widget build(BuildContext context) {
305317
final currentPosition = _isSliderDragging
306318
? _sliderValue
307319
: widget.controller.value.position;
308320

309321
return Row(children: [
310-
Text(_formatDuration(currentPosition),
311-
style: const TextStyle(color: Colors.white)),
322+
VideoDurationLabel(currentPosition),
312323
Expanded(
313324
child: Slider(
314325
value: currentPosition.inMilliseconds.toDouble(),
@@ -337,8 +348,7 @@ class _VideoPositionSliderControlState extends State<_VideoPositionSliderControl
337348
},
338349
),
339350
),
340-
Text(_formatDuration(widget.controller.value.duration),
341-
style: const TextStyle(color: Colors.white)),
351+
VideoDurationLabel(widget.controller.value.duration),
342352
]);
343353
}
344354
}

0 commit comments

Comments
 (0)