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:
+1
-1
@@ -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,
|
||||
),
|
||||
],
|
||||
|
||||
+29
-5
@@ -1,11 +1,35 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
// 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) {
|
||||
String formatOne(String? value) {
|
||||
if (value == null || value.length < 16) {
|
||||
return '--:--';
|
||||
if (starts != null && ends != null) {
|
||||
DateTime startDt = DateTime.parse(starts);
|
||||
DateTime endDt = DateTime.parse(ends);
|
||||
|
||||
Duration songLength = endDt.difference(startDt);
|
||||
|
||||
return _printDuration(songLength);
|
||||
}
|
||||
|
||||
return value.substring(11, 16);
|
||||
return "--:--";
|
||||
}
|
||||
|
||||
return '${formatOne(starts)} - ${formatOne(ends)}';
|
||||
String formatStartingTime(String? startingTime) {
|
||||
if (startingTime != null) {
|
||||
DateTime dtStartTime = DateTime.parse(startingTime);
|
||||
return DateFormat('jm').format(dtStartTime);
|
||||
}
|
||||
return "--:--";
|
||||
}
|
||||
|
||||
+3
-3
@@ -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,
|
||||
),
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user