diff options
author | Iván Ávalos <avalos@disroot.org> | 2023-05-22 23:06:18 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2023-05-22 23:06:18 -0600 |
commit | 79bdf9cac504d35cf3cf671232b28b5b5ac03f12 (patch) | |
tree | c8ddb66955468f399a8a368464d0db53dc5c8f8d /lib/widgets/chat_bubble.dart | |
parent | 9139a65003d758b4ee52758149b178d8dc990e0e (diff) | |
download | linkchat-79bdf9cac504d35cf3cf671232b28b5b5ac03f12.tar.gz linkchat-79bdf9cac504d35cf3cf671232b28b5b5ac03f12.tar.bz2 linkchat-79bdf9cac504d35cf3cf671232b28b5b5ac03f12.zip |
Se implementan favoritos
Diffstat (limited to 'lib/widgets/chat_bubble.dart')
-rw-r--r-- | lib/widgets/chat_bubble.dart | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/lib/widgets/chat_bubble.dart b/lib/widgets/chat_bubble.dart index ba90f6b..e7622e4 100644 --- a/lib/widgets/chat_bubble.dart +++ b/lib/widgets/chat_bubble.dart @@ -10,11 +10,15 @@ enum ChatBubbleAlignment { start, end } class ChatBubble extends StatelessWidget {
final Message message;
final ChatBubbleAlignment alignment;
+ final bool favorited;
+ final Function(String id, bool value) onFavorite;
const ChatBubble(
this.message, {
super.key,
required this.alignment,
+ this.favorited = false,
+ required this.onFavorite,
});
@override
@@ -23,8 +27,16 @@ class ChatBubble extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start,
children: [
alignment == ChatBubbleAlignment.start
- ? BubbleLeft(message)
- : BubbleRight(message),
+ ? BubbleLeft(
+ message,
+ favorited: favorited,
+ onFavorite: onFavorite,
+ )
+ : BubbleRight(
+ message,
+ favorited: favorited,
+ onFavorite: onFavorite,
+ ),
],
);
}
@@ -32,8 +44,15 @@ class ChatBubble extends StatelessWidget { class BubbleLeft extends StatelessWidget {
final Message message;
+ final bool favorited;
+ final Function(String id, bool value) onFavorite;
- const BubbleLeft(this.message, {super.key});
+ const BubbleLeft(
+ this.message, {
+ super.key,
+ this.favorited = false,
+ required this.onFavorite,
+ });
@override
Widget build(BuildContext context) {
@@ -60,6 +79,12 @@ class BubbleLeft extends StatelessWidget { ),
),
),
+ IconButton(
+ icon: favorited
+ ? const Icon(Icons.favorite, color: Colors.black)
+ : const Icon(Icons.favorite_outline, color: Colors.black),
+ onPressed: () => onFavorite(message.id!, !favorited),
+ ),
],
),
),
@@ -70,8 +95,15 @@ class BubbleLeft extends StatelessWidget { class BubbleRight extends StatelessWidget {
final Message message;
+ final bool favorited;
+ final Function(String id, bool value) onFavorite;
- const BubbleRight(this.message, {super.key});
+ const BubbleRight(
+ this.message, {
+ super.key,
+ this.favorited = false,
+ required this.onFavorite,
+ });
@override
Widget build(BuildContext context) {
@@ -101,6 +133,12 @@ class BubbleRight extends StatelessWidget { ),
),
),
+ IconButton(
+ icon: favorited
+ ? const Icon(Icons.favorite, color: Colors.white)
+ : const Icon(Icons.favorite_outline, color: Colors.white),
+ onPressed: () => onFavorite(message.id!, !favorited),
+ ),
],
),
),
|