showSkinToneOverlay method

void showSkinToneOverlay(
  1. Offset emojiBoxPosition,
  2. Emoji emoji,
  3. double emojiSize,
  4. CategoryEmoji? categoryEmoji,
  5. Config config,
  6. OnEmojiSelected onEmojiSelected,
  7. LayerLink link,
)

Overlay for SkinTone

Implementation

void showSkinToneOverlay(
  Offset emojiBoxPosition,
  Emoji emoji,
  double emojiSize,
  CategoryEmoji? categoryEmoji,
  Config config,
  OnEmojiSelected onEmojiSelected,
  LayerLink link,
) {
  // Generate other skintone options
  final skinTonesEmoji = SkinTone.values
      .map((skinTone) => _utils.applySkinTone(emoji, skinTone))
      .toList();

  final screenWidth = MediaQuery.of(context).size.width;
  final emojiPickerRenderbox = context.findRenderObject() as RenderBox;
  final emojiBoxSize = config.emojiViewConfig.getEmojiBoxSize(
    emojiPickerRenderbox.size.width,
  );
  final left = _calculateLeftOffset(
    emojiBoxSize,
    emojiBoxPosition,
    screenWidth,
  );
  final top = _calculateTopOffset(emojiBoxSize);

  _overlay = OverlayEntry(
    builder: (context) => Positioned(
      top: 0,
      left: 0,
      child: CompositedTransformFollower(
        offset: Offset(left, top),
        link: link,
        showWhenUnlinked: false,
        child: TapRegion(
          onTapOutside: (_) => closeSkinToneOverlay(),
          child: Material(
            elevation: 4.0,
            child: Container(
              padding: const EdgeInsets.symmetric(vertical: 4.0),
              color: config.skinToneConfig.dialogBackgroundColor,
              child: Row(
                children: [
                  EmojiCell.fromConfig(
                    emoji: emoji,
                    emojiSize: emojiSize,
                    emojiBoxSize: emojiBoxSize,
                    categoryEmoji: categoryEmoji,
                    onEmojiSelected: onEmojiSelected,
                    config: config,
                  ),
                  ...List.generate(
                    SkinTone.values.length,
                    (index) => EmojiCell.fromConfig(
                      emoji: skinTonesEmoji[index],
                      emojiSize: emojiSize,
                      emojiBoxSize: emojiBoxSize,
                      categoryEmoji: categoryEmoji,
                      onEmojiSelected: onEmojiSelected,
                      config: config,
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
      ),
    ),
  );

  if (_overlay != null) {
    Overlay.of(context).insert(_overlay!);
  } else {
    throw Exception('Nullable skin tone overlay insert attempt');
  }
}