FSelectGroupStyle.inherit constructor

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

Creates a FSelectGroupStyle that inherits its properties.

Implementation

factory FSelectGroupStyle.inherit({required FColors colors, required FTypography typography, required FStyle style}) {
  final vertical = FLabelStyles.inherit(style: style).verticalStyle;

  final itemLabelTextStyle =
      FVariants<FFormFieldVariantConstraint, FFormFieldVariant, TextStyle, TextStyleDelta>.from(
        typography.sm.copyWith(color: colors.foreground, fontWeight: .w500),
        variants: {
          [.disabled]: .delta(color: colors.disable(colors.foreground)),
          //
          [.error]: .delta(color: colors.error),
          [.error.and(.disabled)]: .delta(color: colors.disable(colors.error)),
        },
      );
  final itemDescriptionTextStyle =
      FVariants<FFormFieldVariantConstraint, FFormFieldVariant, TextStyle, TextStyleDelta>.from(
        typography.sm.copyWith(color: colors.mutedForeground),
        variants: {
          [.disabled]: .delta(color: colors.disable(colors.mutedForeground)),
        },
      );
  final itemErrorTextStyle =
      FVariants<FFormFieldErrorVariantConstraint, FFormFieldErrorVariant, TextStyle, TextStyleDelta>.from(
        typography.sm.copyWith(color: colors.error, fontWeight: .w500),
        variants: {
          [.disabled]: .delta(color: colors.disable(colors.error)),
        },
      );

  return .new(
    checkboxStyle: .inherit(colors: colors, style: style).copyWith(
      labelTextStyle: itemLabelTextStyle,
      descriptionTextStyle: itemDescriptionTextStyle,
      errorTextStyle: itemErrorTextStyle,
    ),
    radioStyle: .inherit(colors: colors, style: style).copyWith(
      labelTextStyle: itemLabelTextStyle,
      descriptionTextStyle: itemDescriptionTextStyle,
      errorTextStyle: itemErrorTextStyle,
    ),
    labelTextStyle: style.formFieldStyle.labelTextStyle,
    descriptionTextStyle: style.formFieldStyle.descriptionTextStyle,
    errorTextStyle: style.formFieldStyle.errorTextStyle,
    labelPadding: vertical.labelPadding,
    descriptionPadding: vertical.descriptionPadding,
    errorPadding: vertical.errorPadding,
    childPadding: vertical.childPadding,
  );
}