From 13aca4d647f77e064878b61e552de2a5be01ed05 Mon Sep 17 00:00:00 2001 From: devaryakjha Date: Tue, 24 Oct 2023 02:30:11 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix:=20Internal=20libraries=20no?= =?UTF-8?q?w=20hide=20images?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/features/library/cubit/library_cubit.dart | 7 ++++- .../ui/library_widgets/library_app_bar.dart | 27 ++++++++++++------- .../user-library/ui/user_library_page.dart | 12 ++------- lib/widgets/downloads_icon.dart | 25 +++++++++++++++++ 4 files changed, 50 insertions(+), 21 deletions(-) create mode 100644 lib/widgets/downloads_icon.dart diff --git a/lib/features/library/cubit/library_cubit.dart b/lib/features/library/cubit/library_cubit.dart index 4575b20..d128512 100644 --- a/lib/features/library/cubit/library_cubit.dart +++ b/lib/features/library/cubit/library_cubit.dart @@ -26,7 +26,12 @@ class LibraryCubit extends Cubit { String link = playlist.images.last.link!; if (!appContext.mounted) return; final configCubit = appContext.read(); - final colorPalette = await configCubit.generatePalleteGenerator(link); + PaletteGenerator.fromColors([]); + if (!appContext.mounted) return; + final colorPalette = playlist.isDownload && appContext.mounted + ? PaletteGenerator.fromColors( + [PaletteColor(appContext.colorScheme.secondaryContainer, 1)]) + : await configCubit.generatePalleteGenerator(link); final image = configCubit.getProvider(link); emit(LibraryLoaded( playlist.toMediaPlaylist(), diff --git a/lib/features/library/ui/library_widgets/library_app_bar.dart b/lib/features/library/ui/library_widgets/library_app_bar.dart index bb39891..754693a 100644 --- a/lib/features/library/ui/library_widgets/library_app_bar.dart +++ b/lib/features/library/ui/library_widgets/library_app_bar.dart @@ -17,6 +17,11 @@ class LibraryAppBar extends StatelessWidget { final LibraryLoaded state; final EdgeInsets padding; + bool get isFromUserLibrary => + state.sourceLibrary != null && + (state.sourceLibrary!.isDownload == true || + state.sourceLibrary!.isFavorite == true); + @override Widget build(BuildContext context) { return SliverAppBar( @@ -24,7 +29,7 @@ class LibraryAppBar extends StatelessWidget { elevation: 0, scrolledUnderElevation: 10, stretch: true, - expandedHeight: kSliverExpandedHeight, + expandedHeight: isFromUserLibrary ? 130 : kSliverExpandedHeight, pinned: kSliverAppBarPinned, collapsedHeight: kToolbarHeight, flexibleSpace: LayoutBuilder(builder: (context, constraints) { @@ -64,7 +69,7 @@ class LibraryAppBar extends StatelessWidget { children: [ Container( height: 64, - width: context.width * 0.85, + width: context.width * 0.8, alignment: Alignment.topCenter, child: SizedBox( height: 32, @@ -79,17 +84,19 @@ class LibraryAppBar extends StatelessWidget { ), ), ), - AnimatedContainer( - duration: kThemeAnimationDuration, - height: imageHeight, - width: imageHeight, - decoration: BoxDecoration(boxShadow: state.boxShadow), - child: Image( + if (!isFromUserLibrary) + AnimatedContainer( + duration: kThemeAnimationDuration, height: imageHeight, width: imageHeight, - image: state.image, + decoration: BoxDecoration(boxShadow: state.boxShadow), + child: Image( + height: imageHeight, + width: imageHeight, + image: state.image, + fit: BoxFit.cover, + ), ), - ), ], ), ), diff --git a/lib/features/user-library/ui/user_library_page.dart b/lib/features/user-library/ui/user_library_page.dart index 78206e3..0b2a444 100644 --- a/lib/features/user-library/ui/user_library_page.dart +++ b/lib/features/user-library/ui/user_library_page.dart @@ -12,6 +12,7 @@ import 'package:varanasi_mobile_app/gen/assets.gen.dart'; import 'package:varanasi_mobile_app/utils/extensions/extensions.dart'; import 'package:varanasi_mobile_app/utils/helpers/get_app_context.dart'; import 'package:varanasi_mobile_app/utils/routes.dart'; +import 'package:varanasi_mobile_app/widgets/downloads_icon.dart'; import 'widgets/empty.dart'; @@ -62,16 +63,7 @@ class UserLibraryPage extends HookWidget { return ListTile( onTap: () => context.push(AppRoutes.library.path, extra: item), leading: Visibility( - replacement: Container( - height: 48, - width: 48, - decoration: BoxDecoration( - color: context.colorScheme.secondaryContainer, - borderRadius: BorderRadius.circular(4), - ), - child: Icon(Icons.download_rounded, - color: context.theme.colorScheme.onSecondaryContainer), - ), + replacement: const DownloadsIcon(), visible: !item.isDownload, child: ClipRRect( borderRadius: BorderRadius.circular(4), diff --git a/lib/widgets/downloads_icon.dart b/lib/widgets/downloads_icon.dart new file mode 100644 index 0000000..06fafad --- /dev/null +++ b/lib/widgets/downloads_icon.dart @@ -0,0 +1,25 @@ +import 'package:flutter/material.dart'; +import 'package:varanasi_mobile_app/utils/extensions/extensions.dart'; + +class DownloadsIcon extends StatelessWidget { + const DownloadsIcon({ + super.key, + this.dimension = 48, + }); + + final double dimension; + + @override + Widget build(BuildContext context) { + return Container( + height: dimension, + width: dimension, + decoration: BoxDecoration( + color: context.colorScheme.secondaryContainer, + borderRadius: BorderRadius.circular(4), + ), + child: Icon(Icons.download_rounded, + color: context.theme.colorScheme.onSecondaryContainer), + ); + } +}