Skip to content

Commit

Permalink
added semantic labelling to some icons for accessibility
Browse files Browse the repository at this point in the history
  • Loading branch information
hjiangsu committed Jun 23, 2023
1 parent b462f98 commit f3dbea4
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 14 deletions.
8 changes: 3 additions & 5 deletions lib/account/pages/account_page.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';

import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:cached_network_image/cached_network_image.dart';

import 'package:thunder/account/bloc/account_bloc.dart';
import 'package:thunder/account/models/account.dart';
import 'package:thunder/account/pages/login_page.dart';
import 'package:thunder/account/widgets/profile_modal_body.dart';
import 'package:thunder/core/auth/bloc/auth_bloc.dart';
import 'package:thunder/core/auth/helpers/fetch_account.dart';
import 'package:thunder/thunder/bloc/thunder_bloc.dart';
import 'package:thunder/utils/date_time.dart';
import 'package:thunder/utils/numbers.dart';
Expand Down
5 changes: 4 additions & 1 deletion lib/account/pages/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ class _LoginPageState extends State<LoginPage> {
suffixIcon: Padding(
padding: const EdgeInsets.symmetric(horizontal: 4.0),
child: IconButton(
icon: Icon(showPassword ? Icons.visibility_rounded : Icons.visibility_off_rounded),
icon: Icon(
showPassword ? Icons.visibility_rounded : Icons.visibility_off_rounded,
semanticLabel: showPassword ? 'Hide Password' : 'Show Password',
),
onPressed: () {
setState(() {
showPassword = !showPassword;
Expand Down
5 changes: 4 additions & 1 deletion lib/account/widgets/profile_modal_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ class ProfileSelect extends StatelessWidget {
context.pop();
},
trailing: IconButton(
icon: const Icon(Icons.delete),
icon: const Icon(
Icons.delete,
semanticLabel: 'Remove Account',
),
onPressed: () {
context.read<AuthBloc>().add(RemoveAccount(accountId: snapshot.data![index].id));
context.pop();
Expand Down
2 changes: 1 addition & 1 deletion lib/community/pages/community_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class _CommunityPageState extends State<CommunityPage> with AutomaticKeepAliveCl
},
),
IconButton(
icon: Icon(sortTypeIcon),
icon: Icon(sortTypeIcon, semanticLabel: 'Sort By'),
onPressed: () => showSortBottomSheet(context, state),
),
const SizedBox(width: 8.0),
Expand Down
15 changes: 12 additions & 3 deletions lib/community/widgets/post_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,10 @@ class _PostCardState extends State<PostCard> {
children: [
if (showVoteActions)
IconButton(
icon: const Icon(Icons.arrow_upward),
icon: Icon(
Icons.arrow_upward,
semanticLabel: widget.postView.myVote == 1 ? 'Upvoted' : 'Upvote',
),
color: widget.postView.myVote == 1 ? Colors.orange : null,
visualDensity: VisualDensity.compact,
onPressed: () {
Expand All @@ -391,7 +394,10 @@ class _PostCardState extends State<PostCard> {
}),
if (showVoteActions)
IconButton(
icon: const Icon(Icons.arrow_downward),
icon: Icon(
Icons.arrow_downward,
semanticLabel: widget.postView.myVote == -1 ? 'Downvoted' : 'Downvote',
),
color: widget.postView.myVote == -1 ? Colors.blue : null,
visualDensity: VisualDensity.compact,
onPressed: () {
Expand All @@ -401,7 +407,10 @@ class _PostCardState extends State<PostCard> {
),
if (showSaveAction)
IconButton(
icon: Icon(widget.postView.saved ? Icons.star_rounded : Icons.star_border_rounded),
icon: Icon(
widget.postView.saved ? Icons.star_rounded : Icons.star_border_rounded,
semanticLabel: widget.postView.saved ? 'Saved' : 'Save',
),
color: widget.postView.saved ? Colors.purple : null,
visualDensity: VisualDensity.compact,
onPressed: () {
Expand Down
15 changes: 12 additions & 3 deletions lib/post/widgets/post_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ class PostSubview extends StatelessWidget {
context.read<PostBloc>().add(VotePostEvent(postId: postView.post.id, score: postView.myVote == 1 ? 0 : 1));
}
: null,
icon: const Icon(Icons.arrow_upward),
icon: Icon(
Icons.arrow_upward,
semanticLabel: postView.myVote == 1 ? 'Upvoted' : 'Upvote',
),
color: postView.myVote == 1 ? Colors.orange : null,
),
IconButton(
Expand All @@ -144,7 +147,10 @@ class PostSubview extends StatelessWidget {
context.read<PostBloc>().add(VotePostEvent(postId: postView.post.id, score: postView.myVote == -1 ? 0 : -1));
}
: null,
icon: const Icon(Icons.arrow_downward),
icon: Icon(
Icons.arrow_downward,
semanticLabel: postView.myVote == -1 ? 'Downvoted' : 'Downvote',
),
color: postView.myVote == -1 ? Colors.blue : null,
),
IconButton(
Expand All @@ -154,7 +160,10 @@ class PostSubview extends StatelessWidget {
context.read<PostBloc>().add(SavePostEvent(postId: postView.post.id, save: !postView.saved));
}
: null,
icon: Icon(postView.saved ? Icons.star_rounded : Icons.star_border_rounded),
icon: Icon(
postView.saved ? Icons.star_rounded : Icons.star_border_rounded,
semanticLabel: postView.saved ? 'Saved' : 'Save',
),
color: postView.saved ? Colors.purple : null,
),
// IconButton(
Expand Down

0 comments on commit f3dbea4

Please sign in to comment.