From 41ee0c45debc04383da46c1d49d01239a75ab80b Mon Sep 17 00:00:00 2001 From: Erdem Yerebasmaz Date: Mon, 13 May 2024 20:58:08 +0300 Subject: [PATCH] Display loader around Play/Pause button when buffering --- lib/routes/podcast/transport_controls.dart | 69 +++++++++++----------- pubspec.lock | 8 +-- pubspec.yaml | 4 +- 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/lib/routes/podcast/transport_controls.dart b/lib/routes/podcast/transport_controls.dart index c8f76a1d9..ed12054f0 100644 --- a/lib/routes/podcast/transport_controls.dart +++ b/lib/routes/podcast/transport_controls.dart @@ -199,46 +199,49 @@ class _PlayButton extends StatelessWidget { // in case we are buffering show progress indicator. final translations = L.of(context); - if (buffering) { - return Tooltip( + + return Stack( + alignment: AlignmentDirectional.center, + children: [ + if (buffering) + SpinKitRing( + lineWidth: 2.0, + color: themeData.colorScheme.secondary, + size: 84, + ), + if (!buffering) + const SizedBox( + height: 84, + width: 84, + ), + Tooltip( message: playing ? translations.pause_button_label : translations.play_button_label, child: TextButton( style: TextButton.styleFrom( - shape: const CircleBorder(), + shape: CircleBorder( + side: BorderSide(color: themeData.highlightColor, width: 0.0), + ), + backgroundColor: themeData.primaryColor, + padding: const EdgeInsets.all(8.0), ), - onPressed: null, - child: SpinKitRing( - lineWidth: 2.0, - color: themeData.colorScheme.secondary, - size: 60, + onPressed: buffering + ? null + : () { + if (playing) { + onPause(); + } else { + onPlay(); + } + }, + child: AnimatedIcon( + size: 60.0, + icon: AnimatedIcons.play_pause, + color: Colors.white, + progress: playPauseController, ), - )); - } - - return Tooltip( - message: playing ? translations.pause_button_label : translations.play_button_label, - child: TextButton( - style: TextButton.styleFrom( - shape: CircleBorder( - side: BorderSide(color: themeData.highlightColor, width: 0.0), ), - backgroundColor: themeData.primaryColor, - padding: const EdgeInsets.all(8.0), - ), - onPressed: () { - if (playing) { - onPause(); - } else { - onPlay(); - } - }, - child: AnimatedIcon( - size: 60.0, - icon: AnimatedIcons.play_pause, - color: Colors.white, - progress: playPauseController, ), - ), + ], ); } } diff --git a/pubspec.lock b/pubspec.lock index 99e131a27..307b3ee61 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -37,8 +37,8 @@ packages: dependency: "direct main" description: path: "." - ref: c30de552580d8e64233c4372a7e438b0550de64e - resolved-ref: c30de552580d8e64233c4372a7e438b0550de64e + ref: "7ae0038eb14e1ebaa1eb8a26ae144a795e0b787d" + resolved-ref: "7ae0038eb14e1ebaa1eb8a26ae144a795e0b787d" url: "https://github.com/breez/anytime_podcast_player.git" source: git version: "1.2.1+74-breez" @@ -2094,10 +2094,10 @@ packages: dependency: "direct main" description: name: webdav_client - sha256: b3f5afee27e7db5635817ddd79d57f56d43fdc6dad4c6bc93b0703261f96064c + sha256: "682fffc50b61dc0e8f46717171db03bf9caaa17347be41c0c91e297553bf86b2" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.2.2" webfeed: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 24b513c3b..b3e1be581 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -94,14 +94,14 @@ dependencies: url_launcher: <=6.1.11 # Requires Flutter 3.10 uuid: <=4.2.2 # Requires Flutter 3.10 validators: ^3.0.0 - webdav_client: ^1.2.1 + webdav_client: ^1.2.2 webview_flutter: <=4.4.2 # Requires Flutter 3.10 webview_flutter_android: <=3.12.1 # Requires Flutter 3.10 anytime: git: url: https://github.com/breez/anytime_podcast_player.git - ref: c30de552580d8e64233c4372a7e438b0550de64e + ref: 7ae0038eb14e1ebaa1eb8a26ae144a795e0b787d flutter_downloader: git: url: https://github.com/breez/flutter_downloader.git