Skip to content

Commit

Permalink
🐛 Fix: Internal libraries now hide images
Browse files Browse the repository at this point in the history
  • Loading branch information
devaryakjha committed Oct 23, 2023
1 parent 2cf9f0e commit 13aca4d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 21 deletions.
7 changes: 6 additions & 1 deletion lib/features/library/cubit/library_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ class LibraryCubit extends Cubit<LibraryState> {
String link = playlist.images.last.link!;
if (!appContext.mounted) return;
final configCubit = appContext.read<ConfigCubit>();
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(),
Expand Down
27 changes: 17 additions & 10 deletions lib/features/library/ui/library_widgets/library_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@ class LibraryAppBar extends StatelessWidget {
final LibraryLoaded<PlayableMedia> 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(
centerTitle: true,
elevation: 0,
scrolledUnderElevation: 10,
stretch: true,
expandedHeight: kSliverExpandedHeight,
expandedHeight: isFromUserLibrary ? 130 : kSliverExpandedHeight,
pinned: kSliverAppBarPinned,
collapsedHeight: kToolbarHeight,
flexibleSpace: LayoutBuilder(builder: (context, constraints) {
Expand Down Expand Up @@ -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,
Expand All @@ -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,
),
),
),
],
),
),
Expand Down
12 changes: 2 additions & 10 deletions lib/features/user-library/ui/user_library_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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),
Expand Down
25 changes: 25 additions & 0 deletions lib/widgets/downloads_icon.dart
Original file line number Diff line number Diff line change
@@ -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),
);
}
}

0 comments on commit 13aca4d

Please sign in to comment.