Skip to content

Commit

Permalink
Add semantic label to all overflow/popup buttons (#1705)
Browse files Browse the repository at this point in the history
  • Loading branch information
micahmo authored Feb 19, 2025
1 parent a57dec8 commit a32d5a0
Show file tree
Hide file tree
Showing 9 changed files with 327 additions and 290 deletions.
65 changes: 34 additions & 31 deletions lib/account/widgets/account_page_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,37 +175,40 @@ class AccountAppBarUserActions extends StatelessWidget {
);
},
),
PopupMenuButton(
onOpened: () => HapticFeedback.mediumImpact(),
itemBuilder: (context) => [
ThunderPopupMenuItem(
icon: Icons.sort,
title: l10n.sortBy,
onTap: () {
showModalBottomSheet<void>(
showDragHandle: true,
context: context,
isScrollControlled: true,
builder: (builderContext) => SortPicker(
title: l10n.sortOptions,
onSelect: (selected) async => feedBloc.add(FeedChangeSortTypeEvent(selected.payload)),
previouslySelected: feedBloc.state.sortType,
minimumVersion: LemmyClient.instance.version,
),
);
},
),
ThunderPopupMenuItem(
icon: Icons.refresh_rounded,
title: l10n.refresh,
onTap: () => triggerRefresh(context),
),
ThunderPopupMenuItem(
icon: Icons.share_rounded,
title: l10n.share,
onTap: () => showUserShareSheet(context, feedBloc.state.fullPersonView!.personView),
),
],
Semantics(
label: l10n.menu,
child: PopupMenuButton(
onOpened: () => HapticFeedback.mediumImpact(),
itemBuilder: (context) => [
ThunderPopupMenuItem(
icon: Icons.sort,
title: l10n.sortBy,
onTap: () {
showModalBottomSheet<void>(
showDragHandle: true,
context: context,
isScrollControlled: true,
builder: (builderContext) => SortPicker(
title: l10n.sortOptions,
onSelect: (selected) async => feedBloc.add(FeedChangeSortTypeEvent(selected.payload)),
previouslySelected: feedBloc.state.sortType,
minimumVersion: LemmyClient.instance.version,
),
);
},
),
ThunderPopupMenuItem(
icon: Icons.refresh_rounded,
title: l10n.refresh,
onTap: () => triggerRefresh(context),
),
ThunderPopupMenuItem(
icon: Icons.share_rounded,
title: l10n.share,
onTap: () => showUserShareSheet(context, feedBloc.state.fullPersonView!.personView),
),
],
),
),
],
);
Expand Down
165 changes: 87 additions & 78 deletions lib/feed/widgets/feed_page_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -215,67 +215,70 @@ class FeedAppBarCommunityActions extends StatelessWidget {
);
},
),
PopupMenuButton(
itemBuilder: (context) => [
ThunderPopupMenuItem(
onTap: () => triggerRefresh(context),
icon: Icons.refresh_rounded,
title: l10n.refresh,
),
if (_getSubscriptionStatus(context) == SubscribedType.subscribed)
Semantics(
label: l10n.menu,
child: PopupMenuButton(
itemBuilder: (context) => [
ThunderPopupMenuItem(
onTap: () async {
final Community community = context.read<FeedBloc>().state.fullCommunityView!.communityView.community;
bool isFavorite = _getFavoriteStatus(context);
await toggleFavoriteCommunity(context, community, isFavorite);
},
icon: _getFavoriteStatus(context) ? Icons.star_rounded : Icons.star_border_rounded,
title: _getFavoriteStatus(context) ? l10n.removeFromFavorites : l10n.addToFavorites,
),
if (feedBloc.state.fullCommunityView?.communityView.community.actorId != null)
ThunderPopupMenuItem(
onTap: () => showCommunityShareSheet(context, feedBloc.state.fullCommunityView!.communityView),
icon: Icons.share_rounded,
title: l10n.share,
onTap: () => triggerRefresh(context),
icon: Icons.refresh_rounded,
title: l10n.refresh,
),
if (feedBloc.state.fullCommunityView?.communityView != null)
if (_getSubscriptionStatus(context) == SubscribedType.subscribed)
ThunderPopupMenuItem(
onTap: () async {
final Community community = context.read<FeedBloc>().state.fullCommunityView!.communityView.community;
bool isFavorite = _getFavoriteStatus(context);
await toggleFavoriteCommunity(context, community, isFavorite);
},
icon: _getFavoriteStatus(context) ? Icons.star_rounded : Icons.star_border_rounded,
title: _getFavoriteStatus(context) ? l10n.removeFromFavorites : l10n.addToFavorites,
),
if (feedBloc.state.fullCommunityView?.communityView.community.actorId != null)
ThunderPopupMenuItem(
onTap: () => showCommunityShareSheet(context, feedBloc.state.fullCommunityView!.communityView),
icon: Icons.share_rounded,
title: l10n.share,
),
if (feedBloc.state.fullCommunityView?.communityView != null)
ThunderPopupMenuItem(
onTap: () async {
final ThunderState state = context.read<ThunderBloc>().state;
final bool reduceAnimations = state.reduceAnimations;
final SearchBloc searchBloc = SearchBloc();

await Navigator.of(context).push(
SwipeablePageRoute(
transitionDuration: reduceAnimations ? const Duration(milliseconds: 100) : null,
backGestureDetectionWidth: 45,
canOnlySwipeFromEdge: true,
builder: (context) => MultiBlocProvider(
providers: [
// Create a new SearchBloc so it doesn't conflict with the main one
BlocProvider.value(value: searchBloc),
BlocProvider.value(value: thunderBloc),
],
child: SearchPage(communityToSearch: feedBloc.state.fullCommunityView!.communityView, isInitiallyFocused: true),
),
),
);
},
icon: Icons.search_rounded,
title: l10n.search,
),
ThunderPopupMenuItem(
onTap: () async {
final ThunderState state = context.read<ThunderBloc>().state;
final bool reduceAnimations = state.reduceAnimations;
final SearchBloc searchBloc = SearchBloc();

await Navigator.of(context).push(
SwipeablePageRoute(
transitionDuration: reduceAnimations ? const Duration(milliseconds: 100) : null,
backGestureDetectionWidth: 45,
canOnlySwipeFromEdge: true,
builder: (context) => MultiBlocProvider(
providers: [
// Create a new SearchBloc so it doesn't conflict with the main one
BlocProvider.value(value: searchBloc),
BlocProvider.value(value: thunderBloc),
],
child: SearchPage(communityToSearch: feedBloc.state.fullCommunityView!.communityView, isInitiallyFocused: true),
),
),
await navigateToModlogPage(
context,
feedBloc: feedBloc,
communityId: feedBloc.state.fullCommunityView!.communityView.community.id,
);
},
icon: Icons.search_rounded,
title: l10n.search,
icon: Icons.shield_rounded,
title: l10n.modlog,
),
ThunderPopupMenuItem(
onTap: () async {
await navigateToModlogPage(
context,
feedBloc: feedBloc,
communityId: feedBloc.state.fullCommunityView!.communityView.community.id,
);
},
icon: Icons.shield_rounded,
title: l10n.modlog,
),
],
],
),
),
],
);
Expand Down Expand Up @@ -311,20 +314,23 @@ class FeedAppBarUserActions extends StatelessWidget {
);
},
),
PopupMenuButton(
itemBuilder: (context) => [
ThunderPopupMenuItem(
onTap: () => triggerRefresh(context),
icon: Icons.refresh_rounded,
title: l10n.refresh,
),
if (feedBloc.state.fullPersonView?.personView.person.actorId != null)
Semantics(
label: l10n.menu,
child: PopupMenuButton(
itemBuilder: (context) => [
ThunderPopupMenuItem(
onTap: () => showUserShareSheet(context, feedBloc.state.fullPersonView!.personView),
icon: Icons.share_rounded,
title: l10n.share,
onTap: () => triggerRefresh(context),
icon: Icons.refresh_rounded,
title: l10n.refresh,
),
],
if (feedBloc.state.fullPersonView?.personView.person.actorId != null)
ThunderPopupMenuItem(
onTap: () => showUserShareSheet(context, feedBloc.state.fullPersonView!.personView),
icon: Icons.share_rounded,
title: l10n.share,
),
],
),
),
],
);
Expand Down Expand Up @@ -367,18 +373,21 @@ class FeedAppBarGeneralActions extends StatelessWidget {
);
},
),
PopupMenuButton(
onOpened: () => HapticFeedback.mediumImpact(),
itemBuilder: (context) => [
ThunderPopupMenuItem(
onTap: () async {
HapticFeedback.mediumImpact();
await navigateToModlogPage(context, feedBloc: feedBloc);
},
icon: Icons.shield_rounded,
title: l10n.modlog,
),
],
Semantics(
label: l10n.menu,
child: PopupMenuButton(
onOpened: () => HapticFeedback.mediumImpact(),
itemBuilder: (context) => [
ThunderPopupMenuItem(
onTap: () async {
HapticFeedback.mediumImpact();
await navigateToModlogPage(context, feedBloc: feedBloc);
},
icon: Icons.shield_rounded,
title: l10n.modlog,
),
],
),
),
],
);
Expand Down
67 changes: 35 additions & 32 deletions lib/inbox/pages/inbox_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,38 +136,41 @@ class _InboxPageState extends State<InboxPage> with SingleTickerProviderStateMix
onPressed: () => context.read<InboxBloc>().add(GetInboxEvent(inboxType: inboxType, reset: true, showAll: showAll)),
),
IconButton(onPressed: () => showSortBottomSheet(), icon: Icon(Icons.sort, semanticLabel: l10n.sortBy)),
PopupMenuButton(
onOpened: () => HapticFeedback.mediumImpact(),
itemBuilder: (context) => [
ThunderPopupMenuItem(
onTap: () async {
HapticFeedback.mediumImpact();
await showThunderDialog<bool>(
context: context,
title: l10n.confirmMarkAllAsReadTitle,
contentText: l10n.confirmMarkAllAsReadBody,
onSecondaryButtonPressed: (dialogContext) => Navigator.of(dialogContext).pop(),
secondaryButtonText: l10n.cancel,
onPrimaryButtonPressed: (dialogContext, _) {
Navigator.of(dialogContext).pop();
context.read<InboxBloc>().add(MarkAllAsReadEvent());
},
primaryButtonText: l10n.markAllAsRead,
);
},
icon: Icons.checklist,
title: l10n.markAllAsRead,
),
ThunderPopupMenuItem(
onTap: () async {
HapticFeedback.mediumImpact();
context.read<InboxBloc>().add(GetInboxEvent(inboxType: inboxType, reset: true, showAll: !showAll));
setState(() => showAll = !showAll);
},
icon: showAll ? Icons.mark_as_unread : Icons.all_inbox_rounded,
title: showAll ? l10n.showUnreadOnly : l10n.showAll,
),
],
Semantics(
label: l10n.menu,
child: PopupMenuButton(
onOpened: () => HapticFeedback.mediumImpact(),
itemBuilder: (context) => [
ThunderPopupMenuItem(
onTap: () async {
HapticFeedback.mediumImpact();
await showThunderDialog<bool>(
context: context,
title: l10n.confirmMarkAllAsReadTitle,
contentText: l10n.confirmMarkAllAsReadBody,
onSecondaryButtonPressed: (dialogContext) => Navigator.of(dialogContext).pop(),
secondaryButtonText: l10n.cancel,
onPrimaryButtonPressed: (dialogContext, _) {
Navigator.of(dialogContext).pop();
context.read<InboxBloc>().add(MarkAllAsReadEvent());
},
primaryButtonText: l10n.markAllAsRead,
);
},
icon: Icons.checklist,
title: l10n.markAllAsRead,
),
ThunderPopupMenuItem(
onTap: () async {
HapticFeedback.mediumImpact();
context.read<InboxBloc>().add(GetInboxEvent(inboxType: inboxType, reset: true, showAll: !showAll));
setState(() => showAll = !showAll);
},
icon: showAll ? Icons.mark_as_unread : Icons.all_inbox_rounded,
title: showAll ? l10n.showUnreadOnly : l10n.showAll,
),
],
),
),
],
bottom: TabBar(
Expand Down
43 changes: 23 additions & 20 deletions lib/instance/pages/instance_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,28 +181,31 @@ class _InstancePageState extends State<InstancePage> {
);
},
),
PopupMenuButton(
itemBuilder: (context) => [
ThunderPopupMenuItem(
onTap: () async {
HapticFeedback.mediumImpact();
FeedBloc feedBloc = context.read<FeedBloc>();
navigateToModlogPage(
context,
feedBloc: feedBloc,
lemmyClient: feedBloc.lemmyClient,
);
},
icon: Icons.shield_rounded,
title: l10n.modlog,
),
if (viewType != SearchType.all)
Semantics(
label: l10n.menu,
child: PopupMenuButton(
itemBuilder: (context) => [
ThunderPopupMenuItem(
onTap: () => handleLink(context, url: widget.getSiteResponse.siteView.site.actorId),
icon: Icons.open_in_browser_rounded,
title: l10n.openInBrowser,
onTap: () async {
HapticFeedback.mediumImpact();
FeedBloc feedBloc = context.read<FeedBloc>();
navigateToModlogPage(
context,
feedBloc: feedBloc,
lemmyClient: feedBloc.lemmyClient,
);
},
icon: Icons.shield_rounded,
title: l10n.modlog,
),
],
if (viewType != SearchType.all)
ThunderPopupMenuItem(
onTap: () => handleLink(context, url: widget.getSiteResponse.siteView.site.actorId),
icon: Icons.open_in_browser_rounded,
title: l10n.openInBrowser,
),
],
),
),
],
),
Expand Down
Loading

0 comments on commit a32d5a0

Please sign in to comment.