ToggleSwitchThemeData.standard constructor

ToggleSwitchThemeData.standard(
  1. FluentThemeData theme
)

Implementation

factory ToggleSwitchThemeData.standard(FluentThemeData theme) {
  final defaultKnobDecoration = BoxDecoration(
    borderRadius: BorderRadius.circular(100),
  );

  final defaultDecoration = BoxDecoration(
    borderRadius: BorderRadius.circular(100),
  );

  return ToggleSwitchThemeData(
    foregroundColor: ButtonState.resolveWith((states) {
      return states.isDisabled ? theme.resources.textFillColorDisabled : null;
    }),
    checkedDecoration: ButtonState.resolveWith((states) {
      return defaultDecoration.copyWith(
        color: ButtonThemeData.checkedInputColor(theme, states),
        border: Border.all(
          color: ButtonThemeData.checkedInputColor(theme, states),
        ),
      );
    }),
    uncheckedDecoration: ButtonState.resolveWith((states) {
      return defaultDecoration.copyWith(
        color: ButtonState.forStates(
          states,
          disabled: theme.resources.controlAltFillColorDisabled,
          pressed: theme.resources.controlAltFillColorQuarternary,
          hovering: theme.resources.controlAltFillColorTertiary,
          none: theme.resources.controlAltFillColorSecondary,
        ),
        border: Border.all(
          color: ButtonState.forStates(
            states,
            disabled: theme.resources.controlStrongFillColorDisabled,
            none: theme.resources.controlStrongFillColorDefault,
          ),
        ),
      );
    }),
    animationDuration: theme.fasterAnimationDuration,
    animationCurve: Curves.fastOutSlowIn,
    checkedKnobDecoration: ButtonState.resolveWith((states) {
      return defaultKnobDecoration.copyWith(
        color: states.isDisabled
            ? theme.resources.textOnAccentFillColorDisabled
            : theme.resources.textOnAccentFillColorPrimary,
      );
    }),
    uncheckedKnobDecoration: ButtonState.resolveWith((states) {
      return defaultKnobDecoration.copyWith(
        color: states.isDisabled
            ? theme.resources.textFillColorDisabled
            : theme.resources.textFillColorSecondary,
      );
    }),
  );
}