Skip to content

Commit

Permalink
feat(timestamps)
Browse files Browse the repository at this point in the history
- use ISO and UTC formats to display dates in the app
  • Loading branch information
thiagocarvalhodev committed Sep 25, 2024
1 parent 27d24ce commit 3bb7dff
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 20 deletions.
20 changes: 10 additions & 10 deletions lib/components/details_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import 'package:ardrive/core/arfs/entities/arfs_entities.dart';
import 'package:ardrive/core/crypto/crypto.dart';
import 'package:ardrive/download/multiple_file_download_modal.dart';
import 'package:ardrive/drive_explorer/thumbnail_creation/page/thumbnail_creation_modal.dart';
import 'package:ardrive/l11n/l11n.dart';
import 'package:ardrive/misc/resources.dart';
import 'package:ardrive/models/models.dart';
import 'package:ardrive/pages/drive_detail/components/drive_explorer_item_tile.dart';
Expand All @@ -26,6 +25,7 @@ import 'package:ardrive/services/services.dart';
import 'package:ardrive/theme/theme.dart';
import 'package:ardrive/utils/app_localizations_wrapper.dart';
import 'package:ardrive/utils/filesize.dart';
import 'package:ardrive/utils/format_date.dart';
import 'package:ardrive/utils/num_to_string_parsers.dart';
import 'package:ardrive/utils/open_url.dart';
import 'package:ardrive/utils/show_general_dialog.dart';
Expand Down Expand Up @@ -602,15 +602,15 @@ class _DetailsPanelState extends State<DetailsPanel> {
sizedBoxHeight16px,
DetailsPanelItem(
leading: Text(
yMMdDateFormatter.format(widget.item.lastUpdated),
formatDateToUtcString(widget.item.lastUpdated),
style: typography.paragraphNormal(),
),
itemTitle: appLocalizationsOf(context).lastUpdated,
),
sizedBoxHeight16px,
DetailsPanelItem(
leading: Text(
yMMdDateFormatter.format(widget.item.dateCreated),
formatDateToUtcString(widget.item.dateCreated),
style: typography.paragraphNormal(),
),
itemTitle: appLocalizationsOf(context).dateCreated,
Expand Down Expand Up @@ -672,15 +672,15 @@ class _DetailsPanelState extends State<DetailsPanel> {
sizedBoxHeight16px,
DetailsPanelItem(
leading: Text(
yMMdDateFormatter.format(widget.item.lastUpdated),
formatDateToUtcString(widget.item.lastUpdated),
style: typography.paragraphNormal(),
),
itemTitle: appLocalizationsOf(context).lastUpdated,
),
sizedBoxHeight16px,
DetailsPanelItem(
leading: Text(
yMMdDateFormatter.format(widget.item.dateCreated),
formatDateToUtcString(widget.item.dateCreated),
style: typography.paragraphNormal(),
),
itemTitle: appLocalizationsOf(context).dateCreated,
Expand Down Expand Up @@ -724,15 +724,15 @@ class _DetailsPanelState extends State<DetailsPanel> {
sizedBoxHeight16px,
DetailsPanelItem(
leading: Text(
yMMdDateFormatter.format(item.lastUpdated),
formatDateToUtcString(item.lastUpdated),
style: typography.paragraphNormal(),
),
itemTitle: appLocalizationsOf(context).lastUpdated,
),
sizedBoxHeight16px,
DetailsPanelItem(
leading: Text(
yMMdDateFormatter.format(item.dateCreated),
formatDateToUtcString(item.dateCreated),
style: typography.paragraphNormal(),
),
itemTitle: appLocalizationsOf(context).dateCreated,
Expand Down Expand Up @@ -901,7 +901,7 @@ class _DetailsPanelState extends State<DetailsPanel> {
default:
title = appLocalizationsOf(context).folderWasModified;
}
subtitle = yMMdDateFormatter.format(revision.dateCreated);
subtitle = formatDateToUtcString(revision.dateCreated);

return DetailsPanelItem(
itemSubtitle: subtitle,
Expand Down Expand Up @@ -944,7 +944,7 @@ class _DetailsPanelState extends State<DetailsPanel> {
title = appLocalizationsOf(context).driveWasModified;
}

subtitle = yMMdDateFormatter.format(revision.dateCreated);
subtitle = formatDateToUtcString(revision.dateCreated);

return DetailsPanelItem(
itemSubtitle: subtitle,
Expand Down Expand Up @@ -1023,7 +1023,7 @@ class _DetailsPanelState extends State<DetailsPanel> {
default:
title = appLocalizationsOf(context).fileWasModified;
}
subtitle = yMMdDateFormatter.format(file.unixTime);
subtitle = formatDateToUtcString(file.unixTime);

return DetailsPanelItem(
leading: leading ?? const SizedBox(),
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/drive_detail/components/drive_detail_data_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ Widget _buildDataListContent(
name: row.name,
typography: typography,
size: row.size == null ? '-' : filesize(row.size),
lastUpdated: yMMdDateFormatter.format(row.lastUpdated),
dateCreated: yMMdDateFormatter.format(row.dateCreated),
lastUpdated: row.lastUpdated,
dateCreated: row.dateCreated,
dataTableItem: row,
license: row.licenseType == null
? ''
Expand Down
24 changes: 16 additions & 8 deletions lib/pages/drive_detail/components/drive_explorer_item_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import 'package:ardrive/components/pin_indicator.dart';
import 'package:ardrive/download/multiple_file_download_modal.dart';
import 'package:ardrive/drive_explorer/thumbnail/repository/thumbnail_repository.dart';
import 'package:ardrive/drive_explorer/thumbnail/thumbnail_bloc.dart';
import 'package:ardrive/l11n/l11n.dart';
import 'package:ardrive/models/models.dart';
import 'package:ardrive/pages/congestion_warning_wrapper.dart';
import 'package:ardrive/pages/drive_detail/components/dropdown_item.dart';
import 'package:ardrive/pages/drive_detail/components/hover_widget.dart';
import 'package:ardrive/pages/drive_detail/models/data_table_item.dart';
import 'package:ardrive/utils/app_localizations_wrapper.dart';
import 'package:ardrive/utils/format_date.dart';
import 'package:ardrive/utils/logger.dart';
import 'package:ardrive/utils/size_constants.dart';
import 'package:ardrive_ui/ardrive_ui.dart';
Expand All @@ -28,8 +30,8 @@ class DriveExplorerItemTile extends TableRowWidget {
DriveExplorerItemTile({
required String name,
required String size,
required String lastUpdated,
required String dateCreated,
required DateTime lastUpdated,
required DateTime dateCreated,
required String license,
required Function() onPressed,
required bool isHidden,
Expand Down Expand Up @@ -68,12 +70,18 @@ class DriveExplorerItemTile extends TableRowWidget {
Text(size,
style: _driveExplorerItemTileTextStyle(
isHidden, typography, colorTokens)),
Text(lastUpdated,
style: _driveExplorerItemTileTextStyle(
isHidden, typography, colorTokens)),
Text(dateCreated,
style: _driveExplorerItemTileTextStyle(
isHidden, typography, colorTokens)),
ArDriveTooltip(
message: formatDateToUtcString(lastUpdated),
child: Text(yMMdDateFormatter.format(lastUpdated),
style: _driveExplorerItemTileTextStyle(
isHidden, typography, colorTokens)),
),
ArDriveTooltip(
message: formatDateToUtcString(dateCreated),
child: Text(yMMdDateFormatter.format(dateCreated),
style: _driveExplorerItemTileTextStyle(
isHidden, typography, colorTokens)),
),
Text(license, style: ArDriveTypography.body.captionRegular()),
],
);
Expand Down
8 changes: 8 additions & 0 deletions lib/utils/format_date.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import 'package:intl/intl.dart';

String formatDateToUtcString(DateTime date) {
String formattedDate =
'${DateFormat('yyyy-MM-dd HH:mm:ss').format(date.toUtc())} GMT+0';

return formattedDate;
}

0 comments on commit 3bb7dff

Please sign in to comment.