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 authored and gnprice committed Dec 11, 2024
1 parent f32cc98 commit d9621b8
Show file tree
Hide file tree
Showing 13 changed files with 552 additions and 7 deletions.
12 changes: 12 additions & 0 deletions assets/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,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."
Expand Down Expand Up @@ -643,5 +647,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
Expand Up @@ -583,6 +583,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:
Expand Down Expand Up @@ -960,6 +966,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> {
Expand Down
9 changes: 9 additions & 0 deletions lib/generated/l10n/zulip_localizations_ar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
@override
String get dialogContinue => 'Continue';

@override
String get dialogClose => 'Close';

@override
String get errorDialogContinue => 'OK';

Expand Down Expand Up @@ -508,4 +511,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
Expand Up @@ -284,6 +284,9 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
@override
String get dialogContinue => 'Continue';

@override
String get dialogClose => 'Close';

@override
String get errorDialogContinue => 'OK';

Expand Down Expand Up @@ -508,4 +511,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_fr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ class ZulipLocalizationsFr extends ZulipLocalizations {
@override
String get dialogContinue => 'Continue';

@override
String get dialogClose => 'Close';

@override
String get errorDialogContinue => 'OK';

Expand Down Expand Up @@ -508,4 +511,10 @@ class ZulipLocalizationsFr 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
Expand Up @@ -284,6 +284,9 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
@override
String get dialogContinue => 'Continue';

@override
String get dialogClose => 'Close';

@override
String get errorDialogContinue => 'OK';

Expand Down Expand Up @@ -508,4 +511,10 @@ class ZulipLocalizationsJa 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_pl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ class ZulipLocalizationsPl extends ZulipLocalizations {
@override
String get dialogContinue => 'Kontynuuj';

@override
String get dialogClose => 'Close';

@override
String get errorDialogContinue => 'OK';

Expand Down Expand Up @@ -508,4 +511,10 @@ class ZulipLocalizationsPl 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_ru.dart
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ class ZulipLocalizationsRu extends ZulipLocalizations {
@override
String get dialogContinue => 'Continue';

@override
String get dialogClose => 'Close';

@override
String get errorDialogContinue => 'OK';

Expand Down Expand Up @@ -508,4 +511,10 @@ class ZulipLocalizationsRu extends ZulipLocalizations {

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

@override
String get emojiReactionsMore => 'more';

@override
String get emojiPickerSearchEmoji => 'Search emoji';
}
50 changes: 43 additions & 7 deletions lib/widgets/action_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,16 @@ class ReactionButtons extends StatelessWidget {
: zulipLocalizations.errorReactionAddingFailedTitle);
}

void _handleTapMore() {
// TODO(design): have emoji picker slide in from right and push
// action sheet off to the left

// 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,
Expand Down Expand Up @@ -479,6 +489,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);

Expand All @@ -493,13 +504,38 @@ 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),
]),
)),
]),
);
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/widgets/autocomplete.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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() =>
Expand Down
Loading

0 comments on commit d9621b8

Please sign in to comment.