37 lines
1.3 KiB
Dart
37 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// Central place for rendering emoji glyphs (reactions, pickers, …).
|
|
///
|
|
/// Emojis used to be drawn as bare `Text(emoji)` widgets all over the Talk UI,
|
|
/// which meant they inherited the small default body text size and looked
|
|
/// inconsistent. [EmojiText] gives every emoji a uniform, comfortably large
|
|
/// size and forces the platform's color-emoji font so the rendering is the same
|
|
/// everywhere.
|
|
class EmojiText extends StatelessWidget {
|
|
/// Size for emojis shown inline next to other text, e.g. reaction chips.
|
|
static const double sizeInline = 15;
|
|
|
|
/// Default size for standalone emojis, e.g. list leadings.
|
|
static const double sizeStandard = 20;
|
|
|
|
/// Size for primary tap targets, e.g. the quick-reaction buttons.
|
|
static const double sizeLarge = 24;
|
|
|
|
final String emoji;
|
|
final double size;
|
|
|
|
const EmojiText(this.emoji, {this.size = sizeStandard, super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Text(
|
|
emoji,
|
|
style: TextStyle(
|
|
fontSize: size,
|
|
height: 1.0,
|
|
// Render emojis with the platform color-emoji font instead of the app
|
|
// font, so they look identical across all usages and devices.
|
|
fontFamilyFallback: const ['Noto Color Emoji', 'Apple Color Emoji'],
|
|
),
|
|
);
|
|
}
|