better date formatting
This commit is contained in:
@@ -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';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -125,7 +125,8 @@ class ChatArchiveDetailScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
error: (error, stackTrace) {
|
error: (error, stackTrace) {
|
||||||
return FailureWidget(
|
return FailureWidget(
|
||||||
title: error.toString(),
|
title: 'Could not load chat',
|
||||||
|
exception: error,
|
||||||
onRetry: () => ref.refresh(readArchivedChatProvider(fileName)),
|
onRetry: () => ref.refresh(readArchivedChatProvider(fileName)),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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/core/routing/routes.dart';
|
||||||
import 'package:bang_navigator/features/chat_archive/domain/repositories/chat_archive.dart';
|
import 'package:bang_navigator/features/chat_archive/domain/repositories/chat_archive.dart';
|
||||||
import 'package:bang_navigator/presentation/widgets/failure_widget.dart';
|
import 'package:bang_navigator/presentation/widgets/failure_widget.dart';
|
||||||
@@ -27,7 +28,7 @@ class ChatArchiveListScreen extends HookConsumerWidget {
|
|||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(chat.toString()),
|
title: Text(chat.toString()),
|
||||||
subtitle: (chat.dateTime != null)
|
subtitle: (chat.dateTime != null)
|
||||||
? Text(chat.dateTime.toString())
|
? Text(chat.dateTime!.formatWithMinutePrecision())
|
||||||
: null,
|
: null,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await context.push(
|
await context.push(
|
||||||
@@ -41,7 +42,8 @@ class ChatArchiveListScreen extends HookConsumerWidget {
|
|||||||
},
|
},
|
||||||
error: (error, stackTrace) {
|
error: (error, stackTrace) {
|
||||||
return FailureWidget(
|
return FailureWidget(
|
||||||
title: error.toString(),
|
title: 'Could not load archived chats',
|
||||||
|
exception: error,
|
||||||
onRetry: () => ref.refresh(chatArchiveRepositoryProvider),
|
onRetry: () => ref.refresh(chatArchiveRepositoryProvider),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user