From 7b0bb2ff2de16600ad10284209cec793cbcab6ff Mon Sep 17 00:00:00 2001 From: Frederik Feichtmeier Date: Sun, 4 Feb 2024 10:35:15 +0100 Subject: [PATCH] fix Feature Request: Spacebar Starts and Stops Audio Playback (#489) Fixes #488 --- lib/src/app/app.dart | 74 ++++++++++++++++------------ lib/src/patch_notes/patch_notes.dart | 22 +++++++-- 2 files changed, 62 insertions(+), 34 deletions(-) diff --git a/lib/src/app/app.dart b/lib/src/app/app.dart index ff9a75369..1d544ae91 100644 --- a/lib/src/app/app.dart +++ b/lib/src/app/app.dart @@ -2,6 +2,7 @@ import 'dart:io'; import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; import 'package:ubuntu_service/ubuntu_service.dart'; import 'package:yaru_widgets/yaru_widgets.dart'; @@ -138,42 +139,53 @@ class _AppState extends State with WidgetsBindingObserver { // AppModel final isFullScreen = context.select((AppModel m) => m.fullScreen); - return Stack( - alignment: Alignment.center, - children: [ - Row( - children: [ - Expanded( - child: Column( - children: [ - Expanded( - child: MasterDetailPage( - countryCode: _countryCode, - ), - ), - if (!playerToTheRight) - const PlayerView( - playerViewMode: PlayerViewMode.bottom, + final playerModel = context.read(); + + return KeyboardListener( + focusNode: FocusNode(), + onKeyEvent: (value) { + if (value.runtimeType == KeyDownEvent && + value.logicalKey == LogicalKeyboardKey.space) { + playerModel.playOrPause(); + } + }, + child: Stack( + alignment: Alignment.center, + children: [ + Row( + children: [ + Expanded( + child: Column( + children: [ + Expanded( + child: MasterDetailPage( + countryCode: _countryCode, + ), ), - ], + if (!playerToTheRight) + const PlayerView( + playerViewMode: PlayerViewMode.bottom, + ), + ], + ), ), - ), - if (playerToTheRight) - const SizedBox( - width: kSideBarPlayerWidth, - child: PlayerView( - playerViewMode: PlayerViewMode.sideBar, + if (playerToTheRight) + const SizedBox( + width: kSideBarPlayerWidth, + child: PlayerView( + playerViewMode: PlayerViewMode.sideBar, + ), ), + ], + ), + if (isFullScreen == true) + const Scaffold( + body: PlayerView( + playerViewMode: PlayerViewMode.fullWindow, ), - ], - ), - if (isFullScreen == true) - const Scaffold( - body: PlayerView( - playerViewMode: PlayerViewMode.fullWindow, ), - ), - ], + ], + ), ); } } diff --git a/lib/src/patch_notes/patch_notes.dart b/lib/src/patch_notes/patch_notes.dart index e86ab5f46..f89b0791c 100644 --- a/lib/src/patch_notes/patch_notes.dart +++ b/lib/src/patch_notes/patch_notes.dart @@ -77,8 +77,24 @@ const kPatchNotes20240115 = 'Hello MusicPod Users ๐Ÿ’™๐Ÿง๐Ÿงก\n\n' '\n\nIf you like MusicPod please consider sponsoring me ๐Ÿ™:' '\n'; -const kRecentPatchNotesDisposed = kPatchNotes20240115disposed; -const kRecentPatchNotesTitle = kPatchNotesTitle20240115; -const kRecentPatchNotes = kPatchNotes20240115; +// 2024 02 04 +const kPatchNotes20240204disposed = 'patchNotes20240204disposed'; +const kPatchNotesTitle20240204 = 'Patch notes: 2024-02-04'; +const kPatchNotes20240204 = 'Hello MusicPod Users ๐Ÿ’™๐Ÿง๐Ÿงก\n' + '\n* albums now do not include a trailing space' + '\n* sadly this means you need to re-pin' + '\n your favorite albums again :(' + '\n* new settings dialog, in which you can' + '\n* change the theme' + '\n* switch to podcast index with your own api key/secret' + '\n* MusicPod can now be used to open any audio/video on your computer' + '\n* loading your local music at start now happens faster' + '\n* the space key now toggles between play and pause' + '\n\nIf you like MusicPod please consider sponsoring me ๐Ÿ™:' + '\n'; + +const kRecentPatchNotesDisposed = kPatchNotes20240204disposed; +const kRecentPatchNotesTitle = kPatchNotesTitle20240204; +const kRecentPatchNotes = kPatchNotes20240204; const kPatchNotesDisposed = 'kPatchNotesDisposed';