From 02579378595953a289ea4682ac00c103f70cf920 Mon Sep 17 00:00:00 2001 From: robot Date: Sat, 1 Aug 2026 11:06:17 +0000 Subject: [PATCH] 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. --- lib/app_theme_business_object.dart | 16 +++++++ lib/casting_business_object.dart | 2 +- lib/kryz_audio_handler.dart | 46 +++++++++--------- lib/live_info_business_object.dart | 10 ++-- lib/main.dart | 5 +- lib/show_card.dart | 9 +--- lib/streaming_audio_business_object.dart | 43 +++++++++-------- lib/time_formatter.dart | 5 +- lib/track_card.dart | 8 +--- test/time_formatter_test.dart | 59 +++++++++++++----------- test/widget_test.dart | 10 +++- 11 files changed, 123 insertions(+), 90 deletions(-) diff --git a/lib/app_theme_business_object.dart b/lib/app_theme_business_object.dart index a37b335..3b9ffa4 100755 --- a/lib/app_theme_business_object.dart +++ b/lib/app_theme_business_object.dart @@ -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; } diff --git a/lib/casting_business_object.dart b/lib/casting_business_object.dart index b60e7f9..8f1350d 100755 --- a/lib/casting_business_object.dart +++ b/lib/casting_business_object.dart @@ -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; diff --git a/lib/kryz_audio_handler.dart b/lib/kryz_audio_handler.dart index 0034717..bf43d52 100755 --- a/lib/kryz_audio_handler.dart +++ b/lib/kryz_audio_handler.dart @@ -28,10 +28,7 @@ class KryzAudioHandler extends BaseAudioHandler with SeekHandler { title: AppConfig.defaultTitle, artist: AppConfig.defaultArtist, album: 'Live', - extras: { - 'isLive': true, - 'seekable': false, - }, + extras: {'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: [ - if (isPlaying || isBuffering) MediaControl.stop else MediaControl.play, + if (isPlaying || isBuffering) + MediaControl.stop + else + MediaControl.play, ], systemActions: const {}, - 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. } } -} \ No newline at end of file +} diff --git a/lib/live_info_business_object.dart b/lib/live_info_business_object.dart index 6e4e6be..6c0293d 100755 --- a/lib/live_info_business_object.dart +++ b/lib/live_info_business_object.dart @@ -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; diff --git a/lib/main.dart b/lib/main.dart index 61125d6..80a0e80 100755 --- a/lib/main.dart +++ b/lib/main.dart @@ -139,7 +139,7 @@ class _MainPageState extends State 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 with WidgetsBindingObserver { label: const Text('Stop'), ), ElevatedButton.icon( - onPressed: - _casting.status == CastingStatus.connecting + onPressed: _casting.status == CastingStatus.connecting ? null : _toggleCasting, icon: Icon(_castingIcon()), diff --git a/lib/show_card.dart b/lib/show_card.dart index 48f11b3..004ae41 100755 --- a/lib/show_card.dart +++ b/lib/show_card.dart @@ -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), diff --git a/lib/streaming_audio_business_object.dart b/lib/streaming_audio_business_object.dart index b0eb805..e02c178 100755 --- a/lib/streaming_audio_business_object.dart +++ b/lib/streaming_audio_business_object.dart @@ -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; diff --git a/lib/time_formatter.dart b/lib/time_formatter.dart index 7260be6..429efc6 100755 --- a/lib/time_formatter.dart +++ b/lib/time_formatter.dart @@ -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, diff --git a/lib/track_card.dart b/lib/track_card.dart index 5180b77..6b072e7 100755 --- a/lib/track_card.dart +++ b/lib/track_card.dart @@ -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, ), diff --git a/test/time_formatter_test.dart b/test/time_formatter_test.dart index 49a0bff..37b5819 100755 --- a/test/time_formatter_test.dart +++ b/test/time_formatter_test.dart @@ -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', ); }); diff --git a/test/widget_test.dart b/test/widget_test.dart index e1d3899..fd22e51 100755 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -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, + ); }); }