Skip to content

Commit

Permalink
reactions: Support adding arbitrary reactions
Browse files Browse the repository at this point in the history
  • Loading branch information
rajveermalviya committed Dec 10, 2024
1 parent 5cf87f8 commit 8f768ca
Showing 10 changed files with 483 additions and 9 deletions.
12 changes: 12 additions & 0 deletions assets/l10n/app_en.arb
Original file line number Diff line number Diff line change
@@ -330,6 +330,10 @@
"@dialogContinue": {
"description": "Button label in dialogs to proceed."
},
"dialogClose": "Close",
"@dialogClose": {
"description": "Button label in dialogs to close."
},
"errorDialogContinue": "OK",
"@errorDialogContinue": {
"description": "Button label in error dialogs to acknowledge the error and close the dialog."
@@ -611,5 +615,13 @@
"errorReactionRemovingFailedTitle": "Removing reaction failed",
"@errorReactionRemovingFailedTitle": {
"description": "Error title when removing a message reaction fails"
},
"emojiReactionsMore": "more",
"@emojiReactionsMore": {
"description": "Label for a button opening the emoji picker."
},
"emojiPickerSearchEmoji": "Search emoji",
"@emojiPickerSearchEmoji": {
"description": "Hint text for the emoji picker search text field."
}
}
18 changes: 18 additions & 0 deletions lib/generated/l10n/zulip_localizations.dart
Original file line number Diff line number Diff line change
@@ -529,6 +529,12 @@ abstract class ZulipLocalizations {
/// **'Continue'**
String get dialogContinue;

/// Button label in dialogs to close.
///
/// In en, this message translates to:
/// **'Close'**
String get dialogClose;

/// Button label in error dialogs to acknowledge the error and close the dialog.
///
/// In en, this message translates to:
@@ -906,6 +912,18 @@ abstract class ZulipLocalizations {
/// In en, this message translates to:
/// **'Removing reaction failed'**
String get errorReactionRemovingFailedTitle;

/// Label for a button opening the emoji picker.
///
/// In en, this message translates to:
/// **'more'**
String get emojiReactionsMore;

/// Hint text for the emoji picker search text field.
///
/// In en, this message translates to:
/// **'Search emoji'**
String get emojiPickerSearchEmoji;
}

class _ZulipLocalizationsDelegate extends LocalizationsDelegate<ZulipLocalizations> {
9 changes: 9 additions & 0 deletions lib/generated/l10n/zulip_localizations_ar.dart
Original file line number Diff line number Diff line change
@@ -260,6 +260,9 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
@override
String get dialogContinue => 'Continue';

@override
String get dialogClose => 'Close';

@override
String get errorDialogContinue => 'OK';

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

@override
String get errorReactionRemovingFailedTitle => 'Removing reaction failed';

@override
String get emojiReactionsMore => 'more';

@override
String get emojiPickerSearchEmoji => 'Search emoji';
}
9 changes: 9 additions & 0 deletions lib/generated/l10n/zulip_localizations_en.dart
Original file line number Diff line number Diff line change
@@ -260,6 +260,9 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
@override
String get dialogContinue => 'Continue';

@override
String get dialogClose => 'Close';

@override
String get errorDialogContinue => 'OK';

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

@override
String get errorReactionRemovingFailedTitle => 'Removing reaction failed';

@override
String get emojiReactionsMore => 'more';

@override
String get emojiPickerSearchEmoji => 'Search emoji';
}
9 changes: 9 additions & 0 deletions lib/generated/l10n/zulip_localizations_ja.dart
Original file line number Diff line number Diff line change
@@ -260,6 +260,9 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
@override
String get dialogContinue => 'Continue';

@override
String get dialogClose => 'Close';

@override
String get errorDialogContinue => 'OK';

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

@override
String get errorReactionRemovingFailedTitle => 'Removing reaction failed';

@override
String get emojiReactionsMore => 'more';

@override
String get emojiPickerSearchEmoji => 'Search emoji';
}
51 changes: 42 additions & 9 deletions lib/widgets/action_sheet.dart
Original file line number Diff line number Diff line change
@@ -222,6 +222,13 @@ class ReactionButtons extends StatelessWidget {
: zulipLocalizations.errorReactionAddingFailedTitle);
}

void _handleTapMore() {
// Dismiss current action sheet before opening emoji picker sheet.
Navigator.of(pageContext).pop();

showEmojiPickerSheet(pageContext: pageContext, message: message);
}

Widget _buildButton({
required BuildContext context,
required EmojiCandidate emoji,
@@ -257,6 +264,7 @@ class ReactionButtons extends StatelessWidget {
assert(EmojiStore.popularEmojiCandidates.every(
(emoji) => emoji.emojiType == ReactionType.unicodeEmoji));

final zulipLocalizations = ZulipLocalizations.of(context);
final store = PerAccountStoreWidget.of(pageContext);
final designVariables = DesignVariables.of(context);

@@ -270,15 +278,40 @@ class ReactionButtons extends StatelessWidget {

return Container(
decoration: BoxDecoration(color: designVariables.contextMenuItemBg.withFadedAlpha(0.12)),
child: Row(
spacing: 1,
children: List.unmodifiable(
EmojiStore.popularEmojiCandidates.mapIndexed((index, emoji) =>
_buildButton(
context: context,
emoji: emoji,
isSelfVoted: hasSelfVote(emoji),
isFirst: index == 0)))));
child: Row(children: [
Flexible(child: Row(
spacing: 1,
children: List.unmodifiable(
EmojiStore.popularEmojiCandidates.mapIndexed((index, emoji) =>
_buildButton(
context: context,
emoji: emoji,
isSelfVoted: hasSelfVote(emoji),
isFirst: index == 0))))),
InkWell(
onTap: _handleTapMore,
splashFactory: NoSplash.splashFactory,
borderRadius: const BorderRadius.only(topRight: Radius.circular(7)),
overlayColor: WidgetStateColor.resolveWith((states) =>
states.any((e) => e == WidgetState.pressed)
? designVariables.contextMenuItemBg.withFadedAlpha(0.20)
: Colors.transparent),
child: Padding(
padding: const EdgeInsetsDirectional.fromSTEB(12, 12, 4, 12),
child: Row(children: [
Text(zulipLocalizations.emojiReactionsMore,
textAlign: TextAlign.end,
style: TextStyle(
color: designVariables.contextMenuItemText,
fontSize: 14,
).merge(weightVariableTextStyle(context, wght: 600))),
Icon(ZulipIcons.chevron_right,
color: designVariables.contextMenuItemText,
size: 24),
]),
)),
]),
);
}
}

1 change: 1 addition & 0 deletions lib/widgets/autocomplete.dart
Original file line number Diff line number Diff line change
@@ -260,6 +260,7 @@ class _EmojiAutocompleteItem extends StatelessWidget {
final store = PerAccountStoreWidget.of(context);
final candidate = option.candidate;

// TODO deduplicate this logic with [EmojiPickerListEntry]
final emojiDisplay = candidate.emojiDisplay.resolve(store.userSettings);
final Widget? glyph = switch (emojiDisplay) {
ImageEmojiDisplay() =>
Loading

0 comments on commit 8f768ca

Please sign in to comment.