Files
kryz-go-flutter/lib/live_info_panel.dart
T

146 lines
4.9 KiB
Dart

import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'app_theme_business_object.dart';
import 'live_info_business_object.dart';
import 'show_card.dart';
import 'track_card.dart';
class LiveInfoPanel extends StatelessWidget {
const LiveInfoPanel({
super.key,
required this.liveInfo,
required this.themeColors,
required this.intervalOptions,
});
final LiveInfoBusinessObject liveInfo;
final AppThemeColors themeColors;
final List<int> intervalOptions;
@override
Widget build(BuildContext context) {
final LiveInfoSnapshot? snapshot = liveInfo.snapshot;
final LiveInfoTrackInfo? current = snapshot?.current;
final LiveInfoTrackInfo? next = snapshot?.next;
final LiveInfoShowInfo? currentShow = snapshot?.currentShow.isEmpty ?? true
? null
: snapshot!.currentShow.first;
final LiveInfoShowInfo? nextShow = snapshot?.nextShow.isEmpty ?? true
? null
: snapshot!.nextShow.first;
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
themeColors.controlsGradientStart.withValues(alpha: 0.9),
themeColors.controlsGradientEnd.withValues(alpha: 0.95),
],
),
boxShadow: [
BoxShadow(
color: themeColors.controlsShadow,
blurRadius: 20,
offset: const Offset(0, 8),
),
],
),
child: Padding(
padding: const EdgeInsets.all(14),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Icon(
Icons.graphic_eq_rounded,
color: themeColors.textOnDarkSecondary,
size: 20,
),
const SizedBox(width: 8),
Expanded(
child: Text(
'Live Studio Feed',
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w800,
color: themeColors.textOnDark,
),
),
),
],
),
const SizedBox(height: 8),
if (liveInfo.errorMessage != null)
Padding(
padding: const EdgeInsets.only(bottom: 8),
child: Text(
'Live info warning: ${liveInfo.errorMessage}',
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Theme.of(context).colorScheme.error,
fontWeight: FontWeight.w600,
),
),
),
Expanded(
child: Row(
children: [
Expanded(
child: TrackCard(
label: 'Now Playing',
track: current,
titleColor: themeColors.textOnDark,
cardSurface: themeColors.cardSurface,
cardBorder: themeColors.cardBorder,
),
),
const SizedBox(width: 8),
Expanded(
child: TrackCard(
label: 'Coming Next',
track: next,
titleColor: themeColors.textOnDark,
cardSurface: themeColors.cardSurface,
cardBorder: themeColors.cardBorder,
),
),
],
),
),
const SizedBox(height: 8),
ShowCard(
label: 'On Air Show',
show: currentShow,
sourceTimezone: snapshot?.timezone,
titleColor: themeColors.textOnDarkSecondary,
cardSurface: themeColors.cardSurface,
cardBorder: themeColors.cardBorder,
),
const SizedBox(height: 6),
ShowCard(
label: 'Up Next Show',
show: nextShow,
sourceTimezone: snapshot?.timezone,
titleColor: themeColors.textOnDarkSecondary,
cardSurface: themeColors.cardSurface,
cardBorder: themeColors.cardBorder,
),
const SizedBox(height: 6),
Text(
liveInfo.lastUpdatedAt == null
? 'Waiting for API response...'
: 'Last update (Local): ${DateFormat.yMd().format(liveInfo.lastUpdatedAt!.toLocal())} ${DateFormat.jm().format(liveInfo.lastUpdatedAt!.toLocal())}',
style: Theme.of(context).textTheme.labelSmall,
),
],
),
),
);
}
}