FBadgeStyles.inherit constructor

FBadgeStyles.inherit({
  1. required FColors colors,
  2. required FTypography typography,
  3. required FStyle style,
  4. required bool touch,
})

Creates a FBadgeStyles that inherits its properties.

Implementation

factory FBadgeStyles.inherit({
  required FColors colors,
  required FTypography typography,
  required FStyle style,
  required bool touch,
}) {
  final destructiveTextStyle = typography.xs.copyWith(color: colors.destructive, fontWeight: .w500);
  final destructiveDecoration = ShapeDecoration(
    shape: RoundedSuperellipseBorder(borderRadius: style.borderRadius.pill),
    color: colors.destructive.withValues(alpha: colors.brightness == .light ? 0.1 : 0.2),
  );

  final outlineShape = RoundedSuperellipseBorder(
    side: BorderSide(color: colors.border, width: style.borderWidth),
    borderRadius: style.borderRadius.pill,
  );

  final padding = touch
      ? const EdgeInsets.symmetric(horizontal: 12, vertical: 6)
      : const EdgeInsets.symmetric(horizontal: 10, vertical: 6);

  return FBadgeStyles(
    .from(
      FBadgeStyle(
        decoration: ShapeDecoration(
          shape: RoundedSuperellipseBorder(borderRadius: style.borderRadius.pill),
          color: colors.primary,
        ),
        contentStyle: FBadgeContentStyle(
          labelTextStyle: typography.xs.copyWith(color: colors.primaryForeground, fontWeight: .w500),
          padding: padding,
        ),
      ),
      variants: {
        [.primary]: const .delta(),
        [.secondary]: .delta(
          decoration: .shapeDelta(color: colors.secondary),
          contentStyle: .delta(labelTextStyle: .delta(color: colors.secondaryForeground)),
        ),
        [.destructive]: FBadgeStyle(
          decoration: destructiveDecoration,
          contentStyle: FBadgeContentStyle(labelTextStyle: destructiveTextStyle, padding: padding),
        ),
        [.outline]: .delta(
          decoration: .shapeDelta(shape: outlineShape, color: colors.card),
          contentStyle: .delta(labelTextStyle: .delta(color: colors.foreground)),
        ),
      },
    ),
  );
}