FSliderStyles.inherit constructor

FSliderStyles.inherit({
  1. required FColorScheme colorScheme,
  2. required FTypography typography,
  3. required FStyle style,
})

Creates a FSliderStyles that inherits its properties from the given FColorScheme.

Implementation

factory FSliderStyles.inherit({
  required FColorScheme colorScheme,
  required FTypography typography,
  required FStyle style,
}) {
  final enabledHorizontalStyle = FSliderStateStyle(
    labelTextStyle: style.enabledFormFieldStyle.labelTextStyle,
    descriptionTextStyle: style.enabledFormFieldStyle.descriptionTextStyle,
    activeColor: colorScheme.primary,
    inactiveColor: colorScheme.secondary,
    markStyle: FSliderMarkStyle(
      tickColor: colorScheme.mutedForeground,
      labelTextStyle: typography.xs.copyWith(color: colorScheme.mutedForeground),
      labelAnchor: Alignment.topCenter,
      labelOffset: 10,
    ),
    tooltipStyle: FTooltipStyle.inherit(colorScheme: colorScheme, typography: typography, style: style),
    thumbStyle: FSliderThumbStyle(
      color: colorScheme.primaryForeground,
      borderColor: colorScheme.primary,
      focusedOutlineStyle: style.focusedOutlineStyle,
    ),
  );

  final disabledHorizontalStyle = FSliderStateStyle(
    labelTextStyle: style.disabledFormFieldStyle.labelTextStyle,
    descriptionTextStyle: style.disabledFormFieldStyle.descriptionTextStyle,
    activeColor: colorScheme.disable(colorScheme.primary, colorScheme.secondary),
    inactiveColor: colorScheme.secondary,
    markStyle: FSliderMarkStyle(
      tickColor: colorScheme.mutedForeground,
      labelTextStyle: typography.xs.copyWith(color: colorScheme.mutedForeground),
      labelAnchor: Alignment.topCenter,
      labelOffset: 10,
    ),
    tooltipStyle: FTooltipStyle.inherit(colorScheme: colorScheme, typography: typography, style: style),
    thumbStyle: FSliderThumbStyle(
      color: colorScheme.primaryForeground,
      borderColor: colorScheme.disable(colorScheme.primary),
      focusedOutlineStyle: style.focusedOutlineStyle,
    ),
  );

  final errorHorizontalStyle = FSliderErrorStyle(
    labelTextStyle: style.errorFormFieldStyle.labelTextStyle,
    descriptionTextStyle: style.errorFormFieldStyle.descriptionTextStyle,
    errorTextStyle: style.errorFormFieldStyle.errorTextStyle,
    activeColor: colorScheme.error,
    inactiveColor: colorScheme.secondary,
    markStyle: FSliderMarkStyle(
      tickColor: colorScheme.mutedForeground,
      labelTextStyle: typography.xs.copyWith(color: colorScheme.error),
      labelAnchor: Alignment.topCenter,
      labelOffset: 10,
    ),
    tooltipStyle: FTooltipStyle.inherit(colorScheme: colorScheme, typography: typography, style: style),
    thumbStyle: FSliderThumbStyle(
      color: colorScheme.errorForeground,
      borderColor: colorScheme.error,
      focusedOutlineStyle: style.focusedOutlineStyle,
    ),
  );

  return FSliderStyles(
    horizontalStyle: FSliderStyle(
      labelLayoutStyle: const FLabelLayoutStyle(
        labelPadding: EdgeInsets.only(bottom: 5),
        childPadding: EdgeInsets.only(top: 10, bottom: 20, left: 10, right: 10),
        descriptionPadding: EdgeInsets.only(top: 10),
        errorPadding: EdgeInsets.only(top: 5),
      ),
      enabledStyle: enabledHorizontalStyle,
      disabledStyle: disabledHorizontalStyle,
      errorStyle: errorHorizontalStyle,
    ),
    verticalStyle: FSliderStyle(
      labelLayoutStyle: const FLabelLayoutStyle(
        labelPadding: EdgeInsets.only(bottom: 5),
        childPadding: EdgeInsets.all(10),
        descriptionPadding: EdgeInsets.only(top: 5),
        errorPadding: EdgeInsets.only(top: 5),
      ),
      enabledStyle: enabledHorizontalStyle.copyWith(
        markStyle: enabledHorizontalStyle.markStyle.copyWith(
          labelAnchor: Alignment.centerRight,
          labelOffset: -10,
        ),
      ),
      disabledStyle: disabledHorizontalStyle.copyWith(
        markStyle: disabledHorizontalStyle.markStyle.copyWith(
          labelAnchor: Alignment.centerRight,
          labelOffset: -10,
        ),
      ),
      errorStyle: errorHorizontalStyle.copyWith(
        markStyle: errorHorizontalStyle.markStyle.copyWith(
          labelAnchor: Alignment.centerRight,
          labelOffset: -10,
        ),
      ),
      tooltipTipAnchor: Touch.primary ? Alignment.bottomCenter : Alignment.centerLeft,
      tooltipThumbAnchor: Touch.primary ? Alignment.topCenter : Alignment.centerRight,
    ),
  );
}