Skip to content

Commit

Permalink
Fix spacing of rated app cards on large screens
Browse files Browse the repository at this point in the history
  • Loading branch information
ashuntu committed Oct 15, 2024
1 parent f0e098e commit bc5042d
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions packages/app_center/lib/widgets/snap_grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:snapd/snapd.dart';
class AppCardGrid extends StatelessWidget {
const AppCardGrid({
required this.appCards,
this.cardAspectRatio,
this.small = false,
super.key,
});

Expand Down Expand Up @@ -37,7 +37,7 @@ class AppCardGrid extends StatelessWidget {
rating: entry.key + 1,
),
),
cardAspectRatio: 4.0,
small: true,
);

factory AppCardGrid.fromDebs({
Expand Down Expand Up @@ -65,15 +65,31 @@ class AppCardGrid extends StatelessWidget {
);

final Iterable<AppCard> appCards;
final double? cardAspectRatio;
final bool small;

@override
Widget build(BuildContext context) {
final layout = ResponsiveLayout.of(context);
var columnCount = layout.cardColumnCount;
var cardAspectRatio = layout.cardSize.aspectRatio;
if (small) {
switch (layout.type) {
case ResponsiveLayoutType.small:
columnCount = 2;
cardAspectRatio = 2.5;
case ResponsiveLayoutType.medium:
columnCount = 3;
cardAspectRatio = 2.5;
case ResponsiveLayoutType.large:
columnCount = 4;
cardAspectRatio = 3.0;
}
}

return SliverGrid.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: layout.cardColumnCount,
childAspectRatio: cardAspectRatio ?? layout.cardSize.aspectRatio,
crossAxisCount: columnCount,
childAspectRatio: cardAspectRatio,
mainAxisSpacing: kCardSpacing - 2 * kCardMargin,
crossAxisSpacing: kCardSpacing - 2 * kCardMargin,
),
Expand Down

0 comments on commit bc5042d

Please sign in to comment.