From f21d9d2e09f9e21859123e40f445306c5ba7052f Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 11 Mar 2026 14:36:21 +0000 Subject: [PATCH] feat(ui): add Tooltip to custom icon interactive widgets for accessibility Added `Tooltip` to `InkWell` in `QbSpeedIndicator` and `GestureDetector` in `TorrentListItem` tags expander to provide label texts for screen readers and hover texts for desktop/web. Co-authored-by: JustLookAtNow <12379683+JustLookAtNow@users.noreply.github.com> --- lib/widgets/qb_speed_indicator.dart | 75 +++++++++++++++-------------- lib/widgets/torrent_list_item.dart | 41 ++++++++-------- 2 files changed, 61 insertions(+), 55 deletions(-) diff --git a/lib/widgets/qb_speed_indicator.dart b/lib/widgets/qb_speed_indicator.dart index a47cbde..d8fd593 100644 --- a/lib/widgets/qb_speed_indicator.dart +++ b/lib/widgets/qb_speed_indicator.dart @@ -169,48 +169,51 @@ class _QbSpeedIndicatorState extends State { } final info = _info!; final serverState = _serverState!; - return InkWell( - onTap: _openDownloader, - borderRadius: BorderRadius.circular(8), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.cloud_download, - size: 16, - color: Theme.of(context).brightness == Brightness.light - ? Theme.of(context).colorScheme.onPrimary - : Theme.of(context).colorScheme.onSurface, - ), - const SizedBox(width: 4), - Text( - '↑${Formatters.speedFromBytesPerSec(info.upSpeed)} ↓${Formatters.speedFromBytesPerSec(info.dlSpeed)}', - style: Theme.of(context).textTheme.bodySmall?.copyWith( + return Tooltip( + message: '打开下载器', + child: InkWell( + onTap: _openDownloader, + borderRadius: BorderRadius.circular(8), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + Icons.cloud_download, + size: 16, color: Theme.of(context).brightness == Brightness.light ? Theme.of(context).colorScheme.onPrimary : Theme.of(context).colorScheme.onSurface, ), + const SizedBox(width: 4), + Text( + '↑${Formatters.speedFromBytesPerSec(info.upSpeed)} ↓${Formatters.speedFromBytesPerSec(info.dlSpeed)}', + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).brightness == Brightness.light + ? Theme.of(context).colorScheme.onPrimary + : Theme.of(context).colorScheme.onSurface, + ), + ), + ], + ), + const SizedBox(height: 2), + Text( + '剩余空间: ${Formatters.dataFromBytes(serverState.freeSpaceOnDisk)}', + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: + (Theme.of(context).brightness == Brightness.light + ? Theme.of(context).colorScheme.onPrimary + : Theme.of(context).colorScheme.onSurface) + .withValues(alpha: 0.8), ), - ], - ), - const SizedBox(height: 2), - Text( - '剩余空间: ${Formatters.dataFromBytes(serverState.freeSpaceOnDisk)}', - style: Theme.of(context).textTheme.bodySmall?.copyWith( - color: - (Theme.of(context).brightness == Brightness.light - ? Theme.of(context).colorScheme.onPrimary - : Theme.of(context).colorScheme.onSurface) - .withValues(alpha: 0.8), ), - ), - ], + ], + ), ), ), ); diff --git a/lib/widgets/torrent_list_item.dart b/lib/widgets/torrent_list_item.dart index c1799d5..46746bf 100644 --- a/lib/widgets/torrent_list_item.dart +++ b/lib/widgets/torrent_list_item.dart @@ -1151,25 +1151,28 @@ class _TagsViewState extends State<_TagsView> { ), if (_overflow && !ScreenUtils.isLargeScreen(context)) ...[ const SizedBox(width: 8), - GestureDetector( - onTap: () { - setState(() { - _expanded = true; - }); - }, - child: Container( - padding: const EdgeInsets.symmetric( - horizontal: 4, - vertical: 1, - ), - decoration: BoxDecoration( - color: Theme.of(context).colorScheme.primary, - borderRadius: BorderRadius.circular(3), - ), - child: const Icon( - Icons.keyboard_arrow_down, - size: 12, - color: Colors.white, + Tooltip( + message: '展开标签', + child: GestureDetector( + onTap: () { + setState(() { + _expanded = true; + }); + }, + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 4, + vertical: 1, + ), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.primary, + borderRadius: BorderRadius.circular(3), + ), + child: const Icon( + Icons.keyboard_arrow_down, + size: 12, + color: Colors.white, + ), ), ), ),