fix-talkback-slide-button-accessibility (#2200)

* fix:talkback send slide button accessibility

* fix accessible button color
This commit is contained in:
Serhii 2025-04-14 15:30:41 +03:00 committed by GitHub
parent ce12f517f4
commit 990feb48ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 144 additions and 123 deletions

View file

@ -33,7 +33,7 @@ abstract class BaseBottomSheet extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (titleIconPath != null)
Image.asset(titleIconPath!, height: 24, width: 24)
Image.asset(titleIconPath!, height: 24, width: 24, excludeFromSemantics: true)
else
Container(),
const SizedBox(width: 6),

View file

@ -223,6 +223,7 @@ class ConfirmSendingBottomSheet extends BaseBottomSheet {
onSlideComplete: onSlideComplete,
buttonText: 'Swipe to send',
currentTheme: currentTheme,
accessibleNavigationModeButtonText: S.of(context).send,
),
);
}
@ -248,24 +249,28 @@ class StandardTile extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
decoration:
BoxDecoration(borderRadius: BorderRadius.circular(10), color: tileBackgroundColor),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(itemTitle, style: itemTitleTextStyle),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(itemValue, style: itemTitleTextStyle),
itemSubTitle == null
? Container()
: Text(itemSubTitle!, style: itemSubTitleTextStyle),
],
),
],
return Semantics(
container: true,
label: itemTitle,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
decoration:
BoxDecoration(borderRadius: BorderRadius.circular(10), color: tileBackgroundColor),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(itemTitle, style: itemTitleTextStyle),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(itemValue, style: itemTitleTextStyle),
itemSubTitle == null
? Container()
: Text(itemSubTitle!, style: itemSubTitleTextStyle),
],
),
],
),
),
);
}
@ -357,54 +362,58 @@ class AddressExpansionTile extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(10)),
color: tileBackgroundColor,
),
child: Theme(
data: Theme.of(context).copyWith(dividerColor: Colors.transparent),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 14, vertical: isBatchSending ? 0 : 8),
child: ExpansionTile(
childrenPadding: isBatchSending ? const EdgeInsets.only(bottom: 8) : EdgeInsets.zero,
tilePadding: EdgeInsets.zero,
dense: true,
visualDensity: VisualDensity.compact,
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text(isBatchSending ? name : contactType,
style: itemTitleTextStyle, softWrap: true)),
Text(isBatchSending ? amount : name,
style: TextStyle(
fontSize: 14,
fontFamily: 'Lato',
fontWeight: FontWeight.w600,
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
decoration: TextDecoration.none,
)),
],
),
children: [
Row(
return Semantics(
container: true,
label: name,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(10)),
color: tileBackgroundColor,
),
child: Theme(
data: Theme.of(context).copyWith(dividerColor: Colors.transparent),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 14, vertical: isBatchSending ? 0 : 8),
child: ExpansionTile(
childrenPadding: isBatchSending ? const EdgeInsets.only(bottom: 8) : EdgeInsets.zero,
tilePadding: EdgeInsets.zero,
dense: true,
visualDensity: VisualDensity.compact,
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: AddressFormatter.buildSegmentedAddress(
address: address,
walletType: walletType,
evenTextStyle: TextStyle(
fontSize: 12,
fontFamily: 'Lato',
fontWeight: FontWeight.w600,
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
decoration: TextDecoration.none)
),
),
child: Text(isBatchSending ? name : contactType,
style: itemTitleTextStyle, softWrap: true)),
Text(isBatchSending ? amount : name,
style: TextStyle(
fontSize: 14,
fontFamily: 'Lato',
fontWeight: FontWeight.w600,
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
decoration: TextDecoration.none,
)),
],
),
],
children: [
Row(
children: [
Expanded(
child: AddressFormatter.buildSegmentedAddress(
address: address,
walletType: walletType,
evenTextStyle: TextStyle(
fontSize: 12,
fontFamily: 'Lato',
fontWeight: FontWeight.w600,
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
decoration: TextDecoration.none)
),
),
],
),
],
),
),
),
),

View file

