Skip to content

Commit 901cdf0

Browse files
authored
chore: control panel follows (#1454)
1 parent e448c39 commit 901cdf0

4 files changed

Lines changed: 238 additions & 178 deletions

File tree

lib/app/view/main_page_icon.dart

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,17 @@ class MainPageIcon extends StatelessWidget with WatchItMixin {
3030
final useMoreAnimations = watchPropertyValue(
3131
(SettingsModel m) => m.useMoreAnimations,
3232
);
33-
final isLocalAudioImporting = watchValue(
34-
(LocalAudioModel m) => m.initAudiosCommand.isRunning,
35-
);
3633

37-
if (isLocalAudioImporting && audioType == AudioType.local) {
38-
return Padding(
39-
padding: mainPageIconPadding,
40-
child: const SizedBox(
41-
width: 16,
42-
height: 16,
43-
child: Progress(strokeWidth: 2),
44-
),
34+
if (audioType == AudioType.local) {
35+
return LocalMainPageIcon(
36+
isCurrentlyPlaying: currentAudioType == AudioType.local,
37+
selected: selected,
38+
isPlaying: isPlaying,
39+
useMoreAnimations: useMoreAnimations,
4540
);
46-
} else if (currentAudioType == audioType) {
41+
}
42+
43+
if (currentAudioType == audioType) {
4744
if (isPlaying) {
4845
if (useMoreAnimations) {
4946
return const ActiveAudioSignalIndicator(thickness: 2);
@@ -66,3 +63,48 @@ class MainPageIcon extends StatelessWidget with WatchItMixin {
6663
);
6764
}
6865
}
66+
67+
class LocalMainPageIcon extends StatelessWidget with WatchItMixin {
68+
const LocalMainPageIcon({
69+
super.key,
70+
required this.selected,
71+
required this.isPlaying,
72+
required this.useMoreAnimations,
73+
required this.isCurrentlyPlaying,
74+
});
75+
76+
final bool selected;
77+
final bool isPlaying;
78+
final bool useMoreAnimations;
79+
final bool isCurrentlyPlaying;
80+
81+
@override
82+
Widget build(BuildContext context) {
83+
final isLocalAudioImporting = watchValue(
84+
(LocalAudioModel m) => m.initAudiosCommand.isRunning,
85+
);
86+
87+
if (isLocalAudioImporting)
88+
return Padding(
89+
padding: mainPageIconPadding,
90+
child: const SizedBox(
91+
width: 16,
92+
height: 16,
93+
child: Progress(strokeWidth: 2),
94+
),
95+
);
96+
97+
if (useMoreAnimations && isCurrentlyPlaying && isPlaying) {
98+
return const ActiveAudioSignalIndicator(thickness: 2);
99+
}
100+
101+
return Padding(
102+
padding: mainPageIconPadding,
103+
child: Icon(
104+
selected
105+
? AudioType.local.selectedIconDataMainPage
106+
: AudioType.local.iconDataMainPage,
107+
),
108+
);
109+
}
110+
}

lib/player/register_audio_service_handler.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ import 'player_service.dart';
1212
Future<AudioServiceHandler> registerAudioServiceHandler() async {
1313
final playerService = di<PlayerService>();
1414
final audioHandler = await AudioService.init(
15-
config: AudioServiceConfig(
15+
config: const AudioServiceConfig(
1616
androidNotificationOngoing: false,
1717
androidStopForegroundOnPause: false,
1818
androidNotificationChannelName: AppConfig.appName,
19-
androidNotificationChannelId: isAndroid || isWindows
20-
? AppConfig.androidChannelId
21-
: null,
19+
androidNotificationChannelId: AppConfig.androidChannelId,
2220
androidNotificationChannelDescription: 'MusicPod Media Controls',
2321
),
2422
builder: () => AudioServiceHandler(

0 commit comments

Comments
 (0)