Improve accessibility

This commit is contained in:
problematicconsumer
2024-02-13 18:49:58 +03:30
parent 2293a390e5
commit 437a7ea594
5 changed files with 103 additions and 57 deletions

View File

@@ -15,7 +15,8 @@
"notSet": "Not Set", "notSet": "Not Set",
"agree": "Agree", "agree": "Agree",
"decline": "Decline", "decline": "Decline",
"unknown": "Unknown" "unknown": "Unknown",
"hidden": "Hidden"
}, },
"intro": { "intro": {
"termsAndPolicyCaution(rich)": "by continuing you agree with ${tap(@:about.termsAndConditions)}", "termsAndPolicyCaution(rich)": "by continuing you agree with ${tap(@:about.termsAndConditions)}",
@@ -127,6 +128,19 @@
"unsorted": "Default", "unsorted": "Default",
"name": "Alphabetically", "name": "Alphabetically",
"delay": "By Delay" "delay": "By Delay"
},
"activeProxySemanticLabel": "Active proxy",
"delaySemantics": {
"result": "delay: ${delay}ms",
"testing": "delay: testing..."
},
"ipInfoSemantics": {
"address": "IP address",
"country": "Country"
},
"statsSemantics": {
"speed": "Speed",
"totalTransferred": "Total transferred"
} }
}, },
"logs": { "logs": {

View File

@@ -149,10 +149,12 @@ class _ConnectionButton extends StatelessWidget {
.scaleXY(end: .88, curve: Curves.easeIn), .scaleXY(end: .88, curve: Curves.easeIn),
), ),
const Gap(16), const Gap(16),
Text( ExcludeSemantics(
child: Text(
label, label,
style: Theme.of(context).textTheme.titleMedium, style: Theme.of(context).textTheme.titleMedium,
), ),
),
], ],
); );
} }

View File

@@ -1,6 +1,7 @@
import 'package:fluentui_system_icons/fluentui_system_icons.dart'; import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gap/gap.dart'; import 'package:gap/gap.dart';
import 'package:hiddify/core/localization/translations.dart';
import 'package:hiddify/core/widget/animated_visibility.dart'; import 'package:hiddify/core/widget/animated_visibility.dart';
import 'package:hiddify/core/widget/shimmer_skeleton.dart'; import 'package:hiddify/core/widget/shimmer_skeleton.dart';
import 'package:hiddify/features/proxy/active/active_proxy_notifier.dart'; import 'package:hiddify/features/proxy/active/active_proxy_notifier.dart';
@@ -11,6 +12,7 @@ class ActiveProxyDelayIndicator extends HookConsumerWidget {
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
final t = ref.watch(translationsProvider);
final theme = Theme.of(context); final theme = Theme.of(context);
final activeProxy = ref.watch(activeProxyNotifierProvider); final activeProxy = ref.watch(activeProxyNotifierProvider);
@@ -39,6 +41,8 @@ class ActiveProxyDelayIndicator extends HookConsumerWidget {
const Gap(8), const Gap(8),
if (delay > 0) if (delay > 0)
Text.rich( Text.rich(
semanticsLabel:
t.proxies.delaySemantics.result(delay: delay),
TextSpan( TextSpan(
children: [ children: [
TextSpan( TextSpan(
@@ -51,7 +55,10 @@ class ActiveProxyDelayIndicator extends HookConsumerWidget {
), ),
) )
else else
const ShimmerSkeleton(width: 48, height: 18), Semantics(
label: t.proxies.delaySemantics.testing,
child: const ShimmerSkeleton(width: 48, height: 18),
),
], ],
), ),
), ),

View File

@@ -1,6 +1,7 @@
import 'package:dartx/dartx.dart'; import 'package:dartx/dartx.dart';
import 'package:fluentui_system_icons/fluentui_system_icons.dart'; import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/semantics.dart';
import 'package:gap/gap.dart'; import 'package:gap/gap.dart';
import 'package:hiddify/core/localization/translations.dart'; import 'package:hiddify/core/localization/translations.dart';
import 'package:hiddify/core/widget/animated_visibility.dart'; import 'package:hiddify/core/widget/animated_visibility.dart';
@@ -38,6 +39,7 @@ class ActiveProxyFooter extends HookConsumerWidget {
text: proxy.selectedName.isNotNullOrBlank text: proxy.selectedName.isNotNullOrBlank
? proxy.selectedName! ? proxy.selectedName!
: proxy.name, : proxy.name,
semanticLabel: t.proxies.activeProxySemanticLabel,
), ),
const Gap(8), const Gap(8),
switch (ipInfo) { switch (ipInfo) {
@@ -90,6 +92,7 @@ class _StatsColumn extends HookConsumerWidget {
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
final t = ref.watch(translationsProvider);
final stats = ref.watch(statsNotifierProvider).value; final stats = ref.watch(statsNotifierProvider).value;
return Directionality( return Directionality(
@@ -101,11 +104,13 @@ class _StatsColumn extends HookConsumerWidget {
_InfoProp( _InfoProp(
icon: FluentIcons.arrow_bidirectional_up_down_20_regular, icon: FluentIcons.arrow_bidirectional_up_down_20_regular,
text: (stats?.downlinkTotal ?? 0).size(), text: (stats?.downlinkTotal ?? 0).size(),
semanticLabel: t.proxies.statsSemantics.totalTransferred,
), ),
const Gap(8), const Gap(8),
_InfoProp( _InfoProp(
icon: FluentIcons.arrow_download_20_regular, icon: FluentIcons.arrow_download_20_regular,
text: (stats?.downlink ?? 0).speed(), text: (stats?.downlink ?? 0).speed(),
semanticLabel: t.proxies.statsSemantics.speed,
), ),
], ],
), ),
@@ -118,14 +123,18 @@ class _InfoProp extends StatelessWidget {
const _InfoProp({ const _InfoProp({
required this.icon, required this.icon,
required this.text, required this.text,
this.semanticLabel,
}); });
final IconData icon; final IconData icon;
final String text; final String text;
final String? semanticLabel;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Row( return Semantics(
label: semanticLabel,
child: Row(
children: [ children: [
Icon(icon), Icon(icon),
const Gap(8), const Gap(8),
@@ -137,6 +146,7 @@ class _InfoProp extends StatelessWidget {
), ),
), ),
], ],
),
); );
} }
} }

