2023-06-23 17:44:02 +02:00
|
|
|
import 'package:flutter/material.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/models/curated_content.dart';
|
|
|
|
import 'package:immich_mobile/modules/search/ui/thumbnail_with_info.dart';
|
|
|
|
import 'package:immich_mobile/shared/models/store.dart';
|
|
|
|
import 'package:immich_mobile/utils/image_url_builder.dart';
|
|
|
|
|
|
|
|
class CuratedPeopleRow extends StatelessWidget {
|
|
|
|
final List<CuratedContent> content;
|
|
|
|
|
|
|
|
/// Callback with the content and the index when tapped
|
|
|
|
final Function(CuratedContent, int)? onTap;
|
|
|
|
final Function(CuratedContent, int)? onNameTap;
|
|
|
|
|
|
|
|
const CuratedPeopleRow({
|
|
|
|
super.key,
|
|
|
|
required this.content,
|
|
|
|
this.onTap,
|
|
|
|
required this.onNameTap,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
const imageSize = 85.0;
|
|
|
|
|
|
|
|
// 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(
|
|
|
|
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(
|
|
|
|
"Add name",
|
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
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
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,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|