Skip to content

Commit a5457c8

Browse files
reactions: Support adding arbitary reactions
1 parent 7199ab5 commit a5457c8

9 files changed

+503
-25
lines changed

assets/l10n/app_en.arb

+12
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,10 @@
330330
"@dialogContinue": {
331331
"description": "Button label in dialogs to proceed."
332332
},
333+
"dialogClose": "Close",
334+
"@dialogClose": {
335+
"description": "Button label in dialogs to close."
336+
},
333337
"errorDialogContinue": "OK",
334338
"@errorDialogContinue": {
335339
"description": "Button label in error dialogs to acknowledge the error and close the dialog."
@@ -611,5 +615,13 @@
611615
"errorReactionRemovingFailedTitle": "Removing reaction failed",
612616
"@errorReactionRemovingFailedTitle": {
613617
"description": "Error title when removing a message reaction fails"
618+
},
619+
"emojiReactionsMore": "more",
620+
"@emojiReactionsMore": {
621+
"description": "Label for a button opening the emoji picker."
622+
},
623+
"emojiPickerSearchEmoji": "Search emoji",
624+
"@emojiPickerSearchEmoji": {
625+
"description": "Hint text for the emoji picker search text field."
614626
}
615627
}

lib/generated/l10n/zulip_localizations.dart

+18
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,12 @@ abstract class ZulipLocalizations {
529529
/// **'Continue'**
530530
String get dialogContinue;
531531

532+
/// Button label in dialogs to close.
533+
///
534+
/// In en, this message translates to:
535+
/// **'Close'**
536+
String get dialogClose;
537+
532538
/// Button label in error dialogs to acknowledge the error and close the dialog.
533539
///
534540
/// In en, this message translates to:
@@ -906,6 +912,18 @@ abstract class ZulipLocalizations {
906912
/// In en, this message translates to:
907913
/// **'Removing reaction failed'**
908914
String get errorReactionRemovingFailedTitle;
915+
916+
/// Label for a button opening the emoji picker.
917+
///
918+
/// In en, this message translates to:
919+
/// **'more'**
920+
String get emojiReactionsMore;
921+
922+
/// Hint text for the emoji picker search text field.
923+
///
924+
/// In en, this message translates to:
925+
/// **'Search emoji'**
926+
String get emojiPickerSearchEmoji;
909927
}
910928

911929
class _ZulipLocalizationsDelegate extends LocalizationsDelegate<ZulipLocalizations> {

lib/generated/l10n/zulip_localizations_ar.dart

+9
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
260260
@override
261261
String get dialogContinue => 'Continue';
262262

263+
@override
264+
String get dialogClose => 'Close';
265+
263266
@override
264267
String get errorDialogContinue => 'OK';
265268

@@ -484,4 +487,10 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
484487

485488
@override
486489
String get errorReactionRemovingFailedTitle => 'Removing reaction failed';
490+
491+
@override
492+
String get emojiReactionsMore => 'more';
493+
494+
@override
495+
String get emojiPickerSearchEmoji => 'Search emoji';
487496
}

lib/generated/l10n/zulip_localizations_en.dart

+9
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
260260
@override
261261
String get dialogContinue => 'Continue';
262262

263+
@override
264+
String get dialogClose => 'Close';
265+
263266
@override
264267
String get errorDialogContinue => 'OK';
265268

@@ -484,4 +487,10 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
484487

485488
@override
486489
String get errorReactionRemovingFailedTitle => 'Removing reaction failed';
490+
491+
@override
492+
String get emojiReactionsMore => 'more';
493+
494+
@override
495+
String get emojiPickerSearchEmoji => 'Search emoji';
487496
}

lib/generated/l10n/zulip_localizations_ja.dart

+9
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
260260
@override
261261
String get dialogContinue => 'Continue';
262262

263+
@override
264+
String get dialogClose => 'Close';
265+
263266
@override
264267
String get errorDialogContinue => 'OK';
265268

@@ -484,4 +487,10 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
484487

485488
@override
486489
String get errorReactionRemovingFailedTitle => 'Removing reaction failed';
490+
491+
@override
492+
String get emojiReactionsMore => 'more';
493+
494+
@override
495+
String get emojiPickerSearchEmoji => 'Search emoji';
487496
}

lib/widgets/action_sheet.dart

+58-25
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,19 @@ class ReactionButtons extends StatelessWidget {
222222
: zulipLocalizations.errorReactionAddingFailedTitle);
223223
}
224224

