@@ -32,7 +32,7 @@ class ConversationListItem extends StatelessWidget {
3232 avatar: conversation.avatar,
3333 isDeleted: isDeletedUser (conversation.opponent),
3434 )
35- : AvatarGroupIcon (conversation.avatar),
35+ : AvatarGroupIcon (conversation.avatar, conversation.name ),
3636 title: Text (
3737 conversation.name,
3838 style: const TextStyle (fontWeight: FontWeight .w500, fontSize: 20 ),
@@ -128,62 +128,67 @@ class DateUnreadWidget extends StatelessWidget {
128128
129129 @override
130130 Widget build (BuildContext context) {
131- return Column (
132- crossAxisAlignment: CrossAxisAlignment .end,
133- children: [
134- Padding (
135- padding: const EdgeInsets .only (right: 2 ),
136- child: Text (
137- DateFormatter ().getVerboseDateTimeRepresentation (
138- (conversation.lastMessage? .t != null
139- ? DateTime .fromMillisecondsSinceEpoch (
140- conversation.lastMessage! .t! * 1000 )
141- : conversation.updatedAt! )),
142- style: const TextStyle (color: whiteAluminum, fontSize: 15 ),
143- ),
144- ),
145- if (conversation.unreadMessagesCount != null &&
146- conversation.unreadMessagesCount != 0 )
147- Padding (
148- padding: const EdgeInsets .only (top: 4 ),
149- child: Container (
150- padding: const EdgeInsets .symmetric (vertical: 2 , horizontal: 6 ),
151- decoration: BoxDecoration (
152- color: slateBlue, borderRadius: BorderRadius .circular (10.0 )),
131+ return Padding (
132+ padding: const EdgeInsets .only (top: 5 ),
133+ child: Column (
134+ crossAxisAlignment: CrossAxisAlignment .end,
135+ children: [
136+ Padding (
137+ padding: const EdgeInsets .only (right: 2 ),
153138 child: Text (
154- conversation.unreadMessagesCount.toString (),
155- style: const TextStyle (color: white),
139+ DateFormatter ().getVerboseDateTimeRepresentation (
140+ (conversation.lastMessage? .t != null
141+ ? DateTime .fromMillisecondsSinceEpoch (
142+ conversation.lastMessage! .t! * 1000 )
143+ : conversation.updatedAt)),
144+ style: const TextStyle (color: whiteAluminum, fontSize: 13 ),
156145 ),
157146 ),
158- ),
159- ],
160- );
147+ if (conversation.unreadMessagesCount != null &&
148+ conversation.unreadMessagesCount != 0 )
149+ Padding (
150+ padding: const EdgeInsets .only (top: 4 ),
151+ child: Container (
152+ padding:
153+ const EdgeInsets .symmetric (vertical: 2 , horizontal: 6 ),
154+ decoration: BoxDecoration (
155+ color: slateBlue,
156+ borderRadius: BorderRadius .circular (10.0 )),
157+ child: Text (
158+ conversation.unreadMessagesCount.toString (),
159+ style: const TextStyle (color: white),
160+ ),
161+ ),
162+ ),
163+ ],
164+ ));
161165 }
162166}
163167
164168class DateFormatter {
165- String getVerboseDateTimeRepresentation (DateTime dateTime ) {
166- DateTime now = DateTime .now ();
167- DateTime justNow = DateTime . now (). subtract ( const Duration (minutes : 1 ) );
169+ String getVerboseDateTimeRepresentation (DateTime date ) {
170+ final now = DateTime .now ();
171+ final difference = now. difference (date );
168172
169- DateTime localDateTime = dateTime.toLocal ();
173+ if (difference.inMinutes < 1 ) {
174+ return 'Just now' ;
175+ }
170176
171- if (! localDateTime.difference (justNow).isNegative) {
172- return DateFormat ('jm' ).format (dateTime);
177+ if (now.year == date.year &&
178+ now.month == date.month &&
179+ now.day == date.day) {
180+ return DateFormat ('HH:mm' ).format (date);
173181 }
174182
175- String roughTimeString = DateFormat ('jm' ).format (dateTime);
176- if (localDateTime.day == now.day &&
177- localDateTime.month == now.month &&
178- localDateTime.year == now.year) {
179- return roughTimeString;
183+ final startOfWeek = now.subtract (Duration (days: now.weekday - 1 ));
184+ if (date.isAfter (startOfWeek)) {
185+ return DateFormat ('EEE' ).format (date).toLowerCase ();
180186 }
181187
182- if (now.difference (localDateTime).inDays < 4 ) {
183- String weekday = DateFormat ('EEEE' ).format (localDateTime);
184- return weekday.substring (0 , 2 );
188+ if (now.year == date.year) {
189+ return DateFormat ('dd.MM' ).format (date);
185190 }
186191
187- return DateFormat . yMd ( ).format (dateTime );
192+ return DateFormat ( 'dd.MM.yy' ).format (date );
188193 }
189194}
0 commit comments