feat(ui): add animated decorated box + animate all buttons + customize duration in style

This commit is contained in:
2023-04-28 15:33:26 +02:00
parent abd5e1b558
commit 4ebb679a29
18 changed files with 352 additions and 350 deletions
@@ -47,6 +47,7 @@ class FileSelectionButtonThemeExtensionDefault
padding: const EdgeInsets.symmetric(horizontal: 10),
foregroundColors: MultiColor.single(theme.colorScheme.onPrimary),
backgroundColors: MultiColor.single(theme.colorScheme.primary),
animationDuration: Duration.zero,
);
return FileSelectionButtonThemeExtensionDefault(
@@ -46,6 +46,7 @@ class FlatButtonThemeExtensionDefault extends FlatButtonThemeExtension {
padding: theme.buttonTheme.padding,
foregroundColors: foregroundColor,
backgroundColors: backgroundColor,
animationDuration: Duration.zero,
);
return FlatButtonThemeExtensionDefault(
@@ -46,6 +46,7 @@ class SimpleIconButtonThemeExtensionDefault
padding: theme.buttonTheme.padding,
foregroundColors: foregroundColor,
backgroundColors: backgroundColor,
animationDuration: Duration.zero,
);
return SimpleIconButtonThemeExtensionDefault(
@@ -48,6 +48,7 @@ class SymbolButtonThemeExtensionDefault extends SymbolButtonThemeExtension {
padding: theme.buttonTheme.padding,
foregroundColors: foregroundColor,
backgroundColors: backgroundColor,
animationDuration: Duration.zero,
);
return SymbolButtonThemeExtensionDefault(
@@ -31,6 +31,7 @@ abstract class ButtonStyle<T> extends ThemeStyle<T> {
this.borderColors,
this.stroke,
this.shadow,
this.animationDuration,
});
/// Button radius
@@ -68,9 +69,15 @@ abstract class ButtonStyle<T> extends ThemeStyle<T> {
/// Default to `null`
final BoxShadow? shadow;
/// Animation duration
///
/// Default to `Duration.zero`
final Duration? animationDuration;
@override
String toString() =>
'ButtonStyle(radius: $radius, padding: $padding, foregroundColors: '
'$foregroundColors, backgroundColors: $backgroundColors, borderColors: '
'$borderColors, stroke: $stroke, shadow: $shadow)';
'$borderColors, stroke: $stroke, shadow: $shadow, '
'animationDuration: $animationDuration)';
}
@@ -16,6 +16,7 @@
import 'dart:ui';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:wyatt_ui_components/src/core/utils/multi_color.dart';
import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart';
@@ -37,6 +38,7 @@ class FileSelectionButtonStyle extends ButtonStyle<FileSelectionButtonStyle> {
super.borderColors,
super.stroke,
super.shadow,
super.animationDuration,
});
/// Merges non-null `b` attributes in `a`
@@ -61,6 +63,7 @@ class FileSelectionButtonStyle extends ButtonStyle<FileSelectionButtonStyle> {
borderColors: b.borderColors,
stroke: b.stroke,
shadow: b.shadow,
animationDuration: b.animationDuration,
);
}
@@ -96,6 +99,11 @@ class FileSelectionButtonStyle extends ButtonStyle<FileSelectionButtonStyle> {
padding: EdgeInsetsGeometry.lerp(a.padding, b.padding, t),
stroke: lerpDouble(a.stroke, b.stroke, t),
shadow: BoxShadow.lerp(a.shadow, b.shadow, t),
animationDuration: lerpDuration(
a.animationDuration ?? Duration.zero,
b.animationDuration ?? Duration.zero,
t,
),
);
}
@@ -124,6 +132,7 @@ class FileSelectionButtonStyle extends ButtonStyle<FileSelectionButtonStyle> {
MultiColor? borderColors,
double? stroke,
BoxShadow? shadow,
Duration? animationDuration,
}) =>
FileSelectionButtonStyle(
titleStyle: titleStyle ?? this.titleStyle,
@@ -135,5 +144,6 @@ class FileSelectionButtonStyle extends ButtonStyle<FileSelectionButtonStyle> {
borderColors: borderColors ?? this.borderColors,
stroke: stroke ?? this.stroke,
shadow: shadow ?? this.shadow,
animationDuration: animationDuration ?? this.animationDuration,
);
}
@@ -16,6 +16,7 @@
import 'dart:ui';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:wyatt_ui_components/src/core/utils/multi_color.dart';
import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart';
@@ -36,6 +37,7 @@ class FlatButtonStyle extends ButtonStyle<FlatButtonStyle> {
super.borderColors,
super.stroke,
super.shadow,
super.animationDuration,
});
/// Merges non-null `b` attributes in `a`
@@ -59,6 +61,7 @@ class FlatButtonStyle extends ButtonStyle<FlatButtonStyle> {
borderColors: b.borderColors,
stroke: b.stroke,
shadow: b.shadow,
animationDuration: b.animationDuration,
);
}
@@ -93,6 +96,11 @@ class FlatButtonStyle extends ButtonStyle<FlatButtonStyle> {
padding: EdgeInsetsGeometry.lerp(a.padding, b.padding, t),
stroke: lerpDouble(a.stroke, b.stroke, t),
shadow: BoxShadow.lerp(a.shadow, b.shadow, t),
animationDuration: lerpDuration(
a.animationDuration ?? Duration.zero,
b.animationDuration ?? Duration.zero,
t,
),
);
}
@@ -115,6 +123,7 @@ class FlatButtonStyle extends ButtonStyle<FlatButtonStyle> {
MultiColor? borderColors,
double? stroke,
BoxShadow? shadow,
Duration? animationDuration,
}) =>
FlatButtonStyle(
labelStyle: labelStyle ?? this.labelStyle,
@@ -125,5 +134,6 @@ class FlatButtonStyle extends ButtonStyle<FlatButtonStyle> {
borderColors: borderColors ?? this.borderColors,
stroke: stroke ?? this.stroke,
shadow: shadow ?? this.shadow,
animationDuration: animationDuration ?? this.animationDuration,
);
}
@@ -16,6 +16,7 @@
import 'dart:ui';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:wyatt_ui_components/src/core/utils/multi_color.dart';
import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart';
@@ -36,6 +37,7 @@ class SimpleIconButtonStyle extends ButtonStyle<SimpleIconButtonStyle> {
super.borderColors,
super.stroke,
super.shadow,
super.animationDuration,
});
/// Merges non-null `b` attributes in `a`
@@ -59,6 +61,7 @@ class SimpleIconButtonStyle extends ButtonStyle<SimpleIconButtonStyle> {
borderColors: b.borderColors,
stroke: b.stroke,
shadow: b.shadow,
animationDuration: b.animationDuration,
);
}
@@ -93,6 +96,11 @@ class SimpleIconButtonStyle extends ButtonStyle<SimpleIconButtonStyle> {
padding: EdgeInsetsGeometry.lerp(a.padding, b.padding, t),
stroke: lerpDouble(a.stroke, b.stroke, t),
shadow: BoxShadow.lerp(a.shadow, b.shadow, t),
animationDuration: lerpDuration(
a.animationDuration ?? Duration.zero,
b.animationDuration ?? Duration.zero,
t,
),
);
}
@@ -115,6 +123,7 @@ class SimpleIconButtonStyle extends ButtonStyle<SimpleIconButtonStyle> {
MultiColor? borderColors,
double? stroke,
BoxShadow? shadow,
Duration? animationDuration,
}) =>
SimpleIconButtonStyle(
dimension: dimension ?? this.dimension,
@@ -125,5 +134,6 @@ class SimpleIconButtonStyle extends ButtonStyle<SimpleIconButtonStyle> {
borderColors: borderColors ?? this.borderColors,
stroke: stroke ?? this.stroke,
shadow: shadow ?? this.shadow,
animationDuration: animationDuration ?? this.animationDuration,
);
}
@@ -16,6 +16,7 @@
import 'dart:ui';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:wyatt_ui_components/src/core/utils/multi_color.dart';
import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart';
@@ -37,6 +38,7 @@ class SymbolButtonStyle extends ButtonStyle<SymbolButtonStyle> {
super.borderColors,
super.stroke,
super.shadow,
super.animationDuration,
});
/// Merges non-null `b` attributes in `a`
@@ -61,6 +63,7 @@ class SymbolButtonStyle extends ButtonStyle<SymbolButtonStyle> {
borderColors: b.borderColors,
stroke: b.stroke,
shadow: b.shadow,
animationDuration: b.animationDuration,
);
}
@@ -96,6 +99,11 @@ class SymbolButtonStyle extends ButtonStyle<SymbolButtonStyle> {
padding: EdgeInsetsGeometry.lerp(a.padding, b.padding, t),
stroke: lerpDouble(a.stroke, b.stroke, t),
shadow: BoxShadow.lerp(a.shadow, b.shadow, t),
animationDuration: lerpDuration(
a.animationDuration ?? Duration.zero,
b.animationDuration ?? Duration.zero,
t,
),
);
}
@@ -124,6 +132,7 @@ class SymbolButtonStyle extends ButtonStyle<SymbolButtonStyle> {
MultiColor? borderColors,
double? stroke,
BoxShadow? shadow,
Duration? animationDuration,
}) =>
SymbolButtonStyle(
labelStyle: labelStyle ?? this.labelStyle,
@@ -135,5 +144,6 @@ class SymbolButtonStyle extends ButtonStyle<SymbolButtonStyle> {
borderColors: borderColors ?? this.borderColors,
stroke: stroke ?? this.stroke,
shadow: shadow ?? this.shadow,
animationDuration: animationDuration ?? this.animationDuration,
);
}