2023-06-23 17:44:02 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2024-03-20 16:26:09 +02:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
2023-11-09 18:19:53 +02:00
|
|
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
2024-05-01 04:36:40 +02:00
|
|
|
import 'package:immich_mobile/models/search/search_curated_content.model.dart';
|
2023-06-23 17:44:02 +02:00
|
|
|
import 'package:immich_mobile/modules/search/ui/thumbnail_with_info.dart';
|
2024-05-01 04:36:40 +02:00
|
|
|
import 'package:immich_mobile/entities/store.entity.dart';
|
2023-06-23 17:44:02 +02:00
|
|
|
import 'package:immich_mobile/utils/image_url_builder.dart';
|
|
|
|
|
|
|
|
class CuratedPeopleRow extends StatelessWidget {
|
2024-05-01 04:36:40 +02:00
|
|
|
final List<SearchCuratedContent> content;
|
2024-03-07 05:27:33 +02:00
|
|
|
final EdgeInsets? padding;
|
2023-06-23 17:44:02 +02:00
|
|
|
|
|
|
|
/// Callback with the content and the index when tapped
|
2024-05-01 04:36:40 +02:00
|
|
|
final Function(SearchCuratedContent, int)? onTap;
|
|
|
|
final Function(SearchCuratedContent, int)? onNameTap;
|
2023-06-23 17:44:02 +02:00
|
|
|
|
|
|
|
const CuratedPeopleRow({
|
|
|
|
super.key,
|
|
|
|
required this.content,
|
|
|
|
this.onTap,
|
2024-03-07 05:27:33 +02:00
|
|
|
this.padding,
|
2023-06-23 17:44:02 +02:00
|
|
|
required this.onNameTap,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-03-21 18:23:06 +02:00
|
|
|
const imageSize = 60.0;
|
2023-06-23 17:44:02 +02:00
|
|
|
|
|
|
|
// Guard empty [content]
|
|
|
|
if (content.isEmpty) {
|
|
|
|
// Return empty thumbnail
|
|
|
|
return Align(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
|
|
|
child: SizedBox(
|
|
|
|
width: imageSize,
|
|
|
|
height: imageSize,
|
|
|
|
child: ThumbnailWithInfo(
|
|
|
|
textInfo: '',
|
|
|
|
onTap: () {},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ListView.builder(
|
2024-03-07 05:27:33 +02:00
|
|
|
padding: padding,
|
2023-06-23 17:44:02 +02:00
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
final person = content[index];
|
|
|
|
final headers = {
|
2024-02-04 22:35:13 +02:00
|
|
|
"x-immich-user-token": Store.get(StoreKey.accessToken),
|
2023-06-23 17:44:02 +02:00
|
|
|
};
|
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.only(right: 18.0),
|
|
|
|
child: SizedBox(
|
|
|
|
width: imageSize,
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
GestureDetector(
|
|
|
|
onTap: () => onTap?.call(person, index),
|
|
|
|
child: SizedBox(
|
|
|
|
height: imageSize,
|
|
|
|
child: Material(
|
|
|
|
shape: const CircleBorder(side: BorderSide.none),
|
|
|
|
elevation: 3,
|
|
|
|
child: CircleAvatar(
|
|
|
|
maxRadius: imageSize / 2,
|
|
|
|
backgroundImage: NetworkImage(
|
|
|
|
getFaceThumbnailUrl(person.id),
|
|
|
|
headers: headers,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (person.label == "")
|
|
|
|
GestureDetector(
|
|
|
|
onTap: () => onNameTap?.call(person, index),
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 8.0),
|
|
|
|
child: Text(
|
2024-03-20 16:26:09 +02:00
|
|
|
"exif_bottom_sheet_person_add_person",
|
2023-11-20 16:58:03 +02:00
|
|
|
style: context.textTheme.labelLarge?.copyWith(
|
2023-11-09 18:19:53 +02:00
|
|
|
color: context.primaryColor,
|
2023-06-23 17:44:02 +02:00
|
|
|
),
|
2024-03-20 16:26:09 +02:00
|
|
|
).tr(),
|
2023-06-23 17:44:02 +02:00
|
|
|
),
|
|
|
|
)
|
|
|
|
else
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 8.0),
|
|
|
|
child: Text(
|
|
|
|
person.label,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
2023-11-20 16:58:03 +02:00
|
|
|
style: context.textTheme.labelLarge,
|
2023-06-23 17:44:02 +02:00
|
|
|
),
|
2023-08-19 00:52:40 +02:00
|
|
|
),
|
2023-06-23 17:44:02 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
itemCount: content.length,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|