fix(stream_chat_persistence): tests

This commit is contained in:
Felix Angelov
2021-03-24 00:49:11 -05:00
67 changed files with 5543 additions and 251 deletions
@@ -170,14 +170,14 @@ class ChannelPreview extends StatelessWidget {
if (lastMessageAt.millisecondsSinceEpoch >=
startOfDay.millisecondsSinceEpoch) {
stringDate = Jiffy(lastMessageAt.toLocal()).format('HH:mm');
stringDate = Jiffy(lastMessageAt.toLocal()).jm;
} 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');
stringDate = Jiffy(lastMessageAt.toLocal()).yMd;
}
return Text(
@@ -28,14 +28,14 @@ class DateDivider extends StatelessWidget {
now.subtract(Duration(days: 7)),
Units.DAY,
)) {
dayInfo = createdAt.format('EEEE');
dayInfo = createdAt.EEEE;
} else if (Jiffy(createdAt).isAfter(
Jiffy(now).subtract(years: 1),
Units.DAY,
)) {
dayInfo = createdAt.format('MMMM d');
dayInfo = createdAt.MMMd;
} else {
dayInfo = createdAt.format('MMMM d');
dayInfo = createdAt.MMMd;
}
if (uppercase) dayInfo = dayInfo.toUpperCase();
@@ -220,7 +220,7 @@ class _FullScreenMediaState extends State<FullScreenMedia>
24) {
return 'yesterday';
} else {
return 'on ${Jiffy(dateTime).format("MMM do")}';
return 'on ${Jiffy(dateTime).MMMd}';
}
}
@@ -2233,7 +2233,7 @@ class MessageInputState extends State<MessageInput> {
void _parseExistingMessage(Message message) {
textEditingController.text = message.text;
_messageIsPresent = true;
for (final attachment in message.attachments) {
for (final attachment in message?.attachments) {
_attachments[attachment.id] = attachment.copyWith(
uploadState: attachment.uploadState ?? UploadState.success(),
);
@@ -84,9 +84,9 @@ class MessageSearchItem extends StatelessWidget {
if (now.year != createdAt.year ||
now.month != createdAt.month ||
now.day != createdAt.day) {
stringDate = Jiffy(createdAt.toLocal()).format('dd/MM/yyyy');
stringDate = Jiffy(createdAt.toLocal()).yMd;
} else {
stringDate = Jiffy(createdAt.toLocal()).format('HH:mm');
stringDate = Jiffy(createdAt.toLocal()).jm;
}
return Text(
@@ -3,9 +3,11 @@ import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_portal/flutter_portal.dart';
import 'package:jiffy/jiffy.dart';
import 'package:stream_chat_flutter/src/stream_chat_theme.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
import 'dart:ui' as ui;
/// Widget used to provide information about the chat to the widget tree
///
@@ -121,4 +123,11 @@ class StreamChatState extends State<StreamChat> {
void initState() {
super.initState();
}
@override
void didChangeDependencies() {
final locale = ui.window.locale;
Jiffy.locale(locale.languageCode);
super.didChangeDependencies();
}
}
@@ -36,11 +36,9 @@ dependencies:
lottie: ^1.0.0
substring_highlight: ^0.1.2
flutter_slidable: ^0.5.7
clipboard: ^0.1.2+8
image_gallery_saver: ^1.6.7
share_plus: ^2.0.0
photo_manager: ^1.0.0
transparent_image: ^1.0.0
ezanimation: ^0.4.1
synchronized: ^3.0.0
characters: ^1.0.0
@@ -69,7 +69,7 @@ void main() {
),
));
expect(find.text('22/06/2020'), findsOneWidget);
expect(find.text('6/22/2020'), findsOneWidget);
expect(find.text('test name'), findsOneWidget);
expect(find.text('1'), findsOneWidget);
expect(find.text('hello'), findsOneWidget);