2023-08-05 01:00:46 -04:00
|
|
|
import 'package:awesome_extensions/awesome_extensions.dart';
|
2023-08-04 01:00:38 -04:00
|
|
|
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
2023-08-06 19:46:40 -04:00
|
|
|
import 'package:flutter/foundation.dart';
|
2023-07-28 20:36:05 -04:00
|
|
|
import 'package:flutter/material.dart';
|
2023-08-04 01:00:38 -04:00
|
|
|
import 'package:flutter_translate/flutter_translate.dart';
|
|
|
|
import 'package:searchable_listview/searchable_listview.dart';
|
2023-07-28 20:36:05 -04:00
|
|
|
|
2024-01-30 17:03:14 -05:00
|
|
|
import '../../proto/proto.dart' as proto;
|
2024-04-12 20:55:05 -04:00
|
|
|
import '../../theme/theme.dart';
|
2023-08-04 01:00:38 -04:00
|
|
|
import 'contact_item_widget.dart';
|
2023-07-29 10:55:35 -04:00
|
|
|
import 'empty_contact_list_widget.dart';
|
|
|
|
|
2024-01-30 17:03:14 -05:00
|
|
|
class ContactListWidget extends StatelessWidget {
|
2024-02-27 12:45:58 -05:00
|
|
|
const ContactListWidget(
|
|
|
|
{required this.contactList, required this.disabled, super.key});
|
2023-08-04 01:00:38 -04:00
|
|
|
final IList<proto.Contact> contactList;
|
2024-02-27 12:45:58 -05:00
|
|
|
final bool disabled;
|
2023-07-28 20:36:05 -04:00
|
|
|
|
2023-08-06 19:46:40 -04:00
|
|
|
@override
|
|
|
|
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
|
|
|
super.debugFillProperties(properties);
|
2024-02-27 12:45:58 -05:00
|
|
|
properties
|
|
|
|
..add(IterableProperty<proto.Contact>('contactList', contactList))
|
|
|
|
..add(DiagnosticsProperty<bool>('disabled', disabled));
|
2023-08-06 19:46:40 -04:00
|
|
|
}
|
|
|
|
|
2023-07-28 20:36:05 -04:00
|
|
|
@override
|
2024-04-12 20:55:05 -04:00
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final theme = Theme.of(context);
|
|
|
|
final scale = theme.extension<ScaleScheme>()!;
|
|
|
|
|
|
|
|
return SizedBox.expand(
|
|
|
|
child: styledTitleContainer(
|
|
|
|
context: context,
|
|
|
|
title: translate('contact_list.title'),
|
|
|
|
child: SizedBox.expand(
|
|
|
|
child: (contactList.isEmpty)
|
|
|
|
? const EmptyContactListWidget()
|
|
|
|
: SearchableList<proto.Contact>(
|
|
|
|
initialList: contactList.toList(),
|
2024-05-20 20:48:17 -04:00
|
|
|
itemBuilder: (c) =>
|
2024-04-12 20:55:05 -04:00
|
|
|
ContactItemWidget(contact: c, disabled: disabled)
|
|
|
|
.paddingLTRB(0, 4, 0, 0),
|
|
|
|
filter: (value) {
|
|
|
|
final lowerValue = value.toLowerCase();
|
|
|
|
return contactList
|
|
|
|
.where((element) =>
|
|
|
|
element.editedProfile.name
|
|
|
|
.toLowerCase()
|
|
|
|
.contains(lowerValue) ||
|
|
|
|
element.editedProfile.pronouns
|
|
|
|
.toLowerCase()
|
|
|
|
.contains(lowerValue))
|
|
|
|
.toList();
|
|
|
|
},
|
|
|
|
spaceBetweenSearchAndList: 4,
|
|
|
|
defaultSuffixIconColor: scale.primaryScale.border,
|
|
|
|
inputDecoration: InputDecoration(
|
|
|
|
labelText: translate('contact_list.search'),
|
|
|
|
),
|
|
|
|
).paddingAll(8),
|
|
|
|
))).paddingLTRB(8, 0, 8, 8);
|
|
|
|
}
|
2023-07-28 20:36:05 -04:00
|
|
|
}
|