Skip to content
This repository was archived by the owner on Sep 16, 2023. It is now read-only.

Commit 9acec69

Browse files
author
eightgran
committed
Change styling on CollapseOnScrollActionButton
- Increase button size - Use animation value for color interpolation
1 parent a8633f5 commit 9acec69

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

lib/src/widgets/buttons/collapse_on_scroll_action_button.dart

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ class CollapseOnScrollActionButton extends StatefulWidget
5454
this.collapseDuration = const Duration(milliseconds: 500),
5555
this.requiredScrollOffset = 64.0,
5656
this.padding = const EdgeInsets.symmetric(
57-
vertical: 8.0,
58-
horizontal: 22.0,
57+
vertical: 12.0,
58+
horizontal: 24.0,
5959
),
6060
this.blurred = true,
6161
required this.onPressed,
@@ -75,12 +75,8 @@ class _CollapseOnScrollActionButtonState
7575

7676
/// Create a animated accent color using the [_colorAnimation].
7777
Color get _accentColor {
78-
final int contrastingColorValue =
79-
(0xFFFFFFFF - widget.backgroundColor.value);
80-
final Color? contrastingColor =
81-
Color.lerp(Color(contrastingColorValue), widget.backgroundColor, 0.75);
82-
return Color.lerp(
83-
widget.backgroundColor, contrastingColor, _colorAnimation.value) ??
78+
return Color.lerp(widget.accentColor, widget.backgroundColor,
79+
_colorAnimation.value) ??
8480
widget.accentColor;
8581
}
8682

@@ -96,6 +92,13 @@ class _CollapseOnScrollActionButtonState
9692
return _animationOnScrollController.animationController;
9793
}
9894

95+
Color get _textColor => widget.backgroundColor.applyColorByContrast(
96+
LitColors.white,
97+
Color.lerp(LitColors.grey500, LitColors.grey380,
98+
1.0 - _colorAnimation.value) ??
99+
LitColors.grey500,
100+
);
101+
99102
@override
100103
void initState() {
101104
_colorAnimation = AnimationController(
@@ -152,9 +155,9 @@ class _CollapseOnScrollActionButtonState
152155
),
153156
child: Text(
154157
widget.label,
155-
style: LitTextStyles.sansSerif.copyWith(
156-
color: Colors.white,
157-
fontSize: (1.0 - _scrollAnimation.value) * 15.0,
158+
style: LitSansSerifStyles.button.copyWith(
159+
color: _textColor,
160+
fontSize: (1.0 - _scrollAnimation.value) * 16.0,
158161
letterSpacing: 0.75,
159162
),
160163
),
@@ -164,8 +167,8 @@ class _CollapseOnScrollActionButtonState
164167
),
165168
Icon(
166169
widget.icon,
167-
color: Colors.white,
168-
size: 15.0,
170+
color: _textColor,
171+
size: 16.0,
169172
),
170173
],
171174
),

0 commit comments

Comments
 (0)