Skip to content

Commit

Permalink
playlist subtitles
Browse files Browse the repository at this point in the history
  • Loading branch information
riverscuomo committed Jul 31, 2024
1 parent e4a481f commit e422589
Show file tree
Hide file tree
Showing 11 changed files with 280 additions and 142 deletions.
11 changes: 6 additions & 5 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class MyApp extends StatelessWidget {
color: Colors.black, // Match your scaffold background color
child: Center(
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: 700),
constraints: BoxConstraints(maxWidth: 600),
child: child!,
),
),
Expand Down Expand Up @@ -93,10 +93,11 @@ final spotifyThemeData = ThemeData(
titleTextStyle: TextStyle(
color: Colors.white, fontSize: 20, fontWeight: FontWeight.bold),
),
textTheme: const TextTheme(
headline6: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
bodyText2: TextStyle(color: Colors.white70),
subtitle1: TextStyle(color: Colors.white54),
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),
),
inputDecorationTheme: InputDecorationTheme(
fillColor: const Color(0xFF212121),
Expand Down
91 changes: 42 additions & 49 deletions lib/screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class _HomeScreenState extends State<HomeScreen> {
late ApiService _apiService;
late StorageService _storageService;
final SpotifyService spotifyService = getIt<SpotifyService>();
bool _isResettingTargetPlaylist = false;
// bool _isResettingTargetPlaylist = false;

@override
void initState() {
Expand Down Expand Up @@ -119,21 +119,14 @@ class _HomeScreenState extends State<HomeScreen> {
final updateJob = jobs[0].copyWith(targetPlaylist: selectedPlaylist);
_replaceJob(updateJob);
}
setState(() {
_isResettingTargetPlaylist = false;
});
// setState(() {
// _isResettingTargetPlaylist = false;
// });
},
);
}

