getColor method

Color getColor(
  1. BuildContext context
)

Implementation

Color getColor(BuildContext context) {
  if (color != null) {
    return color!;
  }
  // to refactor: use map instead of multi level switch
  switch (state) {
    case TDLinkState.normal:
      switch (style) {
        case TDLinkStyle.primary:
          return TDTheme.of(context).brandNormalColor;
        case TDLinkStyle.danger:
          return TDTheme.of(context).errorColor6;
        case TDLinkStyle.warning:
          return TDTheme.of(context).warningColor5;
        case TDLinkStyle.success:
          return TDTheme.of(context).successColor5;
        case TDLinkStyle.defaultStyle:
          return TDTheme.of(context).fontGyColor1;
      }

    case TDLinkState.active:
      switch (style) {
        case TDLinkStyle.primary:
          return TDTheme.of(context).brandClickColor;
        case TDLinkStyle.danger:
          return TDTheme.of(context).errorColor7;
        case TDLinkStyle.warning:
          return TDTheme.of(context).warningColor6;
        case TDLinkStyle.success:
          return TDTheme.of(context).successColor6;
        case TDLinkStyle.defaultStyle:
          return TDTheme.of(context).brandClickColor;
      }
    case TDLinkState.disabled:
      switch (style) {
        case TDLinkStyle.primary:
          return TDTheme.of(context).brandDisabledColor;
        case TDLinkStyle.danger:
          return TDTheme.of(context).errorDisabledColor;
        case TDLinkStyle.warning:
          return TDTheme.of(context).warningDisabledColor;
        case TDLinkStyle.success:
          return TDTheme.of(context).successDisabledColor;
        case TDLinkStyle.defaultStyle:
          return TDTheme.of(context).fontGyColor4;
      }
  }
}