2024-08-09 08:43:47 -05:00
|
|
|
import 'package:auto_route/auto_route.dart';
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2025-05-06 18:51:05 +05:30
|
|
|
import 'package:immich_mobile/entities/asset.entity.dart';
|
2024-08-09 08:43:47 -05:00
|
|
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
|
|
|
|
import 'package:immich_mobile/models/search/search_curated_content.model.dart';
|
2025-05-06 18:51:05 +05:30
|
|
|
import 'package:immich_mobile/providers/asset_viewer/asset_people.provider.dart';
|
|
|
|
|
import 'package:immich_mobile/routing/router.dart';
|
2025-08-06 17:13:56 -05:00
|
|
|
import 'package:immich_mobile/utils/people.utils.dart';
|
2024-08-09 08:43:47 -05:00
|
|
|
import 'package:immich_mobile/widgets/search/curated_people_row.dart';
|
|
|
|
|
import 'package:immich_mobile/widgets/search/person_name_edit_form.dart';
|
|
|
|
|
|
|
|
|
|
class PeopleInfo extends ConsumerWidget {
|
|
|
|
|
final Asset asset;
|
|
|
|
|
final EdgeInsets? padding;
|
|
|
|
|
|
|
|
|
|
const PeopleInfo({super.key, required this.asset, this.padding});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
2025-07-25 08:07:22 +05:30
|
|
|
final peopleProvider = ref.watch(assetPeopleNotifierProvider(asset).notifier);
|
|
|
|
|
final people = ref.watch(assetPeopleNotifierProvider(asset)).value?.where((p) => !p.isHidden);
|
2024-08-09 08:43:47 -05:00
|
|
|
|
2025-07-29 00:34:03 +05:30
|
|
|
showPersonNameEditModel(String personId, String personName) {
|
2024-08-09 08:43:47 -05:00
|
|
|
return showDialog(
|
|
|
|
|
context: context,
|
2025-06-09 09:53:03 +07:00
|
|
|
useRootNavigator: false,
|
2024-08-09 08:43:47 -05:00
|
|
|
builder: (BuildContext context) {
|
|
|
|
|
return PersonNameEditForm(personId: personId, personName: personName);
|
|
|
|
|
},
|
|
|
|
|
).then((_) {
|
|
|
|
|
// ensure the people list is up-to-date.
|
|
|
|
|
peopleProvider.refresh();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-29 00:34:03 +05:30
|
|
|
final curatedPeople =
|
|
|
|
|
people
|
2025-03-08 23:02:40 +01:00
|
|
|
?.map(
|
|
|
|
|
(p) => SearchCuratedContent(
|
|
|
|
|
id: p.id,
|
|
|
|
|
label: p.name,
|
2025-07-25 08:07:22 +05:30
|
|
|
subtitle: p.birthDate != null && p.birthDate!.isBefore(asset.fileCreatedAt)
|
2025-08-06 17:13:56 -05:00
|
|
|
? formatAge(p.birthDate!, asset.fileCreatedAt)
|
2025-03-08 23:02:40 +01:00
|
|
|
: null,
|
|
|
|
|
),
|
|
|
|
|
)
|
2024-08-09 08:43:47 -05:00
|
|
|
.toList() ??
|
|
|
|
|
[];
|
|
|
|
|
|
|
|
|
|
return AnimatedCrossFade(
|
2025-07-25 08:07:22 +05:30
|
|
|
crossFadeState: (people?.isEmpty ?? true) ? CrossFadeState.showFirst : CrossFadeState.showSecond,
|
2024-08-09 08:43:47 -05:00
|
|
|
duration: const Duration(milliseconds: 200),
|
|
|
|
|
firstChild: Container(),
|
|
|
|
|
secondChild: Padding(
|
|
|
|
|
padding: const EdgeInsets.only(top: 8.0),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Padding(
|
|
|
|
|
padding: padding ?? EdgeInsets.zero,
|
|
|
|
|
child: Align(
|
|
|
|
|
alignment: Alignment.topLeft,
|
|
|
|
|
child: Text(
|
|
|
|
|
"exif_bottom_sheet_people",
|
|
|
|
|
style: context.textTheme.labelMedium?.copyWith(
|
|
|
|
|
color: context.textTheme.labelMedium?.color?.withAlpha(200),
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
),
|
|
|
|
|
).tr(),
|
|
|
|
|
),
|
|
|
|
|
),
|
2025-03-17 19:51:17 +01:00
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(top: 16.0),
|
|
|
|
|
child: CuratedPeopleRow(
|
|
|
|
|
padding: padding,
|
|
|
|
|
content: curatedPeople,
|
|
|
|
|
onTap: (content, index) {
|
|
|
|
|
context
|
2025-07-29 00:34:03 +05:30
|
|
|
.pushRoute(PersonResultRoute(personId: content.id, personName: content.label))
|
2025-03-17 19:51:17 +01:00
|
|
|
.then((_) => peopleProvider.refresh());
|
|
|
|
|
},
|
2025-07-29 00:34:03 +05:30
|
|
|
onNameTap: (person, index) => {showPersonNameEditModel(person.id, person.label)},
|
2024-08-09 08:43:47 -05:00
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|