chore(ui): bump jiffy to v6.2.1

Signed-off-by: xsahil03x <[email protected]>

(cherry picked from commit 79faac57e5)
Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
Sahil Kumar
2023-07-18 16:35:35 +05:30
parent e008c7057b
commit f944094131
12 changed files with 44 additions and 31 deletions
@@ -106,9 +106,10 @@ class _ConnectedTitleState extends StatelessWidget {
style: textStyle,
);
} else {
final lastActive = otherMember.user?.lastActive ?? DateTime.now();
alternativeWidget = Text(
'${context.translations.userLastOnlineText} '
'${Jiffy(otherMember.user?.lastActive).fromNow()}',
'${Jiffy.parseFromDateTime(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(
@@ -611,13 +611,15 @@ 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')}';
String sentAtText({required DateTime date, required DateTime time}) {
final atTime = Jiffy.parseFromDateTime(time.toLocal());
return 'Sent ${_getDay(date)} at ${atTime.format(pattern: 'HH:mm')}';
}
@override
String get todayLabel => 'Today';
@@ -669,14 +669,20 @@ class _StreamMessageListViewState extends State<StreamMessageListView> {
final isPartOfThread = message.replyCount! > 0 ||
message.showInChannel == true;
final createdAt = message.createdAt.toLocal();
final nextCreatedAt = nextMessage.createdAt.toLocal();
if (!Jiffy(createdAt).isSame(nextCreatedAt, Units.DAY)) {
final createdAt = Jiffy.parseFromDateTime(
message.createdAt.toLocal(),
);
final nextCreatedAt = Jiffy.parseFromDateTime(
nextMessage.createdAt.toLocal(),
);
if (!createdAt.isSame(nextCreatedAt, unit: Unit.day)) {
separator = _buildDateDivider(nextMessage);
} else {
final hasTimeDiff = !Jiffy(createdAt).isSame(
final hasTimeDiff = !createdAt.isSame(
nextCreatedAt,
Units.MINUTE,
unit: Unit.minute,
);
final isNextUserSame =
@@ -1071,10 +1077,12 @@ class _StreamMessageListViewState extends State<StreamMessageListView> {
var hasTimeDiff = false;
if (nextMessage != null) {
hasTimeDiff = !Jiffy(message.createdAt.toLocal()).isSame(
final createdAt = Jiffy.parseFromDateTime(message.createdAt.toLocal());
final nextCreatedAt = Jiffy.parseFromDateTime(
nextMessage.createdAt.toLocal(),
Units.MINUTE,
);
hasTimeDiff = !createdAt.isSame(nextCreatedAt, unit: Unit.minute);
}
final hasFileAttachment =
@@ -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(
@@ -176,11 +176,12 @@ class UserLastActive extends StatelessWidget {
@override
Widget build(BuildContext context) {
final chatTheme = StreamChatTheme.of(context);
final lastActive = user.lastActive ?? DateTime.now();
return Text(
user.online
? context.translations.userOnlineText
: '${context.translations.userLastOnlineText} '
'${Jiffy(user.lastActive).fromNow()}',
'${Jiffy.parseFromDateTime(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();
}
@@ -74,11 +74,12 @@ class StreamUserItem extends StatelessWidget {
Widget _buildLastActive(BuildContext context) {
final chatTheme = StreamChatTheme.of(context);
final lastActive = user.lastActive ?? DateTime.now();
return Text(
user.online
? context.translations.userOnlineText
: '${context.translations.userLastOnlineText} '
'${Jiffy(user.lastActive).fromNow()}',
'${Jiffy.parseFromDateTime(lastActive).fromNow()}',
style: chatTheme.textTheme.footnote.copyWith(
color: chatTheme.colorTheme.textHighEmphasis.withOpacity(0.5),
),
+1 -1
View File
@@ -29,7 +29,7 @@ dependencies:
http_parser: ^4.0.2
image_gallery_saver: ^2.0.3
image_picker: ^1.0.1
jiffy: ^5.0.0
jiffy: ^6.2.1
lottie: ^2.4.0
meta: ^1.9.1
path_provider: ^2.0.15