Skip to content

Commit e6d6441

Browse files
committed
Refactor widget placeholder and error handling for image loading
- Updated placeholder and errorWidget parameters in various widgets to use consistent context and error handling. - Improved formatting and readability in several files by adjusting line breaks and indentation. - Enhanced the MiniPlayer and SongTile widgets for better clarity and maintainability. - Refactored logic in the synced lyrics view for improved performance and readability.
1 parent 090e9a5 commit e6d6441

7 files changed

Lines changed: 516 additions & 334 deletions

File tree

.github/workflows/build.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,10 @@ jobs:
123123
124124
- name: Create IPA
125125
run: |
126-
cd build/ios/iphoneos
126+
ls -la build/ios/
127+
cd build/ios/Release-iphoneos
127128
mkdir -p Payload
128-
cp -r Runner.app Payload/
129+
cp -r *.app Payload/
129130
zip -r ../../../musly-ios.ipa Payload
130131
cd ../../..
131132

lib/screens/home_screen.dart

Lines changed: 335 additions & 200 deletions
Large diffs are not rendered by default.

lib/screens/now_playing_screen.dart

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ class _DynamicBackground extends StatelessWidget {
982982
useOldImageOnUrlChange: true,
983983
fadeInDuration: const Duration(milliseconds: 300),
984984
fadeOutDuration: Duration.zero,
985-
placeholder: (_, _) => Container(color: Colors.black),
985+
placeholder: (ctx, url) => Container(color: Colors.black),
986986
errorWidget: (ctx, e, _) =>
987987
Container(color: Colors.black),
988988
),
@@ -1138,7 +1138,8 @@ class _PlayerHeader extends StatelessWidget {
11381138
Selector<PlayerProvider, double>(
11391139
selector: (_, p) => p.playbackSpeed,
11401140
builder: (context, speed, _) => IconButton(
1141-
tooltip: 'Playback speed (${speed == 1.0 ? '1×' : '$speed×'})',
1141+
tooltip:
1142+
'Playback speed (${speed == 1.0 ? '1×' : '$speed×'})',
11421143
onPressed: () => _showSpeedDialog(context),
11431144
icon: speed != 1.0
11441145
? Text(
@@ -1276,8 +1277,9 @@ class _PlayerHeader extends StatelessWidget {
12761277
return Container(
12771278
decoration: BoxDecoration(
12781279
color: AppTheme.darkSurface,
1279-
borderRadius:
1280-
const BorderRadius.vertical(top: Radius.circular(16)),
1280+
borderRadius: const BorderRadius.vertical(
1281+
top: Radius.circular(16),
1282+
),
12811283
),
12821284
child: SingleChildScrollView(
12831285
child: Column(
@@ -1528,14 +1530,14 @@ class _AlbumArtworkSection extends StatelessWidget {
15281530
useOldImageOnUrlChange: true,
15291531
fadeInDuration: Duration.zero,
15301532
fadeOutDuration: Duration.zero,
1531-
placeholder: (_, _) =>
1533+
placeholder: (ctx, url) =>
15321534
thumbnailUrl != null && thumbnailUrl!.isNotEmpty
15331535
? CachedNetworkImage(
15341536
imageUrl: thumbnailUrl!,
15351537
fit: BoxFit.contain,
15361538
memCacheWidth: 200,
15371539
fadeInDuration: Duration.zero,
1538-
errorWidget: (_, _, _) =>
1540+
errorWidget: (ctx, err, stack) =>
15391541
_buildLoadingPlaceholder(),
15401542
)
15411543
: _buildLoadingPlaceholder(),
@@ -1707,8 +1709,9 @@ class _SwipeableAlbumArtwork extends StatelessWidget {
17071709
useOldImageOnUrlChange: true,
17081710
fadeInDuration: Duration.zero,
17091711
fadeOutDuration: Duration.zero,
1710-
placeholder: (_, _) => _buildPlaceholder(),
1711-
errorWidget: (_, _, _) => _buildNoArtPlaceholder(context),
1712+
placeholder: (ctx, url) => _buildPlaceholder(),
1713+
errorWidget: (ctx, err, stack) =>
1714+
_buildNoArtPlaceholder(context),
17121715
),
17131716
),
17141717
);
@@ -2098,7 +2101,7 @@ class _SongInfoState extends State<_SongInfo> {
20982101
width: 50,
20992102
height: 50,
21002103
fit: BoxFit.cover,
2101-
placeholder: (_, _) => Container(
2104+
placeholder: (ctx, url) => Container(
21022105
width: 50,
21032106
height: 50,
21042107
color: AppTheme.darkCard,
@@ -2705,18 +2708,30 @@ class _VolumeSliderState extends State<_VolumeSlider> {
27052708
_dragValue = currentVolume;
27062709
});
27072710
_updateVolumeFromPosition(
2708-
details.localPosition, trackWidth, provider, isRemote);
2711+
details.localPosition,
2712+
trackWidth,
2713+
provider,
2714+
isRemote,
2715+
);
27092716
},
27102717
onHorizontalDragUpdate: (details) {
27112718
_updateVolumeFromPosition(
2712-
details.localPosition, trackWidth, provider, isRemote);
2719+
details.localPosition,
2720+
trackWidth,
2721+
provider,
2722+
isRemote,
2723+
);
27132724
},
27142725
onHorizontalDragEnd: (details) {
27152726
setState(() => _isDragging = false);
27162727
},
27172728
onTapDown: (details) {
27182729
_updateVolumeFromPosition(
2719-
details.localPosition, trackWidth, provider, isRemote);
2730+
details.localPosition,
2731+
trackWidth,
2732+
provider,
2733+
isRemote,
2734+
);
27202735
},
27212736
child: SizedBox(
27222737
height: 40,
@@ -2753,7 +2768,8 @@ class _VolumeSliderState extends State<_VolumeSlider> {
27532768

27542769
Positioned(
27552770
left:
2756-
((trackWidth * displayVolume.clamp(0.0, 1.0)) -
2771+
((trackWidth *
2772+
displayVolume.clamp(0.0, 1.0)) -
27572773
(_isDragging ? 10 : 6))
27582774
.clamp(
27592775
0.0,

lib/widgets/album_artwork.dart

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import '../services/player_ui_settings_service.dart';
77

88
bool isLocalFilePath(String? s) {
99
if (s == null || s.isEmpty) return false;
10-
if (s.startsWith('/')) return true;
11-
if (s.length > 2 && s[1] == ':') return true;
10+
if (s.startsWith('/')) return true;
11+
if (s.length > 2 && s[1] == ':') return true;
1212
return false;
1313
}
1414

@@ -112,7 +112,7 @@ class AlbumArtwork extends StatelessWidget {
112112
blur = size / 4;
113113
offset = Offset(0, size / 12);
114114
break;
115-
default:
115+
default:
116116
opacity = isDark ? 0.22 : 0.14;
117117
blur = size / 10;
118118
offset = Offset(0, size / 30);
@@ -145,7 +145,6 @@ class AlbumArtwork extends StatelessWidget {
145145
);
146146

147147
if (preserveAspectRatio) {
148-
149148
return Container(
150149
constraints: BoxConstraints(maxWidth: validSize),
151150
decoration: BoxDecoration(
@@ -164,7 +163,7 @@ class AlbumArtwork extends StatelessWidget {
164163
height: validSize,
165164
decoration: BoxDecoration(
166165
borderRadius: BorderRadius.circular(resolvedRadius),
167-
166+
168167
boxShadow: resolvedShadow != null && validSize > 60
169168
? [resolvedShadow]
170169
: null,
@@ -185,7 +184,7 @@ class AlbumArtwork extends StatelessWidget {
185184
artFile,
186185
key: ValueKey(coverArt),
187186
fit: BoxFit.contain,
188-
errorBuilder: (_, _, _) => _buildPlaceholder(isDark),
187+
errorBuilder: (ctx, err, stack) => _buildPlaceholder(isDark),
189188
);
190189
}
191190

@@ -205,8 +204,8 @@ class AlbumArtwork extends StatelessWidget {
205204
fadeInDuration: const Duration(milliseconds: 100),
206205
fadeOutDuration: Duration.zero,
207206
useOldImageOnUrlChange: true,
208-
placeholder: (_, _) => _buildPlaceholder(isDark),
209-
errorWidget: (_, _, _) => _buildPlaceholder(isDark),
207+
placeholder: (ctx, url) => _buildPlaceholder(isDark),
208+
errorWidget: (ctx, err, stack) => _buildPlaceholder(isDark),
210209
);
211210
},
212211
);
@@ -223,7 +222,7 @@ class AlbumArtwork extends StatelessWidget {
223222
fit: BoxFit.cover,
224223
cacheWidth: cacheSize,
225224
cacheHeight: cacheSize,
226-
errorBuilder: (_, _, _) => _buildPlaceholder(isDark),
225+
errorBuilder: (ctx, err, stack) => _buildPlaceholder(isDark),
227226
);
228227
}
229228

@@ -247,8 +246,8 @@ class AlbumArtwork extends StatelessWidget {
247246
fadeInDuration: const Duration(milliseconds: 100),
248247
fadeOutDuration: Duration.zero,
249248
useOldImageOnUrlChange: true,
250-
placeholder: (_, _) => _buildPlaceholder(isDark),
251-
errorWidget: (_, _, _) => _buildPlaceholder(isDark),
249+
placeholder: (ctx, url) => _buildPlaceholder(isDark),
250+
errorWidget: (ctx, err, stack) => _buildPlaceholder(isDark),
252251
);
253252
},
254253
);

lib/widgets/mini_player.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ class MiniPlayer extends StatelessWidget {
4141
if (isPlayingRadio && currentRadioStation != null) {
4242
title = currentRadioStation.name;
4343
subtitle = 'Internet Radio • LIVE';
44-
coverArt =
45-
null;
44+
coverArt = null;
4645
} else if (currentSong != null) {
4746
title = currentSong.title;
48-
subtitle = currentSong.artistParticipants != null &&
47+
subtitle =
48+
currentSong.artistParticipants != null &&
4949
currentSong.artistParticipants!.isNotEmpty
5050
? currentSong.artistParticipants!.map((a) => a.name).join(', ')
5151
: currentSong.artist;
@@ -128,8 +128,8 @@ class MiniPlayer extends StatelessWidget {
128128
children: [
129129
if (!isPlayingRadio)
130130
Selector<PlayerProvider, double>(
131-
selector: (_, p) => p.progress,
132-
builder: (_, progress, _) => LinearProgressIndicator(
131+
selector: (ctx, p) => p.progress,
132+
builder: (ctx, progress, __) => LinearProgressIndicator(
133133
value: progress,
134134
backgroundColor: Colors.transparent,
135135
valueColor: AlwaysStoppedAnimation<Color>(
@@ -272,7 +272,7 @@ class _MiniPlayerControls extends StatelessWidget {
272272
),
273273
color: color,
274274
),
275-
275+
276276
if (!isRadio)
277277
IconButton(
278278
onPressed: hasNext ? provider.skipNext : null,

lib/widgets/song_tile.dart

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ class SongTile extends StatelessWidget {
6363
title: Text(
6464
song.title,
6565
style: theme.textTheme.bodyLarge?.copyWith(
66-
color: isCurrentSong ? Theme.of(context).colorScheme.primary : null,
66+
color: isCurrentSong
67+
? Theme.of(context).colorScheme.primary
68+
: null,
6769
fontWeight: isCurrentSong ? FontWeight.w600 : FontWeight.normal,
6870
),
6971
maxLines: 1,
@@ -87,8 +89,8 @@ class SongTile extends StatelessWidget {
8789
child: Center(
8890
child: isCurrentSong
8991
? Selector<PlayerProvider, bool>(
90-
selector: (_, p) => p.isPlaying,
91-
builder: (_, isPlaying, _) => AnimatedEqualizer(
92+
selector: (ctx, p) => p.isPlaying,
93+
builder: (ctx, isPlaying, __) => AnimatedEqualizer(
9294
color: Theme.of(context).colorScheme.primary,
9395
isPlaying: isPlaying,
9496
),
@@ -119,8 +121,8 @@ class SongTile extends StatelessWidget {
119121
),
120122
child: Center(
121123
child: Selector<PlayerProvider, bool>(
122-
selector: (_, p) => p.isPlaying,
123-
builder: (_, isPlaying, _) => AnimatedEqualizer(
124+
selector: (ctx, p) => p.isPlaying,
125+
builder: (ctx, isPlaying, __) => AnimatedEqualizer(
124126
color: Colors.white,
125127
isPlaying: isPlaying,
126128
),
@@ -191,7 +193,9 @@ class SongTile extends StatelessWidget {
191193
child: Icon(
192194
CupertinoIcons.heart_fill,
193195
size: 14,
194-
color: Theme.of(context).colorScheme.primary.withValues(alpha: 0.7),
196+
color: Theme.of(
197+
context,
198+
).colorScheme.primary.withValues(alpha: 0.7),
195199
),
196200
),
197201
if (showDuration)
@@ -319,7 +323,9 @@ class _SongOptionsSheetState extends State<_SongOptionsSheet> {
319323
title: _isStarred
320324
? 'Remove from Liked Songs'
321325
: 'Add to Liked Songs',
322-
iconColor: _isStarred ? Theme.of(context).colorScheme.primary : null,
326+
iconColor: _isStarred
327+
? Theme.of(context).colorScheme.primary
328+
: null,
323329
onTap: () async {
324330
await _toggleFavorite(context);
325331
if (context.mounted) {
@@ -753,17 +759,17 @@ class _SongOptionsSheetState extends State<_SongOptionsSheet> {
753759

754760
final artistId = widget.song.artistId;
755761
if (artistId != null && artistId.isNotEmpty) {
756-
nav.push(MaterialPageRoute(
757-
builder: (_) => ArtistScreen(artistId: artistId),
758-
));
762+
nav.push(
763+
MaterialPageRoute(builder: (_) => ArtistScreen(artistId: artistId)),
764+
);
759765
}
760766
}
761767

762768
void _pushArtist(NavigatorState nav, ArtistRef artist) {
763769
if (artist.id.isNotEmpty) {
764-
nav.push(MaterialPageRoute(
765-
builder: (_) => ArtistScreen(artistId: artist.id),
766-
));
770+
nav.push(
771+
MaterialPageRoute(builder: (_) => ArtistScreen(artistId: artist.id)),
772+
);
767773
}
768774
}
769775

@@ -908,7 +914,10 @@ class _OptionTile extends StatelessWidget {
908914
@override
909915
Widget build(BuildContext context) {
910916
return ListTile(
911-
leading: Icon(icon, color: iconColor ?? Theme.of(context).colorScheme.primary),
917+
leading: Icon(
918+
icon,
919+
color: iconColor ?? Theme.of(context).colorScheme.primary,
920+
),
912921
title: Text(title),
913922
onTap: onTap,
914923
);

0 commit comments

Comments
 (0)