Skip to content

Commit

Permalink
✨ Add: empty state for user library page (#39)
Browse files Browse the repository at this point in the history
* ✨ New: Added empty state

* 👷 Updated: Version
  • Loading branch information
devaryakjha authored Oct 23, 2023
1 parent 940cee0 commit 144f1ab
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
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

0 comments on commit 144f1ab

Please sign in to comment.