@@ -3,13 +3,13 @@ import 'package:provider/provider.dart';
3
3
import 'package:yaru_widgets/yaru_widgets.dart' ;
4
4
5
5
import '../../build_context_x.dart' ;
6
+ import '../../common.dart' ;
6
7
import '../../data.dart' ;
7
8
import '../../library.dart' ;
8
9
import '../../player.dart' ;
9
10
import '../../radio.dart' ;
10
11
import '../../settings.dart' ;
11
12
import '../../theme.dart' ;
12
- import '../common/common_widgets.dart' ;
13
13
import '../globals.dart' ;
14
14
import '../l10n/l10n.dart' ;
15
15
import 'master_item.dart' ;
@@ -32,7 +32,9 @@ class MasterDetailPage extends StatelessWidget {
32
32
33
33
@override
34
34
Widget build (BuildContext context) {
35
- final startPlaylist = context.read <PlayerModel >().startPlaylist;
35
+ final playerModel = context.read <PlayerModel >();
36
+ final startPlaylist = playerModel.startPlaylist;
37
+ final pause = playerModel.pause;
36
38
37
39
return YaruMasterDetailTheme (
38
40
data: YaruMasterDetailTheme .of (context).copyWith (
@@ -64,19 +66,38 @@ class MasterDetailPage extends StatelessWidget {
64
66
if (index == 3 || index == 5 ) {
65
67
return item.titleBuilder (context);
66
68
}
69
+
70
+ final isEnQueued = context.select (
71
+ (PlayerModel m) =>
72
+ m.queueName != null && m.queueName == item.content? .$1,
73
+ );
74
+ final isPlaying = context.select (
75
+ (PlayerModel m) => m.isPlaying,
76
+ );
77
+
78
+ final onPlay = item.content? .$1 == null || item.content? .$2 == null
79
+ ? null
80
+ : () {
81
+ if (isEnQueued) {
82
+ isPlaying ? pause () : playerModel.resume ();
83
+ } else {
84
+ startPlaylist (
85
+ item.content! .$2,
86
+ item.content! .$1,
87
+ );
88
+ }
89
+ };
90
+
67
91
return Padding (
68
92
padding:
69
93
index == 0 ? const EdgeInsets .only (top: 5 ) : EdgeInsets .zero,
70
94
child: MasterTile (
95
+ iconData:
96
+ isPlaying && isEnQueued ? Iconz ().pause : Iconz ().playFilled,
71
97
selected: index == 4 ? false : selected,
72
98
title: item.titleBuilder (context),
73
99
subtitle: item.subtitleBuilder? .call (context),
74
- onPlay: item.content? .$1 == null || item.content? .$2 == null
75
- ? null
76
- : () => startPlaylist (
77
- item.content! .$2,
78
- item.content! .$1,
79
- ),
100
+ onPlay: onPlay,
80
101
leading: item.iconBuilder == null
81
102
? null
82
103
: Padding (
0 commit comments