|
|
|
|
@ -1,5 +1,3 @@
|
|
|
|
|
import 'dart:math' as math;
|
|
|
|
|
|
|
|
|
|
import 'package:auto_route/auto_route.dart';
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
@ -26,7 +24,6 @@ class PeopleInfo extends ConsumerWidget {
|
|
|
|
|
.watch(assetPeopleNotifierProvider(asset))
|
|
|
|
|
.value
|
|
|
|
|
?.where((p) => !p.isHidden);
|
|
|
|
|
final double imageSize = math.min(context.width / 3, 150);
|
|
|
|
|
|
|
|
|
|
showPersonNameEditModel(
|
|
|
|
|
String personId,
|
|
|
|
|
@ -48,12 +45,9 @@ class PeopleInfo extends ConsumerWidget {
|
|
|
|
|
(p) => SearchCuratedContent(
|
|
|
|
|
id: p.id,
|
|
|
|
|
label: p.name,
|
|
|
|
|
subtitle: p.birthDate != null
|
|
|
|
|
? "exif_bottom_sheet_person_age".tr(
|
|
|
|
|
args: [
|
|
|
|
|
_calculateAge(p.birthDate!).toString(),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
subtitle: p.birthDate != null &&
|
|
|
|
|
p.birthDate!.isBefore(asset.fileCreatedAt)
|
|
|
|
|
? _formatAge(p.birthDate!, asset.fileCreatedAt)
|
|
|
|
|
: null,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
@ -83,27 +77,24 @@ class PeopleInfo extends ConsumerWidget {
|
|
|
|
|
).tr(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: imageSize,
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: const EdgeInsets.only(top: 16.0),
|
|
|
|
|
child: CuratedPeopleRow(
|
|
|
|
|
padding: padding,
|
|
|
|
|
content: curatedPeople,
|
|
|
|
|
onTap: (content, index) {
|
|
|
|
|
context
|
|
|
|
|
.pushRoute(
|
|
|
|
|
PersonResultRoute(
|
|
|
|
|
personId: content.id,
|
|
|
|
|
personName: content.label,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
.then((_) => peopleProvider.refresh());
|
|
|
|
|
},
|
|
|
|
|
onNameTap: (person, index) => {
|
|
|
|
|
showPersonNameEditModel(person.id, person.label),
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(top: 16.0),
|
|
|
|
|
child: CuratedPeopleRow(
|
|
|
|
|
padding: padding,
|
|
|
|
|
content: curatedPeople,
|
|
|
|
|
onTap: (content, index) {
|
|
|
|
|
context
|
|
|
|
|
.pushRoute(
|
|
|
|
|
PersonResultRoute(
|
|
|
|
|
personId: content.id,
|
|
|
|
|
personName: content.label,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
.then((_) => peopleProvider.refresh());
|
|
|
|
|
},
|
|
|
|
|
onNameTap: (person, index) => {
|
|
|
|
|
showPersonNameEditModel(person.id, person.label),
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
@ -112,16 +103,36 @@ class PeopleInfo extends ConsumerWidget {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int _calculateAge(DateTime birthDate) {
|
|
|
|
|
DateTime today = DateTime.now();
|
|
|
|
|
int age = today.year - birthDate.year;
|
|
|
|
|
String _formatAge(DateTime birthDate, DateTime referenceDate) {
|
|
|
|
|
int ageInYears = _calculateAge(birthDate, referenceDate);
|
|
|
|
|
int ageInMonths = _calculateAgeInMonths(birthDate, referenceDate);
|
|
|
|
|
|
|
|
|
|
// Check if the birthday has occurred this year
|
|
|
|
|
if (today.month < birthDate.month ||
|
|
|
|
|
(today.month == birthDate.month && today.day < birthDate.day)) {
|
|
|
|
|
age--;
|
|
|
|
|
if (ageInMonths <= 11) {
|
|
|
|
|
return "exif_bottom_sheet_person_age_months"
|
|
|
|
|
.tr(args: [ageInMonths.toString()]);
|
|
|
|
|
} else if (ageInMonths > 12 && ageInMonths <= 23) {
|
|
|
|
|
return "exif_bottom_sheet_person_age_year_months"
|
|
|
|
|
.tr(args: [(ageInMonths - 12).toString()]);
|
|
|
|
|
} else {
|
|
|
|
|
return "exif_bottom_sheet_person_age_years"
|
|
|
|
|
.tr(args: [ageInYears.toString()]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int _calculateAge(DateTime birthDate, DateTime referenceDate) {
|
|
|
|
|
int age = referenceDate.year - birthDate.year;
|
|
|
|
|
if (referenceDate.month < birthDate.month ||
|
|
|
|
|
(referenceDate.month == birthDate.month &&
|
|
|
|
|
referenceDate.day < birthDate.day)) {
|
|
|
|
|
age--;
|
|
|
|
|
}
|
|
|
|
|
return age;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int _calculateAgeInMonths(DateTime birthDate, DateTime referenceDate) {
|
|
|
|
|
return (referenceDate.year - birthDate.year) * 12 +
|
|
|
|
|
referenceDate.month -
|
|
|
|
|
birthDate.month -
|
|
|
|
|
(referenceDate.day < birthDate.day ? 1 : 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|