From 4dca0457fb989b4a3d773c8eecc7e7b6a490c490 Mon Sep 17 00:00:00 2001 From: Rivers Cuomo Date: Wed, 31 Jul 2024 08:01:08 -0700 Subject: [PATCH] extracted playlist styles --- lib/main.dart | 6 ++--- lib/screens/home_screen.dart | 26 ++++++++++++++------ lib/widgets/spotify_style_playlist_tile.dart | 17 ++----------- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index e9cc676..7886014 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -40,7 +40,7 @@ class MyApp extends StatelessWidget { color: Colors.black, // Match your scaffold background color child: Center( child: ConstrainedBox( - constraints: BoxConstraints(maxWidth: 600), + constraints: const BoxConstraints(maxWidth: 600), child: child!, ), ), @@ -96,8 +96,8 @@ final spotifyThemeData = ThemeData( textTheme: TextTheme( titleLarge: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), bodyMedium: TextStyle(color: Colors.white70), - titleMedium: TextStyle(color: Colors.white54), - labelSmall: TextStyle(color: Colors.grey), + // titleMedium: TextStyle(color: Colors.white54), + labelMedium: TextStyle(color: Colors.grey[400]), ), inputDecorationTheme: InputDecorationTheme( fillColor: const Color(0xFF212121), diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart index 1612d34..5ed269a 100644 --- a/lib/screens/home_screen.dart +++ b/lib/screens/home_screen.dart @@ -184,14 +184,9 @@ class _HomeScreenState extends State { // ? _buildPlaylistSelectionOptions() // : ExpansionTile( - title: Text(targetPlaylist.name ?? 'Unknown Playlist'), + title: PlaylistTitle(context, targetPlaylist), leading: PlaylistImageIcon(playlist: targetPlaylist), - subtitle: targetPlaylist.owner != null - ? Text( - 'Playlist • ${targetPlaylist.owner!.displayName}', - style: Theme.of(context).textTheme.labelSmall, - ) - : null, + subtitle: playlistSubtitle(targetPlaylist, context), initiallyExpanded: jobs.isEmpty, children: [ @@ -268,3 +263,20 @@ class _HomeScreenState extends State { ); } } + +Widget playlistSubtitle(PlaylistSimple playlist, BuildContext context) { + return playlist.owner != null + ? Text( + 'Playlist • ${playlist.owner!.displayName}', + style: Theme.of(context).textTheme.labelMedium, + ) + : const SizedBox(); +} + +Text PlaylistTitle(BuildContext context, PlaylistSimple playlist) { + return Text( + playlist.name ?? 'Unknown Playlist', + style: Theme.of(context).textTheme.titleMedium, + overflow: TextOverflow.ellipsis, + ); +} diff --git a/lib/widgets/spotify_style_playlist_tile.dart b/lib/widgets/spotify_style_playlist_tile.dart index 9b028c6..a942dc2 100644 --- a/lib/widgets/spotify_style_playlist_tile.dart +++ b/lib/widgets/spotify_style_playlist_tile.dart @@ -34,21 +34,8 @@ class SpotifyStylePlaylistTile extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - playlist.name ?? 'Unknown Playlist', - style: const TextStyle( - color: Colors.white, - fontSize: 16, - fontWeight: FontWeight.w500, - ), - overflow: TextOverflow.ellipsis, - ), - playlist.owner != null - ? Text( - 'Playlist • ${playlist.owner!.displayName}', - style: Theme.of(context).textTheme.labelSmall, - ) - : Container(), + PlaylistTitle(context, playlist), + playlistSubtitle(playlist, context) ], ), ),