add mention support
This commit is contained in:
parent
6215537f8e
commit
bbe36ff86f
8 changed files with 198 additions and 107 deletions
|
|
@ -7,6 +7,7 @@ import "package:nexus/controllers/thumbnail_controller.dart";
|
|||
import "package:nexus/helpers/extensions/get_headers.dart";
|
||||
import "package:nexus/helpers/launch_helper.dart";
|
||||
import "package:nexus/models/image_data.dart";
|
||||
import "package:nexus/widgets/chat_page/html/mention_chip.dart";
|
||||
import "package:nexus/widgets/chat_page/html/spoiler_text.dart";
|
||||
import "package:nexus/widgets/chat_page/html/code_block.dart";
|
||||
import "package:nexus/widgets/chat_page/quoted.dart";
|
||||
|
|
@ -41,24 +42,7 @@ class Html extends ConsumerWidget {
|
|||
|
||||
"a" =>
|
||||
Uri.tryParse(element.attributes["href"] ?? "")?.host == "matrix.to"
|
||||
? InlineCustomWidget(
|
||||
child: ActionChip(
|
||||
label: Text(
|
||||
element.text
|
||||
.replaceFirst("https://matrix.to/#/", "")
|
||||
.replaceFirst("http://matrix.to/#/", ""),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).colorScheme.onPrimary,
|
||||
),
|
||||
),
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
onPressed: () {
|
||||
// TODO: Open room or join room dialog, or user popover
|
||||
showAboutDialog(context: context);
|
||||
},
|
||||
),
|
||||
)
|
||||
? MentionChip(element.text)
|
||||
: null,
|
||||
|
||||
"img" =>
|
||||
|
|
|
|||
26
lib/widgets/chat_page/html/mention_chip.dart
Normal file
26
lib/widgets/chat_page/html/mention_chip.dart
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import "package:flutter/material.dart";
|
||||
import "package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart";
|
||||
import "package:matrix/matrix.dart";
|
||||
|
||||
class MentionChip extends StatelessWidget {
|
||||
final String label;
|
||||
const MentionChip(this.label, {super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => InlineCustomWidget(
|
||||
child: ActionChip(
|
||||
label: Text(
|
||||
label.parseIdentifierIntoParts()?.primaryIdentifier ?? label,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).colorScheme.onPrimary,
|
||||
),
|
||||
),
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
onPressed: () {
|
||||
// TODO: Open room or join room dialog, or user popover
|
||||
showAboutDialog(context: context);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue