Make chat selection instant and add bulk selection to direct chats
This commit is contained in:
1 parent
d4a6839413
commit
834bec7ea0
26 files changed
+1311
-213
No files matched your search
@@ -1329,6 +1329,15 @@
|
||||
"chat_receivedGif": "Received a GIF",
|
||||
"chat_reply": "Reply",
|
||||
"chat_resend": "Resend",
|
||||
"chat_resendSelectedTitle": "Resend messages?",
|
||||
"chat_resendSelectedConfirm": "{count, plural, =1{Resend 1 selected outgoing message to this contact?} other{Resend {count} selected outgoing messages to this contact?}}",
|
||||
"@chat_resendSelectedConfirm": {
|
||||
"placeholders": {
|
||||
"count": {
|
||||
"type": "int"
|
||||
}
|
||||
}
|
||||
},
|
||||
"chat_addReaction": "Add Reaction",
|
||||
"chat_me": "Me",
|
||||
"reaction_report": "Emoji Reactions",
|
||||
|
||||
@@ -4537,6 +4537,18 @@ abstract class AppLocalizations {
|
||||
/// **'Resend'**
|
||||
String get chat_resend;
|
||||
|
||||
/// No description provided for @chat_resendSelectedTitle.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Resend messages?'**
|
||||
String get chat_resendSelectedTitle;
|
||||
|
||||
/// No description provided for @chat_resendSelectedConfirm.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'{count, plural, =1{Resend 1 selected outgoing message to this contact?} other{Resend {count} selected outgoing messages to this contact?}}'**
|
||||
String chat_resendSelectedConfirm(int count);
|
||||
|
||||
/// No description provided for @chat_addReaction.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
|
||||
@@ -2616,6 +2616,20 @@ class AppLocalizationsBg extends AppLocalizations {
|
||||
@override
|
||||
String get chat_resend => 'Изпрати отново';
|
||||
|
||||
@override
|
||||
String get chat_resendSelectedTitle => 'Resend messages?';
|
||||
|
||||
@override
|
||||
String chat_resendSelectedConfirm(int count) {
|
||||
String _temp0 = intl.Intl.pluralLogic(
|
||||
count,
|
||||
locale: localeName,
|
||||
other: 'Resend $count selected outgoing messages to this contact?',
|
||||
one: 'Resend 1 selected outgoing message to this contact?',
|
||||
);
|
||||
return '$_temp0';
|
||||
}
|
||||
|
||||
@override
|
||||
String get chat_addReaction => 'Добави Реакция';
|
||||
|
||||
|
||||
@@ -2610,6 +2610,20 @@ class AppLocalizationsCs extends AppLocalizations {
|
||||
@override
|
||||
String get chat_resend => 'Odeslat znovu';
|
||||
|
||||
@override
|
||||
String get chat_resendSelectedTitle => 'Resend messages?';
|
||||
|
||||
@override
|
||||
String chat_resendSelectedConfirm(int count) {
|
||||
String _temp0 = intl.Intl.pluralLogic(
|
||||
count,
|
||||
locale: localeName,
|
||||
other: 'Resend $count selected outgoing messages to this contact?',
|
||||
one: 'Resend 1 selected outgoing message to this contact?',
|
||||
);
|
||||
return '$_temp0';
|
||||
}
|
||||
|
||||
@override
|
||||
String get chat_addReaction => 'Přidat reakci';
|
||||
|
||||
|
||||
@@ -2619,6 +2619,20 @@ class AppLocalizationsDe extends AppLocalizations {
|
||||
@override
|
||||
String get chat_resend => 'Erneut senden';
|
||||
|
||||
@override
|
||||
String get chat_resendSelectedTitle => 'Resend messages?';
|
||||
|
||||
@override
|
||||
String chat_resendSelectedConfirm(int count) {
|
||||
String _temp0 = intl.Intl.pluralLogic(
|
||||
count,
|
||||
locale: localeName,
|
||||
other: 'Resend $count selected outgoing messages to this contact?',
|
||||
one: 'Resend 1 selected outgoing message to this contact?',
|
||||
);
|
||||
return '$_temp0';
|
||||
}
|
||||
|
||||
@override
|
||||
String get chat_addReaction => 'Reaktion hinzufügen';
|
||||
|
||||
|
||||
@@ -2571,6 +2571,20 @@ class AppLocalizationsEn extends AppLocalizations {
|
||||
@override
|
||||
String get chat_resend => 'Resend';
|
||||
|
||||
@override
|
||||
String get chat_resendSelectedTitle => 'Resend messages?';
|
||||
|
||||
@override
|
||||
String chat_resendSelectedConfirm(int count) {
|
||||
String _temp0 = intl.Intl.pluralLogic(
|
||||
count,
|
||||
locale: localeName,
|
||||
other: 'Resend $count selected outgoing messages to this contact?',
|
||||
one: 'Resend 1 selected outgoing message to this contact?',
|
||||
);
|
||||
return '$_temp0';
|
||||
}
|
||||
|
||||
@override
|
||||
String get chat_addReaction => 'Add Reaction';
|
||||
|
||||
|
||||
@@ -2610,6 +2610,20 @@ class AppLocalizationsEs extends AppLocalizations {
|
||||
@override
|
||||
String get chat_resend => 'Reenviar';
|
||||
|
||||
@override
|
||||
String get chat_resendSelectedTitle => 'Resend messages?';
|
||||
|
||||
@override
|
||||
String chat_resendSelectedConfirm(int count) {
|
||||
String _temp0 = intl.Intl.pluralLogic(
|
||||
count,
|
||||
locale: localeName,
|
||||
other: 'Resend $count selected outgoing messages to this contact?',
|
||||
one: 'Resend 1 selected outgoing message to this contact?',
|
||||
);
|
||||
return '$_temp0';
|
||||
}
|
||||
|
||||
@override
|
||||
String get chat_addReaction => 'Añadir Reacción';
|
||||
|
||||
|
||||
@@ -2614,6 +2614,20 @@ class AppLocalizationsFr extends AppLocalizations {
|
||||
@override
|
||||
String get chat_resend => 'Renvoyer';
|
||||
|
||||
@override
|
||||
String get chat_resendSelectedTitle => 'Resend messages?';
|
||||
|
||||
@override
|
||||
String chat_resendSelectedConfirm(int count) {
|
||||
String _temp0 = intl.Intl.pluralLogic(
|
||||
count,
|
||||
locale: localeName,
|
||||
other: 'Resend $count selected outgoing messages to this contact?',
|
||||
one: 'Resend 1 selected outgoing message to this contact?',
|
||||
);
|
||||
return '$_temp0';
|
||||
}
|
||||
|
||||
@override
|
||||
String get chat_addReaction => 'Ajouter une réaction';
|
||||
|
||||
|
||||
@@ -2606,6 +2606,20 @@ class AppLocalizationsHu extends AppLocalizations {
|
||||
@override
|
||||
String get chat_resend => 'Újraküldés';
|
||||
|
||||
@override
|
||||
String get chat_resendSelectedTitle => 'Resend messages?';
|
||||
|
||||
@override
|
||||
String chat_resendSelectedConfirm(int count) {
|
||||
String _temp0 = intl.Intl.pluralLogic(
|
||||
count,
|
||||
locale: localeName,
|
||||
other: 'Resend $count selected outgoing messages to this contact?',
|
||||
one: 'Resend 1 selected outgoing message to this contact?',
|
||||
);
|
||||
return '$_temp0';
|
||||
}
|
||||
|
||||
@override
|
||||
String get chat_addReaction => 'Reakció hozzáadása';
|
||||
|
||||
|
||||
@@ -2613,6 +2613,20 @@ class AppLocalizationsIt extends AppLocalizations {
|
||||
@override
|
||||
String get chat_resend => 'Reinvia';
|
||||
|
||||
@override
|
||||
String get chat_resendSelectedTitle => 'Resend messages?';
|
||||
|
||||
@override
|
||||
String chat_resendSelectedConfirm(int count) {
|
||||
String _temp0 = intl.Intl.pluralLogic(
|
||||
count,
|
||||
locale: localeName,
|
||||
other: 'Resend $count selected outgoing messages to this contact?',
|
||||
one: 'Resend 1 selected outgoing message to this contact?',
|
||||
);
|
||||
return '$_temp0';
|
||||
}
|
||||
|
||||
@override
|
||||
String get chat_addReaction => 'Aggiungi Reazione';
|
||||
|
||||
|
||||
@@ -2492,6 +2492,20 @@ class AppLocalizationsJa extends AppLocalizations {
|
||||
@override
|
||||
String get chat_resend => '再送信';
|
||||
|
||||
@override
|
||||
String get chat_resendSelectedTitle => 'Resend messages?';
|
||||
|
||||
@override
|
||||
String chat_resendSelectedConfirm(int count) {
|
||||
String _temp0 = intl.Intl.pluralLogic(
|
||||
count,
|
||||
locale: localeName,
|
||||
other: 'Resend $count selected outgoing messages to this contact?',
|
||||
one: 'Resend 1 selected outgoing message to this contact?',
|
||||
);
|
||||
return '$_temp0';
|
||||
}
|
||||
|
||||
@override
|
||||
String get chat_addReaction => 'リアクションを追加';
|
||||
|
||||
|
||||
@@ -2492,6 +2492,20 @@ class AppLocalizationsKo extends AppLocalizations {
|
||||
@override
|
||||
String get chat_resend => '다시 보내기';
|
||||
|
||||
@override
|
||||
String get chat_resendSelectedTitle => 'Resend messages?';
|
||||
|
||||
@override
|
||||
String chat_resendSelectedConfirm(int count) {
|
||||
String _temp0 = intl.Intl.pluralLogic(
|
||||
count,
|
||||
locale: localeName,
|
||||
other: 'Resend $count selected outgoing messages to this contact?',
|
||||
one: 'Resend 1 selected outgoing message to this contact?',
|
||||
);
|
||||
return '$_temp0';
|
||||
}
|
||||
|
||||
@override
|
||||
String get chat_addReaction => '댓글 추가';
|
||||
|
||||
|
||||
@@ -2597,6 +2597,20 @@ class AppLocalizationsNl extends AppLocalizations {
|
||||
@override
|
||||
String get chat_resend => 'Opnieuw verzenden';
|
||||
|
||||
@override
|
||||
String get chat_resendSelectedTitle => 'Resend messages?';
|
||||
|
||||
@override
|
||||
String chat_resendSelectedConfirm(int count) {
|
||||
String _temp0 = intl.Intl.pluralLogic(
|
||||
count,
|
||||
locale: localeName,
|
||||
other: 'Resend $count selected outgoing messages to this contact?',
|
||||
one: 'Resend 1 selected outgoing message to this contact?',
|
||||
);
|
||||
return '$_temp0';
|
||||
}
|
||||
|
||||
@override
|
||||
String get chat_addReaction => 'Reactie toevoegen';
|
||||
|
||||
|
||||
@@ -2638,6 +2638,20 @@ class AppLocalizationsPl extends AppLocalizations {
|
||||
@override
|
||||
String get chat_resend => 'Wyślij ponownie';
|
||||
|
||||
@override
|
||||
String get chat_resendSelectedTitle => 'Resend messages?';
|
||||
|
||||
@override
|
||||
String chat_resendSelectedConfirm(int count) {
|
||||
String _temp0 = intl.Intl.pluralLogic(
|
||||
count,
|
||||
locale: localeName,
|
||||
other: 'Resend $count selected outgoing messages to this contact?',
|
||||
one: 'Resend 1 selected outgoing message to this contact?',
|
||||
);
|
||||
return '$_temp0';
|
||||
}
|
||||
|
||||
@override
|
||||
String get chat_addReaction => 'Dodaj Reakcję';
|
||||
|
||||
|
||||
@@ -2607,6 +2607,20 @@ class AppLocalizationsPt extends AppLocalizations {
|
||||
@override
|
||||
String get chat_resend => 'Reenviar';
|
||||
|
||||
@override
|
||||
String get chat_resendSelectedTitle => 'Resend messages?';
|
||||
|
||||
@override
|
||||
String chat_resendSelectedConfirm(int count) {
|
||||
String _temp0 = intl.Intl.pluralLogic(
|
||||
count,
|
||||
locale: localeName,
|
||||
other: 'Resend $count selected outgoing messages to this contact?',
|
||||
one: 'Resend 1 selected outgoing message to this contact?',
|
||||
);
|
||||
return '$_temp0';
|
||||
}
|
||||
|
||||
@override
|
||||
String get chat_addReaction => 'Adicionar Reação';
|
||||
|
||||
|
||||
@@ -2618,6 +2618,20 @@ class AppLocalizationsRu extends AppLocalizations {
|
||||
@override
|
||||
String get chat_resend => 'Отправить снова';
|
||||
|
||||
@override
|
||||
String get chat_resendSelectedTitle => 'Resend messages?';
|
||||
|
||||
@override
|
||||
String chat_resendSelectedConfirm(int count) {
|
||||
String _temp0 = intl.Intl.pluralLogic(
|
||||
count,
|
||||
locale: localeName,
|
||||
other: 'Resend $count selected outgoing messages to this contact?',
|
||||
one: 'Resend 1 selected outgoing message to this contact?',
|
||||
);
|
||||
return '$_temp0';
|
||||
}
|
||||
|
||||
@override
|
||||
String get chat_addReaction => 'Добавить реакцию';
|
||||
|
||||
|
||||
@@ -2610,6 +2610,20 @@ class AppLocalizationsSk extends AppLocalizations {
|
||||
@override
|
||||
String get chat_resend => 'Odoslať znova';
|
||||
|
||||
@override
|
||||
String get chat_resendSelectedTitle => 'Resend messages?';
|
||||
|
||||
@override
|
||||
String chat_resendSelectedConfirm(int count) {
|
||||
String _temp0 = intl.Intl.pluralLogic(
|
||||
count,
|
||||
locale: localeName,
|
||||
other: 'Resend $count selected outgoing messages to this contact?',
|
||||
one: 'Resend 1 selected outgoing message to this contact?',
|
||||
);
|
||||
return '$_temp0';
|
||||
}
|
||||
|
||||
@override
|
||||
String get chat_addReaction => 'Pridať Reakciu';
|
||||
|
||||
|
||||
@@ -2611,6 +2611,20 @@ class AppLocalizationsSl extends AppLocalizations {
|
||||
@override
|
||||
String get chat_resend => 'Pošlji znova';
|
||||
|
||||
@override
|
||||
String get chat_resendSelectedTitle => 'Resend messages?';
|
||||
|
||||
@override
|
||||
String chat_resendSelectedConfirm(int count) {
|
||||
String _temp0 = intl.Intl.pluralLogic(
|
||||
count,
|
||||
locale: localeName,
|
||||
other: 'Resend $count selected outgoing messages to this contact?',
|
||||
one: 'Resend 1 selected outgoing message to this contact?',
|
||||
);
|
||||
return '$_temp0';
|
||||
}
|
||||
|
||||
@override
|
||||
String get chat_addReaction => 'Dodaj reakcijo';
|
||||
|
||||
|
||||
@@ -2585,6 +2585,20 @@ class AppLocalizationsSv extends AppLocalizations {
|
||||
@override
|
||||
String get chat_resend => 'Skicka igen';
|
||||
|
||||
@override
|
||||
String get chat_resendSelectedTitle => 'Resend messages?';
|
||||
|
||||
@override
|
||||
String chat_resendSelectedConfirm(int count) {
|
||||
String _temp0 = intl.Intl.pluralLogic(
|
||||
count,
|
||||
locale: localeName,
|
||||
other: 'Resend $count selected outgoing messages to this contact?',
|
||||
one: 'Resend 1 selected outgoing message to this contact?',
|
||||
);
|
||||
return '$_temp0';
|
||||
}
|
||||
|
||||
@override
|
||||
String get chat_addReaction => 'Lägg till reaktion';
|
||||
|
||||
|
||||
@@ -2615,6 +2615,20 @@ class AppLocalizationsUk extends AppLocalizations {
|
||||
@override
|
||||
String get chat_resend => 'Надіслати знову';
|
||||
|
||||
@override
|
||||
String get chat_resendSelectedTitle => 'Resend messages?';
|
||||
|
||||
@override
|
||||
String chat_resendSelectedConfirm(int count) {
|
||||
String _temp0 = intl.Intl.pluralLogic(
|
||||
count,
|
||||
locale: localeName,
|
||||
other: 'Resend $count selected outgoing messages to this contact?',
|
||||
one: 'Resend 1 selected outgoing message to this contact?',
|
||||
);
|
||||
return '$_temp0';
|
||||
}
|
||||
|
||||
@override
|
||||
String get chat_addReaction => 'Додати реакцію';
|
||||
|
||||
|
||||
@@ -2457,6 +2457,20 @@ class AppLocalizationsZh extends AppLocalizations {
|
||||
@override
|
||||
String get chat_resend => '重新发送';
|
||||
|
||||
@override
|
||||
String get chat_resendSelectedTitle => 'Resend messages?';
|
||||
|
||||
@override
|
||||
String chat_resendSelectedConfirm(int count) {
|
||||
String _temp0 = intl.Intl.pluralLogic(
|
||||
count,
|
||||
locale: localeName,
|
||||
other: 'Resend $count selected outgoing messages to this contact?',
|
||||
one: 'Resend 1 selected outgoing message to this contact?',
|
||||
);
|
||||
return '$_temp0';
|
||||
}
|
||||
|
||||
@override
|
||||
String get chat_addReaction => '添加表情';
|
||||
|
||||
|
||||
@@ -985,6 +985,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen>
|
||||
return Stack(
|
||||
children: [
|
||||
ChatZoomWrapper(
|
||||
enabled: !_selecting,
|
||||
child: ListView.builder(
|
||||
reverse: true, // List grows from bottom up
|
||||
controller: _scrollController,
|
||||
@@ -1010,14 +1011,19 @@ class _ChannelChatScreenState extends State<ChannelChatScreen>
|
||||
);
|
||||
}
|
||||
final row = layout.rowAt(index, messages);
|
||||
final GlobalKey messageKey;
|
||||
// Duplicate-id rows use a stable value key
|
||||
// (not a fresh GlobalKey) so toggling one
|
||||
// row does not remount every visible row.
|
||||
final Key messageKey;
|
||||
if (layout.keyedIndices.contains(index)) {
|
||||
messageKey = _messageKeys.putIfAbsent(
|
||||
row.id,
|
||||
GlobalKey.new,
|
||||
);
|
||||
} else {
|
||||
messageKey = GlobalKey();
|
||||
messageKey = ValueKey<String>(
|
||||
'${row.id}#dup$index',
|
||||
);
|
||||
}
|
||||
final dividerId = _unreadDividerMessageId;
|
||||
final isUnreadAnchor =
|
||||
|
||||
+412
-203
@@ -104,6 +104,8 @@ class _ChatScreenState extends State<ChatScreen> with WidgetsBindingObserver {
|
||||
final GlobalKey _unreadScrollKey = GlobalKey();
|
||||
bool _isLoadingOlder = false;
|
||||
bool _showBookmarkedOnly = false;
|
||||
final Set<String> _selectedIds = <String>{};
|
||||
bool get _selecting => _selectedIds.isNotEmpty;
|
||||
MeshCoreConnector? _connector;
|
||||
Message? _pendingUnreadScrollTarget;
|
||||
String? _unreadDividerMessageId;
|
||||
@@ -415,9 +417,14 @@ class _ChatScreenState extends State<ChatScreen> with WidgetsBindingObserver {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PopScope(
|
||||
canPop: !_searching,
|
||||
canPop: !_searching && !_selecting,
|
||||
onPopInvokedWithResult: (didPop, _) {
|
||||
if (!didPop && _searching) _closeSearch();
|
||||
if (didPop) return;
|
||||
if (_selecting) {
|
||||
_clearSelection();
|
||||
} else if (_searching) {
|
||||
_closeSearch();
|
||||
}
|
||||
},
|
||||
child: _buildScaffold(context),
|
||||
);
|
||||
@@ -425,211 +432,224 @@ class _ChatScreenState extends State<ChatScreen> with WidgetsBindingObserver {
|
||||
|
||||
Widget _buildScaffold(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: _searching
|
||||
? IconButton(
|
||||
tooltip: context.l10n.chatSearch_close,
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: _closeSearch,
|
||||
)
|
||||
: null,
|
||||
title: _searching
|
||||
? _buildSearchField()
|
||||
: Consumer2<PathHistoryService, MeshCoreConnector>(
|
||||
builder: (context, pathService, connector, _) {
|
||||
final contact = _resolveContact(connector);
|
||||
final pathLabel = _currentPathLabel(contact);
|
||||
appBar: _selecting
|
||||
? _buildSelectionAppBar(context)
|
||||
: AppBar(
|
||||
leading: _searching
|
||||
? IconButton(
|
||||
tooltip: context.l10n.chatSearch_close,
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: _closeSearch,
|
||||
)
|
||||
: null,
|
||||
title: _searching
|
||||
? _buildSearchField()
|
||||
: Consumer2<PathHistoryService, MeshCoreConnector>(
|
||||
builder: (context, pathService, connector, _) {
|
||||
final contact = _resolveContact(connector);
|
||||
final pathLabel = _currentPathLabel(contact);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
contact.name,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () =>
|
||||
ContactRoutingSheet.show(context, contact: contact),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
// Follows the chat text size, capped so the two-line
|
||||
// title still fits the app bar.
|
||||
final textScale = context
|
||||
.select<ChatTextScaleService, double>(
|
||||
(service) => service.scale,
|
||||
)
|
||||
.clamp(1.0, 1.3);
|
||||
return Text(
|
||||
pathLabel,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 12 * textScale,
|
||||
fontWeight: FontWeight.normal,
|
||||
decoration: TextDecoration.underline,
|
||||
decorationStyle: TextDecorationStyle.dotted,
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
contact.name,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () => ContactRoutingSheet.show(
|
||||
context,
|
||||
contact: contact,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 6,
|
||||
),
|
||||
);
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
// Follows the chat text size, capped so the two-line
|
||||
// title still fits the app bar.
|
||||
final textScale = context
|
||||
.select<ChatTextScaleService, double>(
|
||||
(service) => service.scale,
|
||||
)
|
||||
.clamp(1.0, 1.3);
|
||||
return Text(
|
||||
pathLabel,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 12 * textScale,
|
||||
fontWeight: FontWeight.normal,
|
||||
decoration: TextDecoration.underline,
|
||||
decorationStyle:
|
||||
TextDecorationStyle.dotted,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
centerTitle: false,
|
||||
bottom: const SyncProgressAppBarBottom(),
|
||||
actionsPadding: const EdgeInsetsDirectional.only(end: 4),
|
||||
// While searching the field gets the whole bar; the leading arrow
|
||||
// closes the search.
|
||||
actions: _searching
|
||||
? null
|
||||
: [
|
||||
const RadioStatsIconButton(),
|
||||
IconButton(
|
||||
tooltip: context.l10n.chatSearch_tooltip,
|
||||
icon: const Icon(Icons.search),
|
||||
onPressed: _openSearch,
|
||||
),
|
||||
Consumer<MeshCoreConnector>(
|
||||
builder: (context, connector, _) {
|
||||
final contact = _resolveContact(connector);
|
||||
final isRoom = contact.type == advTypeRoom;
|
||||
final readOnly = isRadioReadOnly(connector);
|
||||
|
||||
return PopupMenuButton<String>(
|
||||
icon: const Icon(Icons.more_vert),
|
||||
onSelected: (value) {
|
||||
switch (value) {
|
||||
case 'routing':
|
||||
ContactRoutingSheet.show(
|
||||
context,
|
||||
contact: contact,
|
||||
);
|
||||
case 'info':
|
||||
_showContactInfo(context);
|
||||
case 'settings':
|
||||
_showContactSettings(context);
|
||||
case 'showBookmarks':
|
||||
setState(
|
||||
() => _showBookmarkedOnly =
|
||||
!_showBookmarkedOnly,
|
||||
);
|
||||
case 'background':
|
||||
showChatBackgroundSheet(
|
||||
context,
|
||||
ChatBackgroundService.contactKey(contact),
|
||||
);
|
||||
case 'telemetry':
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => TelemetryScreen(
|
||||
contact: widget.contact,
|
||||
),
|
||||
),
|
||||
);
|
||||
case 'roomManagement':
|
||||
_showRoomManagementLogin(contact);
|
||||
case 'clearChat':
|
||||
_confirmClearChat(context, connector);
|
||||
case 'removeContact':
|
||||
confirmRemoveContact(
|
||||
context,
|
||||
connector,
|
||||
contact,
|
||||
onRemoved: () {
|
||||
if (mounted) Navigator.of(context).pop();
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: 'routing',
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.route,
|
||||
label: context.l10n.routing_title,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'info',
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.info_outline,
|
||||
label: context.l10n.contact_info,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'telemetry',
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.bar_chart,
|
||||
label: context.l10n.contact_telemetry,
|
||||
),
|
||||
),
|
||||
if (isRoom)
|
||||
PopupMenuItem(
|
||||
value: 'roomManagement',
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.room_preferences,
|
||||
label: context.l10n.room_management,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'settings',
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.settings,
|
||||
label: context.l10n.contact_settings,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'showBookmarks',
|
||||
child: MeshMenuItemRow(
|
||||
icon: _showBookmarkedOnly
|
||||
? Icons.bookmark
|
||||
: Icons.bookmark_border,
|
||||
label: context.l10n.chat_showBookmarks,
|
||||
color: _showBookmarkedOnly
|
||||
? const Color(0xFFFFE54A)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'background',
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.wallpaper,
|
||||
label: context.l10n.chatBackground_title,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'clearChat',
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.delete,
|
||||
label: context.l10n.contact_clearChat,
|
||||
color: readOnly
|
||||
? null
|
||||
: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'removeContact',
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.person_remove,
|
||||
label:
|
||||
context.l10n.contacts_removeFromContacts,
|
||||
color: readOnly
|
||||
? null
|
||||
: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
centerTitle: false,
|
||||
bottom: const SyncProgressAppBarBottom(),
|
||||
actionsPadding: const EdgeInsetsDirectional.only(end: 4),
|
||||
// While searching the field gets the whole bar; the leading arrow
|
||||
// closes the search.
|
||||
actions: _searching
|
||||
? null
|
||||
: [
|
||||
const RadioStatsIconButton(),
|
||||
IconButton(
|
||||
tooltip: context.l10n.chatSearch_tooltip,
|
||||
icon: const Icon(Icons.search),
|
||||
onPressed: _openSearch,
|
||||
),
|
||||
Consumer<MeshCoreConnector>(
|
||||
builder: (context, connector, _) {
|
||||
final contact = _resolveContact(connector);
|
||||
final isRoom = contact.type == advTypeRoom;
|
||||
final readOnly = isRadioReadOnly(connector);
|
||||
|
||||
return PopupMenuButton<String>(
|
||||
icon: const Icon(Icons.more_vert),
|
||||
onSelected: (value) {
|
||||
switch (value) {
|
||||
case 'routing':
|
||||
ContactRoutingSheet.show(context, contact: contact);
|
||||
case 'info':
|
||||
_showContactInfo(context);
|
||||
case 'settings':
|
||||
_showContactSettings(context);
|
||||
case 'showBookmarks':
|
||||
setState(
|
||||
() => _showBookmarkedOnly = !_showBookmarkedOnly,
|
||||
);
|
||||
case 'background':
|
||||
showChatBackgroundSheet(
|
||||
context,
|
||||
ChatBackgroundService.contactKey(contact),
|
||||
);
|
||||
case 'telemetry':
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
TelemetryScreen(contact: widget.contact),
|
||||
),
|
||||
);
|
||||
case 'roomManagement':
|
||||
_showRoomManagementLogin(contact);
|
||||
case 'clearChat':
|
||||
_confirmClearChat(context, connector);
|
||||
case 'removeContact':
|
||||
confirmRemoveContact(
|
||||
context,
|
||||
connector,
|
||||
contact,
|
||||
onRemoved: () {
|
||||
if (mounted) Navigator.of(context).pop();
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: 'routing',
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.route,
|
||||
label: context.l10n.routing_title,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'info',
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.info_outline,
|
||||
label: context.l10n.contact_info,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'telemetry',
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.bar_chart,
|
||||
label: context.l10n.contact_telemetry,
|
||||
),
|
||||
),
|
||||
if (isRoom)
|
||||
PopupMenuItem(
|
||||
value: 'roomManagement',
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.room_preferences,
|
||||
label: context.l10n.room_management,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'settings',
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.settings,
|
||||
label: context.l10n.contact_settings,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'showBookmarks',
|
||||
child: MeshMenuItemRow(
|
||||
icon: _showBookmarkedOnly
|
||||
? Icons.bookmark
|
||||
: Icons.bookmark_border,
|
||||
label: context.l10n.chat_showBookmarks,
|
||||
color: _showBookmarkedOnly
|
||||
? const Color(0xFFFFE54A)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'background',
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.wallpaper,
|
||||
label: context.l10n.chatBackground_title,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'clearChat',
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.delete,
|
||||
label: context.l10n.contact_clearChat,
|
||||
color: readOnly
|
||||
? null
|
||||
: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: 'removeContact',
|
||||
enabled: !readOnly,
|
||||
child: MeshMenuItemRow(
|
||||
icon: Icons.person_remove,
|
||||
label: context.l10n.contacts_removeFromContacts,
|
||||
color: readOnly
|
||||
? null
|
||||
: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: _showSearchResults
|
||||
? _buildSearchResults(_loadSearchEntries)
|
||||
: Consumer<MeshCoreConnector>(
|
||||
@@ -759,6 +779,7 @@ class _ChatScreenState extends State<ChatScreen> with WidgetsBindingObserver {
|
||||
});
|
||||
|
||||
return ChatZoomWrapper(
|
||||
enabled: !_selecting,
|
||||
child: AnchoredChatListView.builder(
|
||||
scrollAnchor: _scrollAnchor,
|
||||
reverse: true, // List grows from bottom up
|
||||
@@ -840,7 +861,7 @@ class _ChatScreenState extends State<ChatScreen> with WidgetsBindingObserver {
|
||||
message.receivedAt,
|
||||
);
|
||||
final highlighted = message.messageId == _highlightedMessageId;
|
||||
final shown = highlighted
|
||||
final styled = highlighted
|
||||
? AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
decoration: BoxDecoration(
|
||||
@@ -852,6 +873,9 @@ class _ChatScreenState extends State<ChatScreen> with WidgetsBindingObserver {
|
||||
child: bubble,
|
||||
)
|
||||
: bubble;
|
||||
final shown = _selecting
|
||||
? _buildSelectableRow(message, styled)
|
||||
: styled;
|
||||
final child = isUnreadAnchor || startsDay
|
||||
? Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -1428,6 +1452,14 @@ class _ChatScreenState extends State<ChatScreen> with WidgetsBindingObserver {
|
||||
_showEmojiPicker(message, contact);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.checklist),
|
||||
title: Text(context.l10n.chat_selectMessages),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetContext);
|
||||
_toggleSelected(message);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.route),
|
||||
title: Text(context.l10n.chat_path),
|
||||
@@ -1555,6 +1587,183 @@ class _ChatScreenState extends State<ChatScreen> with WidgetsBindingObserver {
|
||||
);
|
||||
}
|
||||
|
||||
// ---- bulk selection -------------------------------------------------------
|
||||
|
||||
void _toggleSelected(Message message) {
|
||||
HapticFeedback.selectionClick();
|
||||
setState(() {
|
||||
if (!_selectedIds.remove(message.messageId)) {
|
||||
_selectedIds.add(message.messageId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _clearSelection() => setState(_selectedIds.clear);
|
||||
|
||||
/// Selected messages still in the transcript, oldest first.
|
||||
List<Message> _selectedMessages() {
|
||||
final messages = context.read<MeshCoreConnector>().getMessages(
|
||||
widget.contact,
|
||||
);
|
||||
return [
|
||||
for (final m in messages)
|
||||
if (_selectedIds.contains(m.messageId)) m,
|
||||
];
|
||||
}
|
||||
|
||||
Widget _buildSelectableRow(Message message, Widget messageBody) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final selected = _selectedIds.contains(message.messageId);
|
||||
return Semantics(
|
||||
selected: selected,
|
||||
button: true,
|
||||
child: Material(
|
||||
color: selected
|
||||
? scheme.primary.withValues(alpha: 0.16)
|
||||
: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () => _toggleSelected(message),
|
||||
onLongPress: () => _toggleSelected(message),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 3, horizontal: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
selected ? Icons.check_circle : Icons.radio_button_unchecked,
|
||||
size: 28,
|
||||
color: selected ? scheme.primary : scheme.onSurfaceVariant,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
// Links, images and reactions inside the bubble must not
|
||||
// react while picking messages.
|
||||
Expanded(child: AbsorbPointer(child: messageBody)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
PreferredSizeWidget _buildSelectionAppBar(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
final selected = _selectedMessages();
|
||||
final readOnly = context.radioReadOnly;
|
||||
final canResend =
|
||||
!readOnly && selected.any((m) => m.isOutgoing && !m.isCli);
|
||||
return AppBar(
|
||||
leading: IconButton(
|
||||
tooltip: l10n.chat_clearSelection,
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: _clearSelection,
|
||||
),
|
||||
title: Text(l10n.chat_selectedCount(selected.length)),
|
||||
actions: [
|
||||
if (canResend)
|
||||
IconButton(
|
||||
tooltip: l10n.chat_resend,
|
||||
icon: const Icon(Icons.replay),
|
||||
onPressed: () => _bulkResend(selected),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: l10n.chat_bookmark,
|
||||
icon: const Icon(Icons.bookmark_border),
|
||||
onPressed: selected.isEmpty ? null : () => _bulkBookmark(selected),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: l10n.common_copy,
|
||||
icon: const Icon(Icons.copy),
|
||||
onPressed: selected.isEmpty ? null : () => _bulkCopy(selected),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: l10n.common_delete,
|
||||
icon: const Icon(Icons.delete_outline),
|
||||
onPressed: selected.isEmpty || readOnly
|
||||
? null
|
||||
: () => _bulkDelete(selected),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void _bulkCopy(List<Message> messages) {
|
||||
final text = messages.map((m) => m.text).join('\n');
|
||||
setState(_selectedIds.clear);
|
||||
copyChatMessageText(context, text);
|
||||
}
|
||||
|
||||
void _bulkBookmark(List<Message> messages) {
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
final contact = _resolveContact(connector);
|
||||
final me = connector.selfName ?? context.l10n.chat_me;
|
||||
setState(_selectedIds.clear);
|
||||
for (final m in messages) {
|
||||
unawaited(
|
||||
connector.setBookmarkedMessage(
|
||||
BookmarkedMessage.fromContact(
|
||||
message: m,
|
||||
contactKey: widget.contact.publicKeyHex,
|
||||
contactName: widget.contact.name,
|
||||
senderName: m.isOutgoing ? me : contact.name,
|
||||
),
|
||||
isBookmarked: true,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _bulkDelete(List<Message> messages) async {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
final confirmed = await confirmBulkDelete(context, messages.length);
|
||||
if (!confirmed || !mounted) return;
|
||||
setState(_selectedIds.clear);
|
||||
for (final m in messages) {
|
||||
await connector.deleteMessage(m);
|
||||
}
|
||||
if (!mounted) return;
|
||||
showDismissibleSnackBar(
|
||||
context,
|
||||
content: Text(context.l10n.chat_messagesDeleted(messages.length)),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _bulkResend(List<Message> messages) async {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
final connector = context.read<MeshCoreConnector>();
|
||||
final outgoing = [
|
||||
for (final m in messages)
|
||||
if (m.isOutgoing && !m.isCli) m,
|
||||
];
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
final l10n = dialogContext.l10n;
|
||||
return AlertDialog(
|
||||
title: Text(l10n.chat_resendSelectedTitle),
|
||||
content: Text(l10n.chat_resendSelectedConfirm(outgoing.length)),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext, false),
|
||||
child: Text(l10n.common_cancel),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.pop(dialogContext, true),
|
||||
child: Text(l10n.chat_resend),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
if (confirmed != true || !mounted) return;
|
||||
final contact = _resolveContact(connector);
|
||||
setState(_selectedIds.clear);
|
||||
// Oldest first so the resent messages keep their order.
|
||||
for (final m in outgoing) {
|
||||
await connector.resendMessage(contact, m);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _deleteMessage(Message message) async {
|
||||
if (!ensureRadioConnected(context)) return;
|
||||
await context.read<MeshCoreConnector>().deleteMessage(message);
|
||||
|
||||
@@ -4,14 +4,27 @@ import 'package:provider/provider.dart';
|
||||
import '../services/chat_text_scale_service.dart';
|
||||
|
||||
/// Gesture wrapper that exposes two-finger pinch-to-zoom for chat scrollables.
|
||||
/// Double-tap resets the scale. Only the wrapper itself listens to gestures;
|
||||
/// child scrollables keep their normal touch handling.
|
||||
/// Double-tap resets the scale, but only while the text is zoomed (or the
|
||||
/// caller supplies [onDoubleTap]) and [enabled] is true: a double-tap
|
||||
/// recognizer in the gesture arena makes every single tap on the child wait
|
||||
/// 300 ms, so it is left out wherever taps must be instant. Only the wrapper
|
||||
/// itself listens to gestures; child scrollables keep their normal touch
|
||||
/// handling.
|
||||
class ChatZoomWrapper extends StatefulWidget {
|
||||
const ChatZoomWrapper({super.key, required this.child, this.onDoubleTap});
|
||||
const ChatZoomWrapper({
|
||||
super.key,
|
||||
required this.child,
|
||||
this.onDoubleTap,
|
||||
this.enabled = true,
|
||||
});
|
||||
|
||||
final Widget child;
|
||||
final VoidCallback? onDoubleTap;
|
||||
|
||||
/// When false (e.g. while selecting messages) no double-tap is recognized,
|
||||
/// so taps on the child are never delayed or swallowed.
|
||||
final bool enabled;
|
||||
|
||||
@override
|
||||
State<ChatZoomWrapper> createState() => _ChatZoomWrapperState();
|
||||
}
|
||||
@@ -22,14 +35,21 @@ class _ChatZoomWrapperState extends State<ChatZoomWrapper> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final service = context.read<ChatTextScaleService>();
|
||||
final zoomed = context.select<ChatTextScaleService, bool>(
|
||||
(s) => s.scale != 1.0,
|
||||
);
|
||||
final allowDoubleTap =
|
||||
widget.enabled && (zoomed || widget.onDoubleTap != null);
|
||||
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onDoubleTap: () {
|
||||
service.reset();
|
||||
service.persist();
|
||||
widget.onDoubleTap?.call();
|
||||
},
|
||||
onDoubleTap: allowDoubleTap
|
||||
? () {
|
||||
service.reset();
|
||||
service.persist();
|
||||
widget.onDoubleTap?.call();
|
||||
}
|
||||
: null,
|
||||
onScaleStart: (details) {
|
||||
if (details.pointerCount != 2) return;
|
||||
_startScale = service.scale;
|
||||
|
||||
Reference in new issue
Block a user