diff --git a/lib/features/sleep_timer/view/sleep_timer_button.dart b/lib/features/sleep_timer/view/sleep_timer_button.dart index 825e955..0367c5a 100644 --- a/lib/features/sleep_timer/view/sleep_timer_button.dart +++ b/lib/features/sleep_timer/view/sleep_timer_button.dart @@ -15,6 +15,8 @@ import 'package:vaani/shared/extensions/duration_format.dart'; class SleepTimerButton extends HookConsumerWidget { const SleepTimerButton({super.key}); + static const _sleepTimerLabel = 'Sleep timer'; + @override Widget build(BuildContext context, WidgetRef ref) { final sleepTimer = ref.watch(sleepTimerProvider); @@ -23,10 +25,10 @@ class SleepTimerButton extends HookConsumerWidget { // if sleep timer is not active, show the button with the sleep timer icon // if the sleep timer is active, show the remaining time in a pill shaped container return Tooltip( - message: 'Sleep Timer', + message: _sleepTimerLabel, child: Semantics( button: true, - label: 'Sleep timer', + label: _sleepTimerLabel, child: InkWell( onTap: () async { appLogger.fine('Sleep Timer button pressed'); diff --git a/lib/shared/widgets/shelves/book_shelf.dart b/lib/shared/widgets/shelves/book_shelf.dart index e3da74f..892a80a 100644 --- a/lib/shared/widgets/shelves/book_shelf.dart +++ b/lib/shared/widgets/shelves/book_shelf.dart @@ -206,6 +206,27 @@ class _BookOnShelfPlayButton extends HookConsumerWidget { /// the id of the library item of the book final String libraryItemId; + String getPlayTooltip({ + required bool isCurrentBookSetInPlayer, + required bool isPlayingThisBook, + required bool isBookCompleted, + required bool hasProgress, + }) { + if (isCurrentBookSetInPlayer) { + return isPlayingThisBook ? 'Pause' : 'Resume'; + } + + if (isBookCompleted) { + return 'Listen again'; + } + + if (hasProgress) { + return 'Continue listening'; + } + + return 'Start listening'; + } + @override Widget build(BuildContext context, WidgetRef ref) { final me = ref.watch(meProvider); @@ -218,15 +239,12 @@ class _BookOnShelfPlayButton extends HookConsumerWidget { (element) => element.libraryItemId == libraryItemId, ); final isBookCompleted = userProgress?.isFinished ?? false; - final playTooltip = isCurrentBookSetInPlayer - ? isPlayingThisBook - ? 'Pause' - : 'Resume' - : isBookCompleted - ? 'Listen again' - : userProgress?.progress != null - ? 'Continue listening' - : 'Start listening'; + final playTooltip = getPlayTooltip( + isCurrentBookSetInPlayer: isCurrentBookSetInPlayer, + isPlayingThisBook: isPlayingThisBook, + isBookCompleted: isBookCompleted, + hasProgress: userProgress?.progress != null, + ); const size = 40.0;