Add accessability semantics

This commit is contained in:
problematicconsumer
2023-09-02 21:09:22 +03:30
parent 5d2abaf748
commit b06ae63486
5 changed files with 150 additions and 124 deletions

View File

@@ -52,6 +52,7 @@
}, },
"update": { "update": {
"buttonTxt": "update", "buttonTxt": "update",
"tooltip": "update profile",
"failureMsg": "failed to update profile: ${reason}", "failureMsg": "failed to update profile: ${reason}",
"successMsg": "successfully updated profile" "successMsg": "successfully updated profile"
}, },

View File

@@ -52,6 +52,7 @@
}, },
"update": { "update": {
"buttonTxt": "بروزرسانی", "buttonTxt": "بروزرسانی",
"tooltip": "بروزرسانی پروفایل",
"failureMsg": "در بروزرسانی پروفایل خطایی رخ داد: ${reason}", "failureMsg": "در بروزرسانی پروفایل خطایی رخ داد: ${reason}",
"successMsg": "پروفایل با موفقیت بروزرسانی شد" "successMsg": "پروفایل با موفقیت بروزرسانی شد"
}, },

View File

@@ -92,6 +92,9 @@ class ProfileTile extends HookConsumerWidget {
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
color: Colors.transparent, color: Colors.transparent,
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
child: Semantics(
button: true,
label: t.profile.overviewPageTitle,
child: InkWell( child: InkWell(
onTap: () => const ProfilesRoute().go(context), onTap: () => const ProfilesRoute().go(context),
child: Row( child: Row(
@@ -109,6 +112,7 @@ class ProfileTile extends HookConsumerWidget {
), ),
), ),
), ),
),
) )
else else
Text( Text(
@@ -154,8 +158,11 @@ class ProfileActionButton extends HookConsumerWidget {
); );
if (!showAllActions) { if (!showAllActions) {
return Tooltip( return Semantics(
message: t.profile.update.buttonTxt, button: true,
enabled: !updateProfileMutation.state.isInProgress,
child: Tooltip(
message: t.profile.update.tooltip,
child: InkWell( child: InkWell(
onTap: () { onTap: () {
if (updateProfileMutation.state.isInProgress) { if (updateProfileMutation.state.isInProgress) {
@@ -169,12 +176,15 @@ class ProfileActionButton extends HookConsumerWidget {
}, },
child: const Icon(Icons.update), child: const Icon(Icons.update),
), ),
),
); );
} }
return ProfileActionsMenu( return ProfileActionsMenu(
profile, profile,
(context, controller, child) { (context, controller, child) {
return Tooltip( return Semantics(
button: true,
child: Tooltip(
message: MaterialLocalizations.of(context).showMenuTooltip, message: MaterialLocalizations.of(context).showMenuTooltip,
child: InkWell( child: InkWell(
onTap: () { onTap: () {
@@ -186,6 +196,7 @@ class ProfileActionButton extends HookConsumerWidget {
}, },
child: const Icon(Icons.more_vert), child: const Icon(Icons.more_vert),
), ),
),
); );
}, },
); );

View File

@@ -87,7 +87,11 @@ class _ConnectionButton extends StatelessWidget {
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Container( Semantics(
button: true,
enabled: enabled,
label: label,
child: Container(
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.circle, shape: BoxShape.circle,
@@ -119,6 +123,7 @@ class _ConnectionButton extends StatelessWidget {
) )
.animate(target: enabled ? 0 : 1) .animate(target: enabled ? 0 : 1)
.scaleXY(end: .88, curve: Curves.easeIn), .scaleXY(end: .88, curve: Curves.easeIn),
),
const Gap(16), const Gap(16),
Text( Text(
label.sentenceCase, label.sentenceCase,

View File

@@ -146,10 +146,12 @@ class AddProfileModal extends HookConsumerWidget {
.addProfile(link.url), .addProfile(link.url),
); );
} else { } else {
if (context.mounted) {
CustomToast.error( CustomToast.error(
t.profile.add.invalidUrlMsg.sentenceCase, t.profile.add.invalidUrlMsg.sentenceCase,
).show(context); ).show(context);
} }
}
}, },
) )
else else
@@ -171,6 +173,8 @@ class AddProfileModal extends HookConsumerWidget {
horizontal: buttonsPadding, horizontal: buttonsPadding,
vertical: 16, vertical: 16,
), ),
child: Semantics(
button: true,
child: SizedBox( child: SizedBox(
height: 36, height: 36,
child: Material( child: Material(
@@ -205,6 +209,7 @@ class AddProfileModal extends HookConsumerWidget {
), ),
), ),
), ),
),
const Gap(24), const Gap(24),
], ],
), ),
@@ -238,7 +243,9 @@ class _Button extends StatelessWidget {
final theme = Theme.of(context); final theme = Theme.of(context);
final color = theme.colorScheme.primary; final color = theme.colorScheme.primary;
return SizedBox( return Semantics(
button: true,
child: SizedBox(
width: size, width: size,
height: size, height: size,
child: Material( child: Material(
@@ -269,6 +276,7 @@ class _Button extends StatelessWidget {
), ),
), ),
), ),
),
); );
} }
} }