Skip to content

Commit

Permalink
Fixed griditem overlap in library playlist section #239
Browse files Browse the repository at this point in the history
  • Loading branch information
anandnet committed Aug 20, 2024
1 parent 2f24c97 commit b649da0
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 42 deletions.
61 changes: 38 additions & 23 deletions lib/ui/screens/Library/library.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ class PlaylistNAlbumLibraryWidget extends StatelessWidget {
final libralbumCntrller = Get.find<LibraryAlbumsController>();
final librplstCntrller = Get.find<LibraryPlaylistsController>();
final settingscrnController = Get.find<SettingsScreenController>();
var size = MediaQuery.of(context).size;
final size = MediaQuery.of(context).size;

const double itemHeight = 220;
const double itemWidth = 180;
const double itemHeight = 180;
const double itemWidth = 130;
final topPadding = context.isLandscape ? 50.0 : 90.0;

return Padding(
Expand Down Expand Up @@ -178,27 +178,42 @@ class PlaylistNAlbumLibraryWidget extends StatelessWidget {
() => (isAlbumContent
? libralbumCntrller.libraryAlbums.isNotEmpty
: librplstCntrller.libraryPlaylists.isNotEmpty)
? GridView.builder(
physics: const BouncingScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: ((size.width - 60) / itemWidth).ceil(),
childAspectRatio: (itemWidth / itemHeight),
),
controller: ScrollController(keepScrollOffset: false),
shrinkWrap: true,
scrollDirection: Axis.vertical,
padding: const EdgeInsets.only(bottom: 200, top: 10),
itemCount: isAlbumContent
? libralbumCntrller.libraryAlbums.length
: librplstCntrller.libraryPlaylists.length,
itemBuilder: (context, index) => Center(
child: ContentListItem(
content: isAlbumContent
? libralbumCntrller.libraryAlbums[index]
: librplstCntrller.libraryPlaylists[index],
isLibraryItem: true,
? LayoutBuilder(builder: (context, constraints) {
//Fix for grid in mobile screen
final availableWidth = constraints.maxWidth > 300 &&
constraints.maxWidth < 394
? 310.0
: constraints.maxWidth;
int columns = (availableWidth / itemWidth).floor();
return SizedBox(
width: availableWidth,
child: GridView.builder(
physics: const BouncingScrollPhysics(),
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: columns,
childAspectRatio: (itemWidth / itemHeight),
),
))
controller:
ScrollController(keepScrollOffset: false),
shrinkWrap: true,
scrollDirection: Axis.vertical,
padding:
const EdgeInsets.only(bottom: 200, top: 10),
itemCount: isAlbumContent
? libralbumCntrller.libraryAlbums.length
: librplstCntrller.libraryPlaylists.length,
itemBuilder: (context, index) => Center(
child: ContentListItem(
content: isAlbumContent
? libralbumCntrller.libraryAlbums[index]
: librplstCntrller
.libraryPlaylists[index],
isLibraryItem: true,
),
)),
);
})
: Center(
child: Text(
"noBookmarks".tr,
Expand Down
46 changes: 27 additions & 19 deletions lib/ui/widgets/content_list_widget_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ class ContentListItem extends StatelessWidget {
id: ScreenNavigationSetup.id, arguments: [isAlbum, content, false]);
},
child: Container(
width: 120,
padding: const EdgeInsets.all(0),
width: 130,
height: 180,
padding: const EdgeInsets.symmetric(horizontal: 5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expand Down Expand Up @@ -91,23 +92,30 @@ class ContentListItem extends StatelessWidget {
size: 40,
))),
const SizedBox(height: 5),
Text(
content.title,
// overflow: TextOverflow.ellipsis,
maxLines: 2,
style: Theme.of(context).textTheme.titleMedium,
),
Text(
isAlbum
? isLibraryItem
? ""
: "${content.artists[0]['name'] ?? ""} | ${content.year ?? ""}"
: isLibraryItem
? ""
: content.description ?? "",
maxLines: 1,
style: Theme.of(context).textTheme.titleSmall,
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
content.title,
// overflow: TextOverflow.ellipsis,
maxLines: 2,
style: Theme.of(context).textTheme.titleMedium,
),
Text(
isAlbum
? isLibraryItem
? ""
: "${content.artists[0]['name'] ?? ""} | ${content.year ?? ""}"
: isLibraryItem
? ""
: content.description ?? "",
maxLines: 1,
style: Theme.of(context).textTheme.titleSmall,
),
],
),
)
],
),
),
Expand Down

0 comments on commit b649da0

Please sign in to comment.