Skip to content

Commit

Permalink
accessibility improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaphasilor committed Oct 27, 2024
1 parent cd71e24 commit 7dfac7b
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 21 deletions.
26 changes: 20 additions & 6 deletions lib/components/AlbumScreen/track_list_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,15 @@ class TrackListItemTile extends StatelessWidget {
Widget build(BuildContext context) {
final bool secondRowNeeded = showArtists || showAlbum || showPlayCount;

final durationLabelFullHours =
(baseItem.runTimeTicksDuration()?.inHours ?? 0);
final durationLabelFullMinutes =
(baseItem.runTimeTicksDuration()?.inMinutes ?? 0) % 60;
final durationLabelSeconds =
(baseItem.runTimeTicksDuration()?.inSeconds ?? 0) % 60;
final durationLabelString =
"${durationLabelFullHours > 0 ? "$durationLabelFullHours ${AppLocalizations.of(context)!.hours} " : ""}${durationLabelFullMinutes > 0 ? "$durationLabelFullMinutes ${AppLocalizations.of(context)!.minutes} " : ""}$durationLabelSeconds ${AppLocalizations.of(context)!.seconds}";

return ListTileTheme(
tileColor: Theme.of(context).colorScheme.surfaceContainer,
child: ListTile(
Expand Down Expand Up @@ -829,17 +838,22 @@ class TrackListItemTile extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"${baseItem.runTimeTicksDuration()?.inMinutes.toString()}:${((baseItem.runTimeTicksDuration()?.inSeconds ?? 0) % 60).toString().padLeft(2, '0')}",
printDuration(baseItem.runTimeTicksDuration(),
leadingZeroes: false),
semanticsLabel: durationLabelString,
textAlign: TextAlign.end,
style: TextStyle(
color: Theme.of(context).textTheme.bodySmall?.color,
),
),
AddToPlaylistButton(
item: baseItem,
size: 24,
visualDensity: const VisualDensity(
horizontal: -4,
Semantics(
excludeSemantics: true,
child: AddToPlaylistButton(
item: baseItem,
size: 24,
visualDensity: const VisualDensity(
horizontal: -4,
),
),
),
if (allowReorder)
Expand Down
21 changes: 14 additions & 7 deletions lib/components/PlayerScreen/queue_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:finamp/components/AlbumScreen/track_list_tile.dart';
import 'package:finamp/components/AlbumScreen/song_menu.dart';
import 'package:finamp/components/Buttons/simple_button.dart';
import 'package:finamp/components/AddToPlaylistScreen/add_to_playlist_button.dart';
import 'package:finamp/components/print_duration.dart';
import 'package:finamp/main.dart';
import 'package:finamp/models/finamp_models.dart';
import 'package:finamp/screens/blurred_player_screen_background.dart';
Expand Down Expand Up @@ -1054,17 +1055,23 @@ class QueueSectionHeader extends StatelessWidget {
builder: (context, snapshot) {
if (snapshot.hasData) {
var remaining = snapshot.data!.remainingDuration;
var remainText = AppLocalizations.of(context)!
.remainingDuration(
remaining.inHours.toString(),
(remaining.inMinutes % 60)
.toString()
.padLeft(2, '0'));
var remainText = printDuration(remaining,
leadingZeroes: false);
final remainingLabelFullHours =
(remaining.inHours);
final remainingLabelFullMinutes =
(remaining.inMinutes) % 60;
final remainingLabelSeconds =
(remaining.inSeconds) % 60;
final remainingLabelString =
"${remainingLabelFullHours > 0 ? "$remainingLabelFullHours ${AppLocalizations.of(context)!.hours} " : ""}${remainingLabelFullMinutes > 0 ? "$remainingLabelFullMinutes ${AppLocalizations.of(context)!.minutes} " : ""}$remainingLabelSeconds ${AppLocalizations.of(context)!.seconds}";
return Padding(
padding: const EdgeInsets.only(
top: 4.0, right: 8.0),
child: Text(
"${snapshot.data!.currentTrackIndex} / ${snapshot.data!.trackCount} ($remainText)"));
"${snapshot.data!.currentTrackIndex} / ${snapshot.data!.trackCount} (${AppLocalizations.of(context)!.remainingDuration(remainText)})",
semanticsLabel:
"${AppLocalizations.of(context)!.trackCountTooltip(snapshot.data!.currentTrackIndex, snapshot.data!.trackCount)} (${AppLocalizations.of(context)!.remainingDuration(remainingLabelString)})"));
}
return const SizedBox.shrink();
}),
Expand Down
28 changes: 20 additions & 8 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,20 @@
"@timeFractionTooltip": {
"description": "Tooltip and accessibility label for the track progress. {currentTime} is the current position within the track, as a translated string like '2 minutes 40 seconds', and {totalTime} is the total duration of the track, also a translated string."
},
"trackCountTooltip": "Track {currentTrackIndex} of {totalTrackCount}",
"@trackCountTooltip": {
"description": "Tooltip and accessibility label for the queue progress. {currentTrackIndex} and {totalTrackCount} are both numbers",
"placeholders": {
"currentTrackIndex": {
"type": "int",
"example": "10"
},
"totalTrackCount": {
"type": "int",
"example": "13"
}
}
},
"invalidNumber": "Invalid Number",
"@invalidNumber": {},
"sleepTimerTooltip": "Sleep timer",
Expand Down Expand Up @@ -1552,17 +1566,15 @@
}
}
},
"remainingDuration": "{hoursRemaining, select, 0{} other{{hoursRemaining}h }}{minutesRemaining}m remaining",
"remainingDuration": "{duration} remaining",
"@remainingDuration": {
"description": "Displays duration of unplayed tracks. {duration} is a pre-formatted string.",
"placeholders": {
"hoursRemaining": {
"type": "String"
},
"minutesRemaining": {
"type": "String"
"duration": {
"type": "String",
"example": "36:23"
}
},
"description": "Displays duration of unplayed tracks"
}
},
"removeFromPlaylistConfirm": "Remove",
"removeFromPlaylistCancel": "Cancel",
Expand Down

0 comments on commit 7dfac7b

Please sign in to comment.