Skip to content

Commit

Permalink
fixup! TW-2114: Add context menu when click on phone number on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
nqhhdev committed Nov 7, 2024
1 parent da9ccd9 commit 6f5378e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/pages/chat/events/html_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class HtmlMessage extends StatelessWidget with LinkifyMixin {
],
shrinkToFit: true,
maxLines: maxLines,
onLinkTap: (tapDownDetails, link) => handleOnTappedLinkHtml(
onTapDownLink: (tapDownDetails, link) => handleOnTappedLinkHtml(
context: context,
details: tapDownDetails,
link: link,
Expand Down
11 changes: 5 additions & 6 deletions lib/presentation/mixins/linkify_mixin.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import 'package:fluffychat/pages/chat/chat_context_menu_actions.dart';
import 'package:fluffychat/utils/extension/build_context_extension.dart';
import 'package:fluffychat/utils/extension/value_notifier_extension.dart';
import 'package:fluffychat/utils/responsive/responsive_utils.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/utils/url_launcher.dart';
import 'package:fluffychat/widgets/context_menu/context_menu_action.dart';
import 'package:fluffychat/widgets/context_menu/twake_context_menu.dart';
import 'package:fluffychat/di/global/get_it_initializer.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter/services.dart';
Expand All @@ -18,8 +17,6 @@ import 'package:url_launcher/url_launcher.dart';
mixin LinkifyMixin {
final ValueNotifier<bool> openingPopupMenu = ValueNotifier(false);

final _responsive = getIt.get<ResponsiveUtils>();

List<ChatContextMenuActions> get phoneNumberContextMenu => [
ChatContextMenuActions.copyNumber,
];
Expand Down Expand Up @@ -118,7 +115,7 @@ mixin LinkifyMixin {
UrlLauncher(context, url: link.value.toString()).launchUrl();
break;
case LinkType.phone:
if (_responsive.isMobile(context)) {
if (PlatformInfos.isMobile) {
await showPullDownMenu(
context: context,
items: [
Expand All @@ -131,7 +128,9 @@ mixin LinkifyMixin {
if (await canLaunchUrl(phoneUri)) {
launchUrl(phoneUri);
} else {
throw 'Could not launch $phoneUri';
Logs().e(
'LinkifyMixin: handleOnTappedLink: Cannot launch phoneUri: $phoneUri',
);
}
},
title: L10n.of(context)!.callViaCarrier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class TwakeLinkPreviewController extends State<TwakeLinkPreview>
linkStyle: widget.linkStyle,
fontSize: widget.fontSize,
)
: LinkifyText(
: MatrixLinkifyText(
widget.localizedBody,
textStyle: widget.richTextStyle,
linkStyle: widget.linkStyle,
Expand All @@ -79,7 +79,7 @@ class TwakeLinkPreviewController extends State<TwakeLinkPreview>
LinkType.phone,
],
textAlign: TextAlign.start,
onLinkTap: (tapDownDetails, link) => handleOnTappedLinkHtml(
onTapDownLink: (tapDownDetails, link) => handleOnTappedLinkHtml(
context: context,
details: tapDownDetails,
link: link,
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ packages:
description:
path: "."
ref: implement-linkify-text
resolved-ref: ababe4f8a777a51b2aa21819b0e4f524ce4ba0a0
resolved-ref: c6440c3a148084b5de5e897eb78e5e02b6a4ed90
url: "https://github.com/linagora/flutter_matrix_html.git"
source: git
version: "1.2.0"
Expand Down Expand Up @@ -1796,7 +1796,7 @@ packages:
description:
path: "."
ref: refactor-linkify
resolved-ref: "9f4b9debbe4da621897ea040f24e66da3c9ba980"
resolved-ref: d635cdb6ae9d8a9947166c34073cf252ee9cb476
url: "[email protected]:nqhhdev/linkfy_text.git"
source: git
version: "1.1.6"
Expand Down

0 comments on commit 6f5378e

Please sign in to comment.