You've already forked immich
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:
@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user