💄 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(),
|
: Text('postDetail').tr(),
|
||||||
),
|
),
|
||||||
|
@ -47,32 +47,33 @@ class MarkdownTextContent extends StatelessWidget {
|
|||||||
styleSheet: MarkdownStyleSheet.fromTheme(
|
styleSheet: MarkdownStyleSheet.fromTheme(
|
||||||
Theme.of(context),
|
Theme.of(context),
|
||||||
).copyWith(
|
).copyWith(
|
||||||
textScaler: textScaler,
|
textScaler: textScaler,
|
||||||
blockquote: TextStyle(
|
blockquote: TextStyle(
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
blockquoteDecoration: BoxDecoration(
|
blockquoteDecoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(4)),
|
borderRadius: const BorderRadius.all(Radius.circular(4)),
|
||||||
),
|
),
|
||||||
horizontalRuleDecoration: BoxDecoration(
|
horizontalRuleDecoration: BoxDecoration(
|
||||||
border: Border(
|
border: Border(
|
||||||
top: BorderSide(
|
top: BorderSide(
|
||||||
width: 1.0,
|
width: 1.0,
|
||||||
color: Theme.of(context).dividerColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
codeblockDecoration: BoxDecoration(
|
|
||||||
border: Border.all(
|
|
||||||
color: Theme.of(context).dividerColor,
|
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: {
|
builders: {
|
||||||
'code': _MarkdownTextCodeElement(),
|
|
||||||
},
|
},
|
||||||
softLineBreak: true,
|
softLineBreak: true,
|
||||||
extensionSet: markdown.ExtensionSet(
|
extensionSet: markdown.ExtensionSet(
|
||||||
@ -253,46 +254,3 @@ class _CustomEmoteInlineSyntax extends markdown.InlineSyntax {
|
|||||||
return true;
|
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"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.3.0+3"
|
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:
|
term_glyph:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -54,7 +54,6 @@ dependencies:
|
|||||||
flutter_markdown: ^0.7.4+1
|
flutter_markdown: ^0.7.4+1
|
||||||
url_launcher: ^6.3.1
|
url_launcher: ^6.3.1
|
||||||
flutter_animate: ^4.5.0
|
flutter_animate: ^4.5.0
|
||||||
syntax_highlight: ^0.4.0
|
|
||||||
google_fonts: ^6.2.1
|
google_fonts: ^6.2.1
|
||||||
path: ^1.9.0
|
path: ^1.9.0
|
||||||
relative_time: ^5.0.0
|
relative_time: ^5.0.0
|
||||||
|
Loading…
Reference in New Issue
Block a user