mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-04-05 13:59:37 +00:00
refactor(accessibility): simplify label handling
This commit is contained in:
parent
53f58aeb8b
commit
72333b7794
2 changed files with 31 additions and 11 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue