💄 Better post rendering

This commit is contained in:
LittleSheep 2024-06-29 18:19:52 +08:00
parent fffad00f00
commit fdeb52bf38
4 changed files with 19 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import 'package:get/get.dart';
import 'package:solian/models/event.dart';
import 'package:solian/widgets/attachments/attachment_list.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:markdown/markdown.dart' as markdown;
class ChatEventMessage extends StatelessWidget {
final Event item;
@ -27,6 +28,7 @@ class ChatEventMessage extends StatelessWidget {
final body = EventMessageBody.fromJson(item.body);
return SizedBox(
key: Key('m${item.uuid}attachments-box'),
width: min(MediaQuery.of(context).size.width, 640),
child: AttachmentList(
key: Key('m${item.uuid}attachments'),
@ -48,6 +50,13 @@ class ChatEventMessage extends StatelessWidget {
data: body.text,
selectable: true,
padding: const EdgeInsets.all(0),
extensionSet: markdown.ExtensionSet(
markdown.ExtensionSet.gitHubFlavored.blockSyntaxes,
<markdown.InlineSyntax>[
markdown.EmojiSyntax(),
...markdown.ExtensionSet.gitHubFlavored.inlineSyntaxes
],
),
onTapLink: (text, href, title) async {
if (href == null) return;
await launchUrlString(

View File

@ -11,6 +11,7 @@ import 'package:solian/widgets/attachments/attachment_list.dart';
import 'package:solian/widgets/posts/post_quick_action.dart';
import 'package:timeago/timeago.dart' show format;
import 'package:url_launcher/url_launcher_string.dart';
import 'package:markdown/markdown.dart' as markdown;
class PostItem extends StatefulWidget {
final Post item;
@ -78,6 +79,13 @@ class _PostItemState extends State<PostItem> {
physics: const NeverScrollableScrollPhysics(),
data: item.content,
padding: const EdgeInsets.all(0),
extensionSet: markdown.ExtensionSet(
markdown.ExtensionSet.gitHubFlavored.blockSyntaxes,
<markdown.InlineSyntax>[
markdown.EmojiSyntax(),
...markdown.ExtensionSet.gitHubFlavored.inlineSyntaxes
],
),
onTapLink: (text, href, title) async {
if (href == null) return;
await launchUrlString(

View File

@ -905,7 +905,7 @@ packages:
source: hosted
version: "1.5.0"
markdown:
dependency: transitive
dependency: "direct main"
description:
name: markdown
sha256: ef2a1298144e3f985cc736b22e0ccdaf188b5b3970648f2d9dc13efd1d9df051

View File

@ -50,6 +50,7 @@ dependencies:
floor: ^1.5.0
sqflite: ^2.3.3+1
protocol_handler: ^0.2.0
markdown: ^7.2.2
dev_dependencies:
flutter_test: