Skip to content

Commit

Permalink
TW-1196: Update display pill with display name
Browse files Browse the repository at this point in the history
  • Loading branch information
nqhhdev authored and hoangdat committed Feb 15, 2024
1 parent 4cd6c2d commit cd49f8c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 4 additions & 0 deletions lib/domain/model/extensions/string_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ extension StringExtension on String {
? '${substring(0, 15)}...${substring(length - 15)}'
: this;
}

String get displayMentioned {
return '@[$this]';
}
}
7 changes: 4 additions & 3 deletions lib/pages/chat/events/html_message.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/config/setting_keys.dart';
import 'package:fluffychat/domain/model/extensions/string_extension.dart';
import 'package:fluffychat/pages/image_viewer/image_viewer.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
import 'package:fluffychat/utils/url_launcher.dart';
import 'package:fluffychat/widgets/mentionned_user.dart';
import 'package:fluffychat/widgets/mentioned_user.dart';
import 'package:flutter/material.dart';

import 'package:flutter_gen/gen_l10n/l10n.dart';
Expand Down Expand Up @@ -178,8 +179,8 @@ class HtmlMessage extends StatelessWidget {
pillBuilder: (identifier, url, onTap, getMxcUrl) {
final user = room.getUser(identifier);
final displayName = user?.displayName ?? identifier;
return MentionnedUser(
displayName: displayName,
return MentionedUser(
displayName: displayName.displayMentioned,
url: url,
onTap: !room.isDirectChat ? onTap : null,
textStyle: !room.isDirectChat
Expand Down
1 change: 1 addition & 0 deletions lib/pages/chat/input_bar/input_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ class InputBar extends StatelessWidget with PasteImageMixin {
textCapitalization: TextCapitalization.sentences,
),
suggestionsCallback: (text) {
if (room!.isDirectChat) return [];
final suggestions = getSuggestions(text);
if (suggestions.isNotEmpty) {
suggestionsController?.open();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import 'package:flutter/material.dart';
import 'package:flutter_matrix_html/text_parser.dart';

class MentionnedUser extends StatelessWidget {
class MentionedUser extends StatelessWidget {
final String displayName;
final String url;
final OnPillTap? onTap;
final TextStyle? textStyle;
final int? maxLines;

const MentionnedUser({
const MentionedUser({
Key? key,
required this.displayName,
required this.url,
this.textStyle,
this.onTap,
this.maxLines,
}) : super(key: key);

@override
Expand All @@ -25,7 +27,7 @@ class MentionnedUser extends StatelessWidget {
child: Text(
displayName,
style: textStyle,
maxLines: 1,
maxLines: maxLines,
overflow: TextOverflow.clip,
),
);
Expand Down

0 comments on commit cd49f8c

Please sign in to comment.