1
0
mirror of https://github.com/immich-app/immich.git synced 2025-07-16 07:24:40 +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;
}
}

View File

@ -86,12 +86,22 @@ class CuratedPeopleRow extends StatelessWidget {
).tr(),
);
}
return Text(
person.label,
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
style: context.textTheme.labelLarge,
maxLines: 2,
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
person.label,
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
style: context.textTheme.labelLarge,
maxLines: 2,
),
if (person.subtitle != null)
Text(
person.subtitle!,
textAlign: TextAlign.center,
),
],
);
}
}