diff --git a/app/lib/core/extension/date_time.dart b/app/lib/core/extension/date_time.dart new file mode 100644 index 00000000..97891149 --- /dev/null +++ b/app/lib/core/extension/date_time.dart @@ -0,0 +1,13 @@ +extension DateTimeFormat on DateTime { + String _twoDigits(int n) => n.toString().padLeft(2, '0'); + + String formatWithMinutePrecision() { + final year = this.year.toString(); + final month = _twoDigits(this.month); + final day = _twoDigits(this.day); + final hour = _twoDigits(this.hour); + final minute = _twoDigits(this.minute); + + return '$year-$month-$day $hour:$minute'; + } +} diff --git a/app/lib/core/extension/result_async_extension.dart b/app/lib/core/extension/result_async.dart similarity index 100% rename from app/lib/core/extension/result_async_extension.dart rename to app/lib/core/extension/result_async.dart diff --git a/app/lib/features/chat_archive/presentation/screens/detail.dart b/app/lib/features/chat_archive/presentation/screens/detail.dart index 283d07b1..d1dd36ea 100644 --- a/app/lib/features/chat_archive/presentation/screens/detail.dart +++ b/app/lib/features/chat_archive/presentation/screens/detail.dart @@ -125,7 +125,8 @@ class ChatArchiveDetailScreen extends HookConsumerWidget { ), error: (error, stackTrace) { return FailureWidget( - title: error.toString(), + title: 'Could not load chat', + exception: error, onRetry: () => ref.refresh(readArchivedChatProvider(fileName)), ); }, diff --git a/app/lib/features/chat_archive/presentation/screens/list.dart b/app/lib/features/chat_archive/presentation/screens/list.dart index 3510be0b..fb6a2577 100644 --- a/app/lib/features/chat_archive/presentation/screens/list.dart +++ b/app/lib/features/chat_archive/presentation/screens/list.dart @@ -1,3 +1,4 @@ +import 'package:bang_navigator/core/extension/date_time.dart'; import 'package:bang_navigator/core/routing/routes.dart'; import 'package:bang_navigator/features/chat_archive/domain/repositories/chat_archive.dart'; import 'package:bang_navigator/presentation/widgets/failure_widget.dart'; @@ -27,7 +28,7 @@ class ChatArchiveListScreen extends HookConsumerWidget { return ListTile( title: Text(chat.toString()), subtitle: (chat.dateTime != null) - ? Text(chat.dateTime.toString()) + ? Text(chat.dateTime!.formatWithMinutePrecision()) : null, onTap: () async { await context.push( @@ -41,7 +42,8 @@ class ChatArchiveListScreen extends HookConsumerWidget { }, error: (error, stackTrace) { return FailureWidget( - title: error.toString(), + title: 'Could not load archived chats', + exception: error, onRetry: () => ref.refresh(chatArchiveRepositoryProvider), ); },