textAreaStylesFromTheme function

TextAreaStyles textAreaStylesFromTheme(
  1. Theme theme
)

Implementation

TextAreaStyles textAreaStylesFromTheme(Theme theme) {
  final editorTheme = theme.editorTheme;
  final selection = Style()
      .background(theme.resolvedHighlight)
      .foreground(theme.resolvedOnHighlight);
  final focusedPrompt = theme.labelLarge.copy()
    ..foreground(editorTheme?.focusedPromptForeground ?? theme.onSurface)
    ..bold();
  final focusedText = theme.bodyMedium.copy().foreground(
    editorTheme?.focusedTextForeground ?? theme.onSurface,
  );
  final focusedPlaceholder = theme.labelMedium.copy().foreground(
    editorTheme?.focusedPlaceholderForeground ?? theme.resolvedOnSurfaceVariant,
  );
  final focusedLineNumber = theme.labelMedium.copy().foreground(
    editorTheme?.focusedLineNumberForeground ?? theme.resolvedOutline,
  );
  final blurredPrompt = theme.labelMedium.copy().foreground(
    editorTheme?.blurredPromptForeground ?? theme.resolvedOnSurfaceVariant,
  );
  final blurredText = theme.bodyMedium.copy().foreground(
    editorTheme?.blurredTextForeground ?? theme.resolvedOnSurfaceVariant,
  );
  final blurredPlaceholder = theme.labelSmall.copy()
    ..foreground(editorTheme?.blurredPlaceholderForeground ?? theme.muted);
  final blurredLineNumber = theme.labelSmall.copy().foreground(
    editorTheme?.blurredLineNumberForeground ?? theme.resolvedOutline,
  );
  final searchMatch = Style()
      .background(
        editorTheme?.searchMatchBackground ?? theme.resolvedSurfaceVariant,
      )
      .underline()
      .underlineColor(editorTheme?.searchMatchUnderlineColor ?? theme.primary);
  final errorLineNumber = theme.labelSmall.copy().foreground(theme.error);
  final warningLineNumber = theme.labelSmall.copy().foreground(theme.warning);
  final infoLineNumber = theme.labelSmall.copy().foreground(theme.resolvedInfo);
  final hintLineNumber = theme.labelSmall.copy().foreground(theme.muted);
  return TextAreaStyles(
    focused: TextAreaStyleState(
      decorationStyles: <String, Style>{
        textSearchMatchDecorationKey: searchMatch,
        textSearchActiveMatchDecorationKey: Style()
            .background(theme.resolvedHighlight)
            .foreground(theme.resolvedOnHighlight),
        textDiagnosticErrorDecorationKey: Style().underline().underlineColor(
          theme.error,
        ),
        textDiagnosticWarningDecorationKey: Style().underline().underlineColor(
          theme.warning,
        ),
        textDiagnosticInfoDecorationKey: Style().underline().underlineColor(
          theme.resolvedInfo,
        ),
        textDiagnosticHintDecorationKey: Style().underline().underlineColor(
          theme.muted,
        ),
      },
      lineDecorationStyles: <String, Style>{
        textActiveLineDecorationKey: Style().background(
          theme.resolvedSurfaceVariant,
        ),
        textActiveLineNumberDecorationKey: theme.labelSmall.copy().foreground(
          theme.primary,
        ),
        textDiagnosticErrorLineDecorationKey: Style(),
        textDiagnosticWarningLineDecorationKey: Style(),
        textDiagnosticInfoLineDecorationKey: Style(),
        textDiagnosticHintLineDecorationKey: Style(),
        textDiagnosticErrorLineNumberDecorationKey: errorLineNumber,
        textDiagnosticWarningLineNumberDecorationKey: warningLineNumber,
        textDiagnosticInfoLineNumberDecorationKey: infoLineNumber,
        textDiagnosticHintLineNumberDecorationKey: hintLineNumber,
      },
      prompt: focusedPrompt,
      text: focusedText,
      placeholder: focusedPlaceholder,
      lineNumber: focusedLineNumber,
      cursorLine: Style().background(
        editorTheme?.focusedCursorLineBackground ??
            theme.resolvedSurfaceVariant,
      ),
      cursorLineNumber: theme.labelMedium.copy()
        ..foreground(
          editorTheme?.focusedCursorLineNumberForeground ?? theme.primary,
        )
        ..bold(),
      endOfBuffer: theme.labelSmall.copy().foreground(theme.resolvedOutline),
      selection: selection,
    ),
    blurred: TextAreaStyleState(
      decorationStyles: <String, Style>{
        textSearchMatchDecorationKey: searchMatch,
        textSearchActiveMatchDecorationKey: Style()
            .background(theme.resolvedHighlight)
            .foreground(theme.resolvedOnHighlight),
        textDiagnosticErrorDecorationKey: Style().underline().underlineColor(
          theme.error,
        ),
        textDiagnosticWarningDecorationKey: Style().underline().underlineColor(
          theme.warning,
        ),
        textDiagnosticInfoDecorationKey: Style().underline().underlineColor(
          theme.resolvedInfo,
        ),
        textDiagnosticHintDecorationKey: Style().underline().underlineColor(
          theme.muted,
        ),
      },
      lineDecorationStyles: <String, Style>{
        textActiveLineDecorationKey: Style().background(theme.surface),
        textActiveLineNumberDecorationKey: theme.labelSmall.copy().foreground(
          theme.primary,
        ),
        textDiagnosticErrorLineDecorationKey: Style(),
        textDiagnosticWarningLineDecorationKey: Style(),
        textDiagnosticInfoLineDecorationKey: Style(),
        textDiagnosticHintLineDecorationKey: Style(),
        textDiagnosticErrorLineNumberDecorationKey: errorLineNumber,
        textDiagnosticWarningLineNumberDecorationKey: warningLineNumber,
        textDiagnosticInfoLineNumberDecorationKey: infoLineNumber,
        textDiagnosticHintLineNumberDecorationKey: hintLineNumber,
      },
      prompt: blurredPrompt,
      text: blurredText,
      placeholder: blurredPlaceholder,
      lineNumber: blurredLineNumber,
      cursorLine: Style().background(
        editorTheme?.blurredCursorLineBackground ??
            theme.resolvedSurfaceVariant,
      ),
      cursorLineNumber: blurredLineNumber.copy()
        ..foreground(
          editorTheme?.blurredCursorLineNumberForeground ??
              theme.resolvedOutline,
        ),
      endOfBuffer: theme.labelSmall.copy().foreground(theme.resolvedOutline),
      selection: selection,
    ),
    cursor: TextAreaCursorStyle(
      color: theme.primary,
      shape: CursorShape.block,
      blink: false,
    ),
  );
}