Skip to content

Commit

Permalink
feat(playlist,album page): play and shuffle take full width on smalle…
Browse files Browse the repository at this point in the history
…r screens, add new xs breakpoint
  • Loading branch information
KRTirtho committed Jun 18, 2023
1 parent 7a8bd92 commit dce1b88
Show file tree
Hide file tree
Showing 25 changed files with 276 additions and 177 deletions.
2 changes: 1 addition & 1 deletion lib/components/album/album_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class AlbumCard extends HookConsumerWidget {
[playlistNotifier, query?.data, album.tracks],
);
final int marginH =
useBreakpointValue(sm: 10, md: 15, lg: 20, xl: 20, xxl: 20);
useBreakpointValue(xs: 10, sm: 10, md: 15, lg: 20, xl: 20, xxl: 20);

final updating = useState(false);
final spotify = ref.watch(spotifyProvider);
Expand Down
1 change: 1 addition & 0 deletions lib/components/artist/artist_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ArtistCard extends HookConsumerWidget {
final radius = BorderRadius.circular(15);

final double size = useBreakpointValue<double>(
xs: 130,
sm: 130,
md: 150,
others: 170,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class _MultiSelectDialog<T> extends HookWidget {
return AlertDialog(
scrollable: true,
title: dialogTitle ?? const Text('Select'),
contentPadding: mediaQuery.isSm ? const EdgeInsets.all(16) : null,
contentPadding: mediaQuery.mdAndUp ? null : const EdgeInsets.all(16),
insetPadding: const EdgeInsets.all(16),
actions: [
OutlinedButton(
Expand Down
1 change: 1 addition & 0 deletions lib/components/library/user_albums.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class UserAlbums extends HookConsumerWidget {
final albumsQuery = useQueries.album.ofMine(ref);

final spacing = useBreakpointValue<double>(
xs: 0,
sm: 0,
others: 20,
);
Expand Down
2 changes: 1 addition & 1 deletion lib/components/player/player_track_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class PlayerTrackDetails extends HookConsumerWidget {
),
),
),
if (mediaQuery.isSm || mediaQuery.isMd)
if (mediaQuery.mdAndDown)
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
Expand Down
2 changes: 1 addition & 1 deletion lib/components/playlist/playlist_create_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class PlaylistCreateDialogButton extends HookConsumerWidget {
final mediaQuery = MediaQuery.of(context);
final spotify = ref.watch(spotifyProvider);

if (mediaQuery.isSm) {
if (mediaQuery.smAndDown) {
return ElevatedButton(
style: FilledButton.styleFrom(
foregroundColor: Theme.of(context).colorScheme.primary,
Expand Down
3 changes: 1 addition & 2 deletions lib/components/root/bottom_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ class BottomPlayer extends HookConsumerWidget {
// returning an empty non spacious Container as the overlay will take
// place in the global overlay stack aka [_entries]
if (layoutMode == LayoutMode.compact ||
((mediaQuery.isSm || mediaQuery.isMd) &&
layoutMode == LayoutMode.adaptive)) {
((mediaQuery.mdAndDown) && layoutMode == LayoutMode.adaptive)) {
return PlayerOverlay(albumArt: albumArt);
}

Expand Down
9 changes: 5 additions & 4 deletions lib/components/root/sidebar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,17 @@ class Sidebar extends HookConsumerWidget {
}, [controller]);

useEffect(() {
if (!context.mounted) return;
if (mediaQuery.lgAndUp && !controller.extended) {
controller.setExtended(true);
} else if ((mediaQuery.isSm || mediaQuery.isMd) && controller.extended) {
} else if (mediaQuery.mdAndDown && controller.extended) {
controller.setExtended(false);
}
return null;
}, [mediaQuery, controller]);

if (layoutMode == LayoutMode.compact ||
(mediaQuery.isSm && layoutMode == LayoutMode.adaptive)) {
(mediaQuery.smAndDown && layoutMode == LayoutMode.adaptive)) {
return Scaffold(body: child);
}

Expand Down Expand Up @@ -186,7 +187,7 @@ class SidebarHeader extends HookWidget {
final mediaQuery = MediaQuery.of(context);
final theme = Theme.of(context);

if (mediaQuery.isSm || mediaQuery.isMd) {
if (mediaQuery.mdAndDown) {
return Container(
height: 40,
width: 40,
Expand Down Expand Up @@ -236,7 +237,7 @@ class SidebarFooter extends HookConsumerWidget {

final auth = ref.watch(AuthenticationNotifier.provider);

if (mediaQuery.isSm || mediaQuery.isMd) {
if (mediaQuery.mdAndDown) {
return IconButton(
icon: const Icon(SpotubeIcons.settings),
onPressed: () => Sidebar.goToSettings(context),
Expand Down
9 changes: 5 additions & 4 deletions lib/components/shared/adaptive/adaptive_list_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AdaptiveListTile extends HookWidget {
this.title,
this.subtitle,
this.leading,
this.breakOn ,
this.breakOn,
});

@override
Expand All @@ -27,10 +27,11 @@ class AdaptiveListTile extends HookWidget {
return ListTile(
title: title,
subtitle: subtitle,
trailing:
breakOn ?? mediaQuery.isSm ? null : trailing?.call(context, null),
trailing: breakOn ?? mediaQuery.smAndDown
? null
: trailing?.call(context, null),
leading: leading,
onTap: breakOn ?? mediaQuery.isSm
onTap: breakOn ?? mediaQuery.smAndDown
? () {
onTap?.call();
showDialog(
Expand Down
2 changes: 2 additions & 0 deletions lib/components/shared/playbutton_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ class PlaybuttonCard extends HookWidget {
final radius = BorderRadius.circular(15);

final double size = useBreakpointValue<double>(
xs: 130,
sm: 130,
md: 150,
others: 170,
) ??
170;

final end = useBreakpointValue<double>(
xs: 15,
sm: 15,
others: 20,
) ??
Expand Down
1 change: 1 addition & 0 deletions lib/components/shared/shimmers/shimmer_artist_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ShimmerArtistProfile extends HookWidget {
shimmerTheme.shimmerBackgroundColor ?? Colors.grey;

final avatarWidth = useBreakpointValue(
xs: MediaQuery.of(context).size.width * 0.80,
sm: MediaQuery.of(context).size.width * 0.80,
md: MediaQuery.of(context).size.width * 0.50,
lg: MediaQuery.of(context).size.width * 0.30,
Expand Down
1 change: 1 addition & 0 deletions lib/components/shared/shimmers/shimmer_categories.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ShimmerCategories extends HookWidget {
shimmerTheme.shimmerBackgroundColor ?? Colors.grey;

final shimmerCount = useBreakpointValue(
xs: 2,
sm: 2,
md: 3,
lg: 3,
Expand Down
2 changes: 1 addition & 1 deletion lib/components/shared/shimmers/shimmer_lyrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ShimmerLyrics extends HookWidget {
if (mediaQuery.isMd) {
widthsCp.removeLast();
}
if (mediaQuery.isSm) {
if (mediaQuery.smAndDown) {
widthsCp.removeLast();
widthsCp.removeLast();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class ShimmerPlaybuttonCard extends HookWidget {
Widget build(BuildContext context) {
final theme = Theme.of(context);
final Size size = useBreakpointValue<Size>(
xs: const Size(130, 200),
sm: const Size(130, 200),
md: const Size(150, 220),
others: const Size(170, 240),
Expand Down
1 change: 1 addition & 0 deletions lib/components/shared/themed_button_tab_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ThemedButtonsTabBar extends HookWidget implements PreferredSizeWidget {
);

final breakpoint = useBreakpointValue(
xs: 85.0,
sm: 85.0,
md: 35.0,
others: 0.0,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
import 'dart:ui';

import 'package:fl_query/fl_query.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:palette_generator/palette_generator.dart';
import 'package:spotify/spotify.dart';
import 'package:spotube/collections/assets.gen.dart';
import 'package:spotube/collections/spotube_icons.dart';
import 'package:spotube/components/album/album_card.dart';
import 'package:spotube/components/shared/image/universal_image.dart';
import 'package:spotube/extensions/constrains.dart';
import 'package:spotube/extensions/context.dart';

class TrackCollectionHeading<T> extends HookConsumerWidget {
final String title;
final String? description;
final String titleImage;
final List<Widget> buttons;
final AlbumSimple? album;
final Query<List<TrackSimple>, T> tracksSnapshot;
final bool isPlaying;
final void Function([Track? currentTrack]) onPlay;
final void Function([Track? currentTrack]) onShuffledPlay;
final PaletteColor? color;

const TrackCollectionHeading({
Key? key,
required this.title,
required this.titleImage,
required this.buttons,
required this.tracksSnapshot,
required this.isPlaying,
required this.onPlay,
required this.onShuffledPlay,
required this.color,
this.description,
this.album,
}) : super(key: key);

@override
Widget build(BuildContext context, ref) {
final theme = Theme.of(context);

return LayoutBuilder(
builder: (context, constrains) {
return DecoratedBox(
decoration: BoxDecoration(
image: DecorationImage(
image: UniversalImage.imageProvider(titleImage),
fit: BoxFit.cover,
),
),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10),
child: DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.black45,
theme.colorScheme.surface,
],
begin: const FractionalOffset(0, 0),
end: const FractionalOffset(0, 1),
tileMode: TileMode.clamp,
),
),
child: Material(
type: MaterialType.transparency,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20,
),
child: Flex(
direction:
constrains.mdAndDown ? Axis.vertical : Axis.horizontal,
mainAxisAlignment: MainAxisAlignment.center,
children: [
ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 200),
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: UniversalImage(
path: titleImage,
placeholder: Assets.albumPlaceholder.path,
),
),
),
const SizedBox(width: 10, height: 10),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: [
Text(
title,
style: theme.textTheme.titleLarge!.copyWith(
color: Colors.white,
fontWeight: FontWeight.w600,
),
),
if (album != null)
Text(
"${AlbumType.from(album?.albumType).formatted}${context.l10n.released}${DateTime.tryParse(
album?.releaseDate ?? "",
)?.year}",
style: theme.textTheme.titleMedium!.copyWith(
color: Colors.white,
fontWeight: FontWeight.normal,
),
),
if (description != null)
ConstrainedBox(
constraints: BoxConstraints(
maxWidth: constrains.mdAndDown ? 400 : 300,
),
child: Text(
description!,
style: const TextStyle(color: Colors.white),
maxLines: 2,
overflow: TextOverflow.fade,
),
),
const SizedBox(height: 10),
IconTheme(
data: theme.iconTheme.copyWith(
color: Colors.white,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: buttons,
),
),
const SizedBox(height: 10),
ConstrainedBox(
constraints: BoxConstraints(
maxWidth: constrains.mdAndDown ? 400 : 300,
),
child: Row(
mainAxisSize: constrains.smAndUp
? MainAxisSize.min
: MainAxisSize.min,
children: [
Expanded(
child: FilledButton.icon(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
foregroundColor: color?.color,
),
label: Text(context.l10n.shuffle),
icon: const Icon(SpotubeIcons.shuffle),
onPressed:
tracksSnapshot.data == null || isPlaying
? null
: onShuffledPlay,
),
),
const SizedBox(width: 10),
Expanded(
child: FilledButton.icon(
style: ElevatedButton.styleFrom(
backgroundColor: color?.color,
foregroundColor: color?.bodyTextColor,
),
onPressed: tracksSnapshot.data != null
? onPlay
: null,
icon: Icon(
isPlaying
? SpotubeIcons.stop
: SpotubeIcons.play,
),
label: Text(
isPlaying
? context.l10n.stop
: context.l10n.play,
),
),
),
],
),
),
],
)
],
),
),
),
),
),
);
},
);
}
}

0 comments on commit dce1b88

Please sign in to comment.