mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 20:39:51 +00:00
fix-talkback-slide-button-accessibility (#2200)
* fix:talkback send slide button accessibility * fix accessible button color
This commit is contained in:
parent
ce12f517f4
commit
990feb48ec
3 changed files with 144 additions and 123 deletions
|
@ -33,7 +33,7 @@ abstract class BaseBottomSheet extends StatelessWidget {
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
if (titleIconPath != null)
|
if (titleIconPath != null)
|
||||||
Image.asset(titleIconPath!, height: 24, width: 24)
|
Image.asset(titleIconPath!, height: 24, width: 24, excludeFromSemantics: true)
|
||||||
else
|
else
|
||||||
Container(),
|
Container(),
|
||||||
const SizedBox(width: 6),
|
const SizedBox(width: 6),
|
||||||
|
|
|
@ -223,6 +223,7 @@ class ConfirmSendingBottomSheet extends BaseBottomSheet {
|
||||||
onSlideComplete: onSlideComplete,
|
onSlideComplete: onSlideComplete,
|
||||||
buttonText: 'Swipe to send',
|
buttonText: 'Swipe to send',
|
||||||
currentTheme: currentTheme,
|
currentTheme: currentTheme,
|
||||||
|
accessibleNavigationModeButtonText: S.of(context).send,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -248,24 +249,28 @@ class StandardTile extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Semantics(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
|
container: true,
|
||||||
decoration:
|
label: itemTitle,
|
||||||
BoxDecoration(borderRadius: BorderRadius.circular(10), color: tileBackgroundColor),
|
child: Container(
|
||||||
child: Row(
|
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
decoration:
|
||||||
children: [
|
BoxDecoration(borderRadius: BorderRadius.circular(10), color: tileBackgroundColor),
|
||||||
Text(itemTitle, style: itemTitleTextStyle),
|
child: Row(
|
||||||
Column(
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
children: [
|
||||||
children: [
|
Text(itemTitle, style: itemTitleTextStyle),
|
||||||
Text(itemValue, style: itemTitleTextStyle),
|
Column(
|
||||||
itemSubTitle == null
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
? Container()
|
children: [
|
||||||
: Text(itemSubTitle!, style: itemSubTitleTextStyle),
|
Text(itemValue, style: itemTitleTextStyle),
|
||||||
],
|
itemSubTitle == null
|
||||||
),
|
? Container()
|
||||||
],
|
: Text(itemSubTitle!, style: itemSubTitleTextStyle),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -357,54 +362,58 @@ class AddressExpansionTile extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Semantics(
|
||||||
decoration: BoxDecoration(
|
container: true,
|
||||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
label: name,
|
||||||
color: tileBackgroundColor,
|
child: Container(
|
||||||
),
|
decoration: BoxDecoration(
|
||||||
child: Theme(
|
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||||
data: Theme.of(context).copyWith(dividerColor: Colors.transparent),
|
color: tileBackgroundColor,
|
||||||
child: Padding(
|
),
|
||||||
padding: EdgeInsets.symmetric(horizontal: 14, vertical: isBatchSending ? 0 : 8),
|
child: Theme(
|
||||||
child: ExpansionTile(
|
data: Theme.of(context).copyWith(dividerColor: Colors.transparent),
|
||||||
childrenPadding: isBatchSending ? const EdgeInsets.only(bottom: 8) : EdgeInsets.zero,
|
child: Padding(
|
||||||
tilePadding: EdgeInsets.zero,
|
padding: EdgeInsets.symmetric(horizontal: 14, vertical: isBatchSending ? 0 : 8),
|
||||||
dense: true,
|
child: ExpansionTile(
|
||||||
visualDensity: VisualDensity.compact,
|
childrenPadding: isBatchSending ? const EdgeInsets.only(bottom: 8) : EdgeInsets.zero,
|
||||||
title: Row(
|
tilePadding: EdgeInsets.zero,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
dense: true,
|
||||||
children: [
|
visualDensity: VisualDensity.compact,
|
||||||
Expanded(
|
title: Row(
|
||||||
child: Text(isBatchSending ? name : contactType,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
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: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: AddressFormatter.buildSegmentedAddress(
|
child: Text(isBatchSending ? name : contactType,
|
||||||
address: address,
|
style: itemTitleTextStyle, softWrap: true)),
|
||||||
walletType: walletType,
|
Text(isBatchSending ? amount : name,
|
||||||
evenTextStyle: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 14,
|
||||||
fontFamily: 'Lato',
|
fontFamily: 'Lato',
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
|
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
|
||||||
decoration: TextDecoration.none)
|
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)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -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/cake_text_theme.dart';
|
||||||
import 'package:cake_wallet/themes/extensions/filter_theme.dart';
|
import 'package:cake_wallet/themes/extensions/filter_theme.dart';
|
||||||
import 'package:cake_wallet/themes/extensions/menu_theme.dart';
|
import 'package:cake_wallet/themes/extensions/menu_theme.dart';
|
||||||
|
@ -12,12 +13,14 @@ class StandardSlideButton extends StatefulWidget {
|
||||||
this.buttonText = '',
|
this.buttonText = '',
|
||||||
this.height = 48.0,
|
this.height = 48.0,
|
||||||
required this.currentTheme,
|
required this.currentTheme,
|
||||||
|
required this.accessibleNavigationModeButtonText,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final VoidCallback onSlideComplete;
|
final VoidCallback onSlideComplete;
|
||||||
final String buttonText;
|
final String buttonText;
|
||||||
final double height;
|
final double height;
|
||||||
final ThemeBase currentTheme;
|
final ThemeBase currentTheme;
|
||||||
|
final String accessibleNavigationModeButtonText;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_StandardSlideButtonState createState() => _StandardSlideButtonState();
|
_StandardSlideButtonState createState() => _StandardSlideButtonState();
|
||||||
|
@ -28,68 +31,77 @@ class _StandardSlideButtonState extends State<StandardSlideButton> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return LayoutBuilder(builder: (context, constraints) {
|
final bool accessible = MediaQuery.of(context).accessibleNavigation;
|
||||||
final double maxWidth = constraints.maxWidth;
|
|
||||||
const double sideMargin = 4.0;
|
|
||||||
final double effectiveMaxWidth = maxWidth - 2 * sideMargin;
|
|
||||||
const double sliderWidth = 42.0;
|
|
||||||
|
|
||||||
final tileBackgroundColor = widget.currentTheme.type == ThemeType.light
|
final tileBackgroundColor = widget.currentTheme.type == ThemeType.light
|
||||||
? Theme.of(context).extension<SyncIndicatorTheme>()!.syncedBackgroundColor
|
? Theme.of(context).extension<SyncIndicatorTheme>()!.syncedBackgroundColor
|
||||||
: widget.currentTheme.type == ThemeType.oled
|
: widget.currentTheme.type == ThemeType.oled
|
||||||
? Colors.black.withOpacity(0.5)
|
? Colors.black.withOpacity(0.5)
|
||||||
: Theme.of(context).extension<FilterTheme>()!.buttonColor;
|
: Theme.of(context).extension<FilterTheme>()!.buttonColor;
|
||||||
|
|
||||||
return Container(
|
return accessible
|
||||||
height: widget.height,
|
? PrimaryButton(
|
||||||
decoration: BoxDecoration(
|
text: widget.accessibleNavigationModeButtonText,
|
||||||
borderRadius: BorderRadius.circular(10),
|
color: Theme.of(context).primaryColor,
|
||||||
color: tileBackgroundColor),
|
textColor: Colors.white,
|
||||||
child: Stack(
|
onPressed: () => widget.onSlideComplete())
|
||||||
alignment: Alignment.centerLeft,
|
: LayoutBuilder(builder: (context, constraints) {
|
||||||
children: [
|
final double maxWidth = constraints.maxWidth;
|
||||||
Center(
|
const double sideMargin = 4.0;
|
||||||
child: Text(widget.buttonText,
|
final double effectiveMaxWidth = maxWidth - 2 * sideMargin;
|
||||||
style: TextStyle(
|
const double sliderWidth = 42.0;
|
||||||
fontSize: 16,
|
|
||||||
fontFamily: 'Lato',
|
return Container(
|
||||||
fontWeight: FontWeight.w600,
|
height: widget.height,
|
||||||
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor))),
|
decoration: BoxDecoration(
|
||||||
Positioned(
|
borderRadius: BorderRadius.circular(10), color: tileBackgroundColor),
|
||||||
left: sideMargin + _dragPosition,
|
child: Stack(
|
||||||
child: GestureDetector(
|
alignment: Alignment.centerLeft,
|
||||||
onHorizontalDragUpdate: (details) {
|
children: [
|
||||||
setState(() {
|
Center(
|
||||||
_dragPosition += details.delta.dx;
|
child: Text(widget.buttonText,
|
||||||
if (_dragPosition < 0) _dragPosition = 0;
|
style: TextStyle(
|
||||||
if (_dragPosition > effectiveMaxWidth - sliderWidth) {
|
fontSize: 16,
|
||||||
_dragPosition = effectiveMaxWidth - sliderWidth;
|
fontFamily: 'Lato',
|
||||||
}
|
fontWeight: FontWeight.w600,
|
||||||
});
|
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor))),
|
||||||
},
|
Positioned(
|
||||||
onHorizontalDragEnd: (details) {
|
left: sideMargin + _dragPosition,
|
||||||
if (_dragPosition >= effectiveMaxWidth - sliderWidth - 10) {
|
child: GestureDetector(
|
||||||
widget.onSlideComplete();
|
onHorizontalDragUpdate: (details) {
|
||||||
} else {
|
setState(() {
|
||||||
setState(() => _dragPosition = 0);
|
_dragPosition += details.delta.dx;
|
||||||
}
|
if (_dragPosition < 0) _dragPosition = 0;
|
||||||
},
|
if (_dragPosition > effectiveMaxWidth - sliderWidth) {
|
||||||
child: Container(
|
_dragPosition = effectiveMaxWidth - sliderWidth;
|
||||||
width: sliderWidth,
|
}
|
||||||
height: widget.height - 8,
|
});
|
||||||
decoration: BoxDecoration(
|
},
|
||||||
borderRadius: BorderRadius.circular(10),
|
onHorizontalDragEnd: (details) {
|
||||||
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
|
if (_dragPosition >= effectiveMaxWidth - sliderWidth - 10) {
|
||||||
),
|
widget.onSlideComplete();
|
||||||
alignment: Alignment.center,
|
} else {
|
||||||
child: Icon(Icons.arrow_forward,
|
setState(() => _dragPosition = 0);
|
||||||
color: widget.currentTheme.type == ThemeType.bright ? Theme.of(context).extension<CakeMenuTheme>()!.backgroundColor : Theme.of(context).extension<FilterTheme>()!.buttonColor),
|
}
|
||||||
),
|
},
|
||||||
|
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),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
)
|
);
|
||||||
],
|
});
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue