Skip to content

Commit 312b61f

Browse files
committed
Removed album card component's "magic numbers"
1 parent 934a727 commit 312b61f

3 files changed

Lines changed: 23 additions & 23 deletions

File tree

lib/components/cards/album_card.dart

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ class AlbumCard extends StatelessWidget {
2626
final Function()? onMove;
2727
final bool showActions;
2828

29-
static const double kAlbumAnchorRadius = 8.0;
30-
static const double kAlbumOuterRadius = 16.0;
31-
static const double kAlbumRatio = 3;
29+
static const double ALBUM_ANCHOR_RADIUS = 8.0;
30+
static const double ALBUM_OUTER_RADIUS = 16.0;
31+
static const double ALBUM_RATIO = 3.0;
3232

3333
@override
3434
Widget build(BuildContext context) {
3535
return GestureDetector(
3636
onTap: onTap,
3737
child: ClipRRect(
38-
borderRadius: BorderRadius.circular(kAlbumOuterRadius),
38+
borderRadius: BorderRadius.circular(ALBUM_OUTER_RADIUS),
3939
child: Slidable(
4040
enabled: showActions,
4141
endActionPane: _actionPane(context),
@@ -93,12 +93,12 @@ class AlbumCard extends StatelessWidget {
9393
right: 0.0,
9494
top: 1.0,
9595
bottom: 1.0,
96-
width: kAlbumAnchorRadius * 2.0,
96+
width: ALBUM_ANCHOR_RADIUS * 2.0,
9797
child: OverflowBox(
9898
alignment: Alignment.centerLeft,
99-
maxWidth: kAlbumAnchorRadius * 2.0 + 1.0,
99+
maxWidth: ALBUM_ANCHOR_RADIUS * 2.0 + 1.0,
100100
child: Container(
101-
width: kAlbumAnchorRadius * 2.0 + 1.0,
101+
width: ALBUM_ANCHOR_RADIUS * 2.0 + 1.0,
102102
decoration: BoxDecoration(
103103
color: Theme.of(context).primaryColor,
104104
border: Border.all(
@@ -109,8 +109,8 @@ class AlbumCard extends StatelessWidget {
109109
),
110110
ClipShadowPath(
111111
clipper: const AlbumCardClipper(
112-
anchorRadius: kAlbumAnchorRadius,
113-
outerRadius: kAlbumOuterRadius,
112+
anchorRadius: ALBUM_ANCHOR_RADIUS,
113+
outerRadius: ALBUM_OUTER_RADIUS,
114114
isAdmin: true,
115115
),
116116
shadow: Shadow(
@@ -139,8 +139,8 @@ class AlbumCard extends StatelessWidget {
139139
return Builder(builder: (context) {
140140
return ClipPath(
141141
clipper: const AlbumCardClipper(
142-
anchorRadius: kAlbumAnchorRadius,
143-
outerRadius: kAlbumOuterRadius,
142+
anchorRadius: ALBUM_ANCHOR_RADIUS,
143+
outerRadius: ALBUM_OUTER_RADIUS,
144144
isAdmin: false,
145145
),
146146
child: Container(
@@ -172,7 +172,7 @@ class AlbumCardContent extends StatelessWidget {
172172
return Row(
173173
children: [
174174
_thumbnail,
175-
const SizedBox(width: AlbumCard.kAlbumAnchorRadius * 2 + 16),
175+
const SizedBox(width: AlbumCard.ALBUM_ANCHOR_RADIUS * 2 + 16.0),
176176
Expanded(
177177
child: _content,
178178
),
@@ -190,7 +190,7 @@ class AlbumCardContent extends StatelessWidget {
190190
return FittedBox(
191191
fit: BoxFit.cover,
192192
child: Container(
193-
padding: const EdgeInsets.all(16),
193+
padding: const EdgeInsets.all(16.0),
194194
decoration: BoxDecoration(
195195
color: Theme.of(context).scaffoldBackgroundColor,
196196
),

lib/components/cards/album_card_action.dart

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,23 @@ class AlbumCardAction extends StatelessWidget {
1717
final bool autoClose;
1818
final Function()? onPressed;
1919

20+
static const double ICON_SIZE = 28.0;
21+
2022
@override
2123
Widget build(BuildContext context) {
2224
return CustomSlidableAction(
25+
padding: EdgeInsets.zero,
2326
backgroundColor: backgroundColor ?? Theme.of(context).cardColor,
2427
onPressed: (_) {
2528
if (onPressed != null) {
2629
onPressed!();
2730
}
2831
},
2932
autoClose: autoClose,
30-
child: SizedBox.expand(
31-
child: FittedBox(
32-
fit: BoxFit.contain,
33-
child: Icon(
34-
icon,
35-
color: foregroundColor ?? const Color(0xFFFFFFFF),
36-
),
37-
),
33+
child: Icon(
34+
icon,
35+
size: ICON_SIZE,
36+
color: foregroundColor ?? Colors.white,
3837
),
3938
);
4039
}

lib/components/scroll_widgets/album_grid_view.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ class AlbumGridView extends StatelessWidget {
2626
@override
2727
Widget build(BuildContext context) {
2828
return GridView.builder(
29-
padding: padding ?? const EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0),
29+
padding:
30+
padding ?? const EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0),
3031
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
3132
maxCrossAxisExtent: Settings.defaultAlbumGridSize,
3233
mainAxisSpacing: 8.0,
3334
crossAxisSpacing: 8.0,
34-
childAspectRatio: AlbumCard.kAlbumRatio,
35+
childAspectRatio: AlbumCard.ALBUM_RATIO,
3536
),
3637
shrinkWrap: true,
3738
physics: const NeverScrollableScrollPhysics(),

0 commit comments

Comments
 (0)