View File

@@ -1,6 +1,7 @@
import 'package:circle_flags/circle_flags.dart'; import 'package:circle_flags/circle_flags.dart';
import 'package:fluentui_system_icons/fluentui_system_icons.dart'; import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hiddify/core/localization/translations.dart';
import 'package:hiddify/utils/riverpod_utils.dart'; import 'package:hiddify/utils/riverpod_utils.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
@@ -23,10 +24,13 @@ class IPText extends HookConsumerWidget {
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
final t = ref.watch(translationsProvider);
final isVisible = ref.watch(_showIp); final isVisible = ref.watch(_showIp);
final textTheme = Theme.of(context).textTheme; final textTheme = Theme.of(context).textTheme;
return InkWell( return Semantics(
label: t.proxies.ipInfoSemantics.address,
child: InkWell(
onTap: () { onTap: () {
ref.read(_showIp.notifier).state = !isVisible; ref.read(_showIp.notifier).state = !isVisible;
}, },
@@ -46,15 +50,19 @@ class IPText extends HookConsumerWidget {
: const EdgeInsetsDirectional.only(end: 48), : const EdgeInsetsDirectional.only(end: 48),
child: Text( child: Text(
"*.*.*.*", "*.*.*.*",
style: constrained ? textTheme.labelMedium : textTheme.labelLarge, semanticsLabel: t.general.hidden,
style:
constrained ? textTheme.labelMedium : textTheme.labelLarge,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
), ),
crossFadeState: crossFadeState: isVisible
isVisible ? CrossFadeState.showFirst : CrossFadeState.showSecond, ? CrossFadeState.showFirst
: CrossFadeState.showSecond,
duration: const Duration(milliseconds: 200), duration: const Duration(milliseconds: 200),
), ),
), ),
),
); );
} }
} }
@@ -67,9 +75,12 @@ class IPCountryFlag extends HookConsumerWidget {
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
final t = ref.watch(translationsProvider);
final isVisible = ref.watch(_showIp); final isVisible = ref.watch(_showIp);
return InkWell( return Semantics(
label: t.proxies.ipInfoSemantics.country,
child: InkWell(
onTap: () { onTap: () {
ref.read(_showIp.notifier).state = !isVisible; ref.read(_showIp.notifier).state = !isVisible;
}, },
@@ -81,7 +92,8 @@ class IPCountryFlag extends HookConsumerWidget {
child: Center( child: Center(
child: AnimatedCrossFade( child: AnimatedCrossFade(
firstChild: CircleFlag(countryCode), firstChild: CircleFlag(countryCode),
secondChild: Icon(FluentIcons.eye_off_24_regular, size: size * .8), secondChild:
Icon(FluentIcons.eye_off_24_regular, size: size * .8),
crossFadeState: isVisible crossFadeState: isVisible
? CrossFadeState.showFirst ? CrossFadeState.showFirst
: CrossFadeState.showSecond, : CrossFadeState.showSecond,
@@ -89,6 +101,7 @@ class IPCountryFlag extends HookConsumerWidget {
), ),
), ),
), ),
),
); );
} }
} }