Added 99 limit for unreads and changed logic for date implementation
This commit is contained in:
@@ -155,12 +155,18 @@ class ChannelPreview extends StatelessWidget {
|
|||||||
String stringDate;
|
String stringDate;
|
||||||
final now = DateTime.now();
|
final now = DateTime.now();
|
||||||
|
|
||||||
if (now.year != lastMessageAt.year ||
|
var startOfDay = DateTime(now.year, now.month, now.day);
|
||||||
now.month != lastMessageAt.month ||
|
|
||||||
now.day != lastMessageAt.day) {
|
if (lastMessageAt.millisecondsSinceEpoch >=
|
||||||
stringDate = Jiffy(lastMessageAt.toLocal()).format('dd/MM/yyyy');
|
startOfDay.millisecondsSinceEpoch) {
|
||||||
} else {
|
|
||||||
stringDate = Jiffy(lastMessageAt.toLocal()).format('HH:mm');
|
stringDate = Jiffy(lastMessageAt.toLocal()).format('HH:mm');
|
||||||
|
} else if (lastMessageAt.millisecondsSinceEpoch >=
|
||||||
|
startOfDay.subtract(Duration(days: 1)).millisecondsSinceEpoch) {
|
||||||
|
stringDate = 'Yesterday';
|
||||||
|
} else if (startOfDay.difference(lastMessageAt).inDays < 7) {
|
||||||
|
stringDate = Jiffy(lastMessageAt.toLocal()).EEEE;
|
||||||
|
} else {
|
||||||
|
stringDate = Jiffy(lastMessageAt.toLocal()).format('dd/MM/yyyy');
|
||||||
}
|
}
|
||||||
|
|
||||||
return Text(
|
return Text(
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class ChannelUnreadIndicator extends StatelessWidget {
|
|||||||
if (!snapshot.hasData || snapshot.data == 0) {
|
if (!snapshot.hasData || snapshot.data == 0) {
|
||||||
return SizedBox();
|
return SizedBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Material(
|
return Material(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
color: StreamChatTheme.of(context)
|
color: StreamChatTheme.of(context)
|
||||||
@@ -33,7 +34,7 @@ class ChannelUnreadIndicator extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
'${snapshot.data}',
|
'${snapshot.data > 99 ? '99+' : snapshot.data}',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 11,
|
fontSize: 11,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
|||||||
Reference in New Issue
Block a user