Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add: empty state for user library page #39

Merged
merged 2 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion lib/features/user-library/ui/user_library_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,42 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:varanasi_mobile_app/features/user-library/cubit/user_library_cubit.dart';
import 'package:varanasi_mobile_app/features/user-library/ui/widgets/add_playlist_button.dart';
import 'package:varanasi_mobile_app/gen/assets.gen.dart';
import 'package:varanasi_mobile_app/utils/extensions/extensions.dart';
import 'package:varanasi_mobile_app/utils/routes.dart';

import 'widgets/empty.dart';

class UserLibraryPage extends StatelessWidget {
const UserLibraryPage({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Your Library'),
title: Row(
children: [
Assets.icon.appIconMonotone.svg(width: 36, height: 36),
const SizedBox(width: 8),
Text(
'Your Library',
style: context.textTheme.titleLarge
?.copyWith(fontWeight: FontWeight.bold),
),
],
),
centerTitle: false,
actions: const [AddPlaylistButton()],
elevation: 10,
),
body: BlocBuilder<UserLibraryCubit, UserLibraryState>(
builder: (context, state) {
if (state is! UserLibraryLoaded) {
return const Center(child: CircularProgressIndicator());
}
final library = state.library;
if (library.isEmpty) return const EmptyUserLibrary();
return ListView.builder(
itemBuilder: (context, index) {
final item = library[index];
Expand Down
15 changes: 15 additions & 0 deletions lib/features/user-library/ui/widgets/add_playlist_button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:flutter/material.dart';

class AddPlaylistButton extends StatelessWidget {
const AddPlaylistButton({
super.key,
});

@override
Widget build(BuildContext context) {
return IconButton(
onPressed: () {},
icon: const Icon(Icons.add_rounded),
);
}
}
32 changes: 32 additions & 0 deletions lib/features/user-library/ui/widgets/empty.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:flutter/material.dart';
import 'package:varanasi_mobile_app/utils/extensions/extensions.dart';
import 'package:varanasi_mobile_app/utils/extensions/media_query.dart';

class EmptyUserLibrary extends StatelessWidget {
const EmptyUserLibrary({super.key});

@override
Widget build(BuildContext context) {
return SizedBox(
width: context.width,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"Add music to your library",
style: context.textTheme.titleLarge?.copyWith(
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 8),
Text(
"Collect your favorites so that you can listen\nwhenever you want",
style: context.textTheme.titleSmall,
textAlign: TextAlign.center,
),
],
),
);
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 0.1.1+14
version: 0.1.2+15

environment:
sdk: ">=3.0.6 <4.0.0"
Expand Down