Update Jiffy & Fixed

This commit is contained in:
rlee1990
2023-06-05 13:18:29 -04:00
parent c307ee86f9
commit dea5664851
13 changed files with 38 additions and 31 deletions
@@ -108,7 +108,7 @@ class _ConnectedTitleState extends StatelessWidget {
} else {
alternativeWidget = Text(
'${context.translations.userLastOnlineText} '
'${Jiffy(otherMember.user?.lastActive).fromNow()}',
'${Jiffy.parseFromDateTime(otherMember.user!.lastActive!).fromNow()}',
style: textStyle,
);
}
@@ -349,16 +349,16 @@ class _Date extends StatelessWidget {
if (lastMessageAt.millisecondsSinceEpoch >=
startOfDay.millisecondsSinceEpoch) {
stringDate = Jiffy(lastMessageAt.toLocal()).jm;
stringDate = Jiffy.parseFromDateTime(lastMessageAt.toLocal()).jm;
} else if (lastMessageAt.millisecondsSinceEpoch >=
startOfDay
.subtract(const Duration(days: 1))
.millisecondsSinceEpoch) {
stringDate = context.translations.yesterdayLabel;
} else if (startOfDay.difference(lastMessageAt).inDays < 7) {
stringDate = Jiffy(lastMessageAt.toLocal()).EEEE;
stringDate = Jiffy.parseFromDateTime(lastMessageAt.toLocal()).EEEE;
} else {
stringDate = Jiffy(lastMessageAt.toLocal()).yMd;
stringDate = Jiffy.parseFromDateTime(lastMessageAt.toLocal()).yMd;
}
return Text(
@@ -83,7 +83,7 @@ abstract class Translations {
/// in the [StreamMessageListView]
String unreadMessagesSeparatorText(
@Deprecated('unreadCount is not used anymore and will be removed ')
int unreadCount,
int unreadCount,
);
/// The label for "connected" in [StreamConnectionStatusBuilder]
@@ -611,13 +611,13 @@ class DefaultTranslations implements Translations {
} else if (date == yesterday) {
return 'yesterday';
} else {
return 'on ${Jiffy(date).MMMd}';
return 'on ${Jiffy.parseFromDateTime(date).MMMd}';
}
}
@override
String sentAtText({required DateTime date, required DateTime time}) =>
'Sent ${_getDay(date)} at ${Jiffy(time.toLocal()).format('HH:mm')}';
'Sent ${_getDay(date)} at ${Jiffy.parseFromDateTime(time.toLocal()).format(pattern: 'HH:mm')}';
@override
String get todayLabel => 'Today';
@@ -666,12 +666,15 @@ class _StreamMessageListViewState extends State<StreamMessageListView> {
final createdAt = message.createdAt.toLocal();
final nextCreatedAt = nextMessage.createdAt.toLocal();
if (!Jiffy(createdAt).isSame(nextCreatedAt, Units.DAY)) {
if (!Jiffy.parseFromDateTime(createdAt).isSame(
Jiffy.parseFromDateTime(nextCreatedAt),
unit: Unit.day)) {
separator = _buildDateDivider(nextMessage);
} else {
final hasTimeDiff = !Jiffy(createdAt).isSame(
nextCreatedAt,
Units.MINUTE,
final hasTimeDiff =
!Jiffy.parseFromDateTime(createdAt).isSame(
Jiffy.parseFromDateTime(nextCreatedAt),
unit: Unit.minute,
);
final isNextUserSame =
@@ -1061,9 +1064,10 @@ class _StreamMessageListViewState extends State<StreamMessageListView> {
var hasTimeDiff = false;
if (nextMessage != null) {
hasTimeDiff = !Jiffy(message.createdAt.toLocal()).isSame(
nextMessage.createdAt.toLocal(),
Units.MINUTE,
hasTimeDiff =
!Jiffy.parseFromDateTime(message.createdAt.toLocal()).isSame(
Jiffy.parseFromDateTime(nextMessage.createdAt.toLocal()),
unit: Unit.minute,
);
}
@@ -191,7 +191,7 @@ class BottomRow extends StatelessWidget {
),
if (showTimeStamp)
Text(
Jiffy(message.createdAt.toLocal()).jm,
Jiffy.parseFromDateTime(message.createdAt.toLocal()).jm,
style: messageTheme.createdAtStyle,
),
if (showSendingIndicator)
@@ -20,17 +20,17 @@ class StreamDateDivider extends StatelessWidget {
@override
Widget build(BuildContext context) {
final createdAt = Jiffy(dateTime);
final now = Jiffy(DateTime.now());
final createdAt = Jiffy.parseFromDateTime(dateTime);
final now = Jiffy.parseFromDateTime(DateTime.now());
var dayInfo = createdAt.MMMd;
if (createdAt.isSame(now, Units.DAY)) {
if (createdAt.isSame(now, unit: Unit.day)) {
dayInfo = context.translations.todayLabel;
} else if (createdAt.isSame(now.subtract(days: 1), Units.DAY)) {
} else if (createdAt.isSame(now.subtract(days: 1), unit: Unit.day)) {
dayInfo = context.translations.yesterdayLabel;
} else if (createdAt.isAfter(now.subtract(days: 7), Units.DAY)) {
} else if (createdAt.isAfter(now.subtract(days: 7), unit: Unit.day)) {
dayInfo = createdAt.EEEE;
} else if (createdAt.isAfter(now.subtract(years: 1), Units.DAY)) {
} else if (createdAt.isAfter(now.subtract(years: 1), unit: Unit.day)) {
dayInfo = createdAt.MMMd;
}
@@ -287,16 +287,16 @@ class ChannelLastMessageDate extends StatelessWidget {
if (lastMessageAt.millisecondsSinceEpoch >=
startOfDay.millisecondsSinceEpoch) {
stringDate = Jiffy(lastMessageAt.toLocal()).jm;
stringDate = Jiffy.parseFromDateTime(lastMessageAt.toLocal()).jm;
} else if (lastMessageAt.millisecondsSinceEpoch >=
startOfDay
.subtract(const Duration(days: 1))
.millisecondsSinceEpoch) {
stringDate = context.translations.yesterdayLabel;
} else if (startOfDay.difference(lastMessageAt).inDays < 7) {
stringDate = Jiffy(lastMessageAt.toLocal()).EEEE;
stringDate = Jiffy.parseFromDateTime(lastMessageAt.toLocal()).EEEE;
} else {
stringDate = Jiffy(lastMessageAt.toLocal()).yMd;
stringDate = Jiffy.parseFromDateTime(lastMessageAt.toLocal()).yMd;
}
return Text(
@@ -227,9 +227,9 @@ class MessageSearchTileMessageDate extends StatelessWidget {
if (now.year != createdAt.year ||
now.month != createdAt.month ||
now.day != createdAt.day) {
stringDate = Jiffy(createdAt.toLocal()).yMd;
stringDate = Jiffy.parseFromDateTime(createdAt.toLocal()).yMd;
} else {
stringDate = Jiffy(createdAt.toLocal()).jm;
stringDate = Jiffy.parseFromDateTime(createdAt.toLocal()).jm;
}
return Text(
@@ -179,7 +179,7 @@ class UserLastActive extends StatelessWidget {
user.online
? context.translations.userOnlineText
: '${context.translations.userLastOnlineText} '
'${Jiffy(user.lastActive).fromNow()}',
'${Jiffy.parseFromDateTime(user.lastActive!).fromNow()}',
style: chatTheme.textTheme.footnote.copyWith(
color: chatTheme.colorTheme.textHighEmphasis.withOpacity(0.5),
),
@@ -165,9 +165,9 @@ class StreamChatState extends State<StreamChat> {
@override
void didChangeDependencies() {
final currentLocale = Localizations.localeOf(context).toString();
final availableLocales = Jiffy.getAllAvailableLocales();
final availableLocales = Jiffy.getSupportedLocales();
if (availableLocales.contains(currentLocale)) {
Jiffy.locale(currentLocale);
Jiffy.setLocale(currentLocale);
}
super.didChangeDependencies();
}
@@ -77,7 +77,7 @@ class StreamUserItem extends StatelessWidget {
user.online
? context.translations.userOnlineText
: '${context.translations.userLastOnlineText} '
'${Jiffy(user.lastActive).fromNow()}',
'${Jiffy.parseFromDateTime(user.lastActive!).fromNow()}',
style: chatTheme.textTheme.footnote.copyWith(
color: chatTheme.colorTheme.textHighEmphasis.withOpacity(0.5),
),
@@ -0,0 +1,3 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M20.525 8.15C20.23 7.967 19.862 7.951 19.552 8.106L17 9.382V8C17 6.896 16.104 6 15 6H6C4.896 6 4 6.896 4 8V16C4 17.104 4.896 18 6 18H15C16.104 18 17 17.104 17 16V14.619L19.553 15.894C19.693 15.965 19.848 16 20 16C20.183 16 20.365 15.949 20.525 15.851C20.82 15.668 21 15.347 21 15V9C21 8.653 20.82 8.332 20.525 8.15Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 444 B

+1 -1
View File
@@ -29,7 +29,7 @@ dependencies:
http_parser: ^4.0.0
image_gallery_saver: ^2.0.1
image_picker: ^0.8.2
jiffy: ^5.0.0
jiffy: ^6.2.1
lottie: ^2.0.0
meta: ^1.8.0
path_provider: ^2.0.9