From 177a7c3d74e7d094b53cff45ff9927870b2ca03d Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Mon, 27 Jan 2020 23:50:39 +0100 Subject: [PATCH] DarkMode: Improve markdown code blocks color Flutter_markdown has hardcoded certain grey colors. This doesn't go well with a dark theme. For now we're overwriting it. --- lib/screens/journal_browsing.dart | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/screens/journal_browsing.dart b/lib/screens/journal_browsing.dart index dd0c8927..c457267d 100644 --- a/lib/screens/journal_browsing.dart +++ b/lib/screens/journal_browsing.dart @@ -181,6 +181,26 @@ class NoteViewer extends StatelessWidget { ), ); + // Copied from MarkdownStyleSheet except Grey is replaced with Highlight color + var markdownStyleSheet = MarkdownStyleSheet.fromTheme(theme).copyWith( + code: theme.textTheme.body1.copyWith( + backgroundColor: theme.dialogBackgroundColor, + fontFamily: "monospace", + fontSize: theme.textTheme.body1.fontSize * 0.85, + ), + tableBorder: TableBorder.all(color: theme.highlightColor, width: 0), + tableCellsDecoration: BoxDecoration(color: theme.dialogBackgroundColor), + codeblockDecoration: BoxDecoration( + color: theme.dialogBackgroundColor, + borderRadius: BorderRadius.circular(2.0), + ), + horizontalRuleDecoration: BoxDecoration( + border: Border( + top: BorderSide(width: 5.0, color: theme.highlightColor), + ), + ), + ); + var view = SingleChildScrollView( child: Column( children: [ @@ -192,7 +212,7 @@ class NoteViewer extends StatelessWidget { padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), child: MarkdownBody( data: note.body, - styleSheet: MarkdownStyleSheet.fromTheme(theme), + styleSheet: markdownStyleSheet, onTapLink: (String link) { print("Launching " + link); launch(link);