38 lines
1.0 KiB
Dart
38 lines
1.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../core/contracts/library.dart';
|
|
|
|
class QualityBadge extends StatelessWidget {
|
|
const QualityBadge({super.key, required this.quality});
|
|
|
|
final MediaQualityInfo? quality;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final label = _buildLabel();
|
|
if (label == null) return const SizedBox.shrink();
|
|
return Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
|
decoration: BoxDecoration(
|
|
color: Colors.black54,
|
|
borderRadius: BorderRadius.circular(4),
|
|
),
|
|
child: Text(
|
|
label,
|
|
style: const TextStyle(color: Colors.white70, fontSize: 12),
|
|
),
|
|
);
|
|
}
|
|
|
|
String? _buildLabel() {
|
|
final q = quality;
|
|
if (q == null) return null;
|
|
final res = q.resolutionLabel;
|
|
if (res.isEmpty) return null;
|
|
final range = q.dynamicRangeLabel;
|
|
if (range == 'SDR' || range.isEmpty) return res;
|
|
final shortRange = range == 'Dolby Vision' ? 'DV' : range;
|
|
return '$res $shortRange';
|
|
}
|
|
}
|