starting with #2 animated emoji

This commit is contained in:
otsmr 2025-02-13 13:59:34 +01:00
parent 1b249e494e
commit baae1b04c0
11 changed files with 83 additions and 33 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,41 @@
import 'package:cv/cv.dart';
import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';
// animations from: https://googlefonts.github.io/noto-emoji-animation/
class EmojiAnimation extends StatelessWidget {
final String emoji;
static final Map<String, String> animatedIcons = {
"": "red_heart.json",
"💪": "💪.json",
"🔥": "🔥.json",
"🤠": "🤠.json",
"🤯": "🤯.json",
"🥰": "🥰.json",
"😂": "😂.json",
"😭": "😭.json",
};
const EmojiAnimation({super.key, required this.emoji});
static bool supported(String emoji) {
return animatedIcons.containsKey(emoji);
}
@override
Widget build(BuildContext context) {
// List of emojis and their corresponding Lottie file names
// Check if the emoji has a corresponding Lottie animation
if (animatedIcons.containsKey(emoji)) {
return Lottie.asset(
"assets/animated_icons/${animatedIcons.getValue(emoji)}");
} else {
return Text(
emoji,
style: TextStyle(fontSize: 100), // Adjust the size as needed
);
}
}
}

View file

@ -2,6 +2,7 @@ import 'dart:collection';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:twonly/src/components/animate_icon.dart';
import 'package:twonly/src/components/initialsavatar.dart'; import 'package:twonly/src/components/initialsavatar.dart';
import 'package:twonly/src/components/message_send_state_icon.dart'; import 'package:twonly/src/components/message_send_state_icon.dart';
import 'package:twonly/src/components/verified_shield.dart'; import 'package:twonly/src/components/verified_shield.dart';
@ -46,6 +47,16 @@ class ChatListEntry extends StatelessWidget {
Widget child = Container(); Widget child = Container();
if (content is TextMessageContent) { if (content is TextMessageContent) {
if (EmojiAnimation.supported(content.text)) {
child = child = Container(
constraints: BoxConstraints(
maxWidth: 100,
),
padding: EdgeInsets.symmetric(
vertical: 4, horizontal: 10), // Add some padding around the text
child: EmojiAnimation(emoji: content.text),
);
} else {
child = Container( child = Container(
constraints: BoxConstraints( constraints: BoxConstraints(
maxWidth: MediaQuery.of(context).size.width * 0.8, maxWidth: MediaQuery.of(context).size.width * 0.8,
@ -68,6 +79,7 @@ class ChatListEntry extends StatelessWidget {
textAlign: TextAlign.left, // Center the text textAlign: TextAlign.left, // Center the text
), ),
); );
}
} else if (content is MediaMessageContent && !content.isVideo) { } else if (content is MediaMessageContent && !content.isVideo) {
Color color = message.messageContent Color color = message.messageContent
.getColor(Theme.of(context).colorScheme.primary); .getColor(Theme.of(context).colorScheme.primary);

View file

@ -82,18 +82,7 @@ flutter:
assets: assets:
# Add assets from the images directory to the application. # Add assets from the images directory to the application.
- assets/images/logo.jpg
- assets/
- assets/images/ - assets/images/
- assets/images/onboarding/ricky_the_greedy_racoon.png - assets/images/onboarding/ricky_the_greedy_racoon.png
- assets/animations/present.lottie.json - assets/animated_icons/
- assets/animations/selfie2.json
- assets/animations/selfie.json
- assets/animations/takephoto.json
- assets/animations/local.json
- assets/animations/test.json
- assets/animations/product.json
- assets/animations/twonlies.json
- assets/animations/rocket.json
- assets/animations/e2e.json