mirror of
https://github.com/immich-app/immich.git
synced 2024-12-25 10:43:13 +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_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",
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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(),
|
||||
|
@ -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(),
|
||||
|
@ -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,
|
||||
),
|
||||
|
@ -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