2024-01-05 07:20:55 +02:00
|
|
|
import 'package:auto_route/auto_route.dart';
|
2023-11-19 04:32:28 +02:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
2023-06-23 17:44:02 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2024-01-05 23:23:58 +02:00
|
|
|
import 'package:flutter_hooks/flutter_hooks.dart' hide Store;
|
2023-06-23 17:44:02 +02:00
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2023-11-09 18:19:53 +02:00
|
|
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
2023-06-23 17:44:02 +02:00
|
|
|
import 'package:immich_mobile/modules/search/providers/people.provider.dart';
|
|
|
|
import 'package:immich_mobile/modules/search/ui/person_name_edit_form.dart';
|
2024-01-05 23:23:58 +02:00
|
|
|
import 'package:immich_mobile/shared/models/store.dart';
|
|
|
|
import 'package:immich_mobile/shared/ui/asset_grid/multiselect_grid.dart';
|
2023-06-23 17:44:02 +02:00
|
|
|
import 'package:immich_mobile/utils/image_url_builder.dart';
|
|
|
|
|
|
|
|
class PersonResultPage extends HookConsumerWidget {
|
|
|
|
final String personId;
|
|
|
|
final String personName;
|
|
|
|
|
|
|
|
const PersonResultPage({
|
|
|
|
super.key,
|
|
|
|
required this.personId,
|
|
|
|
required this.personName,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
|
|
final name = useState(personName);
|
|
|
|
|
|
|
|
showEditNameDialog() {
|
2023-11-19 18:04:44 +02:00
|
|
|
showDialog(
|
2023-06-23 17:44:02 +02:00
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return PersonNameEditForm(
|
|
|
|
personId: personId,
|
2023-11-19 18:04:44 +02:00
|
|
|
personName: name.value,
|
2023-06-23 17:44:02 +02:00
|
|
|
);
|
|
|
|
},
|
|
|
|
).then((result) {
|
|
|
|
if (result != null && result.success) {
|
|
|
|
name.value = result.updatedName;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void buildBottomSheet() {
|
|
|
|
showModalBottomSheet(
|
2023-11-09 18:19:53 +02:00
|
|
|
backgroundColor: context.scaffoldBackgroundColor,
|
2023-06-23 17:44:02 +02:00
|
|
|
isScrollControlled: false,
|
|
|
|
context: context,
|
|
|
|
useSafeArea: true,
|
|
|
|
builder: (context) {
|
|
|
|
return SafeArea(
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
ListTile(
|
|
|
|
leading: const Icon(Icons.edit_outlined),
|
|
|
|
title: const Text(
|
2023-11-19 04:32:28 +02:00
|
|
|
'search_page_person_edit_name',
|
2023-06-23 17:44:02 +02:00
|
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
2023-11-19 04:32:28 +02:00
|
|
|
).tr(),
|
2023-06-23 17:44:02 +02:00
|
|
|
onTap: showEditNameDialog,
|
2023-08-19 00:52:40 +02:00
|
|
|
),
|
2023-06-23 17:44:02 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
buildTitleBlock() {
|
2023-11-19 18:04:44 +02:00
|
|
|
return GestureDetector(
|
|
|
|
onTap: showEditNameDialog,
|
|
|
|
child: name.value.isEmpty
|
|
|
|
? Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
'search_page_person_add_name_title',
|
2023-11-20 20:59:53 +02:00
|
|
|
style: context.textTheme.titleMedium?.copyWith(
|
|
|
|
color: context.primaryColor,
|
2023-11-19 18:04:44 +02:00
|
|
|
),
|
|
|
|
).tr(),
|
|
|
|
Text(
|
|
|
|
'search_page_person_add_name_subtitle',
|
2023-11-20 20:59:53 +02:00
|
|
|
style: context.textTheme.labelLarge,
|
2023-11-19 18:04:44 +02:00
|
|
|
).tr(),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
name.value,
|
|
|
|
style: context.textTheme.titleLarge,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2023-06-23 17:44:02 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
title: Text(name.value),
|
|
|
|
leading: IconButton(
|
2024-01-05 07:20:55 +02:00
|
|
|
onPressed: () => context.popRoute(),
|
2023-06-23 17:44:02 +02:00
|
|
|
icon: const Icon(Icons.arrow_back_ios_rounded),
|
|
|
|
),
|
|
|
|
actions: [
|
|
|
|
IconButton(
|
|
|
|
onPressed: buildBottomSheet,
|
|
|
|
icon: const Icon(Icons.more_vert_rounded),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2024-01-05 23:23:58 +02:00
|
|
|
body: MultiselectGrid(
|
|
|
|
renderListProvider: personAssetsProvider(personId),
|
|
|
|
topWidget: Padding(
|
|
|
|
padding: const EdgeInsets.only(left: 8.0, top: 24),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
CircleAvatar(
|
|
|
|
radius: 36,
|
|
|
|
backgroundImage: NetworkImage(
|
|
|
|
getFaceThumbnailUrl(personId),
|
|
|
|
headers: {
|
|
|
|
"Authorization":
|
|
|
|
"Bearer ${Store.get(StoreKey.accessToken)}",
|
|
|
|
},
|
2023-11-19 18:04:44 +02:00
|
|
|
),
|
|
|
|
),
|
2024-01-05 23:23:58 +02:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(left: 16.0),
|
|
|
|
child: buildTitleBlock(),
|
|
|
|
),
|
|
|
|
],
|
2023-06-23 17:44:02 +02:00
|
|
|
),
|
2024-01-05 23:23:58 +02:00
|
|
|
),
|
|
|
|
),
|
2023-06-23 17:44:02 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|