aboutsummaryrefslogtreecommitdiff
path: root/lib/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'lib/widgets')
-rw-r--r--lib/widgets/active_chats.dart42
-rw-r--r--lib/widgets/chat_bubble.dart46
2 files changed, 42 insertions, 46 deletions
diff --git a/lib/widgets/active_chats.dart b/lib/widgets/active_chats.dart
deleted file mode 100644
index 6893edb..0000000
--- a/lib/widgets/active_chats.dart
+++ /dev/null
@@ -1,42 +0,0 @@
-import 'package:flutter/material.dart';
-
-class ActiveChats extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- return Padding(
- padding: const EdgeInsets.only(top: 25, left: 5),
- child: SingleChildScrollView(
- scrollDirection: Axis.horizontal,
- child: Row(
- children: [
- for (int i = 0; i < 10; i++)
- Padding(
- padding:
- const EdgeInsets.symmetric(vertical: 10, horizontal: 12),
- child: Container(
- width: 55,
- height: 55,
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(35),
- boxShadow: [
- BoxShadow(
- color: Colors.grey.withOpacity(0.5),
- blurRadius: 10,
- spreadRadius: 2,
- offset: const Offset(0, 3),
- ),
- ]),
- child: const ClipRRect(
- //child: Image.asset(
- // "images/avatar.png",
- //),
- child: Icon(Icons.person),
- ),
- ),
- ),
- ],
- )),
- );
- }
-}
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),
+ ),
],
),
),