style: apply dart formatting fixes across lib/ and test/
11 files had formatting inconsistencies that caused the --set-exit-if-changed gate to fail. Automated formatting via dart format now passes cleanly.
This commit is contained in:
@@ -25,36 +25,52 @@ class AppThemeColors {
|
||||
|
||||
/// Website: `primary` → headings (h1–h6)
|
||||
final Color headingColor;
|
||||
|
||||
/// Website: `accent` → links & accent highlights
|
||||
final Color accentColor;
|
||||
|
||||
/// Page background gradient start — website: `background` (cream)
|
||||
final Color scaffoldGradientStart;
|
||||
|
||||
/// Page background gradient end — website: `light`
|
||||
final Color scaffoldGradientEnd;
|
||||
|
||||
/// Top header card surface
|
||||
final Color shellSurface;
|
||||
|
||||
/// Top header card border
|
||||
final Color shellBorder;
|
||||
|
||||
/// Website: `medium` → muted / secondary text
|
||||
final Color mutedText;
|
||||
|
||||
/// Website: `white` → text on dark surfaces
|
||||
final Color textOnDark;
|
||||
|
||||
/// Website: `light` → secondary text on dark surfaces
|
||||
final Color textOnDarkSecondary;
|
||||
|
||||
/// Controls bar / card surface gradient start — website: `primary_dark`
|
||||
final Color controlsGradientStart;
|
||||
|
||||
/// Controls bar / card surface gradient end — website: `primary_dark`
|
||||
final Color controlsGradientEnd;
|
||||
|
||||
/// Shadow color for elevated surfaces
|
||||
final Color controlsShadow;
|
||||
|
||||
/// Website: `text` → body text
|
||||
final Color bodyText;
|
||||
|
||||
/// Inner card background overlay — derived from `primary_dark` / `primary_light`
|
||||
final Color cardSurface;
|
||||
|
||||
/// Inner card border — derived from `primary_dark` / `primary_light`
|
||||
final Color cardBorder;
|
||||
|
||||
/// Website: `success` → live indicator, success states
|
||||
final Color successColor;
|
||||
|
||||
/// Website: `danger` → error states
|
||||
final Color dangerColor;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class CastingBusinessObject extends ChangeNotifier {
|
||||
CastingPlaybackStatus _playbackStatus = CastingPlaybackStatus.unknown;
|
||||
String? _connectedDeviceName;
|
||||
String? _lastError;
|
||||
|
||||
|
||||
/// Callback for when native side requests local audio to stop
|
||||
VoidCallback? onStopLocalAudioRequested;
|
||||
|
||||
|
||||
+25
-21
@@ -28,10 +28,7 @@ class KryzAudioHandler extends BaseAudioHandler with SeekHandler {
|
||||
title: AppConfig.defaultTitle,
|
||||
artist: AppConfig.defaultArtist,
|
||||
album: 'Live',
|
||||
extras: <String, dynamic>{
|
||||
'isLive': true,
|
||||
'seekable': false,
|
||||
},
|
||||
extras: <String, dynamic>{'isLive': true, 'seekable': false},
|
||||
);
|
||||
|
||||
final AudioPlayer _player = AudioPlayer();
|
||||
@@ -83,10 +80,7 @@ class KryzAudioHandler extends BaseAudioHandler with SeekHandler {
|
||||
try {
|
||||
if (!_isSourceLoaded) {
|
||||
await _player.setAudioSource(
|
||||
AudioSource.uri(
|
||||
Uri.parse(streamUrl),
|
||||
tag: mediaItem.value,
|
||||
),
|
||||
AudioSource.uri(Uri.parse(streamUrl), tag: mediaItem.value),
|
||||
);
|
||||
_isSourceLoaded = true;
|
||||
}
|
||||
@@ -159,25 +153,35 @@ class KryzAudioHandler extends BaseAudioHandler with SeekHandler {
|
||||
}
|
||||
|
||||
void _onPlayerStateChanged(PlayerState state) {
|
||||
final AudioProcessingState processingState = switch (state.processingState) {
|
||||
ProcessingState.idle => AudioProcessingState.idle,
|
||||
ProcessingState.loading => AudioProcessingState.loading,
|
||||
ProcessingState.buffering => AudioProcessingState.buffering,
|
||||
ProcessingState.ready => AudioProcessingState.ready,
|
||||
ProcessingState.completed => AudioProcessingState.completed,
|
||||
};
|
||||
final AudioProcessingState processingState =
|
||||
switch (state.processingState) {
|
||||
ProcessingState.idle => AudioProcessingState.idle,
|
||||
ProcessingState.loading => AudioProcessingState.loading,
|
||||
ProcessingState.buffering => AudioProcessingState.buffering,
|
||||
ProcessingState.ready => AudioProcessingState.ready,
|
||||
ProcessingState.completed => AudioProcessingState.completed,
|
||||
};
|
||||
|
||||
final bool isPlaying = state.playing && state.processingState == ProcessingState.ready;
|
||||
final bool isBuffering = (state.playing && state.processingState != ProcessingState.ready) ||
|
||||
(_playRequested && !state.playing && state.processingState != ProcessingState.completed);
|
||||
final bool isPlaying =
|
||||
state.playing && state.processingState == ProcessingState.ready;
|
||||
final bool isBuffering =
|
||||
(state.playing && state.processingState != ProcessingState.ready) ||
|
||||
(_playRequested &&
|
||||
!state.playing &&
|
||||
state.processingState != ProcessingState.completed);
|
||||
|
||||
playbackState.add(
|
||||
playbackState.value.copyWith(
|
||||
controls: <MediaControl>[
|
||||
if (isPlaying || isBuffering) MediaControl.stop else MediaControl.play,
|
||||
if (isPlaying || isBuffering)
|
||||
MediaControl.stop
|
||||
else
|
||||
MediaControl.play,
|
||||
],
|
||||
systemActions: const <MediaAction>{},
|
||||
processingState: isBuffering ? AudioProcessingState.buffering : processingState,
|
||||
processingState: isBuffering
|
||||
? AudioProcessingState.buffering
|
||||
: processingState,
|
||||
playing: isPlaying,
|
||||
),
|
||||
);
|
||||
@@ -220,4 +224,4 @@ class KryzAudioHandler extends BaseAudioHandler with SeekHandler {
|
||||
// Keep existing metadata if live-info fetch fails.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ class LiveInfoBusinessObject extends ChangeNotifier {
|
||||
String? endpoint,
|
||||
int refreshIntervalSeconds = 20,
|
||||
this.requestTimeout = const Duration(seconds: 8),
|
||||
}) : _endpointOverride = endpoint,
|
||||
_refreshIntervalSeconds = refreshIntervalSeconds;
|
||||
}) : _endpointOverride = endpoint,
|
||||
_refreshIntervalSeconds = refreshIntervalSeconds;
|
||||
|
||||
/// Explicit endpoint passed at construction, if any.
|
||||
final String? _endpointOverride;
|
||||
@@ -23,12 +23,16 @@ class LiveInfoBusinessObject extends ChangeNotifier {
|
||||
if (override != null && override.isNotEmpty) {
|
||||
return override;
|
||||
}
|
||||
const envUrl = String.fromEnvironment('KRYZ_LIVE_INFO_URL', defaultValue: '');
|
||||
const envUrl = String.fromEnvironment(
|
||||
'KRYZ_LIVE_INFO_URL',
|
||||
defaultValue: '',
|
||||
);
|
||||
if (envUrl.isNotEmpty) {
|
||||
return envUrl;
|
||||
}
|
||||
return AppConfig.metadataUrl ?? '';
|
||||
}
|
||||
|
||||
final Duration requestTimeout;
|
||||
|
||||
Timer? _pollTimer;
|
||||
|
||||
+2
-3
@@ -139,7 +139,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
|
||||
_liveInfo.addListener(_handleLiveInfoChanged);
|
||||
_liveInfo.start();
|
||||
_playbackChannel.setMethodCallHandler(_handlePlaybackMethodCall);
|
||||
|
||||
|
||||
// When native code requests local audio to stop (cast media loaded)
|
||||
_casting.onStopLocalAudioRequested = () {
|
||||
unawaited(_audio.stop());
|
||||
@@ -458,8 +458,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
|
||||
label: const Text('Stop'),
|
||||
),
|
||||
ElevatedButton.icon(
|
||||
onPressed:
|
||||
_casting.status == CastingStatus.connecting
|
||||
onPressed: _casting.status == CastingStatus.connecting
|
||||
? null
|
||||
: _toggleCasting,
|
||||
icon: Icon(_castingIcon()),
|
||||
|
||||
+2
-7
@@ -39,9 +39,7 @@ class ShowCard extends StatelessWidget {
|
||||
'$label: ${show?.name ?? 'No scheduled show'}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.bodyMedium?.copyWith(
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: titleColor,
|
||||
),
|
||||
@@ -49,10 +47,7 @@ class ShowCard extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
formatStartingTime(
|
||||
show?.starts,
|
||||
sourceTimezone: sourceTimezone,
|
||||
),
|
||||
formatStartingTime(show?.starts, sourceTimezone: sourceTimezone),
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.labelSmall?.copyWith(color: titleColor),
|
||||
|
||||
@@ -35,21 +35,25 @@ class StreamingAudioBusinessObject extends ChangeNotifier {
|
||||
return;
|
||||
}
|
||||
|
||||
_audioHandlerInitFuture ??= AudioService.init(
|
||||
builder: () => KryzAudioHandler(),
|
||||
config: const AudioServiceConfig(
|
||||
androidNotificationChannelId: 'com.kryzgoflutter.audio.channel',
|
||||
androidNotificationChannelName: '${AppConfig.appName} Audio Playback',
|
||||
androidNotificationOngoing: true,
|
||||
androidStopForegroundOnPause: true,
|
||||
),
|
||||
).then((handler) {
|
||||
_audioHandler = handler;
|
||||
return handler;
|
||||
}).catchError((error) {
|
||||
_audioHandlerInitFuture = null;
|
||||
throw error;
|
||||
});
|
||||
_audioHandlerInitFuture ??=
|
||||
AudioService.init(
|
||||
builder: () => KryzAudioHandler(),
|
||||
config: const AudioServiceConfig(
|
||||
androidNotificationChannelId: 'com.kryzgoflutter.audio.channel',
|
||||
androidNotificationChannelName:
|
||||
'${AppConfig.appName} Audio Playback',
|
||||
androidNotificationOngoing: true,
|
||||
androidStopForegroundOnPause: true,
|
||||
),
|
||||
)
|
||||
.then((handler) {
|
||||
_audioHandler = handler;
|
||||
return handler;
|
||||
})
|
||||
.catchError((error) {
|
||||
_audioHandlerInitFuture = null;
|
||||
throw error;
|
||||
});
|
||||
|
||||
await _audioHandlerInitFuture;
|
||||
}
|
||||
@@ -146,9 +150,12 @@ class StreamingAudioBusinessObject extends ChangeNotifier {
|
||||
return;
|
||||
}
|
||||
|
||||
final title = item.title.trim().isEmpty ? AppConfig.defaultTitle : item.title;
|
||||
final subtitle =
|
||||
(item.artist ?? '').trim().isEmpty ? AppConfig.defaultArtist : item.artist!.trim();
|
||||
final title = item.title.trim().isEmpty
|
||||
? AppConfig.defaultTitle
|
||||
: item.title;
|
||||
final subtitle = (item.artist ?? '').trim().isEmpty
|
||||
? AppConfig.defaultArtist
|
||||
: item.artist!.trim();
|
||||
|
||||
if (title == _currentTitle && subtitle == _currentSubtitle) {
|
||||
return;
|
||||
|
||||
@@ -120,8 +120,9 @@ DateTime? _tryParseServerDateTime(String value) {
|
||||
final int second = parsePart(6);
|
||||
|
||||
final String fraction = (match.group(7) ?? '').padRight(6, '0');
|
||||
final int microseconds =
|
||||
fraction.isEmpty ? 0 : int.parse(fraction.substring(0, 6));
|
||||
final int microseconds = fraction.isEmpty
|
||||
? 0
|
||||
: int.parse(fraction.substring(0, 6));
|
||||
|
||||
return DateTime(
|
||||
year,
|
||||
|
||||
+2
-6
@@ -47,9 +47,7 @@ class TrackCard extends StatelessWidget {
|
||||
title,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.titleMedium?.copyWith(
|
||||
style: Theme.of(context).textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: titleColor,
|
||||
),
|
||||
@@ -66,9 +64,7 @@ class TrackCard extends StatelessWidget {
|
||||
const Spacer(),
|
||||
Text(
|
||||
window,
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.labelMedium?.copyWith(
|
||||
style: Theme.of(context).textTheme.labelMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: titleColor,
|
||||
),
|
||||
|
||||
@@ -54,46 +54,51 @@ void main() {
|
||||
|
||||
test('does not double-convert timestamps with explicit UTC designator', () {
|
||||
const String utcStamp = '2026-05-15T03:00:00Z';
|
||||
final String expected = DateFormat('jm').format(DateTime.parse(utcStamp).toLocal());
|
||||
final String expected = DateFormat(
|
||||
'jm',
|
||||
).format(DateTime.parse(utcStamp).toLocal());
|
||||
|
||||
expect(
|
||||
formatStartingTime(
|
||||
utcStamp,
|
||||
sourceTimezone: 'America/Los_Angeles',
|
||||
),
|
||||
formatStartingTime(utcStamp, sourceTimezone: 'America/Los_Angeles'),
|
||||
expected,
|
||||
);
|
||||
});
|
||||
|
||||
test('keeps wall-clock time when local matches source zone for naive input', () {
|
||||
const String sourceTime = '2026-05-14 20:00:00';
|
||||
const String sourceZone = 'America/Los_Angeles';
|
||||
test(
|
||||
'keeps wall-clock time when local matches source zone for naive input',
|
||||
() {
|
||||
const String sourceTime = '2026-05-14 20:00:00';
|
||||
const String sourceZone = 'America/Los_Angeles';
|
||||
|
||||
final tz.TZDateTime source = tz.TZDateTime(
|
||||
tz.getLocation(sourceZone),
|
||||
2026,
|
||||
5,
|
||||
14,
|
||||
20,
|
||||
);
|
||||
final String expected = DateFormat('jm').format(
|
||||
DateTime.fromMillisecondsSinceEpoch(
|
||||
source.millisecondsSinceEpoch,
|
||||
isUtc: true,
|
||||
).toLocal(),
|
||||
);
|
||||
final tz.TZDateTime source = tz.TZDateTime(
|
||||
tz.getLocation(sourceZone),
|
||||
2026,
|
||||
5,
|
||||
14,
|
||||
20,
|
||||
);
|
||||
final String expected = DateFormat('jm').format(
|
||||
DateTime.fromMillisecondsSinceEpoch(
|
||||
source.millisecondsSinceEpoch,
|
||||
isUtc: true,
|
||||
).toLocal(),
|
||||
);
|
||||
|
||||
expect(
|
||||
formatStartingTime(sourceTime, sourceTimezone: sourceZone),
|
||||
expected,
|
||||
);
|
||||
});
|
||||
expect(
|
||||
formatStartingTime(sourceTime, sourceTimezone: sourceZone),
|
||||
expected,
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
group('formatTimeWindow', () {
|
||||
test('returns mm:ss style duration from server times', () {
|
||||
expect(
|
||||
formatTimeWindow('2026-05-15 05:18:46.000000', '2026-05-15 05:23:21.000000'),
|
||||
formatTimeWindow(
|
||||
'2026-05-15 05:18:46.000000',
|
||||
'2026-05-15 05:23:21.000000',
|
||||
),
|
||||
'04:35',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -16,7 +16,13 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('KRYZ Go!'), findsWidgets);
|
||||
expect(find.widgetWithIcon(ElevatedButton, Icons.play_arrow_rounded), findsOneWidget);
|
||||
expect(find.widgetWithIcon(ElevatedButton, Icons.stop_rounded), findsOneWidget);
|
||||
expect(
|
||||
find.widgetWithIcon(ElevatedButton, Icons.play_arrow_rounded),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.widgetWithIcon(ElevatedButton, Icons.stop_rounded),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user