diff --git a/lib/screens/post/post_detail.dart b/lib/screens/post/post_detail.dart index 845fe31..1c60acd 100644 --- a/lib/screens/post/post_detail.dart +++ b/lib/screens/post/post_detail.dart @@ -96,6 +96,8 @@ class _PostDetailScreenState extends State { ), ), ]), + maxLines: 2, + overflow: TextOverflow.ellipsis, ) : Text('postDetail').tr(), ), diff --git a/lib/widgets/markdown_content.dart b/lib/widgets/markdown_content.dart index 6917b4e..2fcae6f 100644 --- a/lib/widgets/markdown_content.dart +++ b/lib/widgets/markdown_content.dart @@ -47,32 +47,33 @@ class MarkdownTextContent extends StatelessWidget { styleSheet: MarkdownStyleSheet.fromTheme( Theme.of(context), ).copyWith( - textScaler: textScaler, - blockquote: TextStyle( - color: Theme.of(context).colorScheme.onSurfaceVariant, - ), - blockquoteDecoration: BoxDecoration( - color: Theme.of(context).colorScheme.surfaceContainerHigh, - borderRadius: const BorderRadius.all(Radius.circular(4)), - ), - horizontalRuleDecoration: BoxDecoration( - border: Border( - top: BorderSide( - width: 1.0, - color: Theme.of(context).dividerColor, - ), - ), - ), - codeblockDecoration: BoxDecoration( - border: Border.all( + textScaler: textScaler, + blockquote: TextStyle( + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + blockquoteDecoration: BoxDecoration( + color: Theme.of(context).colorScheme.surfaceContainerHigh, + borderRadius: const BorderRadius.all(Radius.circular(4)), + ), + horizontalRuleDecoration: BoxDecoration( + border: Border( + top: BorderSide( + width: 1.0, color: Theme.of(context).dividerColor, - width: 0.3, ), - borderRadius: const BorderRadius.all(Radius.circular(4)), - color: Theme.of(context).colorScheme.surface.withOpacity(0.5), - )), + ), + ), + codeblockDecoration: BoxDecoration( + border: Border.all( + color: Theme.of(context).dividerColor, + width: 0.3, + ), + borderRadius: const BorderRadius.all(Radius.circular(4)), + color: Theme.of(context).colorScheme.surface.withOpacity(0.5), + ), + code: GoogleFonts.robotoMono(height: 1), + ), builders: { - 'code': _MarkdownTextCodeElement(), }, softLineBreak: true, extensionSet: markdown.ExtensionSet( @@ -253,46 +254,3 @@ class _CustomEmoteInlineSyntax extends markdown.InlineSyntax { return true; } } - -class _MarkdownTextCodeElement extends MarkdownElementBuilder { - @override - Widget? visitElementAfter( - markdown.Element element, - TextStyle? preferredStyle, - ) { - var language = ''; - - if (element.attributes['class'] != null) { - String lg = element.attributes['class'] as String; - language = lg.substring(9).trim(); - } - return SizedBox( - child: FutureBuilder( - future: (() async { - final docPath = '../../../'; - final highlightingPath = join(docPath, 'assets/highlighting', language); - await Highlighter.initialize([highlightingPath]); - return Highlighter( - language: highlightingPath, - theme: PlatformDispatcher.instance.platformBrightness == Brightness.light - ? await HighlighterTheme.loadLightTheme() - : await HighlighterTheme.loadDarkTheme(), - ); - })(), - builder: (context, snapshot) { - if (snapshot.hasData) { - final highlighter = snapshot.data!; - return Text.rich( - highlighter.highlight(element.textContent.trim()), - style: GoogleFonts.robotoMono(), - ); - } - return Text( - element.textContent.trim(), - style: GoogleFonts.robotoMono(), - ); - }, - ), - ).padding(all: 8); - } -} diff --git a/pubspec.lock b/pubspec.lock index d1e6787..e0f02c0 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1863,14 +1863,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.3.0+3" - syntax_highlight: - dependency: "direct main" - description: - name: syntax_highlight - sha256: ee33b6aa82cc722bb9b40152a792181dee222353b486c0255fde666a3e3a4997 - url: "https://pub.dev" - source: hosted - version: "0.4.0" term_glyph: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index f0d8f41..2bbc205 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -54,7 +54,6 @@ dependencies: flutter_markdown: ^0.7.4+1 url_launcher: ^6.3.1 flutter_animate: ^4.5.0 - syntax_highlight: ^0.4.0 google_fonts: ^6.2.1 path: ^1.9.0 relative_time: ^5.0.0