diff --git a/lib/api/audio/audioplayer_service.dart b/lib/api/audio/audioplayer_service.dart index d328e3d..ebaaeee 100644 --- a/lib/api/audio/audioplayer_service.dart +++ b/lib/api/audio/audioplayer_service.dart @@ -201,7 +201,9 @@ class AudioPlayerService { initialPosition: Duration.zero, ); + songNotifier.value = _songList[queuePast.length]; playerKey.currentState?.update(); + await _setColorScheme(); resume(); } } diff --git a/lib/widgets/player.dart b/lib/widgets/player.dart index 2f82d96..82fb545 100644 --- a/lib/widgets/player.dart +++ b/lib/widgets/player.dart @@ -10,11 +10,11 @@ import 'package:responsive_sizer/responsive_sizer.dart'; import 'package:shimmer/shimmer.dart'; import 'package:text_scroll/text_scroll.dart'; -/// The player widget +/// The player control widget /// /// Showcases the playing song's details and features playback controls class Player extends StatefulWidget { - /// The player widget + /// The player control widget /// /// Showcases the playing song's details and features playback controls const Player({super.key}); @@ -54,25 +54,25 @@ class PlayerState extends State { controller: s, child: Column( children: [ - AnimatedOpacity( - opacity: _showFullControls ? 0 : 1, - duration: const Duration(milliseconds: 300), - child: ClipRRect( - borderRadius: BorderRadius.circular(8), - child: GestureDetector( - onTap: () { - _sheetController.animateTo( - (_sheetController.size == 1) ? 0.1 : 1, - duration: const Duration(milliseconds: 300), - curve: Curves.easeIn, - ); - }, - child: Container( - color: Theme.of(context).colorScheme.primaryContainer, - height: 10.h, - width: 100.w, + ClipRRect( + borderRadius: BorderRadius.circular(8), + child: GestureDetector( + onTap: () { + _sheetController.animateTo( + (_sheetController.size == 1) ? 0.1 : 1, + duration: const Duration(milliseconds: 300), + curve: Curves.easeIn, + ); + }, + child: Container( + color: Theme.of(context).colorScheme.primaryContainer, + height: 10.h, + width: 100.w, + child: AnimatedOpacity( + opacity: _showFullControls ? 0 : 1, + duration: const Duration(milliseconds: 300), child: Padding( - padding: const EdgeInsets.all(8), + padding: const EdgeInsets.all(16), child: ValueListenableBuilder( valueListenable: songNotifier, builder: (c, t, w) { @@ -82,7 +82,7 @@ class PlayerState extends State { height: 10.h, width: 10.h, child: Padding( - padding: const EdgeInsets.all(8), + padding: const EdgeInsets.all(16), child: ClipRRect( child: (t == null) ? ColoredBox( @@ -224,18 +224,18 @@ class PlayerState extends State { width: 80.w, height: 80.w, child: ClipRRect( - // borderRadius: BorderRadius.circular(16), + borderRadius: BorderRadius.circular(16), child: (AudioPlayerService().song == null) ? ColoredBox( color: Theme.of(context) .colorScheme - .primaryContainer, + .secondaryContainer, child: Center( child: Icon( Icons.music_note, color: Theme.of(context) .colorScheme - .onPrimaryContainer, + .onSecondaryContainer, ), ), ) @@ -258,13 +258,13 @@ class PlayerState extends State { return ColoredBox( color: Theme.of(context) .colorScheme - .primaryContainer, + .secondaryContainer, child: Center( child: Icon( Icons.music_note, color: Theme.of(context) .colorScheme - .onPrimaryContainer, + .onSecondaryContainer, ), ), ); @@ -297,7 +297,7 @@ class PlayerState extends State { ), SizedBox( width: 70.w, - height: 50, + height: 30, child: AutoSizeText( AudioPlayerService().song?.artistName ?? "Nobody", style: TextStyle(fontSize: 16.sp), @@ -310,9 +310,6 @@ class PlayerState extends State { ), ), ), - const SizedBox( - height: 10, - ), SizedBox( width: 60.w, height: 40, @@ -342,6 +339,59 @@ class PlayerState extends State { ], ), ), + const SizedBox( + height: 10, + ), + SizedBox( + width: 60.w, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + IconButton( + onPressed: () { + AudioPlayerService().previous(); + }, + icon: const Icon( + Icons.skip_previous, + size: 36, + ), + ), + IconButton( + onPressed: () async { + if (AudioPlayerService().song == null) { + return; + } + if (AudioPlayerService().isPlaying) { + await AudioPlayerService().pause(); + } else { + AudioPlayerService().resume(); + } + setState(() {}); + }, + icon: AnimatedCrossFade( + firstChild: const Icon( + Icons.play_arrow, + size: 36, // TODO: adapt to display size + ), + secondChild: const Icon(Icons.pause, size: 36), + crossFadeState: (AudioPlayerService().isPlaying) + ? CrossFadeState.showSecond + : CrossFadeState.showFirst, + duration: const Duration(milliseconds: 300), + ), + ), + IconButton( + onPressed: () { + AudioPlayerService().next(); + }, + icon: const Icon( + Icons.skip_next, + size: 36, + ), + ), + ], + ), + ), ], ), ),