@ -1,3 +1,4 @@
import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
import 'package:cake_wallet/themes/extensions/filter_theme.dart';
import 'package:cake_wallet/themes/extensions/menu_theme.dart';
@ -12,12 +13,14 @@ class StandardSlideButton extends StatefulWidget {
this.buttonText = '',
this.height = 48.0,
required this.currentTheme,
required this.accessibleNavigationModeButtonText,
}) : super(key: key);
final VoidCallback onSlideComplete;
final String buttonText;
final double height;
final ThemeBase currentTheme;
final String accessibleNavigationModeButtonText;
@override
_StandardSlideButtonState createState() => _StandardSlideButtonState();
@ -28,68 +31,77 @@ class _StandardSlideButtonState extends State<StandardSlideButton> {
@override
Widget build(BuildContext context) {
return LayoutBuilder(builder: (context, constraints) {
final double maxWidth = constraints.maxWidth;
const double sideMargin = 4.0;
final double effectiveMaxWidth = maxWidth - 2 * sideMargin;
const double sliderWidth = 42.0;
final bool accessible = MediaQuery.of(context).accessibleNavigation;
final tileBackgroundColor = widget.currentTheme.type == ThemeType.light
? Theme.of(context).extension<SyncIndicatorTheme>()!.syncedBackgroundColor
: widget.currentTheme.type == ThemeType.oled
? Colors.black.withOpacity(0.5)
: Theme.of(context).extension<FilterTheme>()!.buttonColor;
final tileBackgroundColor = widget.currentTheme.type == ThemeType.light
? Theme.of(context).extension<SyncIndicatorTheme>()!.syncedBackgroundColor
: widget.currentTheme.type == ThemeType.oled
? Colors.black.withOpacity(0.5)
: Theme.of(context).extension<FilterTheme>()!.buttonColor;
return Container(
height: widget.height,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: tileBackgroundColor),
child: Stack(
alignment: Alignment.centerLeft,
children: [
Center(
child: Text(widget.buttonText,
style: TextStyle(
fontSize: 16,
fontFamily: 'Lato',
fontWeight: FontWeight.w600,
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor))),
Positioned(
left: sideMargin + _dragPosition,
child: GestureDetector(
onHorizontalDragUpdate: (details) {
setState(() {
_dragPosition += details.delta.dx;
if (_dragPosition < 0) _dragPosition = 0;
if (_dragPosition > effectiveMaxWidth - sliderWidth) {
_dragPosition = effectiveMaxWidth - sliderWidth;
}
});
},
onHorizontalDragEnd: (details) {
if (_dragPosition >= effectiveMaxWidth - sliderWidth - 10) {
widget.onSlideComplete();
} else {
setState(() => _dragPosition = 0);
}
},
child: Container(
width: sliderWidth,
height: widget.height - 8,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
),
alignment: Alignment.center,
child: Icon(Icons.arrow_forward,
color: widget.currentTheme.type == ThemeType.bright ? Theme.of(context).extension<CakeMenuTheme>()!.backgroundColor : Theme.of(context).extension<FilterTheme>()!.buttonColor),
),
return accessible
? PrimaryButton(
text: widget.accessibleNavigationModeButtonText,
color: Theme.of(context).primaryColor,
textColor: Colors.white,
onPressed: () => widget.onSlideComplete())
: LayoutBuilder(builder: (context, constraints) {
final double maxWidth = constraints.maxWidth;
const double sideMargin = 4.0;
final double effectiveMaxWidth = maxWidth - 2 * sideMargin;
const double sliderWidth = 42.0;
return Container(
height: widget.height,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10), color: tileBackgroundColor),
child: Stack(
alignment: Alignment.centerLeft,
children: [
Center(
child: Text(widget.buttonText,
style: TextStyle(
fontSize: 16,
fontFamily: 'Lato',
fontWeight: FontWeight.w600,
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor))),
Positioned(
left: sideMargin + _dragPosition,
child: GestureDetector(
onHorizontalDragUpdate: (details) {
setState(() {
_dragPosition += details.delta.dx;
if (_dragPosition < 0) _dragPosition = 0;
if (_dragPosition > effectiveMaxWidth - sliderWidth) {
_dragPosition = effectiveMaxWidth - sliderWidth;
}
});
},
onHorizontalDragEnd: (details) {
if (_dragPosition >= effectiveMaxWidth - sliderWidth - 10) {
widget.onSlideComplete();
} else {
setState(() => _dragPosition = 0);
}
},
child: Container(
width: sliderWidth,
height: widget.height - 8,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
),
alignment: Alignment.center,
child: Icon(Icons.arrow_forward,
color: widget.currentTheme.type == ThemeType.bright
? Theme.of(context).extension<CakeMenuTheme>()!.backgroundColor
: Theme.of(context).extension<FilterTheme>()!.buttonColor),
),
),
)
],
),
)
],
),
);
});
);
});
}
}