1
- // ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables, unused_local_variable
1
+ // ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables, unused_local_variable, dead_code
2
2
3
3
import 'package:cloud_firestore/cloud_firestore.dart' ;
4
4
import 'package:firebase_auth/firebase_auth.dart' ;
5
5
import 'package:flutter/gestures.dart' ;
6
6
import 'package:flutter/material.dart' ;
7
7
import 'package:get/get.dart' ;
8
+ import 'package:intl/intl.dart' ;
8
9
import 'package:nelaamproject/frontend/message/message.dart' ;
9
10
10
11
class chatPage extends StatefulWidget {
@@ -17,6 +18,25 @@ class chatPage extends StatefulWidget {
17
18
class _chatPageState extends State <chatPage> {
18
19
@override
19
20
Widget build (BuildContext context) {
21
+ final now = DateTime .now ();
22
+ // UploadTask? uploa;
23
+ final today = DateTime (now.year, now.month, now.day);
24
+ final yesterday = DateTime (now.year, now.month, now.day - 1 );
25
+ final tomorrow = DateTime (now.year, now.month, now.day + 1 );
26
+
27
+ String dateToday (DateTime Time ) {
28
+ String time = '' ;
29
+ final dateToCheck = Time ;
30
+ final aDate =
31
+ DateTime (dateToCheck.year, dateToCheck.month, dateToCheck.day);
32
+ if (aDate == today) {
33
+ return time = DateFormat .jm ().format (Time );
34
+ } else {
35
+ return time = DateFormat .yMd ().format (Time );
36
+ }
37
+ return time;
38
+ }
39
+
20
40
return Scaffold (
21
41
appBar: AppBar (
22
42
automaticallyImplyLeading: false ,
@@ -129,13 +149,74 @@ class _chatPageState extends State<chatPage> {
129
149
horizontal: 8 , vertical: 3 ),
130
150
child: Column (
131
151
children: [
132
- Text (
133
- snap['username' ],
134
- style: TextStyle (
135
- fontSize: 17 ,
136
- fontWeight: FontWeight .bold,
152
+ Container (
153
+ width:
154
+ MediaQuery .of (context).size.width -
155
+ 135 ,
156
+ child: Row (
157
+ mainAxisAlignment:
158
+ MainAxisAlignment .spaceBetween,
159
+ children: [
160
+ Text (
161
+ snap['username' ],
162
+ textAlign: TextAlign .start,
163
+ style: TextStyle (
164
+ fontSize: 17 ,
165
+ fontWeight: FontWeight .bold,
166
+ ),
167
+ ),
168
+ Text (
169
+ dateToday (snap['time' ]
170
+ .toDate ())
171
+ .toString (),
172
+ style: TextStyle (
173
+ color:
174
+ snap['lastMessage' ] ==
175
+ 'bid'
176
+ ? Color .fromARGB (
177
+ 255 ,
178
+ 30 ,
179
+ 76 ,
180
+ 106 )
181
+ : Colors .grey,
182
+ fontWeight: FontWeight .bold,
183
+ fontSize: 13 )),
184
+ ],
137
185
),
138
- )
186
+ ),
187
+ snap['lastMessage' ] == 'bid'
188
+ ? Container (
189
+ height: 30 ,
190
+ width: MediaQuery .of (context)
191
+ .size
192
+ .width -
193
+ 138 ,
194
+ color: Colors .transparent,
195
+ child: Row (
196
+ mainAxisAlignment:
197
+ MainAxisAlignment
198
+ .spaceBetween,
199
+ children: [
200
+ Text (
201
+ '${snap ['username' ]} Accepted your bid request!' ,
202
+ textAlign: TextAlign .start,
203
+ style: TextStyle (
204
+ fontSize: 12 ,
205
+ color: Colors .grey,
206
+ fontWeight:
207
+ FontWeight .bold,
208
+ ),
209
+ ),
210
+ CircleAvatar (
211
+ radius: 10 ,
212
+ backgroundColor:
213
+ Color .fromARGB (
214
+ 255 , 30 , 76 , 106 ),
215
+ )
216
+ ],
217
+ ),
218
+ )
219
+ : Container (),
139
220
],
140
221
),
141
222
)
0 commit comments