custom emojis in names and no more markdown
This commit is contained in:
parent
d98150007e
commit
6fe0f6967e
|
@ -1,6 +1,8 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||||
import 'package:loris/business_logic/notifications/notifs.dart';
|
import 'package:loris/business_logic/notifications/notifs.dart';
|
||||||
import 'package:loris/dialogues/profile_view.dart';
|
import 'package:loris/dialogues/profile_view.dart';
|
||||||
|
import 'package:loris/partials/name.dart';
|
||||||
import 'package:loris/partials/post.dart';
|
import 'package:loris/partials/post.dart';
|
||||||
import '../../global.dart' as global;
|
import '../../global.dart' as global;
|
||||||
import 'package:loris/themes/themes.dart' as themes;
|
import 'package:loris/themes/themes.dart' as themes;
|
||||||
|
@ -49,9 +51,10 @@ class SingleNotif extends StatelessWidget {
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
SelectableText(
|
NameDisplay(
|
||||||
model.account.displayName,
|
emoji: model.account.emojis,
|
||||||
style: Theme.of(context).textTheme.displaySmall,
|
content: model.account.displayName,
|
||||||
|
style: Theme.of(context).textTheme.displaySmall!,
|
||||||
),
|
),
|
||||||
SelectableText.rich(
|
SelectableText.rich(
|
||||||
TextSpan(
|
TextSpan(
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||||
|
import 'package:loris/business_logic/emoji/emoji.dart';
|
||||||
|
|
||||||
|
class NameDisplay extends StatelessWidget {
|
||||||
|
const NameDisplay({
|
||||||
|
super.key,
|
||||||
|
required this.emoji,
|
||||||
|
required this.content,
|
||||||
|
required this.style,
|
||||||
|
});
|
||||||
|
final List<Emoji> emoji;
|
||||||
|
final String content;
|
||||||
|
final TextStyle style;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
String newtext = content;
|
||||||
|
newtext = newtext
|
||||||
|
.replaceAll("~", r"\~")
|
||||||
|
.replaceAll("_", r"\_")
|
||||||
|
.replaceAll("*", r"\*");
|
||||||
|
for (var e in emoji) {
|
||||||
|
newtext = insertEmojiInMd(newtext, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return MarkdownBody(
|
||||||
|
data: newtext,
|
||||||
|
styleSheet: MarkdownStyleSheet(p: style),
|
||||||
|
imageBuilder: (uri, title, alt) {
|
||||||
|
try {
|
||||||
|
return Image.network(
|
||||||
|
uri.toString(),
|
||||||
|
height: style.fontSize,
|
||||||
|
errorBuilder: (context, error, stackTrace) =>
|
||||||
|
SelectableText(alt ?? error.toString()),
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
return SelectableText(alt ?? "");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ import 'package:loris/dialogues/makepost.dart';
|
||||||
import 'package:loris/dialogues/profile_view.dart';
|
import 'package:loris/dialogues/profile_view.dart';
|
||||||
import 'package:loris/partials/interaction_button.dart';
|
import 'package:loris/partials/interaction_button.dart';
|
||||||
import 'package:loris/partials/media_attachment.dart';
|
import 'package:loris/partials/media_attachment.dart';
|
||||||
|
import 'package:loris/partials/name.dart';
|
||||||
import 'package:loris/partials/post_options.dart';
|
import 'package:loris/partials/post_options.dart';
|
||||||
import 'package:loris/partials/post_text_renderer.dart';
|
import 'package:loris/partials/post_text_renderer.dart';
|
||||||
import 'package:url_launcher/url_launcher_string.dart';
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
|
@ -117,13 +118,11 @@ class DisplayName extends StatelessWidget {
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
MarkdownBody(
|
NameDisplay(
|
||||||
data: dname,
|
emoji: account.emojis,
|
||||||
selectable: true,
|
content: account.displayName,
|
||||||
imageBuilder: (uri, title, alt) => Image.network(
|
style: usernameStyle!,
|
||||||
uri.toString(),
|
),
|
||||||
height: usernameStyle?.fontSize),
|
|
||||||
styleSheet: MarkdownStyleSheet(p: usernameStyle)),
|
|
||||||
SelectableText(
|
SelectableText(
|
||||||
account.acct,
|
account.acct,
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
|
|
Loading…
Reference in New Issue