1
0
mirror of https://github.com/immich-app/immich.git synced 2025-08-08 23:07:06 +02:00

feat(mobile): person age on photo properties (#16728)

* feat(mobile): person age on photo properties

* switch to using placeholder
This commit is contained in:
Yaros
2025-03-08 23:02:40 +01:00
committed by GitHub
parent 1e127ae3a1
commit 6c5f99c47a
4 changed files with 54 additions and 9 deletions

View File

@ -44,7 +44,19 @@ class PeopleInfo extends ConsumerWidget {
}
final curatedPeople = people
?.map((p) => SearchCuratedContent(id: p.id, label: p.name))
?.map(
(p) => SearchCuratedContent(
id: p.id,
label: p.name,
subtitle: p.birthDate != null
? "exif_bottom_sheet_person_age".tr(
args: [
_calculateAge(p.birthDate!).toString(),
],
)
: null,
),
)
.toList() ??
[];
@ -99,4 +111,17 @@ class PeopleInfo extends ConsumerWidget {
),
);
}
int _calculateAge(DateTime birthDate) {
DateTime today = DateTime.now();
int age = today.year - birthDate.year;
// Check if the birthday has occurred this year
if (today.month < birthDate.month ||
(today.month == birthDate.month && today.day < birthDate.day)) {
age--;
}
return age;
}
}