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