kopia lustrzana https://gitlab.com/mysocialportal/relatica
Fix contacts search to include name and handle not just name and make case insensitive.
rodzic
20858e1778
commit
61d12542fb
|
@ -1,5 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../controls/app_bottom_nav_bar.dart';
|
||||
|
@ -13,17 +14,24 @@ class ContactsScreen extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _ContactsScreenState extends State<ContactsScreen> {
|
||||
static final _logger = Logger('$ContactsScreen');
|
||||
var filterText = '';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final manager = context.watch<ConnectionsManager>();
|
||||
final contacts = manager
|
||||
.getMyContacts()
|
||||
final allContacts = manager.getMyContacts();
|
||||
final filterTextLC = filterText.toLowerCase();
|
||||
final contacts = allContacts
|
||||
.where((c) =>
|
||||
filterText.isEmpty || c.name.toLowerCase().contains(filterText))
|
||||
filterText.isEmpty ||
|
||||
c.name.toLowerCase().contains(filterTextLC) ||
|
||||
c.handle.toLowerCase().contains(filterTextLC))
|
||||
.toList();
|
||||
contacts.sort((c1, c2) => c1.name.compareTo(c2.name));
|
||||
_logger.finer(
|
||||
() => '# Contacts: ${allContacts.length}, #filtered: ${contacts.length}',
|
||||
);
|
||||
late Widget body;
|
||||
if (contacts.isEmpty) {
|
||||
body = const SingleChildScrollView(
|
||||
|
|
Ładowanie…
Reference in New Issue