mirror of
https://github.com/immich-app/immich.git
synced 2024-12-29 11:24:37 +02:00
bffc2cdf60
* refactor: move all extensions to separate package * refactor(mobile): add BuildContext extension * refactor(mobile): use theme getters from context * refactor(mobile): use media query size from context * refactor(mobile): use auto router methods from context * refactor(mobile): use navigator methods from context --------- Co-authored-by: shalong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
116 lines
3.6 KiB
Dart
116 lines
3.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
|
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,
|
|
padding: const EdgeInsets.only(
|
|
left: 16,
|
|
top: 8,
|
|
),
|
|
itemBuilder: (context, index) {
|
|
final person = content[index];
|
|
final headers = {
|
|
"Authorization": "Bearer ${Store.get(StoreKey.accessToken)}",
|
|
};
|
|
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",
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
color: context.primaryColor,
|
|
),
|
|
),
|
|
),
|
|
)
|
|
else
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 8.0),
|
|
child: Text(
|
|
person.label,
|
|
textAlign: TextAlign.center,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: const TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 13.0,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
itemCount: content.length,
|
|
);
|
|
}
|
|
}
|