Widget _buildRecipeCard(Job job, int index) {
// if (job.recipe.isEmpty) {
// print('Job ${job.targetPlaylist.name} recipe is empty');
// return const SizedBox();
// } else {
// print(
// 'Job ${job.targetPlaylist.name} recipe first ingredient before passing to widget: ${job.recipe[0].playlist.id} ${job.recipe[0].quantity}');
// }
return Card(
child: Padding(
padding: const EdgeInsets.all(8),
Expand All @@ -149,7 +142,7 @@ class _HomeScreenState extends State<HomeScreen> {
updateJob(index, job);
});
},
)
),
],
),
),
Expand All @@ -160,7 +153,6 @@ class _HomeScreenState extends State<HomeScreen> {
Widget build(BuildContext context) {
final job = jobs.isEmpty ? Job.empty() : jobs[0];
final targetPlaylist = job.targetPlaylist;
// final spotifyService = getIt<SpotifyService>();
return Scaffold(
appBar: AppBar(
title: const Text('Spotkin'),
Expand All @@ -178,12 +170,6 @@ class _HomeScreenState extends State<HomeScreen> {
);
},
),
IconButton(
icon: const Icon(Icons.info),
onPressed: () {
showInfoDialog(context);
},
)
],
),
body: SingleChildScrollView(
Expand All @@ -194,36 +180,43 @@ class _HomeScreenState extends State<HomeScreen> {
children: [
Column(
children: [
jobs.isEmpty || _isResettingTargetPlaylist
? _buildPlaylistSelectionOptions()
: SpotifyStylePlaylistTile(
playlist: targetPlaylist,
trailingButton: IconButton(
icon: const Icon(Icons.edit),
onPressed: () {
setState(() {
_isResettingTargetPlaylist = true;
});
},
),
onTileTapped: () {
setState(() {
_isResettingTargetPlaylist = true;
});
}),
// ListTile(
// title:
// Text(targetPlaylist.name ?? 'Unknown Playlist'),
// leading: Utils.getPlaylistImageOrIcon(targetPlaylist),
// trailing: IconButton(
// icon: Icon(Icons.edit),
// onPressed: () {
// setState(() {
// _isResettingTargetPlaylist = true;
// });
// },
// ),
// ),
// jobs.isEmpty || _isResettingTargetPlaylist
// ? _buildPlaylistSelectionOptions()
// :
ExpansionTile(
title: Text(targetPlaylist.name ?? 'Unknown Playlist'),
leading: PlaylistImageIcon(playlist: targetPlaylist),
subtitle: targetPlaylist.owner != null
? Text(
'Playlist • ${targetPlaylist.owner!.displayName}',
style: Theme.of(context).textTheme.labelSmall,
)
: null,
initiallyExpanded: jobs.isEmpty,

children: [
_buildPlaylistSelectionOptions(),
],

// playlist: targetPlaylist,
// trailingButton: IconButton(
// icon: const Icon(Icons.edit),
// onPressed: () {
// setState(
// () {
// _isResettingTargetPlaylist = true;
// },
// );
// },
// ),
// onTileTapped: () {
// setState(
// () {
// _isResettingTargetPlaylist = true;
// },
// );
// },
),
const SizedBox(height: 20),
...jobs.asMap().entries.map((entry) {
return _buildRecipeCard(entry.value, entry.key);
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/screens.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export 'package:spotkin_flutter/screens/auth_screen.dart';
export 'package:spotkin_flutter/screens/home_screen.dart';
export 'package:spotkin_flutter/screens/list_management_screen.dart';
export 'package:spotkin_flutter/screens/search_bottom_sheet.dart';
export 'package:spotkin_flutter/widgets/bottom_sheets/search_bottom_sheet.dart';
export 'package:spotkin_flutter/screens/settings_screen.dart';
8 changes: 8 additions & 0 deletions lib/screens/settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ class SettingsScreen extends StatelessWidget {
return Scaffold(
appBar: AppBar(
title: const Text('Settings'),
actions: [
IconButton(
icon: const Icon(Icons.info),
onPressed: () {
showInfoBottomSheet(context);
},
)
],
),
body: ListView.builder(
itemCount: jobs.length,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
import 'package:flutter/material.dart';

void showInfoDialog(BuildContext context) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: const Text('Spotkin'),
content: const Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: infoScreenContent,
),
actions: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text('Close'),
),
],
);
},
);
}

const infoScreenContent = [
const infoSheetContent = [
Text(
'Spotkin updates one of your Spotify playlists every day with a random selection of tracks from any of your playlists.'),
SizedBox(height: 10),
Expand Down
100 changes: 100 additions & 0 deletions lib/widgets/bottom_sheets/bottom_sheets.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import 'package:flutter/material.dart';
import 'bottom_sheet_content.dart';

class CustomBottomSheet extends StatelessWidget {
final Widget title;
final List<Widget> content;
final double initialChildSize;
final double minChildSize;
final double maxChildSize;

const CustomBottomSheet({
Key? key,
required this.title,
required this.content,
this.initialChildSize = 0.9,
this.minChildSize = 0.5,
this.maxChildSize = 0.9,
}) : super(key: key);

static Future<void> show({
required BuildContext context,
required Widget title,
required List<Widget> content,
double initialChildSize = 0.9,
double minChildSize = 0.5,
double maxChildSize = 0.9,
}) {
return showModalBottomSheet(
context: context,
isScrollControlled: true,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
),
builder: (BuildContext context) {
return CustomBottomSheet(
title: title,
content: content,
initialChildSize: initialChildSize,
minChildSize: minChildSize,
maxChildSize: maxChildSize,
);
},
);
}

@override
Widget build(BuildContext context) {
return DraggableScrollableSheet(
expand: false,
initialChildSize: initialChildSize,
minChildSize: minChildSize,
maxChildSize: maxChildSize,
builder: (_, controller) {
return Column(
children: [
Container(
height: 5,
width: 40,
margin: const EdgeInsets.symmetric(vertical: 8),
decoration: BoxDecoration(
color: Colors.grey[300],
borderRadius: BorderRadius.circular(2.5),
),
),
Padding(
padding: const EdgeInsets.all(16.0),
child: DefaultTextStyle(
style: Theme.of(context).textTheme.titleLarge!,
child: title,
),
),
Expanded(
child: ListView.builder(
controller: controller,
itemCount: content.length,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16.0,
vertical: 8.0,
),
child: content[index],
);
},
),
),
],
);
},
);
}
}

void showInfoBottomSheet(BuildContext context) {
CustomBottomSheet.show(
context: context,
title: Text('About Spotkin'),
content: infoSheetContent,
);
}
Loading

0 comments on commit e422589

Please sign in to comment.