Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the colors of inline code and code blocks #363

Closed
maelchiotti opened this issue Jun 3, 2024 · 5 comments · Fixed by #365
Closed

Improve the colors of inline code and code blocks #363

maelchiotti opened this issue Jun 3, 2024 · 5 comments · Fixed by #365
Labels
enhancement New feature or request

Comments

@maelchiotti
Copy link
Contributor

Steps to Reproduce

  1. Add some inline code or a code block

I find the colors of inline code and code blocks make them hard to use:

  • In light mode (pure white background), the code block especially is so light that I can barely distinguish it from the background. I prefer the background color of the inline code.
  • In dark mode, and even more in black mode, the background of the inline code and the code block should really be a dark gray. The inline code also has some really bad contrast that make it hard to read.

Screenshot_2024-06-03-09-43-19-289_com.maelchiotti.localmaterialnotes.jpg

Screenshot_2024-06-03-09-43-38-448_com.maelchiotti.localmaterialnotes.jpg

Screenshot_2024-06-03-09-43-44-608_com.maelchiotti.localmaterialnotes.jpg

Environment

  • OS: Android
  • Flutter version: 3.22
  • Fleather version: 1.14.5+1
@Amir-P
Copy link
Member

Amir-P commented Jun 9, 2024

Our default theme does not care much about the brightness and the base app theme. We need to improve it but for now it's better to customize it the way you want.

@maelchiotti
Copy link
Contributor Author

In the meantime, if it can be useful to anyone: here is how I customized the theme in my material 3 app. Inline code and code blocks look great in light, dark and black theme, with or without dynamic colors. I also made the text colors the same.

@override
Widget build(BuildContext context) {
  final theme = Theme.of(context);
  final fleatherThemeFallback = FleatherThemeData.fallback(context);

  return FleatherTheme(
    data: fleatherThemeFallback.copyWith(
      inlineCode: InlineCodeThemeData(
        backgroundColor: theme.colorScheme.surfaceContainerHigh, // Changed
        radius: fleatherThemeFallback.inlineCode.radius,
        style: fleatherThemeFallback.inlineCode.style.copyWith(
          color: theme.colorScheme.primary, // Changed
        ),
        heading1: fleatherThemeFallback.inlineCode.heading1,
        heading2: fleatherThemeFallback.inlineCode.heading2,
        heading3: fleatherThemeFallback.inlineCode.heading3,
      ),
      code: TextBlockTheme(
        decoration: fleatherThemeFallback.code.decoration!.copyWith(
          color: theme.colorScheme.surfaceContainerHigh, // Changed
        ),
        style: fleatherThemeFallback.code.style.copyWith(
          color: theme.colorScheme.primary, // Changed
        ),
        spacing: fleatherThemeFallback.code.spacing,
      ),
    ),
    child: FleatherField(
      controller: FleatherController(),
    ),
  );
}

@Amir-P
Copy link
Member

Amir-P commented Jun 9, 2024

Thanks! I haven't checked it yet but do you want to create a PR? @maelchiotti

@maelchiotti
Copy link
Contributor Author

Yeah why not! That would be my first ever! I'll fork the repo and check that my modifications do work properly

@maelchiotti
Copy link
Contributor Author

@Amir-P done in #365! Let me know over there if anything needs to be changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants