This commit is contained in:
otsmr 2025-04-30 22:21:33 +02:00
parent 687d2d7380
commit 32bdb0115d
2 changed files with 12 additions and 3 deletions

View file

@ -18,6 +18,7 @@ bool isEmoji(String character) {
class EmojiAnimation extends StatelessWidget { class EmojiAnimation extends StatelessWidget {
final String emoji; final String emoji;
final bool repeat;
static final Map<String, String> animatedIcons = { static final Map<String, String> animatedIcons = {
"": "red_heart.json", "": "red_heart.json",
"😂": "joy.json", "😂": "joy.json",
@ -388,7 +389,7 @@ class EmojiAnimation extends StatelessWidget {
"🏴": "black-flag.json", "🏴": "black-flag.json",
}; };
const EmojiAnimation({super.key, required this.emoji}); const EmojiAnimation({super.key, required this.emoji, this.repeat = true});
static bool supported(String emoji) { static bool supported(String emoji) {
if (emoji.length > 4) return false; if (emoji.length > 4) return false;
@ -401,7 +402,10 @@ class EmojiAnimation extends StatelessWidget {
// Check if the emoji has a corresponding Lottie animation // Check if the emoji has a corresponding Lottie animation
if (animatedIcons.containsKey(emoji)) { if (animatedIcons.containsKey(emoji)) {
return Lottie.asset("assets/animated_icons/${animatedIcons[emoji]}"); return Lottie.asset(
"assets/animated_icons/${animatedIcons[emoji]}",
repeat: repeat,
);
} else if (isEmoji(emoji)) { } else if (isEmoji(emoji)) {
return Text( return Text(
emoji, emoji,
@ -421,6 +425,7 @@ class EmojiAnimationFlying extends StatelessWidget {
final Duration duration; final Duration duration;
final double startPosition; final double startPosition;
final int size; final int size;
final bool repeat;
const EmojiAnimationFlying({ const EmojiAnimationFlying({
super.key, super.key,
@ -428,6 +433,7 @@ class EmojiAnimationFlying extends StatelessWidget {
required this.duration, required this.duration,
required this.startPosition, required this.startPosition,
required this.size, required this.size,
this.repeat = true,
}); });
@override @override

View file

@ -79,7 +79,10 @@ class _ChatReactionSelectionView extends State<ChatReactionSelectionView> {
child: SizedBox( child: SizedBox(
width: 40, width: 40,
height: 40, height: 40,
child: EmojiAnimation(emoji: emoji), child: EmojiAnimation(
emoji: emoji,
repeat: selectedEmojis.contains(emoji),
),
), ),
), ),
), ),