Tweak animation curves (#90)

Changed button and scale curves to
improve responsiveness (makes the button react
faster when tapping).
This commit is contained in:
Tommy Chow 2022-06-28 21:32:27 -04:00
parent 00a7e82d15
commit 5c3b0c6775
8 changed files with 17 additions and 6 deletions

View file

@ -97,6 +97,8 @@ class Chat extends StatelessWidget {
child: Observer(
builder: (_) => AnimatedSwitcher(
duration: const Duration(milliseconds: 200),
switchInCurve: Curves.easeOutCubic,
switchOutCurve: Curves.easeInCubic,
child: chatStore.autoScroll
? null
: Button(

View file

@ -205,6 +205,8 @@ class _ChattersListState extends State<ChattersList> {
Observer(
builder: (context) => AnimatedSwitcher(
duration: const Duration(milliseconds: 200),
switchInCurve: Curves.easeOutCubic,
switchOutCurve: Curves.easeInCubic,
child: chatDetailsStore.showJumpButton ? ScrollToTopButton(scrollController: _scrollController) : null,
),
),

View file

@ -72,6 +72,8 @@ class _CategoriesState extends State<Categories> with AutomaticKeepAliveClientMi
Observer(
builder: (context) => AnimatedSwitcher(
duration: const Duration(milliseconds: 200),
switchInCurve: Curves.easeOutCubic,
switchOutCurve: Curves.easeInCubic,
child: _categoriesStore.showJumpButton ? ScrollToTopButton(scrollController: _categoriesStore.scrollController) : null,
),
),

View file

@ -141,6 +141,8 @@ class _CategoryStreamsState extends State<CategoryStreams> {
child: Observer(
builder: (context) => AnimatedSwitcher(
duration: const Duration(milliseconds: 200),
switchInCurve: Curves.easeOutCubic,
switchOutCurve: Curves.easeInCubic,
child: widget.listStore.showJumpButton ? ScrollToTopButton(scrollController: widget.listStore.scrollController) : null,
),
),

View file

@ -102,6 +102,8 @@ class _StreamsListState extends State<StreamsList> with AutomaticKeepAliveClient
Observer(
builder: (context) => AnimatedSwitcher(
duration: const Duration(milliseconds: 200),
switchInCurve: Curves.easeOutCubic,
switchOutCurve: Curves.easeInCubic,
child: _listStore.showJumpButton ? ScrollToTopButton(scrollController: _listStore.scrollController) : null,
),
),

View file

@ -26,8 +26,8 @@ class _AnimateScaleState extends State<AnimateScale> with SingleTickerProviderSt
@override
Widget build(BuildContext context) {
const duration = Duration(milliseconds: 200);
const downCurve = Curves.easeInCubic;
const upCurve = Curves.easeOutCubic;
const downCurve = Curves.easeOutCubic;
const upCurve = Curves.easeInCubic;
return InkWell(
onTap: widget.onTap,

View file

@ -79,17 +79,17 @@ class _ButtonState extends State<Button> with SingleTickerProviderStateMixin {
: Listener(
onPointerDown: (_) => _animationController.animateTo(
_animationController.upperBound,
curve: Curves.easeInCubic,
curve: Curves.easeOutCubic,
duration: duration,
),
onPointerUp: (_) => _animationController.animateTo(
_animationController.lowerBound,
curve: Curves.easeOutCubic,
curve: Curves.easeInCubic,
duration: duration,
),
onPointerCancel: (_) => _animationController.animateTo(
_animationController.lowerBound,
curve: Curves.easeOutCubic,
curve: Curves.easeInCubic,
duration: duration,
),
child: button,

View file

@ -14,9 +14,10 @@ class ScrollToTopButton extends StatelessWidget {
child: FloatingActionButton(
onPressed: () {
HapticFeedback.lightImpact();
scrollController.animateTo(
0.0,
curve: Curves.fastOutSlowIn,
curve: Curves.easeOutCubic,
duration: const Duration(milliseconds: 500),
);
},