Skip to content

Commit dc686ef

Browse files
committed
emoji [nfc]: Remove UnicodeEmojiWidget.notoColorEmojiTextSize
Instead of passing this property each time the widget is used, we now calculate it internally. See discussion: #1629 (comment)
1 parent ce1c664 commit dc686ef

File tree

4 files changed

+20
-26
lines changed

4 files changed

+20
-26
lines changed

lib/widgets/action_sheet.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,6 @@ class ReactionButtons extends StatelessWidget {
774774
: null,
775775
child: UnicodeEmojiWidget(
776776
emojiDisplay: emoji.emojiDisplay as UnicodeEmojiDisplay,
777-
notoColorEmojiTextSize: 20.1,
778777
size: 24))));
779778
}
780779

lib/widgets/autocomplete.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ class _EmojiAutocompleteItem extends StatelessWidget {
327327
final EmojiAutocompleteResult option;
328328

329329
static const _size = 24.0;
330-
static const _notoColorEmojiTextSize = 19.3;
331330

332331
@override
333332
Widget build(BuildContext context) {
@@ -341,9 +340,7 @@ class _EmojiAutocompleteItem extends StatelessWidget {
341340
ImageEmojiDisplay() =>
342341
ImageEmojiWidget(size: _size, emojiDisplay: emojiDisplay),
343342
UnicodeEmojiDisplay() =>
344-
UnicodeEmojiWidget(
345-
size: _size, notoColorEmojiTextSize: _notoColorEmojiTextSize,
346-
emojiDisplay: emojiDisplay),
343+
UnicodeEmojiWidget(size: _size, emojiDisplay: emojiDisplay),
347344
TextEmojiDisplay() => null, // The text is already shown separately.
348345
};
349346

lib/widgets/emoji.dart

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ class UnicodeEmojiWidget extends StatelessWidget {
99
super.key,
1010
required this.emojiDisplay,
1111
required this.size,
12-
required this.notoColorEmojiTextSize,
1312
this.textScaler = TextScaler.noScaling,
1413
});
1514

@@ -20,12 +19,6 @@ class UnicodeEmojiWidget extends StatelessWidget {
2019
/// This will be scaled by [textScaler].
2120
final double size;
2221

23-
/// A font size that, with Noto Color Emoji and our line-height config,
24-
/// causes a Unicode emoji to occupy a square of size [size] in the layout.
25-
///
26-
/// This has to be determined experimentally, as far as we know.
27-
final double notoColorEmojiTextSize;
28-
2922
/// The text scaler to apply to [size].
3023
///
3124
/// Defaults to [TextScaler.noScaling].
@@ -38,14 +31,26 @@ class UnicodeEmojiWidget extends StatelessWidget {
3831
case TargetPlatform.fuchsia:
3932
case TargetPlatform.linux:
4033
case TargetPlatform.windows:
34+
// A font size that, with Noto Color Emoji and our line-height
35+
// config (the use of `forceStrutHeight: true`), causes a Unicode emoji
36+
// to occupy a square of size [size] in the layout.
37+
//
38+
// Determined experimentally:
39+
// <https://github.com/zulip/zulip-flutter/pull/410#discussion_r1402808701>
40+
// <https://github.com/zulip/zulip-flutter/pull/1629#discussion_r2188037245>
41+
final double notoColorEmojiTextSize = size * (14.5 / 17);
42+
4143
return Text(
4244
textScaler: textScaler,
4345
style: TextStyle(
4446
fontFamily: 'Noto Color Emoji',
4547
fontSize: notoColorEmojiTextSize,
4648
),
4749
strutStyle: StrutStyle(
48-
fontSize: notoColorEmojiTextSize, forceStrutHeight: true),
50+
fontSize: notoColorEmojiTextSize,
51+
// Responsible for keeping the line height constant, even
52+
// with ambient DefaultTextStyle.
53+
forceStrutHeight: true),
4954
emojiDisplay.emojiUnicode);
5055

5156
case TargetPlatform.iOS:
@@ -74,7 +79,11 @@ class UnicodeEmojiWidget extends StatelessWidget {
7479
style: TextStyle(
7580
fontFamily: 'Apple Color Emoji',
7681
fontSize: size),
77-
strutStyle: StrutStyle(fontSize: size, forceStrutHeight: true),
82+
strutStyle: StrutStyle(
83+
fontSize: size,
84+
// Responsible for keeping the line height constant, even
85+
// with ambient DefaultTextStyle.
86+
forceStrutHeight: true),
7887
emojiDisplay.emojiUnicode)),
7988
]);
8089
}

lib/widgets/emoji_reaction.dart

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,6 @@ class ReactionChip extends StatelessWidget {
270270
/// Should be scaled by [_emojiTextScalerClamped].
271271
const _squareEmojiSize = 17.0;
272272

273-
/// A font size that, with Noto Color Emoji and our line-height config,
274-
/// causes a Unicode emoji to occupy a [_squareEmojiSize] square in the layout.
275-
///
276-
/// Determined experimentally:
277-
/// <https://github.com/zulip/zulip-flutter/pull/410#discussion_r1402808701>
278-
const _notoColorEmojiTextSize = 14.5;
279-
280273
/// A [TextScaler] that limits Unicode and image emojis' max scale factor,
281274
/// to leave space for the label.
282275
///
@@ -306,7 +299,6 @@ class _UnicodeEmoji extends StatelessWidget {
306299
Widget build(BuildContext context) {
307300
return UnicodeEmojiWidget(
308301
size: _squareEmojiSize,
309-
notoColorEmojiTextSize: _notoColorEmojiTextSize,
310302
textScaler: _squareEmojiScalerClamped(context),
311303
emojiDisplay: emojiDisplay);
312304
}
@@ -563,7 +555,6 @@ class EmojiPickerListEntry extends StatelessWidget {
563555
final Message message;
564556

565557
static const _emojiSize = 24.0;
566-
static const _notoColorEmojiTextSize = 20.1;
567558

568559
void _onPressed() {
569560
// Dismiss the enclosing action sheet immediately,
@@ -590,9 +581,7 @@ class EmojiPickerListEntry extends StatelessWidget {
590581
ImageEmojiDisplay() =>
591582
ImageEmojiWidget(size: _emojiSize, emojiDisplay: emojiDisplay),
592583
UnicodeEmojiDisplay() =>
593-
UnicodeEmojiWidget(
594-
size: _emojiSize, notoColorEmojiTextSize: _notoColorEmojiTextSize,
595-
emojiDisplay: emojiDisplay),
584+
UnicodeEmojiWidget(size: _emojiSize, emojiDisplay: emojiDisplay),
596585
TextEmojiDisplay() => null, // The text is already shown separately.
597586
};
598587

0 commit comments

Comments
 (0)