💄 Optimize some styling
This commit is contained in:
parent
ecf362cffc
commit
bcb176344c
@ -96,6 +96,8 @@ class _PostDetailScreenState extends State<PostDetailScreen> {
|
||||
),
|
||||
),
|
||||
]),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
)
|
||||
: Text('postDetail').tr(),
|
||||
),
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user