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 { } else {
alternativeWidget = Text( alternativeWidget = Text(
'${context.translations.userLastOnlineText} ' '${context.translations.userLastOnlineText} '
'${Jiffy(otherMember.user?.lastActive).fromNow()}', '${Jiffy.parseFromDateTime(otherMember.user!.lastActive!).fromNow()}',
style: textStyle, style: textStyle,
); );
} }
@@ -349,16 +349,16 @@ class _Date extends StatelessWidget {
if (lastMessageAt.millisecondsSinceEpoch >= if (lastMessageAt.millisecondsSinceEpoch >=
startOfDay.millisecondsSinceEpoch) { startOfDay.millisecondsSinceEpoch) {
stringDate = Jiffy(lastMessageAt.toLocal()).jm; stringDate = Jiffy.parseFromDateTime(lastMessageAt.toLocal()).jm;
} else if (lastMessageAt.millisecondsSinceEpoch >= } else if (lastMessageAt.millisecondsSinceEpoch >=
startOfDay startOfDay
.subtract(const Duration(days: 1)) .subtract(const Duration(days: 1))
.millisecondsSinceEpoch) { .millisecondsSinceEpoch) {
stringDate = context.translations.yesterdayLabel; stringDate = context.translations.yesterdayLabel;
} else if (startOfDay.difference(lastMessageAt).inDays < 7) { } else if (startOfDay.difference(lastMessageAt).inDays < 7) {
stringDate = Jiffy(lastMessageAt.toLocal()).EEEE; stringDate = Jiffy.parseFromDateTime(lastMessageAt.toLocal()).EEEE;
} else { } else {
stringDate = Jiffy(lastMessageAt.toLocal()).yMd; stringDate = Jiffy.parseFromDateTime(lastMessageAt.toLocal()).yMd;
} }
return Text( return Text(
@@ -83,7 +83,7 @@ abstract class Translations {
/// in the [StreamMessageListView] /// in the [StreamMessageListView]
String unreadMessagesSeparatorText( String unreadMessagesSeparatorText(
@Deprecated('unreadCount is not used anymore and will be removed ') @Deprecated('unreadCount is not used anymore and will be removed ')
int unreadCount, int unreadCount,
); );
/// The label for "connected" in [StreamConnectionStatusBuilder] /// The label for "connected" in [StreamConnectionStatusBuilder]
@@ -611,13 +611,13 @@ class DefaultTranslations implements Translations {
} else if (date == yesterday) { } else if (date == yesterday) {
return 'yesterday'; return 'yesterday';
} else { } else {
return 'on ${Jiffy(date).MMMd}'; return 'on ${Jiffy.parseFromDateTime(date).MMMd}';
} }
} }
@override @override
String sentAtText({required DateTime date, required DateTime time}) => 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 @override
String get todayLabel => 'Today'; String get todayLabel => 'Today';
@@ -666,12 +666,15 @@ class _StreamMessageListViewState extends State<StreamMessageListView> {
final createdAt = message.createdAt.toLocal(); final createdAt = message.createdAt.toLocal();
final nextCreatedAt = nextMessage.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); separator = _buildDateDivider(nextMessage);
} else { } else {
final hasTimeDiff = !Jiffy(createdAt).isSame( final hasTimeDiff =
nextCreatedAt, !Jiffy.parseFromDateTime(createdAt).isSame(
Units.MINUTE, Jiffy.parseFromDateTime(nextCreatedAt),
unit: Unit.minute,
); );
final isNextUserSame = final isNextUserSame =
@@ -1061,9 +1064,10 @@ class _StreamMessageListViewState extends State<StreamMessageListView> {
var hasTimeDiff = false; var hasTimeDiff = false;
if (nextMessage != null) { if (nextMessage != null) {
hasTimeDiff = !Jiffy(message.createdAt.toLocal()).isSame( hasTimeDiff =
nextMessage.createdAt.toLocal(), !Jiffy.parseFromDateTime(message.createdAt.toLocal()).isSame(
Units.MINUTE, Jiffy.parseFromDateTime(nextMessage.createdAt.toLocal()),
unit: Unit.minute,
); );
} }
@@ -191,7 +191,7 @@ class BottomRow extends StatelessWidget {
), ),
if (showTimeStamp) if (showTimeStamp)
Text( Text(
Jiffy(message.createdAt.toLocal()).jm, Jiffy.parseFromDateTime(message.createdAt.toLocal()).jm,
style: messageTheme.createdAtStyle, style: messageTheme.createdAtStyle,
), ),
if (showSendingIndicator) if (showSendingIndicator)
@@ -20,17 +20,17 @@ class StreamDateDivider extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final createdAt = Jiffy(dateTime); final createdAt = Jiffy.parseFromDateTime(dateTime);
final now = Jiffy(DateTime.now()); final now = Jiffy.parseFromDateTime(DateTime.now());
var dayInfo = createdAt.MMMd; var dayInfo = createdAt.MMMd;
if (createdAt.isSame(now, Units.DAY)) { if (createdAt.isSame(now, unit: Unit.day)) {
dayInfo = context.translations.todayLabel; 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; 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; 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; dayInfo = createdAt.MMMd;
} }
@@ -287,16 +287,16 @@ class ChannelLastMessageDate extends StatelessWidget {
if (lastMessageAt.millisecondsSinceEpoch >= if (lastMessageAt.millisecondsSinceEpoch >=
startOfDay.millisecondsSinceEpoch) { startOfDay.millisecondsSinceEpoch) {
stringDate = Jiffy(lastMessageAt.toLocal()).jm; stringDate = Jiffy.parseFromDateTime(lastMessageAt.toLocal()).jm;
} else if (lastMessageAt.millisecondsSinceEpoch >= } else if (lastMessageAt.millisecondsSinceEpoch >=
startOfDay startOfDay
.subtract(const Duration(days: 1)) .subtract(const Duration(days: 1))
.millisecondsSinceEpoch) { .millisecondsSinceEpoch) {
stringDate = context.translations.yesterdayLabel; stringDate = context.translations.yesterdayLabel;
} else if (startOfDay.difference(lastMessageAt).inDays < 7) { } else if (startOfDay.difference(lastMessageAt).inDays < 7) {
stringDate = Jiffy(lastMessageAt.toLocal()).EEEE; stringDate = Jiffy.parseFromDateTime(lastMessageAt.toLocal()).EEEE;
} else { } else {
stringDate = Jiffy(lastMessageAt.toLocal()).yMd; stringDate = Jiffy.parseFromDateTime(lastMessageAt.toLocal()).yMd;
} }
return Text( return Text(
@@ -227,9 +227,9 @@ class MessageSearchTileMessageDate extends StatelessWidget {
if (now.year != createdAt.year || if (now.year != createdAt.year ||
now.month != createdAt.month || now.month != createdAt.month ||
now.day != createdAt.day) { now.day != createdAt.day) {
stringDate = Jiffy(createdAt.toLocal()).yMd; stringDate = Jiffy.parseFromDateTime(createdAt.toLocal()).yMd;
} else { } else {
stringDate = Jiffy(createdAt.toLocal()).jm; stringDate = Jiffy.parseFromDateTime(createdAt.toLocal()).jm;
} }
return Text( return Text(
@@ -179,7 +179,7 @@ class UserLastActive extends StatelessWidget {
user.online user.online
? context.translations.userOnlineText ? context.translations.userOnlineText
: '${context.translations.userLastOnlineText} ' : '${context.translations.userLastOnlineText} '
'${Jiffy(user.lastActive).fromNow()}', '${Jiffy.parseFromDateTime(user.lastActive!).fromNow()}',
style: chatTheme.textTheme.footnote.copyWith( style: chatTheme.textTheme.footnote.copyWith(
color: chatTheme.colorTheme.textHighEmphasis.withOpacity(0.5), color: chatTheme.colorTheme.textHighEmphasis.withOpacity(0.5),
), ),
@@ -165,9 +165,9 @@ class StreamChatState extends State<StreamChat> {
@override @override
void didChangeDependencies() { void didChangeDependencies() {
final currentLocale = Localizations.localeOf(context).toString(); final currentLocale = Localizations.localeOf(context).toString();
final availableLocales = Jiffy.getAllAvailableLocales(); final availableLocales = Jiffy.getSupportedLocales();
if (availableLocales.contains(currentLocale)) { if (availableLocales.contains(currentLocale)) {
Jiffy.locale(currentLocale); Jiffy.setLocale(currentLocale);
} }
super.didChangeDependencies(); super.didChangeDependencies();
} }
@@ -77,7 +77,7 @@ class StreamUserItem extends StatelessWidget {
user.online user.online
? context.translations.userOnlineText ? context.translations.userOnlineText
: '${context.translations.userLastOnlineText} ' : '${context.translations.userLastOnlineText} '
'${Jiffy(user.lastActive).fromNow()}', '${Jiffy.parseFromDateTime(user.lastActive!).fromNow()}',
style: chatTheme.textTheme.footnote.copyWith( style: chatTheme.textTheme.footnote.copyWith(
color: chatTheme.colorTheme.textHighEmphasis.withOpacity(0.5), 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 http_parser: ^4.0.0
image_gallery_saver: ^2.0.1 image_gallery_saver: ^2.0.1
image_picker: ^0.8.2 image_picker: ^0.8.2
jiffy: ^5.0.0 jiffy: ^6.2.1
lottie: ^2.0.0 lottie: ^2.0.0
meta: ^1.8.0 meta: ^1.8.0
path_provider: ^2.0.9 path_provider: ^2.0.9