Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TW-893: Remove pill on mentionned users #927

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/pages/chat/events/html_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import 'package:fluffychat/pages/chat/chat.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/pill.dart';
import 'package:fluffychat/widgets/mentionned_user.dart';
import 'package:flutter/material.dart';

import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter_matrix_html/flutter_html.dart';
import 'package:matrix/matrix.dart';
import 'package:fluffychat/presentation/extensions/send_file_extension.dart';

import 'package:fluffychat/widgets/matrix.dart';

Expand Down Expand Up @@ -174,11 +175,16 @@ class HtmlMessage extends StatelessWidget {
if (chatController == null) {
return null;
}
return Pill(
identifier: identifier,
chatController: chatController!,

final user = chatController?.room?.getUser(identifier);
final displayName = user?.displayName ?? identifier;
return MentionnedUser(
displayName: displayName,
url: url,
onTap: onTap,
textStyle: defaultTextStyle?.copyWith(
color: themeData.colorScheme.primary,
),
);
},
);
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/chat/input_bar/focus_suggestion_list.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:math';

import 'package:fluffychat/pages/chat/input_bar/focus_suggestion_controller.dart';
import 'package:fluffychat/pages/chat/input_bar/input_bar.dart';
import 'package:fluffychat/pages/chat/input_bar/input_bar_style.dart';
import 'package:flutter/material.dart';

class FocusSuggestionList extends StatefulWidget {
Expand Down
58 changes: 32 additions & 26 deletions lib/pages/chat/input_bar/input_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:fluffychat/pages/chat/input_bar/context_menu_input_bar.dart';
import 'package:fluffychat/pages/chat/input_bar/focus_suggestion_controller.dart';
import 'package:fluffychat/pages/chat/input_bar/focus_suggestion_list.dart';
import 'package:fluffychat/pages/chat/input_bar/input_bar_shortcut.dart';
import 'package:fluffychat/pages/chat/input_bar/input_bar_style.dart';
import 'package:fluffychat/presentation/extensions/text_editting_controller_extension.dart';
import 'package:fluffychat/presentation/mixins/paste_image_mixin.dart';
import 'package:fluffychat/utils/clipboard.dart';
Expand All @@ -14,6 +15,7 @@ import 'package:fluffychat/widgets/mxc_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter_typeahead/flutter_typeahead.dart';
import 'package:linagora_design_flutter/linagora_design_flutter.dart';
import 'package:matrix/matrix.dart';
import 'package:slugify/slugify.dart';

Expand Down Expand Up @@ -535,7 +537,7 @@ class SuggestionTile extends StatelessWidget {
if (suggestion['type'] == 'user' || suggestion['type'] == 'room') {
final url = Uri.parse(suggestion['avatar_url'] ?? '');
return Container(
padding: const EdgeInsetsDirectional.all(4.0),
padding: const EdgeInsetsDirectional.all(8.0),
nqhhdev marked this conversation as resolved.
Show resolved Hide resolved
height: InputBarStyle.suggestionSize,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
Expand All @@ -548,12 +550,35 @@ class SuggestionTile extends StatelessWidget {
fontSize: InputBarStyle.suggestionAvatarFontSize,
client: client,
),
const SizedBox(width: 6),
Flexible(
child: Text(
suggestion['displayname'] ?? suggestion['mxid']!,
maxLines: 1,
overflow: TextOverflow.clip,
const SizedBox(
width: InputBarStyle.suggestionTileAvatarTextGap,
),
Expanded(
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Flexible(
child: Text(
suggestion['displayname'] ?? suggestion['mxid']!,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
color: Theme.of(context).colorScheme.onSurface,
),
),
),
Flexible(
child: Text(
maxLines: 1,
suggestion['mxid']!,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.labelLarge?.copyWith(
color: LinagoraRefColors.material().tertiary[30],
),
),
),
],
),
),
],
Expand All @@ -563,22 +588,3 @@ class SuggestionTile extends StatelessWidget {
return Container();
}
}

class InputBarStyle {
static const double suggestionAvatarSize = 30;

static const double suggestionAvatarFontSize = 15;

static const double suggestionSize = 50;

static const double suggestionBorderRadius = 12.0;

static const double suggestionListPadding = 8.0;

static TextStyle getTypeAheadTextStyle(BuildContext context) => TextStyle(
fontSize: 15,
color: Theme.of(context).brightness == Brightness.light
? Colors.black
: Colors.white,
);
}
22 changes: 22 additions & 0 deletions lib/pages/chat/input_bar/input_bar_style.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'package:flutter/material.dart';

class InputBarStyle {
static const double suggestionAvatarSize = 30;

static const double suggestionAvatarFontSize = 15;

static const double suggestionSize = 50;

static const double suggestionBorderRadius = 12.0;

static const double suggestionListPadding = 8.0;

static TextStyle getTypeAheadTextStyle(BuildContext context) => TextStyle(
fontSize: 15,
color: Theme.of(context).brightness == Brightness.light
? Colors.black
: Colors.white,
);

static const double suggestionTileAvatarTextGap = 8.0;
}
37 changes: 37 additions & 0 deletions lib/widgets/mentionned_user.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'package:fluffychat/utils/string_extension.dart';
import 'package:flutter/material.dart';
import 'package:flutter_matrix_html/text_parser.dart';

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

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

final int _maxCharactersDisplayNameForPill = 12;

@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
onTap?.call(url);
},
child: Text(
displayName.shortenDisplayName(
maxCharacters: _maxCharactersDisplayNameForPill,
),
style: textStyle,
maxLines: 1,
overflow: TextOverflow.clip,
),
);
}
}
74 changes: 0 additions & 74 deletions lib/widgets/pill.dart

This file was deleted.