@@ -48,6 +48,7 @@ class SongBar extends StatefulWidget {
4848 this .borderRadius = BorderRadius .zero,
4949 this .isFromLikedSongs = false ,
5050 this .showQueueActions = true ,
51+ this .showPlayTime = false ,
5152 this .playlistId,
5253 this .onRenamed,
5354 super .key,
@@ -60,6 +61,7 @@ class SongBar extends StatefulWidget {
6061 final VoidCallback ? onPlay;
6162 final bool ? isRecentSong;
6263 final bool showMusicDuration;
64+ final bool showPlayTime;
6365 final BorderRadius borderRadius;
6466 final bool isFromLikedSongs;
6567 final bool showQueueActions;
@@ -127,6 +129,12 @@ class _SongBarState extends State<SongBar> {
127129 @override
128130 Widget build (BuildContext context) {
129131 final colorScheme = Theme .of (context).colorScheme;
132+ final _plays = widget.showPlayTime
133+ ? (widget.song['listeningCount' ] is int )
134+ ? widget.song['listeningCount' ] as int
135+ : int .tryParse (widget.song['listeningCount' ]? .toString () ?? '' ) ??
136+ 0
137+ : null ;
130138
131139 return Padding (
132140 padding: commonBarPadding,
@@ -147,6 +155,7 @@ class _SongBarState extends State<SongBar> {
147155 child: _SongInfo (
148156 title: _songTitle,
149157 artist: _songArtist,
158+ plays: _plays,
150159 colorScheme: colorScheme,
151160 ),
152161 ),
@@ -526,11 +535,13 @@ class _SongInfo extends StatelessWidget {
526535 const _SongInfo ({
527536 required this .title,
528537 required this .artist,
538+ this .plays,
529539 required this .colorScheme,
530540 });
531541
532542 final String title;
533543 final String artist;
544+ final int ? plays;
534545 final ColorScheme colorScheme;
535546
536547 @override
@@ -548,14 +559,46 @@ class _SongInfo extends StatelessWidget {
548559 ),
549560 ),
550561 const SizedBox (height: 2 ),
551- Text (
552- artist,
553- overflow: TextOverflow .ellipsis,
554- style: TextStyle (
555- fontWeight: FontWeight .w400,
556- fontSize: 13 ,
557- color: colorScheme.onSurfaceVariant,
558- ),
562+ Row (
563+ children: [
564+ Flexible (
565+ child: Text (
566+ artist,
567+ overflow: TextOverflow .ellipsis,
568+ style: TextStyle (
569+ fontWeight: FontWeight .w400,
570+ fontSize: 13 ,
571+ color: colorScheme.onSurfaceVariant,
572+ ),
573+ ),
574+ ),
575+ if (plays != null && plays! > 0 ) ...[
576+ Padding (
577+ padding: const EdgeInsets .symmetric (horizontal: 4 ),
578+ child: Text (
579+ '•' ,
580+ style: TextStyle (
581+ fontSize: 13 ,
582+ color: colorScheme.onSurfaceVariant,
583+ ),
584+ ),
585+ ),
586+ Icon (
587+ FluentIcons .headphones_20_regular,
588+ size: 12 ,
589+ color: colorScheme.primary,
590+ ),
591+ const SizedBox (width: 3 ),
592+ Text (
593+ '$plays ' ,
594+ style: TextStyle (
595+ fontSize: 12 ,
596+ fontWeight: FontWeight .w600,
597+ color: colorScheme.primary,
598+ ),
599+ ),
600+ ],
601+ ],
559602 ),
560603 ],
561604 );
0 commit comments