From bc741a1310d8e39dab2dd1ae483ae1bef611a618 Mon Sep 17 00:00:00 2001 From: Tazio Date: Wed, 12 Nov 2025 09:23:56 +0100 Subject: [PATCH] refactor: move cast below seasons --- lib/client/plex_client.dart | 10 ---- lib/screens/media_detail_screen.dart | 88 ++++++++++++++-------------- 2 files changed, 44 insertions(+), 54 deletions(-) diff --git a/lib/client/plex_client.dart b/lib/client/plex_client.dart index 578cc5f5..961e6834 100644 --- a/lib/client/plex_client.dart +++ b/lib/client/plex_client.dart @@ -266,22 +266,12 @@ class PlexClient { queryParameters: {'includeOnDeck': 1}, ); - // Log raw API response to see all available fields - appLogger.d('=== RAW API RESPONSE ==='); - appLogger.d('Full response data: ${response.data}'); - appLogger.d('=== END RAW API RESPONSE ==='); - PlexMetadata? metadata; PlexMetadata? onDeckEpisode; final metadataJson = _getFirstMetadataJson(response); // Log the parsed metadata JSON - if (metadataJson != null) { - appLogger.d('=== PARSED METADATA JSON ==='); - appLogger.d('Metadata JSON: $metadataJson'); - appLogger.d('=== END PARSED METADATA JSON ==='); - } if (metadataJson != null) { metadata = PlexMetadata.fromJsonWithImages(metadataJson); diff --git a/lib/screens/media_detail_screen.dart b/lib/screens/media_detail_screen.dart index 68835e76..549486bf 100644 --- a/lib/screens/media_detail_screen.dart +++ b/lib/screens/media_detail_screen.dart @@ -764,6 +764,50 @@ class _MediaDetailScreenState extends State { const SizedBox(height: 24), ], + // Seasons (for TV shows) + if (isShow) ...[ + Text( + 'Seasons', + style: Theme.of(context).textTheme.titleLarge?.copyWith( + fontWeight: FontWeight.bold, + ), + ), + const SizedBox(height: 12), + if (_isLoadingSeasons) + const Center( + child: Padding( + padding: EdgeInsets.all(32), + child: CircularProgressIndicator(), + ), + ) + else if (_seasons.isEmpty) + Padding( + padding: const EdgeInsets.all(32), + child: Center( + child: Text( + t.messages.noSeasonsFound, + style: Theme.of( + context, + ).textTheme.bodyLarge?.copyWith(color: Colors.grey), + ), + ), + ) + else + ListView.separated( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + padding: EdgeInsets.zero, + itemCount: _seasons.length, + separatorBuilder: (context, index) => + const SizedBox(height: 12), + itemBuilder: (context, index) { + final season = _seasons[index]; + return _buildSeasonCard(season); + }, + ), + const SizedBox(height: 24), + ], + // Cast if (metadata.role != null && metadata.role!.isNotEmpty) ...[ Text( @@ -875,50 +919,6 @@ class _MediaDetailScreenState extends State { const SizedBox(height: 24), ], - // Seasons (for TV shows) - if (isShow) ...[ - Text( - 'Seasons', - style: Theme.of(context).textTheme.titleLarge?.copyWith( - fontWeight: FontWeight.bold, - ), - ), - const SizedBox(height: 12), - if (_isLoadingSeasons) - const Center( - child: Padding( - padding: EdgeInsets.all(32), - child: CircularProgressIndicator(), - ), - ) - else if (_seasons.isEmpty) - Padding( - padding: const EdgeInsets.all(32), - child: Center( - child: Text( - t.messages.noSeasonsFound, - style: Theme.of( - context, - ).textTheme.bodyLarge?.copyWith(color: Colors.grey), - ), - ), - ) - else - ListView.separated( - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - padding: EdgeInsets.zero, - itemCount: _seasons.length, - separatorBuilder: (context, index) => - const SizedBox(height: 12), - itemBuilder: (context, index) { - final season = _seasons[index]; - return _buildSeasonCard(season); - }, - ), - const SizedBox(height: 24), - ], - // Additional info if (metadata.studio != null) ...[ _buildInfoRow('Studio', metadata.studio!),