High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
feat(mobile): improve date formatting (#1804)
Michel Heusschen88a29666664a
diff --git a/mobile/assets/i18n/en-US.json b/mobile/assets/i18n/en-US.jsonindex 3226e418bb..486f116eeb 100644--- a/mobile/assets/i18n/en-US.json+++ b/mobile/assets/i18n/en-US.json@@ -108,9 +108,6 @@"create_shared_album_page_share": "Share","create_shared_album_page_share_add_assets": "ADD ASSETS","create_shared_album_page_share_select_photos": "Select Photos",- "daily_title_text_date": "E, MMM dd",- "daily_title_text_date_year": "E, MMM dd, yyyy",- "date_format": "E, LLL d, y • h:mm a","delete_dialog_alert": "These items will be permanently deleted from Immich and from your device","delete_dialog_cancel": "Cancel","delete_dialog_ok": "Delete",@@ -153,7 +150,6 @@"login_form_label_password": "Password","login_form_password_hint": "password","login_form_save_login": "Stay logged in",- "monthly_title_text_date_format": "MMMM y","profile_drawer_app_logs": "Logs","profile_drawer_client_server_up_to_date": "Client and Server are up-to-date","profile_drawer_settings": "Settings",diff --git a/mobile/lib/modules/album/views/album_viewer_page.dart b/mobile/lib/modules/album/views/album_viewer_page.dartindex 834e847ec4..1b63637359 100644--- a/mobile/lib/modules/album/views/album_viewer_page.dart+++ b/mobile/lib/modules/album/views/album_viewer_page.dart@@ -123,9 +123,9 @@ class AlbumViewerPage extends HookConsumerWidget {final DateTime startDate = album.assets.first.fileCreatedAt;final DateTime endDate = album.assets.last.fileCreatedAt; //Need default.final String startDateText =- DateFormat(startDate.year == endDate.year ? 'LLL d' : 'LLL d, y')+ (startDate.year == endDate.year ? DateFormat.MMMd() : DateFormat.yMMMd()).format(startDate);- final String endDateText = DateFormat('LLL d, y').format(endDate);+ final String endDateText = DateFormat.yMMMd().format(endDate);return Padding(padding: EdgeInsets.only(@@ -134,7 +134,7 @@ class AlbumViewerPage extends HookConsumerWidget {bottom: album.shared ? 0.0 : 8.0,),child: Text(- "$startDateText-$endDateText",+ "$startDateText - $endDateText",style: const TextStyle(fontSize: 14,fontWeight: FontWeight.bold,diff --git a/mobile/lib/modules/asset_viewer/ui/exif_bottom_sheet.dart b/mobile/lib/modules/asset_viewer/ui/exif_bottom_sheet.dartindex 214196c162..0f0e391510 100644--- a/mobile/lib/modules/asset_viewer/ui/exif_bottom_sheet.dart+++ b/mobile/lib/modules/asset_viewer/ui/exif_bottom_sheet.dart@@ -144,10 +144,12 @@ class ExifBottomSheet extends HookConsumerWidget {}buildDate() {+ final fileCreatedAt = assetDetail.fileCreatedAt.toLocal();+ final date = DateFormat.yMMMEd().format(fileCreatedAt);+ final time = DateFormat.jm().format(fileCreatedAt);+return Text(- DateFormat('date_format'.tr()).format(- assetDetail.fileCreatedAt.toLocal(),- ),+ '$date • $time',style: const TextStyle(fontWeight: FontWeight.bold,fontSize: 14,diff --git a/mobile/lib/modules/backup/ui/current_backup_asset_info_box.dart b/mobile/lib/modules/backup/ui/current_backup_asset_info_box.dartindex 63a783de63..ac50edee77 100644--- a/mobile/lib/modules/backup/ui/current_backup_asset_info_box.dart+++ b/mobile/lib/modules/backup/ui/current_backup_asset_info_box.dart@@ -18,7 +18,7 @@ class CurrentUploadingAssetInfoBox extends HookConsumerWidget {final isShowThumbnail = useState(false);String getAssetCreationDate() {- return DateFormat.yMMMMd('en_US').format(+ return DateFormat.yMMMMd().format(DateTime.parse(asset.fileCreatedAt.toString(),).toLocal(),diff --git a/mobile/lib/modules/backup/views/failed_backup_status_page.dart b/mobile/lib/modules/backup/views/failed_backup_status_page.dartindex 46cf573fb1..7028591a71 100644--- a/mobile/lib/modules/backup/views/failed_backup_status_page.dart+++ b/mobile/lib/modules/backup/views/failed_backup_status_page.dart@@ -87,7 +87,7 @@ class FailedBackupStatusPage extends HookConsumerWidget {mainAxisAlignment: MainAxisAlignment.spaceBetween,children: [Text(- DateFormat.yMMMMd('en_US').format(+ DateFormat.yMMMMd().format(DateTime.parse(errorAsset.fileCreatedAt.toString(),).toLocal(),diff --git a/mobile/lib/modules/home/ui/asset_grid/asset_grid_data_structure.dart b/mobile/lib/modules/home/ui/asset_grid/asset_grid_data_structure.dartindex 8e003e8add..90253d09d5 100644--- a/mobile/lib/modules/home/ui/asset_grid/asset_grid_data_structure.dart+++ b/mobile/lib/modules/home/ui/asset_grid/asset_grid_data_structure.dart@@ -55,16 +55,10 @@ class AssetGridLayoutParameters {}class _AssetGroupsToRenderListComputeParameters {- final String monthFormat;- final String dayFormat;- final String dayFormatYear;final List<Asset> assets;final AssetGridLayoutParameters layout;_AssetGroupsToRenderListComputeParameters(- this.monthFormat,- this.dayFormat,- this.dayFormatYear,this.assets,this.layout,);@@ -101,9 +95,10 @@ class RenderList {static Future<RenderList> _processAssetGroupData(_AssetGroupsToRenderListComputeParameters data,) async {- final monthFormat = DateFormat(data.monthFormat);- final dayFormatSameYear = DateFormat(data.dayFormat);- final dayFormatOtherYear = DateFormat(data.dayFormatYear);+ // TODO: Make DateFormat use the configured locale.+ final monthFormat = DateFormat.yMMM();+ final dayFormatSameYear = DateFormat.MMMEd();+ final dayFormatOtherYear = DateFormat.yMMMEd();final allAssets = data.assets;final perRow = data.layout.perRow;final dynamicLayout = data.layout.dynamicLayout;@@ -210,9 +205,6 @@ class RenderList {return compute(_processAssetGroupData,_AssetGroupsToRenderListComputeParameters(- "monthly_title_text_date_format".tr(),- "daily_title_text_date".tr(),- "daily_title_text_date_year".tr(),assets,layout,),diff --git a/mobile/lib/modules/home/ui/asset_grid/monthly_title_text.dart b/mobile/lib/modules/home/ui/asset_grid/monthly_title_text.dartdeleted file mode 100644index c4ffb6c71c..0000000000--- a/mobile/lib/modules/home/ui/asset_grid/monthly_title_text.dart+++ /dev/null@@ -1,31 +0,0 @@-import 'package:easy_localization/easy_localization.dart';-import 'package:flutter/material.dart';--class MonthlyTitleText extends StatelessWidget {- const MonthlyTitleText({- Key? key,- required this.isoDate,- }) : super(key: key);-- final String isoDate;-- @override- Widget build(BuildContext context) {- var monthTitleText = DateFormat("monthly_title_text_date_format".tr())- .format(DateTime.parse(isoDate).toLocal());-- return SliverToBoxAdapter(- child: Padding(- padding: const EdgeInsets.only(left: 12.0, top: 32),- child: Text(- monthTitleText,- style: TextStyle(- fontSize: 26,- fontWeight: FontWeight.bold,- color: Theme.of(context).textTheme.displayLarge?.color,- ),- ),- ),- );- }-}