225+
void _onMorePressed() {
226+
// Dismiss current action sheet before opening emoji picker sheet.
227+
Navigator.of(pageContext).pop();
228+
229+
showEmojiPickerSheet(pageContext: pageContext, message: message);
230+
}
231+
225232
@override
226233
Widget build(BuildContext context) {
227234
assert(EmojiStore.popularEmojiCandidates.every(
228235
(emoji) => emoji.emojiType == ReactionType.unicodeEmoji));
229236

237+
final zulipLocalizations = ZulipLocalizations.of(context);
230238
final store = PerAccountStoreWidget.of(pageContext);
231239
final designVariables = DesignVariables.of(context);
232240

@@ -240,32 +248,57 @@ class ReactionButtons extends StatelessWidget {
240248

241249
return Container(
242250
decoration: BoxDecoration(color: designVariables.contextMenuCancelBg),
243-
child: Row(
244-
spacing: 1,
245-
children: List.unmodifiable(EmojiStore.popularEmojiCandidates.mapIndexed((index, emoji) {
246-
final isSelfVoted = hasSelfVote(emoji);
247-
return Flexible(child: InkWell(
248-
onTap: () => _onReactionPressed(emoji: emoji, isSelfVoted: isSelfVoted),
249-
splashFactory: NoSplash.splashFactory,
250-
borderRadius: index == 0
251-
? const BorderRadius.only(topLeft: Radius.circular(7))
252-
: null,
253-
overlayColor: WidgetStateColor.resolveWith((states) =>
254-
states.any((e) => e == WidgetState.pressed)
255-
? designVariables.contextMenuItemBg.withFadedAlpha(0.20)
256-
: Colors.transparent),
257-
child: Container(
258-
width: double.infinity,
259-
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 5),
260-
alignment: Alignment.center,
261-
color: isSelfVoted
262-
? designVariables.contextMenuItemBg.withFadedAlpha(0.20)
251+
child: Row(children: [
252+
Flexible(child: Row(
253+
spacing: 1,
254+
children: List.unmodifiable(EmojiStore.popularEmojiCandidates.mapIndexed((index, emoji) {
255+
final isSelfVoted = hasSelfVote(emoji);
256+
return Flexible(child: InkWell(
257+
onTap: () => _onReactionPressed(emoji: emoji, isSelfVoted: isSelfVoted),
258+
splashFactory: NoSplash.splashFactory,
259+
borderRadius: index == 0
260+
? const BorderRadius.only(topLeft: Radius.circular(7))
263261
: null,
264-
child: UnicodeEmojiWidget(
265-
emojiDisplay: emoji.emojiDisplay as UnicodeEmojiDisplay,
266-
notoColorEmojiTextSize: 20.1,
267-
size: 24))));
268-
}))));
262+
overlayColor: WidgetStateColor.resolveWith((states) =>
263+
states.any((e) => e == WidgetState.pressed)
264+
? designVariables.contextMenuItemBg.withFadedAlpha(0.20)
265+
: Colors.transparent),
266+
child: Container(
267+
width: double.infinity,
268+
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 5),
269+
alignment: Alignment.center,
270+
color: isSelfVoted
271+
? designVariables.contextMenuItemBg.withFadedAlpha(0.20)
272+
: null,
273+
child: UnicodeEmojiWidget(
274+
emojiDisplay: emoji.emojiDisplay as UnicodeEmojiDisplay,
275+
notoColorEmojiTextSize: 20.1,
276+
size: 24))));
277+
})))),
278+
InkWell(
279+
onTap: _onMorePressed,
280+
splashFactory: NoSplash.splashFactory,
281+
borderRadius: const BorderRadius.only(topRight: Radius.circular(7)),
282+
overlayColor: WidgetStateColor.resolveWith((states) =>
283+
states.any((e) => e == WidgetState.pressed)
284+
? designVariables.contextMenuItemBg.withFadedAlpha(0.20)
285+
: Colors.transparent),
286+
child: Padding(
287+
padding: const EdgeInsetsDirectional.fromSTEB(12, 12, 4, 12),
288+
child: Row(children: [
289+
Text(zulipLocalizations.emojiReactionsMore,
290+
textAlign: TextAlign.end,
291+
style: TextStyle(
292+
color: designVariables.contextMenuItemText,
293+
fontSize: 14,
294+
).merge(weightVariableTextStyle(context, wght: 600))),
295+
Icon(ZulipIcons.chevron_right,
296+
color: designVariables.contextMenuItemText,
297+
size: 24),
298+
]),
299+
)),
300+
]),
301+
);
269302
}
270303
}
271304

0 commit comments

Comments
 (0)