veilidchat/lib/components/contact_list_widget.dart

67 lines
2.3 KiB
Dart
Raw Normal View History

2023-08-04 01:00:38 -04:00
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
2023-07-28 20:36:05 -04:00
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
2023-08-04 01:00:38 -04:00
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:flutter_translate/flutter_translate.dart';
import 'package:searchable_listview/searchable_listview.dart';
2023-07-28 20:36:05 -04:00
2023-07-29 10:55:35 -04:00
import '../../entities/proto.dart' as proto;
2023-08-04 01:00:38 -04:00
import '../tools/tools.dart';
import 'contact_item_widget.dart';
2023-07-29 10:55:35 -04:00
import 'empty_contact_list_widget.dart';
class ContactListWidget extends ConsumerWidget {
const ContactListWidget({required this.contactList, super.key});
2023-08-04 01:00:38 -04:00
final IList<proto.Contact> contactList;
2023-07-28 20:36:05 -04:00
@override
// ignore: prefer_expression_function_bodies
Widget build(BuildContext context, WidgetRef ref) {
2023-08-04 01:00:38 -04:00
final theme = Theme.of(context);
final textTheme = theme.textTheme;
//final scale = theme.extension<ScaleScheme>()!;
2023-07-29 10:55:35 -04:00
2023-07-28 20:36:05 -04:00
return Container(
decoration: BoxDecoration(
color: Theme.of(context).scaffoldBackgroundColor,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
2023-07-29 10:55:35 -04:00
'Contacts',
2023-08-04 01:00:38 -04:00
style: textTheme.bodyMedium,
),
SearchableList<proto.Contact>(
initialList: contactList.toList(),
builder: (contact) => ContactItemWidget(contact: contact),
filter: (value) {
final lowerValue = value.toLowerCase();
return contactList
.where((element) =>
element.editedProfile.name
.toLowerCase()
.contains(lowerValue) ||
element.editedProfile.title
.toLowerCase()
.contains(lowerValue))
.toList();
},
emptyWidget: const EmptyContactListWidget(),
inputDecoration: InputDecoration(
labelText: translate('contact_list.search'),
fillColor: Colors.white,
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Colors.blue,
2023-07-28 20:36:05 -04:00
),
2023-08-04 01:00:38 -04:00
borderRadius: BorderRadius.circular(10),
),
),
2023-07-28 20:36:05 -04:00
),
],
),
);
}
}