Fixes time display of current/next song UI. Adds localized formatting code for start times of shows current and next.

This commit is contained in:
2026-05-10 00:45:31 +00:00
parent de0a243388
commit a5e1e36ebf
4 changed files with 36 additions and 11 deletions
+1 -1
View File
@@ -40,7 +40,7 @@ class ShowCard extends StatelessWidget {
),
const SizedBox(width: 8),
Text(
formatTimeWindow(show?.starts, show?.ends),
formatStartingTime(show?.starts),
style: Theme.of(context).textTheme.labelSmall,
),
],
+31 -7
View File
@@ -1,11 +1,35 @@
String formatTimeWindow(String? starts, String? ends) {
String formatOne(String? value) {
if (value == null || value.length < 16) {
return '--:--';
}
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
return value.substring(11, 16);
// Source - https://stackoverflow.com/a/54775297
// Posted by diegoveloper, modified by community. See post 'Timeline' for change history
// Retrieved 2026-05-09, License - CC BY-SA 4.0
String _printDuration(Duration duration) {
String negativeSign = duration.isNegative ? '-' : '';
String twoDigits(int n) => n.toString().padLeft(2, "0");
String twoDigitMinutes = twoDigits(duration.inMinutes.remainder(60).abs());
String twoDigitSeconds = twoDigits(duration.inSeconds.remainder(60).abs());
return "$negativeSign$twoDigitMinutes:$twoDigitSeconds";
}
String formatTimeWindow(String? starts, String? ends) {
if (starts != null && ends != null) {
DateTime startDt = DateTime.parse(starts);
DateTime endDt = DateTime.parse(ends);
Duration songLength = endDt.difference(startDt);
return _printDuration(songLength);
}
return '${formatOne(starts)} - ${formatOne(ends)}';
return "--:--";
}
String formatStartingTime(String? startingTime) {
if (startingTime != null) {
DateTime dtStartTime = DateTime.parse(startingTime);
return DateFormat('jm').format(dtStartTime);
}
return "--:--";
}
+3 -3
View File
@@ -29,7 +29,7 @@ class TrackCard extends StatelessWidget {
border: Border.all(color: Colors.black.withValues(alpha: 0.12)),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
label,
@@ -47,10 +47,10 @@ class TrackCard extends StatelessWidget {
context,
).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.w700),
),
const SizedBox(height: 3),
const SizedBox(height: 6),
Text(
subtitle.isEmpty ? 'No metadata provided' : subtitle,
maxLines: 2,
maxLines: 6,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodySmall,
),
+1
View File
@@ -39,6 +39,7 @@ dependencies:
audio_session: ^0.2.2
webview_flutter: ^4.13.0
http: ^1.5.0
intl: ^0.20.2
dev_dependencies:
flutter_name_manager: ^1.0.0