Skip to content

Commit bad037c

Browse files
msg
1 parent b53395a commit bad037c

File tree

5 files changed

+195
-16
lines changed

5 files changed

+195
-16
lines changed

analysis_options.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# The following line activates a set of recommended lints for Flutter apps,
99
# packages, and plugins designed to encourage good coding practices.
10-
include: package:flutter_lints/flutter.yaml
10+
# include: package:flutter_lints/flutter.yaml
1111

1212
linter:
1313
# The lint rules applied to this project can be customized in the

lib/frontend/message/message.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ class _message_screenState extends State<message_screen>
937937
),
938938
Container(
939939
height: 50,
940-
width: 300,
940+
width: 270,
941941
color: Colors.transparent,
942942
child: Row(
943943
mainAxisAlignment:
@@ -958,7 +958,7 @@ class _message_screenState extends State<message_screen>
958958
LottieBuilder.asset(
959959
"images/record1.json",
960960
// height: 300,
961-
width: 200,
961+
width: 170,
962962
),
963963
StreamBuilder<RecordingDisposition>(
964964
stream: recorder.onProgress,

lib/frontend/screens/bid_show.dart

+102-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:cloud_firestore/cloud_firestore.dart';
22
import 'package:firebase_auth/firebase_auth.dart';
33
import 'package:flutter/material.dart';
4+
import 'package:get/get.dart';
45
import 'package:nelaamproject/Widgets/snackbar.dart';
56
import 'package:uuid/uuid.dart';
67

@@ -107,7 +108,7 @@ class _bid_ShowState extends State<bid_Show> {
107108
.doc(postId)
108109
.set({
109110
'message':
110-
'Hi you send me bid on my $product and i accepted your bid request if you want to buy my product you can contact me',
111+
'Hi you send me bid on my $product product and i accepted your bid request if you want to buy my product you can contact me',
111112
'chatId': uid,
112113
'uid': FirebaseAuth.instance.currentUser!.uid,
113114
'name': name1,
@@ -120,12 +121,12 @@ class _bid_ShowState extends State<bid_Show> {
120121
.collection('users')
121122
.doc(uid)
122123
.collection('Chatrooms')
123-
.doc(uid)
124+
.doc(FirebaseAuth.instance.currentUser!.uid)
124125
.collection('messages')
125126
.doc(postId)
126127
.set({
127128
'message':
128-
'Hi you send me bid on my $product and i accepted your bid request if you want to buy my product you can contact me',
129+
'Hi you send me bid on my $product product and i accepted your bid request if you want to buy my product you can contact me',
129130
'chatId': uid,
130131
'uid': FirebaseAuth.instance.currentUser!.uid,
131132
'read': false,
@@ -244,7 +245,15 @@ class _bid_ShowState extends State<bid_Show> {
244245
Row(
245246
children: [
246247
GestureDetector(
247-
onTap: () {
248+
onTap: () async {
249+
showDialog(
250+
context: context,
251+
barrierDismissible: false,
252+
builder: (context) => Center(
253+
child:
254+
CircularProgressIndicator(),
255+
));
256+
248257
CreateChatRoom(
249258
userData['uid'],
250259
userData1['username'],
@@ -253,6 +262,95 @@ class _bid_ShowState extends State<bid_Show> {
253262
userData['profileUrl'],
254263
widget.product,
255264
context);
265+
await FirebaseFirestore.instance
266+
.collection('Products')
267+
.doc(widget.postId)
268+
.update({
269+
'bids':
270+
FieldValue.arrayRemove([snap['uid']])
271+
});
272+
await FirebaseFirestore.instance
273+
.collection('Products')
274+
.doc(widget.postId)
275+
.collection('bids')
276+
.doc(snap['uid'])
277+
.delete();
278+
279+
showDialog(
280+
context: context,
281+
barrierDismissible: false,
282+
builder: (context) {
283+
return AlertDialog(
284+
content: Container(
285+
height: 180,
286+
child: Column(
287+
mainAxisAlignment:
288+
MainAxisAlignment
289+
.center,
290+
crossAxisAlignment:
291+
CrossAxisAlignment
292+
.center,
293+
children: [
294+
CircleAvatar(
295+
radius: 28,
296+
backgroundColor:
297+
Colors.green,
298+
child: Icon(
299+
Icons.check,
300+
color: Colors.white,
301+
size: 50,
302+
),
303+
),
304+
SizedBox(
305+
height: 5,
306+
),
307+
Text(
308+
'Your Message send to the Buyer wait until he replied to you',
309+
textAlign:
310+
TextAlign.center,
311+
style: TextStyle(
312+
fontWeight:
313+
FontWeight.bold,
314+
),
315+
),
316+
SizedBox(
317+
height: 5,
318+
),
319+
GestureDetector(
320+
onTap: () {
321+
Get.back();
322+
Get.back();
323+
},
324+
child: Container(
325+
height: 40,
326+
width: 120,
327+
decoration:
328+
BoxDecoration(
329+
color:
330+
Colors.blue,
331+
borderRadius:
332+
BorderRadius
333+
.circular(
334+
8),
335+
),
336+
child: Center(
337+
child: Text(
338+
'Dismiss',
339+
style:
340+
TextStyle(
341+
color: Colors
342+
.white,
343+
fontSize: 17,
344+
fontWeight:
345+
FontWeight
346+
.bold,
347+
),
348+
),
349+
),
350+
),
351+
),
352+
])));
353+
});
256354
},
257355
child: CircleAvatar(
258356
radius: 17.0,

lib/frontend/screens/chat.dart

+88-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
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
22

33
import 'package:cloud_firestore/cloud_firestore.dart';
44
import 'package:firebase_auth/firebase_auth.dart';
55
import 'package:flutter/gestures.dart';
66
import 'package:flutter/material.dart';
77
import 'package:get/get.dart';
8+
import 'package:intl/intl.dart';
89
import 'package:nelaamproject/frontend/message/message.dart';
910

1011
class chatPage extends StatefulWidget {
@@ -17,6 +18,25 @@ class chatPage extends StatefulWidget {
1718
class _chatPageState extends State<chatPage> {
1819
@override
1920
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+
2040
return Scaffold(
2141
appBar: AppBar(
2242
automaticallyImplyLeading: false,
@@ -129,13 +149,74 @@ class _chatPageState extends State<chatPage> {
129149
horizontal: 8, vertical: 3),
130150
child: Column(
131151
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+
],
137185
),
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(),
139220
],
140221
),
141222
)

lib/widgets/message_card.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ class _audioCardState extends State<audioCard> {
323323
return Column(
324324
children: [
325325
Bubble(
326-
margin: BubbleEdges.only(top: 10, left: 60),
326+
margin: BubbleEdges.only(top: 10, left: 46),
327327
alignment: Alignment.topRight,
328328
nipWidth: 15,
329329
nipHeight: 10,
@@ -504,7 +504,7 @@ class _audioCard1State extends State<audioCard1> {
504504
return Column(
505505
children: [
506506
Bubble(
507-
margin: BubbleEdges.only(top: 10, right: 60),
507+
margin: BubbleEdges.only(top: 10, right: 46),
508508
alignment: Alignment.topLeft,
509509
nipWidth: 15,
510510
nipHeight: 10,

0 commit comments

Comments
 (0)