buildButtonStyle static method
Implementation
static ButtonStyle buildButtonStyle(
BuildContext context, {
required OudsButtonHierarchy hierarchy,
required OudsButtonLayout layout,
OudsButtonStyle? style,
}) {
double iconSize;
if (layout == OudsButtonLayout.iconOnly) {
iconSize = OudsTheme.of(context).componentsTokens.button.sizeIconOnly;
} else if (layout == OudsButtonLayout.iconAndText) {
iconSize = OudsTheme.of(context).componentsTokens.button.sizeIcon;
} else {
iconSize = 0.0;
}
return ButtonStyle(
backgroundColor: ButtonBackgroundModifier.resolveBackgroundColor(context, hierarchy, style),
foregroundColor: ButtonForegroundModifier.resolveForegroundColor(context, hierarchy, style),
iconColor: ButtonForegroundModifier.resolveForegroundColor(context, hierarchy, style),
splashFactory: NoSplash.splashFactory,
overlayColor: WidgetStateProperty.all(Colors.transparent),
iconSize: WidgetStateProperty.all<double>(iconSize),
textStyle: WidgetStateProperty.all<TextStyle>(
TextStyle(
fontSize: OudsTheme.of(context).fontTokens.sizeLabelLarge,
fontWeight: OudsTheme.of(context).fontTokens.weightLabelStrong,
letterSpacing: OudsTheme.of(context).fontTokens.letterSpacingLabelLarge,
fontFamily: OudsTheme.of(context).fontFamily,
package: OudsTheme.of(context).packageName),
),
side: ButtonBorderModifier.resolveBorderColor(context, hierarchy, style),
shape: WidgetStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(OudsTheme.of(context).componentsTokens.button.borderRadius),
),
),
padding: WidgetStateProperty.all<EdgeInsetsGeometry>(
ButtonPaddingModifier.getPadding(context, layout),
),
minimumSize: WidgetStateProperty.all<Size>(
Size(OudsTheme.of(context).componentsTokens.button.sizeMinWidth, OudsTheme.of(context).componentsTokens.button.sizeMinHeight),
),
animationDuration: Duration.zero,
);
}