From 82116cffb8bb794ce87baaf4b124be092aef87be Mon Sep 17 00:00:00 2001 From: anandnet Date: Sun, 29 Sep 2024 10:37:56 +0530 Subject: [PATCH] Added Gesture on miniplayer, Album art image : next,prev --- lib/ui/home.dart | 247 +++++++++--------- lib/ui/player/components/albumart_lyrics.dart | 10 +- lib/ui/player/components/standard_player.dart | 7 +- 3 files changed, 136 insertions(+), 128 deletions(-) diff --git a/lib/ui/home.dart b/lib/ui/home.dart index 1cb76087..6eb1c7d1 100644 --- a/lib/ui/home.dart +++ b/lib/ui/home.dart @@ -39,137 +39,136 @@ class Home extends StatelessWidget { } } return PopScope( - canPop: false, - onPopInvokedWithResult: (didPop, result) async { - if (didPop) return; - if (playerController.playerPanelController.isPanelOpen) { - playerController.playerPanelController.close(); + canPop: false, + onPopInvokedWithResult: (didPop, result) async { + if (didPop) return; + if (playerController.playerPanelController.isPanelOpen) { + playerController.playerPanelController.close(); + } else { + if (Get.nestedKey(ScreenNavigationSetup.id)!.currentState!.canPop()) { + Get.nestedKey(ScreenNavigationSetup.id)!.currentState!.pop(); } else { - if (Get.nestedKey(ScreenNavigationSetup.id)! - .currentState! - .canPop()) { - Get.nestedKey(ScreenNavigationSetup.id)!.currentState!.pop(); + if (playerController.buttonState.value == PlayButtonState.playing) { + SystemNavigator.pop(); } else { - if (playerController.buttonState.value == - PlayButtonState.playing) { - SystemNavigator.pop(); - } else { - await Get.find().customAction("saveSession"); - exit(0); - } + await Get.find().customAction("saveSession"); + exit(0); } } + } + }, + child: CallbackShortcuts( + bindings: { + LogicalKeySet(LogicalKeyboardKey.space): playerController.playPause }, - child: CallbackShortcuts( - bindings: { - LogicalKeySet(LogicalKeyboardKey.space): - playerController.playPause - }, - child: Obx( - () => Scaffold( - bottomNavigationBar: settingsScreenController - .isBottomNavBarEnabled.isTrue - ? ScrollToHideWidget( - isVisible: - homeScreenController.isHomeSreenOnTop.isTrue && - playerController.isPanelGTHOpened.isFalse, - child: const BottomNavBar()) - : null, - key: playerController.homeScaffoldkey, - endDrawer: GetPlatform.isDesktop - ? Container( - constraints: const BoxConstraints(maxWidth: 600), - decoration: BoxDecoration( - borderRadius: const BorderRadius.only( - topLeft: Radius.circular(10)), - border: Border( - left: BorderSide( - color: - Theme.of(context).colorScheme.secondary), - top: BorderSide( - color: - Theme.of(context).colorScheme.secondary), - ), - ), - margin: const EdgeInsets.only( - top: 5, - bottom: 106, - ), - child: SizedBox( - child: Column( - children: [ - SizedBox( - height: 60, - child: ColoredBox( - color: Theme.of(context).canvasColor, - child: Center( - child: Padding( - padding: const EdgeInsets.only( - left: 15.0, right: 15), - child: Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Text( - "${playerController.currentQueue.length} ${"songs".tr}"), - Text( - "upNext".tr, - style: Theme.of(context) - .textTheme - .titleLarge, - ), - IconButton( - onPressed: () { - if (playerController - .isShuffleModeEnabled - .isTrue) { - ScaffoldMessenger.of(context) - .showSnackBar(snackbar( - context, - "queueShufflingDeniedMsg" - .tr, - size: SanckBarSize - .BIG)); - return; - } - playerController.shuffleQueue(); - }, - icon: const Icon(Icons.shuffle)) - ], + child: Obx( + () => Scaffold( + bottomNavigationBar: settingsScreenController + .isBottomNavBarEnabled.isTrue + ? ScrollToHideWidget( + isVisible: homeScreenController.isHomeSreenOnTop.isTrue && + playerController.isPanelGTHOpened.isFalse, + child: const BottomNavBar()) + : null, + key: playerController.homeScaffoldkey, + endDrawer: GetPlatform.isDesktop + ? Container( + constraints: const BoxConstraints(maxWidth: 600), + decoration: BoxDecoration( + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(10)), + border: Border( + left: BorderSide( + color: Theme.of(context).colorScheme.secondary), + top: BorderSide( + color: Theme.of(context).colorScheme.secondary), + ), + ), + margin: const EdgeInsets.only( + top: 5, + bottom: 106, + ), + child: SizedBox( + child: Column( + children: [ + SizedBox( + height: 60, + child: ColoredBox( + color: Theme.of(context).canvasColor, + child: Center( + child: Padding( + padding: const EdgeInsets.only( + left: 15.0, right: 15), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Text( + "${playerController.currentQueue.length} ${"songs".tr}"), + Text( + "upNext".tr, + style: Theme.of(context) + .textTheme + .titleLarge, ), - )), - ), - ), - const Expanded( - child: UpNextQueue( - isQueueInSlidePanel: false, + IconButton( + onPressed: () { + if (playerController + .isShuffleModeEnabled.isTrue) { + ScaffoldMessenger.of(context) + .showSnackBar(snackbar( + context, + "queueShufflingDeniedMsg" + .tr, + size: SanckBarSize.BIG)); + return; + } + playerController.shuffleQueue(); + }, + icon: const Icon(Icons.shuffle)) + ], ), - ), - ], + )), + ), + ), + const Expanded( + child: UpNextQueue( + isQueueInSlidePanel: false, + ), ), - ), - ) - : null, - drawerScrimColor: Colors.transparent, - body: Obx(() => SlidingUpPanel( - onPanelSlide: playerController.panellistener, - controller: playerController.playerPanelController, - minHeight: playerController.playerPanelMinHeight.value, - maxHeight: size.height, - isDraggable: !isWideScreen, - onSwipeUp: () { - playerController.queuePanelController.open(); - }, - panel: const Player(), - body: const ScreenNavigation(), - header: !isWideScreen - ? InkWell( - onTap: - playerController.playerPanelController.open, - child: const MiniPlayer(), - ) - : const MiniPlayer(), - ))), - ))); + ], + ), + ), + ) + : null, + drawerScrimColor: Colors.transparent, + body: Obx(() => SlidingUpPanel( + onPanelSlide: playerController.panellistener, + controller: playerController.playerPanelController, + minHeight: playerController.playerPanelMinHeight.value, + maxHeight: size.height, + isDraggable: !isWideScreen, + onSwipeUp: () { + playerController.queuePanelController.open(); + }, + panel: const Player(), + body: const ScreenNavigation(), + header: !isWideScreen + ? GestureDetector( + onTap: playerController.playerPanelController.open, + onHorizontalDragEnd: (DragEndDetails details) { + if (details.primaryVelocity! < 0) { + playerController.next(); + } else if (details.primaryVelocity! > 0) { + playerController.prev(); + } + }, + child: const MiniPlayer(), + ) + : const MiniPlayer(), + ))), + ), + ), + ); } } diff --git a/lib/ui/player/components/albumart_lyrics.dart b/lib/ui/player/components/albumart_lyrics.dart index 7b78fa21..ff008d8c 100644 --- a/lib/ui/player/components/albumart_lyrics.dart +++ b/lib/ui/player/components/albumart_lyrics.dart @@ -19,7 +19,7 @@ class AlbumArtNLyrics extends StatelessWidget { return Obx(() => playerController.currentSong.value != null ? Stack( children: [ - InkWell( + GestureDetector( onLongPress: () { showModalBottomSheet( constraints: const BoxConstraints(maxWidth: 500), @@ -40,6 +40,14 @@ class AlbumArtNLyrics extends StatelessWidget { onTap: () { playerController.showLyrics(); }, + onHorizontalDragEnd: (DragEndDetails details) { + if (playerController.showLyricsflag.isTrue) return; + if (details.primaryVelocity! < 0) { + playerController.next(); + } else if (details.primaryVelocity! > 0) { + playerController.prev(); + } + }, child: ImageWidget( size: playerArtImageSize, song: playerController.currentSong.value!, diff --git a/lib/ui/player/components/standard_player.dart b/lib/ui/player/components/standard_player.dart index d9ddfb83..ff933cd4 100644 --- a/lib/ui/player/components/standard_player.dart +++ b/lib/ui/player/components/standard_player.dart @@ -83,17 +83,18 @@ class StandardPlayer extends StatelessWidget { Align( alignment: Alignment.bottomCenter, child: Container( - height: 65 + Get.mediaQuery.padding.bottom + 150, + height: 65 + Get.mediaQuery.padding.bottom + 120, decoration: BoxDecoration( gradient: LinearGradient( colors: [ Theme.of(context).primaryColor, Theme.of(context).primaryColor, - Colors.transparent, + Theme.of(context).primaryColor.withOpacity(0.4), + Theme.of(context).primaryColor.withOpacity(0), ], begin: Alignment.bottomCenter, end: Alignment.topCenter, - stops: const [0, 0.4, 1], + stops: const [0, 0.5,0.8, 1], ), ), ),