@@ -3,6 +3,8 @@ import 'package:cloud_firestore/cloud_firestore.dart';
3
3
import 'package:emart/common_widgets/loading_indicator.dart' ;
4
4
import 'package:emart/consts/consts.dart' ;
5
5
import 'package:emart/services/firestore_service.dart' ;
6
+ import 'package:emart/views/chat_screen_view/chat_screen.dart' ;
7
+ import 'package:get/get.dart' ;
6
8
7
9
class MessagesScreen extends StatelessWidget {
8
10
const MessagesScreen ({super .key});
@@ -13,7 +15,7 @@ class MessagesScreen extends StatelessWidget {
13
15
backgroundColor: whiteColor,
14
16
appBar: AppBar (
15
17
title:
16
- "My Wishlist " .text.color (darkFontGrey).fontFamily (semibold).make (),
18
+ "My Messages " .text.color (darkFontGrey).fontFamily (semibold).make (),
17
19
),
18
20
body: StreamBuilder (
19
21
stream: FirestoreService .getAllMessages (),
@@ -22,8 +24,41 @@ class MessagesScreen extends StatelessWidget {
22
24
return loadingIndicator ();
23
25
else if (snapshot.data! .docs.isEmpty)
24
26
return "No messages yet!" .text.color (darkFontGrey).makeCentered ();
25
- else
26
- return Container ();
27
+ else {
28
+ var data = snapshot.data! .docs;
29
+ return Padding (
30
+ padding: const EdgeInsets .all (8.0 ),
31
+ child: Column (
32
+ children: [
33
+ Expanded (
34
+ child: ListView .builder (
35
+ itemCount: data.length,
36
+ itemBuilder: (BuildContext context, int index) => Card (
37
+ child: ListTile (
38
+ onTap: () => Get .to (() => const ChatScreen (),
39
+ arguments: [
40
+ data[index]['friend_name' ],
41
+ data[index]['toId' ]
42
+ ]),
43
+ leading: const CircleAvatar (
44
+ backgroundColor: redColor,
45
+ child: Icon (Icons .person),
46
+ ),
47
+ title: "${data [index ]['friend_name' ]}"
48
+ .text
49
+ .fontFamily (semibold)
50
+ .color (darkFontGrey)
51
+ .make (),
52
+ subtitle:
53
+ "${data [index ]['last_message' ]}" .text.make (),
54
+ ),
55
+ ),
56
+ ),
57
+ ),
58
+ ],
59
+ ),
60
+ );
61
+ }
27
62
},
28
63
),
29
64
);
0 commit comments