mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-11-26 11:14:11 +01:00
fix-talkback-slide-button-accessibility (#2200)
* fix:talkback send slide button accessibility * fix accessible button color
This commit is contained in:
@@ -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),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user