feat(ui): add shared widgets, utils, and models for deduplicated screens

Single homes for logic that was copy-pasted across screens: the settings
collapsing header, album detail header (online screen's design as the
reference), selection pill button + bottom-bar chrome, disc separator
chip, error card, cover URL upgrade, byte/clock formatting, duration
extraction, UnifiedLibraryItem (moved out of the queue_tab library so
other screens can import it), and the batch convert/ReplayGain engine
keyed on it.
This commit is contained in:
zarzet
2026-07-11 16:34:16 +07:00
parent 49ecfe261a
commit 9580fafe4f
11 changed files with 1508 additions and 0 deletions
+18
View File
@@ -55,6 +55,24 @@ String? normalizeRemoteHttpUrl(String? value) {
return null;
}
/// Human-readable byte size: "512 B", "3.4 KB", "12.0 MB", "1.25 GB".
String formatBytes(int bytes) {
if (bytes < 1024) return '$bytes B';
if (bytes < 1024 * 1024) return '${(bytes / 1024).toStringAsFixed(1)} KB';
if (bytes < 1024 * 1024 * 1024) {
return '${(bytes / (1024 * 1024)).toStringAsFixed(1)} MB';
}
return '${(bytes / (1024 * 1024 * 1024)).toStringAsFixed(2)} GB';
}
/// "m:ss" clock formatting for track durations.
String formatClock(num seconds) {
final total = seconds.round();
final minutes = total ~/ 60;
final secs = total % 60;
return '$minutes:${secs.toString().padLeft(2, '0')}';
}
String formatSampleRateKHz(int sampleRate) {
final khz = sampleRate / 1000;
final precision = sampleRate % 1000 == 0 ? 0 : 1;