FRadioStyle.inherit constructor

FRadioStyle.inherit({
  1. required FColors colors,
  2. required FStyle style,
  3. required bool touch,
})

Creates a FRadioStyle that inherits its properties.

Implementation

factory FRadioStyle.inherit({required FColors colors, required FStyle style, required bool touch}) {
  final labels = FLabelStyles.inherit(style: style);
  final (padding, indicatorSize) = switch (touch) {
    true => (const EdgeInsets.all(3), 12.0),
    false => (const EdgeInsets.all(3), 8.0),
  };

  return .new(
    tappableStyle: style.tappableStyle.copyWith(motion: FTappableMotion.none),
    focusedOutlineStyle: FFocusedOutlineStyle(color: colors.primary, borderRadius: .circular(100)),
    padding: padding,
    borderColor: FVariants(
      colors.mutedForeground,
      variants: {
        [.disabled]: colors.disable(colors.mutedForeground),
        //
        [.error]: colors.error,
        [.error.and(.disabled)]: colors.disable(colors.error),
      },
    ),
    borderWidth: style.borderWidth,
    indicatorSize: indicatorSize,
    backgroundColor: FVariants(
      colors.card,
      variants: {
        [.disabled]: colors.disable(colors.card),
      },
    ),
    indicatorColor: FVariants(
      colors.primary,
      variants: {
        [.disabled]: colors.disable(colors.primary),
        //
        [.error]: colors.error,
        [.error.and(.disabled)]: colors.disable(colors.error),
      },
    ),
    leadingLabelStyle: labels.horizontalLeadingStyle,
    trailingLabelStyle: labels.horizontalTrailingStyle,
  );
}