Skip to content

Commit 1bcaed7

Browse files
committed
fix(song_bar): conditionally display menu items based on offline mode
1 parent 81c0ecd commit 1bcaed7

File tree

1 file changed

+65
-52
lines changed

1 file changed

+65
-52
lines changed

lib/widgets/song_bar.dart

Lines changed: 65 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import 'package:musify/extensions/l10n.dart';
2929
import 'package:musify/main.dart';
3030
import 'package:musify/services/common_services.dart';
3131
import 'package:musify/services/playlists_manager.dart';
32+
import 'package:musify/services/settings_manager.dart';
3233
import 'package:musify/utilities/common_variables.dart';
3334
import 'package:musify/utilities/flutter_toast.dart';
3435
import 'package:musify/utilities/formatter.dart';
@@ -422,7 +423,10 @@ class _SongBarState extends State<SongBar> {
422423
value: 'add_to_queue',
423424
child: Row(
424425
children: [
425-
Icon(FluentIcons.text_bullet_list_add_24_regular, color: colorScheme.primary),
426+
Icon(
427+
FluentIcons.text_bullet_list_add_24_regular,
428+
color: colorScheme.primary,
429+
),
426430
const SizedBox(width: 8),
427431
Text(
428432
addToQueueText,
@@ -431,24 +435,28 @@ class _SongBarState extends State<SongBar> {
431435
],
432436
),
433437
),
434-
PopupMenuItem<String>(
435-
value: 'like',
436-
child: ValueListenableBuilder<bool>(
437-
valueListenable: _songLikeStatus,
438-
builder: (_, value, __) {
439-
return Row(
440-
children: [
441-
Icon(likeStatusToIconMapper[value], color: colorScheme.primary),
442-
const SizedBox(width: 8),
443-
Text(
444-
value ? removeFromLikedSongsText : addToLikedSongsText,
445-
style: TextStyle(color: colorScheme.secondary),
446-
),
447-
],
448-
);
449-
},
438+
if (!offlineMode.value)
439+
PopupMenuItem<String>(
440+
value: 'like',
441+
child: ValueListenableBuilder<bool>(
442+
valueListenable: _songLikeStatus,
443+
builder: (_, value, __) {
444+
return Row(
445+
children: [
446+
Icon(
447+
likeStatusToIconMapper[value],
448+
color: colorScheme.primary,
449+
),
450+
const SizedBox(width: 8),
451+
Text(
452+
value ? removeFromLikedSongsText : addToLikedSongsText,
453+
style: TextStyle(color: colorScheme.secondary),
454+
),
455+
],
456+
);
457+
},
458+
),
450459
),
451-
),
452460
if (canRename)
453461
PopupMenuItem<String>(
454462
value: 'rename',
@@ -477,19 +485,23 @@ class _SongBarState extends State<SongBar> {
477485
],
478486
),
479487
),
480-
PopupMenuItem<String>(
481-
value: 'add_to_playlist',
482-
child: Row(
483-
children: [
484-
Icon(FluentIcons.album_add_24_regular, color: colorScheme.primary),
485-
const SizedBox(width: 8),
486-
Text(
487-
addToPlaylistText,
488-
style: TextStyle(color: colorScheme.secondary),
489-
),
490-
],
488+
if (!offlineMode.value)
489+
PopupMenuItem<String>(
490+
value: 'add_to_playlist',
491+
child: Row(
492+
children: [
493+
Icon(
494+
FluentIcons.album_add_24_regular,
495+
color: colorScheme.primary,
496+
),
497+
const SizedBox(width: 8),
498+
Text(
499+
addToPlaylistText,
500+
style: TextStyle(color: colorScheme.secondary),
501+
),
502+
],
503+
),
491504
),
492-
),
493505
if (widget.isRecentSong == true)
494506
PopupMenuItem<String>(
495507
value: 'remove_from_recents',
@@ -504,29 +516,30 @@ class _SongBarState extends State<SongBar> {
504516
],
505517
),
506518
),
507-
PopupMenuItem<String>(
508-
value: 'offline',
509-
child: ValueListenableBuilder<bool>(
510-
valueListenable: _songOfflineStatus,
511-
builder: (_, value, __) {
512-
return Row(
513-
children: [
514-
Icon(
515-
value
516-
? FluentIcons.cloud_off_24_filled
517-
: FluentIcons.cloud_arrow_down_24_regular,
518-
color: colorScheme.primary,
519-
),
520-
const SizedBox(width: 8),
521-
Text(
522-
value ? removeOfflineText : makeOfflineText,
523-
style: TextStyle(color: colorScheme.secondary),
524-
),
525-
],
526-
);
527-
},
519+
if (!offlineMode.value || _songOfflineStatus.value)
520+
PopupMenuItem<String>(
521+
value: 'offline',
522+
child: ValueListenableBuilder<bool>(
523+
valueListenable: _songOfflineStatus,
524+
builder: (_, value, __) {
525+
return Row(
526+
children: [
527+
Icon(
528+
value
529+
? FluentIcons.cloud_off_24_filled
530+
: FluentIcons.cloud_arrow_down_24_regular,
531+
color: colorScheme.primary,
532+
),
533+
const SizedBox(width: 8),
534+
Text(
535+
value ? removeOfflineText : makeOfflineText,
536+
style: TextStyle(color: colorScheme.secondary),
537+
),
538+
],
539+
);
540+
},
541+
),
528542
),
529-
),
530543
];
531544
}
532545
}

0 commit comments

Comments
 (0)