feat(ui_kit): make flat button fade on transition

This commit is contained in:
Hugo Pointcheval 2023-04-18 11:47:56 +02:00
parent 2baaf5c0bb
commit 32cc6e8288
Signed by: hugo
GPG Key ID: 3AAC487E131E00BC

View File

@ -130,9 +130,24 @@ class FlatButtonScreen extends CubitScreen<ButtonCubit, ButtonState> {
onPressed?.call(state.state); onPressed?.call(state.state);
bloc(context).onClickUpOut(); bloc(context).onClickUpOut();
}, },
child: DecoratedBox( child: AnimatedContainer(
// TODO(wyatt): make it configurable, and generalize it
duration: const Duration(milliseconds: 150),
curve: Curves.easeOut,
decoration: BoxDecoration( decoration: BoxDecoration(
color: style.backgroundColors?.color, color: style.backgroundColors?.color,
// if no gradient colors => no default value
gradient: (style.backgroundColors?.isGradient ?? false)
? LinearGradient(
colors: style.backgroundColors!.colors,
)
: null,
borderRadius: style.radius,
),
child: DecoratedBox(
decoration: BoxDecoration(
// If no border color => no default value // If no border color => no default value
border: (style.borderColors != null && style.stroke != null) border: (style.borderColors != null && style.stroke != null)
? (style.borderColors?.isGradient ?? false) ? (style.borderColors?.isGradient ?? false)
@ -147,12 +162,7 @@ class FlatButtonScreen extends CubitScreen<ButtonCubit, ButtonState> {
width: style.stroke!, width: style.stroke!,
) )
: null, : null,
// if no gradient colors => no default value
gradient: (style.backgroundColors?.isGradient ?? false)
? LinearGradient(
colors: style.backgroundColors!.colors,
)
: null,
boxShadow: [ boxShadow: [
if (style.shadow != null) ...[style.shadow!] if (style.shadow != null) ...[style.shadow!]
], ],
@ -245,6 +255,7 @@ class FlatButtonScreen extends CubitScreen<ButtonCubit, ButtonState> {
), ),
), ),
), ),
),
); );
} }
} }