FButtonStyles.inherit constructor

FButtonStyles.inherit({
  1. required FColors colors,
  2. required FTypography typography,
  3. required FStyle style,
})

Creates a FButtonStyles that inherits its properties.

Implementation

FButtonStyles.inherit({required FColors colors, required FTypography typography, required FStyle style})
  : this._(
      FVariants(
        FButtonSizeStyles.inherit(
          typography: typography,
          style: style,
          decoration: FVariants.from(
            BoxDecoration(borderRadius: style.borderRadius, color: colors.primary),
            variants: {
              [.hovered, .pressed]: .delta(color: colors.hover(colors.primary)),
              //
              [.disabled]: .delta(color: colors.disable(colors.primary)),
              //
              [.selected]: .delta(color: colors.hover(colors.primary)),
              [.selected.and(.disabled)]: .delta(color: colors.disable(colors.hover(colors.primary))),
            },
          ),
          foregroundColor: colors.primaryForeground,
          disabledForegroundColor: colors.disable(colors.primaryForeground),
        ),
        variants: {
          [.secondary]: FButtonSizeStyles.inherit(
            typography: typography,
            style: style,
            decoration: FVariants.from(
              BoxDecoration(borderRadius: style.borderRadius, color: colors.secondary),
              variants: {
                [.hovered, .pressed]: .delta(color: colors.hover(colors.secondary)),
                //
                [.disabled]: .delta(color: colors.disable(colors.secondary)),
                //
                [.selected]: .delta(color: colors.hover(colors.secondary)),
                [.selected.and(.disabled)]: .delta(color: colors.disable(colors.hover(colors.secondary))),
              },
            ),
            foregroundColor: colors.secondaryForeground,
            disabledForegroundColor: colors.disable(colors.secondaryForeground),
          ),
          [.destructive]: FButtonSizeStyles.inherit(
            typography: typography,
            style: style,
            decoration: FVariants.from(
              BoxDecoration(
                borderRadius: style.borderRadius,
                color: colors.destructive.withValues(alpha: colors.brightness == .light ? 0.1 : 0.2),
              ),
              variants: {
                [.hovered, .pressed]: .delta(
                  color: colors.destructive.withValues(alpha: colors.brightness == .light ? 0.2 : 0.3),
                ),
                //
                [.disabled]: .delta(
                  color: colors.destructive.withValues(alpha: colors.brightness == .light ? 0.05 : 0.1),
                ),
                //
                [.selected]: .delta(
                  color: colors.destructive.withValues(alpha: colors.brightness == .light ? 0.2 : 0.3),
                ),
                [.selected.and(.disabled)]: .delta(
                  color: colors.disable(
                    colors.destructive.withValues(alpha: colors.brightness == .light ? 0.2 : 0.3),
                  ),
                ),
              },
            ),
            foregroundColor: colors.destructive,
            disabledForegroundColor: colors.destructive.withValues(alpha: 0.5),
          ),
          [.outline]: FButtonSizeStyles.inherit(
            typography: typography,
            style: style,
            decoration: FVariants.from(
              BoxDecoration(
                border: .all(color: colors.border),
                borderRadius: style.borderRadius,
                color: colors.card,
              ),
              variants: {
                [.hovered, .pressed]: .delta(color: colors.secondary),
                //
                [.disabled]: .delta(color: colors.disable(colors.card)),
                //
                [.selected]: .delta(color: colors.secondary),
                [.selected.and(.disabled)]: .delta(color: colors.disable(colors.secondary)),
              },
            ),
            foregroundColor: colors.secondaryForeground,
            disabledForegroundColor: colors.disable(colors.secondaryForeground),
          ),
          [.ghost]: FButtonSizeStyles.inherit(
            typography: typography,
            style: style,
            decoration: FVariants.from(
              BoxDecoration(borderRadius: style.borderRadius),
              variants: {
                [.hovered, .pressed]: .delta(color: colors.secondary),
                //
                [.disabled]: const .delta(),
                //
                [.selected]: .delta(color: colors.secondary),
                [.selected.and(.disabled)]: .delta(color: colors.disable(colors.secondary)),
              },
            ),
            foregroundColor: colors.secondaryForeground,
            disabledForegroundColor: colors.disable(colors.secondaryForeground),
          ),
        },
      ),
    );