diff --git a/ios/Gemfile.lock b/ios/Gemfile.lock index b6731f0dc..aaaffc7b4 100644 --- a/ios/Gemfile.lock +++ b/ios/Gemfile.lock @@ -156,7 +156,8 @@ GEM trailblazer-option (>= 0.1.1, < 0.2.0) uber (< 0.2.0) retriable (3.1.2) - rexml (3.2.5) + rexml (3.2.8) + strscan (>= 3.0.9) rouge (2.0.7) ruby2_keywords (0.0.4) rubyzip (2.3.0) @@ -169,6 +170,7 @@ GEM simctl (1.6.8) CFPropertyList naturally + strscan (3.1.0) terminal-notifier (2.0.0) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) diff --git a/lib/pages/chat/events/message_content.dart b/lib/pages/chat/events/message_content.dart index 5910c15f4..ee6753e8b 100644 --- a/lib/pages/chat/events/message_content.dart +++ b/lib/pages/chat/events/message_content.dart @@ -286,7 +286,6 @@ class MessageContent extends StatelessWidget { final bigEmotes = event.onlyEmotes && event.numberEmotes > 0 && event.numberEmotes <= 10; - // #Pangea final messageTextStyle = TextStyle( color: textColor, fontSize: bigEmotes ? fontSize * 3 : fontSize, @@ -305,87 +304,59 @@ class MessageContent extends StatelessWidget { pangeaMessageEvent!.body, ); } - // Pangea# - return FutureBuilder( - future: event.calcLocalizedBody( + + // return Linkify( + return SelectableLinkify( + onSelectionChanged: (selection, cause) { + if (cause == SelectionChangedCause.longPress && + toolbarController != null && + pangeaMessageEvent != null && + !(toolbarController!.highlighted) && + !selected) { + toolbarController!.controller.onSelectMessage( + pangeaMessageEvent!.event, + ); + return; + } + toolbarController?.toolbar?.textSelection + .onTextSelection(selection); + }, + onTap: () => toolbarController?.showToolbar(context), + contextMenuBuilder: (context, state) => + (toolbarController?.highlighted ?? false) + ? const SizedBox.shrink() + : MessageContextMenu.contextMenuOverride( + context: context, + textSelection: state, + onDefine: () => toolbarController?.showToolbar( + context, + mode: MessageMode.definition, + ), + onListen: () => toolbarController?.showToolbar( + context, + mode: MessageMode.textToSpeech, + ), + ), + enableInteractiveSelection: + toolbarController?.highlighted ?? false, + // Pangea# + text: event.calcLocalizedBodyFallback( MatrixLocals(L10n.of(context)!), hideReply: true, ), - builder: (context, snapshot) { - // #Pangea - if (!snapshot.hasData) { - return Text( - // Pangea# - event.calcLocalizedBodyFallback( - MatrixLocals(L10n.of(context)!), - hideReply: true, - ), - // #Pangea - style: messageTextStyle, - ); - } - // return Linkify( - final String messageText = snapshot.data ?? - event.calcLocalizedBodyFallback( - MatrixLocals(L10n.of(context)!), - hideReply: true, - ); - return SelectableLinkify( - onSelectionChanged: (selection, cause) { - if (cause == SelectionChangedCause.longPress && - toolbarController != null && - pangeaMessageEvent != null && - !(toolbarController!.highlighted) && - !selected) { - toolbarController!.controller.onSelectMessage( - pangeaMessageEvent!.event, - ); - return; - } - toolbarController?.toolbar?.textSelection - .onTextSelection(selection); - }, - onTap: () => toolbarController?.showToolbar(context), - text: messageText, - contextMenuBuilder: (context, state) => - (toolbarController?.highlighted ?? false) - ? const SizedBox.shrink() - : MessageContextMenu.contextMenuOverride( - context: context, - textSelection: state, - onDefine: () => toolbarController?.showToolbar( - context, - mode: MessageMode.definition, - ), - onListen: () => toolbarController?.showToolbar( - context, - mode: MessageMode.textToSpeech, - ), - ), - enableInteractiveSelection: - toolbarController?.highlighted ?? false, - // text: snapshot.data ?? - // event.calcLocalizedBodyFallback( - // MatrixLocals(L10n.of(context)!), - // hideReply: true, - // ), - // Pangea# - style: TextStyle( - color: textColor, - fontSize: bigEmotes ? fontSize * 3 : fontSize, - decoration: - event.redacted ? TextDecoration.lineThrough : null, - ), - options: const LinkifyOptions(humanize: false), - linkStyle: TextStyle( - color: textColor.withAlpha(150), - fontSize: bigEmotes ? fontSize * 3 : fontSize, - decoration: TextDecoration.underline, - decorationColor: textColor.withAlpha(150), - ), - onOpen: (url) => UrlLauncher(context, url.url).launchUrl(), - ); - }, + style: TextStyle( + color: textColor, + fontSize: bigEmotes ? fontSize * 3 : fontSize, + decoration: event.redacted ? TextDecoration.lineThrough : null, + ), + options: const LinkifyOptions(humanize: false), + linkStyle: TextStyle( + color: textColor.withAlpha(150), + fontSize: bigEmotes ? fontSize * 3 : fontSize, + decoration: TextDecoration.underline, + decorationColor: textColor.withAlpha(150), + ), + onOpen: (url) => UrlLauncher(context, url.url).launchUrl(), ); } case EventTypes.CallInvite: diff --git a/lib/pages/chat/events/state_message.dart b/lib/pages/chat/events/state_message.dart index 861247b95..79ab9a617 100644 --- a/lib/pages/chat/events/state_message.dart +++ b/lib/pages/chat/events/state_message.dart @@ -21,22 +21,15 @@ class StateMessage extends StatelessWidget { color: Theme.of(context).colorScheme.background, borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2), ), - child: FutureBuilder( - future: event.calcLocalizedBody(MatrixLocals(L10n.of(context)!)), - builder: (context, snapshot) { - return Text( - snapshot.data ?? - event.calcLocalizedBodyFallback( - MatrixLocals(L10n.of(context)!), - ), - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 12 * AppConfig.fontSizeFactor, - decoration: - event.redacted ? TextDecoration.lineThrough : null, - ), - ); - }, + child: Text( + event.calcLocalizedBodyFallback( + MatrixLocals(L10n.of(context)!), + ), + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12 * AppConfig.fontSizeFactor, + decoration: event.redacted ? TextDecoration.lineThrough : null, + ), ), ), ), diff --git a/lib/pages/chat/input_bar.dart b/lib/pages/chat/input_bar.dart index 330508af7..a02626978 100644 --- a/lib/pages/chat/input_bar.dart +++ b/lib/pages/chat/input_bar.dart @@ -1,7 +1,6 @@ import 'package:emojis/emoji.dart'; import 'package:fluffychat/config/app_config.dart'; import 'package:fluffychat/pangea/widgets/igc/pangea_text_controller.dart'; -import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_file_extension.dart'; import 'package:fluffychat/utils/platform_infos.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -50,12 +49,12 @@ class InputBar extends StatelessWidget { List> getSuggestions(String text) { // #Pangea final List> ret = >[]; + // Pangea# if (controller!.selection.baseOffset != controller!.selection.extentOffset || controller!.selection.baseOffset < 0) { return []; // no entries if there is selected text } - // Pangea# final searchText = controller!.text.substring(0, controller!.selection.baseOffset); // #Pangea @@ -479,8 +478,11 @@ class InputBar extends StatelessWidget { mimeType: content.mimeType, bytes: data, name: content.uri.split('/').last, - ).detectFileType; - room.sendFileEvent(file, shrinkImageMaxDimension: 1600); + ); + room.sendFileEvent( + file, + shrinkImageMaxDimension: 1600, + ); }, ), minLines: minLines, @@ -488,6 +490,9 @@ class InputBar extends StatelessWidget { keyboardType: keyboardType!, textInputAction: textInputAction, autofocus: autofocus!, + inputFormatters: [ + LengthLimitingTextInputFormatter((maxPDUSize / 3).floor()), + ], onSubmitted: (text) { // fix for library for now // it sets the types for the callback incorrectly diff --git a/lib/pages/chat/pinned_events.dart b/lib/pages/chat/pinned_events.dart index be4ea73ed..0940a786f 100644 --- a/lib/pages/chat/pinned_events.dart +++ b/lib/pages/chat/pinned_events.dart @@ -63,33 +63,24 @@ class PinnedEvents extends StatelessWidget { future: controller.room.getEventById(pinnedEventIds.last), builder: (context, snapshot) { final event = snapshot.data; - return FutureBuilder( - future: event?.calcLocalizedBody( - MatrixLocals(L10n.of(context)!), - withSenderNamePrefix: true, - hideReply: true, - ), - builder: (context, snapshot) => ChatAppBarListTile( - title: snapshot.data ?? - event?.calcLocalizedBodyFallback( - MatrixLocals(L10n.of(context)!), - withSenderNamePrefix: true, - hideReply: true, - ) ?? - L10n.of(context)!.loadingPleaseWait, - leading: IconButton( - splashRadius: 20, - iconSize: 20, - color: Theme.of(context).colorScheme.onSurfaceVariant, - icon: const Icon(Icons.push_pin), - tooltip: L10n.of(context)!.unpin, - onPressed: - controller.room.canSendEvent(EventTypes.RoomPinnedEvents) - ? () => controller.unpinEvent(event!.eventId) - : null, - ), - onTap: () => _displayPinnedEventsDialog(context), + return ChatAppBarListTile( + title: event?.calcLocalizedBodyFallback( + MatrixLocals(L10n.of(context)!), + withSenderNamePrefix: true, + hideReply: true, + ) ?? + L10n.of(context)!.loadingPleaseWait, + leading: IconButton( + splashRadius: 20, + iconSize: 20, + color: Theme.of(context).colorScheme.onSurfaceVariant, + icon: const Icon(Icons.push_pin), + tooltip: L10n.of(context)!.unpin, + onPressed: controller.room.canSendEvent(EventTypes.RoomPinnedEvents) + ? () => controller.unpinEvent(event!.eventId) + : null, ), + onTap: () => _displayPinnedEventsDialog(context), ); }, ); diff --git a/lib/pages/chat/reply_display.dart b/lib/pages/chat/reply_display.dart index 67bf47c52..03acd269e 100644 --- a/lib/pages/chat/reply_display.dart +++ b/lib/pages/chat/reply_display.dart @@ -66,27 +66,17 @@ class _EditContent extends StatelessWidget { color: Theme.of(context).colorScheme.primary, ), Container(width: 15.0), - FutureBuilder( - future: event.calcLocalizedBody( + Text( + event.calcLocalizedBodyFallback( MatrixLocals(L10n.of(context)!), withSenderNamePrefix: false, hideReply: true, ), - builder: (context, snapshot) { - return Text( - snapshot.data ?? - event.calcLocalizedBodyFallback( - MatrixLocals(L10n.of(context)!), - withSenderNamePrefix: false, - hideReply: true, - ), - overflow: TextOverflow.ellipsis, - maxLines: 1, - style: TextStyle( - color: Theme.of(context).textTheme.bodyMedium!.color, - ), - ); - }, + overflow: TextOverflow.ellipsis, + maxLines: 1, + style: TextStyle( + color: Theme.of(context).textTheme.bodyMedium!.color, + ), ), ], ); diff --git a/lib/pages/chat_list/chat_list_item.dart b/lib/pages/chat_list/chat_list_item.dart index 0dabf9d0a..48ecc80f6 100644 --- a/lib/pages/chat_list/chat_list_item.dart +++ b/lib/pages/chat_list/chat_list_item.dart @@ -234,20 +234,8 @@ class ChatListItem extends StatelessWidget { maxLines: 1, softWrap: false, ) + // #Pangea : FutureBuilder( - // #Pangea - // future: room.lastEvent?.calcLocalizedBody( - // MatrixLocals(L10n.of(context)!), - // hideReply: true, - // hideEdit: true, - // plaintextBody: true, - // removeMarkdown: true, - // withSenderNamePrefix: !isDirectChat || - // directChatMatrixId != - // room.lastEvent?.senderId, - // ) ?? - // Future.value(L10n.of(context)!.emptyChat), - // Pangea# future: room.lastEvent != null ? GetChatListItemSubtitle().getSubtitle( L10n.of(context)!, @@ -256,12 +244,15 @@ class ChatListItem extends StatelessWidget { ) : Future.value(L10n.of(context)!.emptyChat), builder: (context, snapshot) { + // Pangea# return Text( room.membership == Membership.invite ? isDirectChat ? L10n.of(context)!.invitePrivateChat : L10n.of(context)!.inviteGroupChat + // #Pangea : snapshot.data ?? + // Pangea# room.lastEvent ?.calcLocalizedBodyFallback( MatrixLocals(L10n.of(context)!), diff --git a/pubspec.lock b/pubspec.lock index 2667b83d9..24b87b776 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1409,10 +1409,10 @@ packages: dependency: "direct main" description: name: matrix - sha256: b9aa3c1bdb1ca16c2365bb3681f861eeeb86acd0ea2df9c9ba453fdbcb564076 + sha256: "8610e6d207d6b667e4fe9e769d5b479db27aa1f80570880d3f171a5d3ff49d1a" url: "https://pub.dev" source: hosted - version: "0.29.1" + version: "0.29.2" meta: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 1fefa5b4e..9f4c63423 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -70,7 +70,7 @@ dependencies: keyboard_shortcuts: ^0.1.4 latlong2: ^0.9.1 linkify: ^5.0.0 - matrix: ^0.29.1 + matrix: ^0.29.2 native_imaging: ^0.1.0 package_info_plus: ^6.0.0 pasteboard: ^0.2.0