mirror of
https://github.com/immich-app/immich.git
synced 2024-12-26 10:50:29 +02:00
feat(mobile): improve date formatting (#1804)
This commit is contained in:
parent
e408e8ca4a
commit
88a2966666
@ -108,9 +108,6 @@
|
|||||||
"create_shared_album_page_share": "Share",
|
"create_shared_album_page_share": "Share",
|
||||||
"create_shared_album_page_share_add_assets": "ADD ASSETS",
|
"create_shared_album_page_share_add_assets": "ADD ASSETS",
|
||||||
"create_shared_album_page_share_select_photos": "Select Photos",
|
"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_alert": "These items will be permanently deleted from Immich and from your device",
|
||||||
"delete_dialog_cancel": "Cancel",
|
"delete_dialog_cancel": "Cancel",
|
||||||
"delete_dialog_ok": "Delete",
|
"delete_dialog_ok": "Delete",
|
||||||
@ -153,7 +150,6 @@
|
|||||||
"login_form_label_password": "Password",
|
"login_form_label_password": "Password",
|
||||||
"login_form_password_hint": "password",
|
"login_form_password_hint": "password",
|
||||||
"login_form_save_login": "Stay logged in",
|
"login_form_save_login": "Stay logged in",
|
||||||
"monthly_title_text_date_format": "MMMM y",
|
|
||||||
"profile_drawer_app_logs": "Logs",
|
"profile_drawer_app_logs": "Logs",
|
||||||
"profile_drawer_client_server_up_to_date": "Client and Server are up-to-date",
|
"profile_drawer_client_server_up_to_date": "Client and Server are up-to-date",
|
||||||
"profile_drawer_settings": "Settings",
|
"profile_drawer_settings": "Settings",
|
||||||
|
@ -123,9 +123,9 @@ class AlbumViewerPage extends HookConsumerWidget {
|
|||||||
final DateTime startDate = album.assets.first.fileCreatedAt;
|
final DateTime startDate = album.assets.first.fileCreatedAt;
|
||||||
final DateTime endDate = album.assets.last.fileCreatedAt; //Need default.
|
final DateTime endDate = album.assets.last.fileCreatedAt; //Need default.
|
||||||
final String startDateText =
|
final String startDateText =
|
||||||
DateFormat(startDate.year == endDate.year ? 'LLL d' : 'LLL d, y')
|
(startDate.year == endDate.year ? DateFormat.MMMd() : DateFormat.yMMMd())
|
||||||
.format(startDate);
|
.format(startDate);
|
||||||
final String endDateText = DateFormat('LLL d, y').format(endDate);
|
final String endDateText = DateFormat.yMMMd().format(endDate);
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
@ -134,7 +134,7 @@ class AlbumViewerPage extends HookConsumerWidget {
|
|||||||
bottom: album.shared ? 0.0 : 8.0,
|
bottom: album.shared ? 0.0 : 8.0,
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
"$startDateText-$endDateText",
|
"$startDateText - $endDateText",
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
|
@ -144,10 +144,12 @@ class ExifBottomSheet extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buildDate() {
|
buildDate() {
|
||||||
|
final fileCreatedAt = assetDetail.fileCreatedAt.toLocal();
|
||||||
|
final date = DateFormat.yMMMEd().format(fileCreatedAt);
|
||||||
|
final time = DateFormat.jm().format(fileCreatedAt);
|
||||||
|
|
||||||
return Text(
|
return Text(
|
||||||
DateFormat('date_format'.tr()).format(
|
'$date • $time',
|
||||||
assetDetail.fileCreatedAt.toLocal(),
|
|
||||||
),
|
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
|
@ -18,7 +18,7 @@ class CurrentUploadingAssetInfoBox extends HookConsumerWidget {
|
|||||||
final isShowThumbnail = useState(false);
|
final isShowThumbnail = useState(false);
|
||||||
|
|
||||||
String getAssetCreationDate() {
|
String getAssetCreationDate() {
|
||||||
return DateFormat.yMMMMd('en_US').format(
|
return DateFormat.yMMMMd().format(
|
||||||
DateTime.parse(
|
DateTime.parse(
|
||||||
asset.fileCreatedAt.toString(),
|
asset.fileCreatedAt.toString(),
|
||||||
).toLocal(),
|
).toLocal(),
|
||||||
|
@ -87,7 +87,7 @@ class FailedBackupStatusPage extends HookConsumerWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
DateFormat.yMMMMd('en_US').format(
|
DateFormat.yMMMMd().format(
|
||||||
DateTime.parse(
|
DateTime.parse(
|
||||||
errorAsset.fileCreatedAt.toString(),
|
errorAsset.fileCreatedAt.toString(),
|
||||||
).toLocal(),
|
).toLocal(),
|
||||||
|
@ -55,16 +55,10 @@ class AssetGridLayoutParameters {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _AssetGroupsToRenderListComputeParameters {
|
class _AssetGroupsToRenderListComputeParameters {
|
||||||
final String monthFormat;
|
|
||||||
final String dayFormat;
|
|
||||||
final String dayFormatYear;
|
|
||||||
final List<Asset> assets;
|
final List<Asset> assets;
|
||||||
final AssetGridLayoutParameters layout;
|
final AssetGridLayoutParameters layout;
|
||||||
|
|
||||||
_AssetGroupsToRenderListComputeParameters(
|
_AssetGroupsToRenderListComputeParameters(
|
||||||
this.monthFormat,
|
|
||||||
this.dayFormat,
|
|
||||||
this.dayFormatYear,
|
|
||||||
this.assets,
|
this.assets,
|
||||||
this.layout,
|
this.layout,
|
||||||
);
|
);
|
||||||
@ -101,9 +95,10 @@ class RenderList {
|
|||||||
static Future<RenderList> _processAssetGroupData(
|
static Future<RenderList> _processAssetGroupData(
|
||||||
_AssetGroupsToRenderListComputeParameters data,
|
_AssetGroupsToRenderListComputeParameters data,
|
||||||
) async {
|
) async {
|
||||||
final monthFormat = DateFormat(data.monthFormat);
|
// TODO: Make DateFormat use the configured locale.
|
||||||
final dayFormatSameYear = DateFormat(data.dayFormat);
|
final monthFormat = DateFormat.yMMM();
|
||||||
final dayFormatOtherYear = DateFormat(data.dayFormatYear);
|
final dayFormatSameYear = DateFormat.MMMEd();
|
||||||
|
final dayFormatOtherYear = DateFormat.yMMMEd();
|
||||||
final allAssets = data.assets;
|
final allAssets = data.assets;
|
||||||
final perRow = data.layout.perRow;
|
final perRow = data.layout.perRow;
|
||||||
final dynamicLayout = data.layout.dynamicLayout;
|
final dynamicLayout = data.layout.dynamicLayout;
|
||||||
@ -210,9 +205,6 @@ class RenderList {
|
|||||||
return compute(
|
return compute(
|
||||||
_processAssetGroupData,
|
_processAssetGroupData,
|
||||||
_AssetGroupsToRenderListComputeParameters(
|
_AssetGroupsToRenderListComputeParameters(
|
||||||
"monthly_title_text_date_format".tr(),
|
|
||||||
"daily_title_text_date".tr(),
|
|
||||||
"daily_title_text_date_year".tr(),
|
|
||||||
assets,
|
assets,
|
||||||
layout,
|
layout,
|
||||||
),
|
),
|
||||||
|
@ -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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user