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),
|
const SizedBox(width: 8),
|
||||||
Text(
|
Text(
|
||||||
formatTimeWindow(show?.starts, show?.ends),
|
formatStartingTime(show?.starts),
|
||||||
style: Theme.of(context).textTheme.labelSmall,
|
style: Theme.of(context).textTheme.labelSmall,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
+32
-8
@@ -1,11 +1,35 @@
|
|||||||
String formatTimeWindow(String? starts, String? ends) {
|
import 'package:flutter/material.dart';
|
||||||
String formatOne(String? value) {
|
import 'package:intl/intl.dart';
|
||||||
if (value == null || value.length < 16) {
|
|
||||||
return '--:--';
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
return '${formatOne(starts)} - ${formatOne(ends)}';
|
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 "--:--";
|
||||||
|
}
|
||||||
|
|
||||||
|
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)),
|
border: Border.all(color: Colors.black.withValues(alpha: 0.12)),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
label,
|
label,
|
||||||
@@ -47,10 +47,10 @@ class TrackCard extends StatelessWidget {
|
|||||||
context,
|
context,
|
||||||
).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.w700),
|
).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.w700),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 3),
|
const SizedBox(height: 6),
|
||||||
Text(
|
Text(
|
||||||
subtitle.isEmpty ? 'No metadata provided' : subtitle,
|
subtitle.isEmpty ? 'No metadata provided' : subtitle,
|
||||||
maxLines: 2,
|
maxLines: 6,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ dependencies:
|
|||||||
audio_session: ^0.2.2
|
audio_session: ^0.2.2
|
||||||
webview_flutter: ^4.13.0
|
webview_flutter: ^4.13.0
|
||||||
http: ^1.5.0
|
http: ^1.5.0
|
||||||
|
intl: ^0.20.2
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_name_manager: ^1.0.0
|
flutter_name_manager: ^1.0.0
|
||||||
|
|||||||
Reference in New Issue
Block a user