Skip to content

Commit

Permalink
Added Gesture on miniplayer, Album art image : next,prev
Browse files Browse the repository at this point in the history
  • Loading branch information
anandnet committed Sep 29, 2024
1 parent 70fbe67 commit 82116cf
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 128 deletions.
247 changes: 123 additions & 124 deletions lib/ui/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<AudioHandler>().customAction("saveSession");
exit(0);
}
await Get.find<AudioHandler>().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(),
))),
),
),
);
}
}
10 changes: 9 additions & 1 deletion lib/ui/player/components/albumart_lyrics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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!,
Expand Down
7 changes: 4 additions & 3 deletions lib/ui/player/components/standard_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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],
),
),
),
Expand Down

0 comments on commit 82116cf

Please sign in to comment.