@@ -44,73 +44,85 @@ class StandardSlideButtonState extends State<StandardSlideButton> {
4444 ? Colors .black.withOpacity (0.5 )
4545 : Theme .of (context).extension < FilterTheme > ()! .buttonColor;
4646
47- return accessible
48- ? PrimaryButton (
49- text: widget.accessibleNavigationModeButtonText,
50- color: Theme .of (context).primaryColor,
51- textColor: Colors .white,
52- onPressed: () => widget.onSlideComplete ())
53- : LayoutBuilder (builder: (context, constraints) {
54- final double maxWidth = constraints.maxWidth;
55- const double sideMargin = 4.0 ;
56- final double effectiveMaxWidth = maxWidth - 2 * sideMargin;
57- const double sliderWidth = 42.0 ;
47+ if (accessible) {
48+ return PrimaryButton (
49+ text: widget.accessibleNavigationModeButtonText,
50+ color: Theme .of (context).primaryColor,
51+ textColor: Colors .white,
52+ onPressed: widget.onSlideComplete,
53+ );
54+ }
5855
59- return Container (
60- height: widget.height,
61- decoration: BoxDecoration (
62- borderRadius: BorderRadius .circular (10 ), color: tileBackgroundColor),
63- child: Stack (
64- alignment: Alignment .centerLeft,
65- children: [
66- Center (
67- child: Text (widget.buttonText,
68- style: TextStyle (
69- fontSize: 16 ,
70- fontFamily: 'Lato' ,
71- fontWeight: FontWeight .w600,
72- color: Theme .of (context).extension < CakeTextTheme > ()! .titleColor))),
73- Positioned (
74- left: sideMargin + _dragPosition,
75- child: GestureDetector (
76- key: ValueKey ('standard_slide_button_widget_slider_key' ),
77- onHorizontalDragUpdate: (details) {
78- setState (() {
79- _dragPosition += details.delta.dx;
80- if (_dragPosition < 0 ) _dragPosition = 0 ;
81- if (_dragPosition > effectiveMaxWidth - sliderWidth) {
82- _dragPosition = effectiveMaxWidth - sliderWidth;
83- }
84- });
85- },
86- onHorizontalDragEnd: (details) {
87- if (_dragPosition >= effectiveMaxWidth - sliderWidth - 10 ) {
88- widget.onSlideComplete ();
89- } else {
90- setState (() => _dragPosition = 0 );
91- }
92- },
93- child: Container (
94- key: ValueKey ('standard_slide_button_widget_slider_container_key' ),
95- width: sliderWidth,
96- height: widget.height - 8 ,
97- decoration: BoxDecoration (
98- borderRadius: BorderRadius .circular (10 ),
99- color: Theme .of (context).extension < CakeTextTheme > ()! .titleColor,
100- ),
101- alignment: Alignment .center,
102- child: Icon (
103- key: ValueKey ('standard_slide_button_widget_slider_icon_key' ),
104- Icons .arrow_forward,
105- color: widget.currentTheme.type == ThemeType .bright
106- ? Theme .of (context).extension < CakeMenuTheme > ()! .backgroundColor
107- : Theme .of (context).extension < FilterTheme > ()! .buttonColor),
108- ),
56+ return LayoutBuilder (
57+ builder: (context, constraints) {
58+ final maxWidth = constraints.maxWidth;
59+ sideMargin = 4.0 ;
60+ effectiveMaxWidth = maxWidth - 2 * sideMargin;
61+ sliderWidth = 42.0 ;
62+
63+ return Container (
64+ height: widget.height,
65+ decoration: BoxDecoration (
66+ borderRadius: BorderRadius .circular (10 ),
67+ color: tileBackgroundColor,
68+ ),
69+ child: Stack (
70+ alignment: Alignment .centerLeft,
71+ children: [
72+ Center (
73+ child: Text (
74+ widget.buttonText,
75+ style: TextStyle (
76+ fontSize: 16 ,
77+ fontFamily: 'Lato' ,
78+ fontWeight: FontWeight .w600,
79+ color: Theme .of (context).extension < CakeTextTheme > ()! .titleColor,
80+ ),
81+ ),
82+ ),
83+ Positioned (
84+ left: sideMargin + _dragPosition,
85+ child: GestureDetector (
86+ key: ValueKey ('standard_slide_button_widget_slider_key' ),
87+ onHorizontalDragUpdate: (details) {
88+ setState (() {
89+ _dragPosition += details.delta.dx;
90+ if (_dragPosition < 0 ) _dragPosition = 0 ;
91+ if (_dragPosition > effectiveMaxWidth - sliderWidth) {
92+ _dragPosition = effectiveMaxWidth - sliderWidth;
93+ }
94+ });
95+ },
96+ onHorizontalDragEnd: (details) {
97+ if (_dragPosition >= effectiveMaxWidth - sliderWidth - 10 ) {
98+ widget.onSlideComplete ();
99+ } else {
100+ setState (() => _dragPosition = 0 );
101+ }
102+ },
103+ child: Container (
104+ key: ValueKey ('standard_slide_button_widget_slider_container_key' ),
105+ width: sliderWidth,
106+ height: widget.height - 8 ,
107+ decoration: BoxDecoration (
108+ borderRadius: BorderRadius .circular (10 ),
109+ color: Theme .of (context).extension < CakeTextTheme > ()! .titleColor,
110+ ),
111+ alignment: Alignment .center,
112+ child: Icon (
113+ key: ValueKey ('standard_slide_button_widget_slider_icon_key' ),
114+ Icons .arrow_forward,
115+ color: widget.currentTheme.type == ThemeType .bright
116+ ? Theme .of (context).extension < CakeMenuTheme > ()! .backgroundColor
117+ : Theme .of (context).extension < FilterTheme > ()! .buttonColor,
109118 ),
110- )
111- ] ,
119+ ),
120+ ) ,
112121 ),
113- );
114- });
122+ ],
123+ ),
124+ );
125+ },
126+ );
115127 }
116128}
0 commit comments