mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-04-20 22:13:48 +00:00
add chat filter list, more space for search bar.
This commit is contained in:
parent
a4bbeffddc
commit
e12debeff9
4 changed files with 37 additions and 7 deletions
|
|
@ -672,6 +672,14 @@ class _ContactsScreenState extends State<ContactsScreen>
|
|||
: "",
|
||||
);
|
||||
break;
|
||||
case ContactTypeFilter.chat:
|
||||
hintText = context.l10n.contacts_searchContacts(
|
||||
filteredAndSorted.length,
|
||||
viewState.contactsShowUnreadOnly
|
||||
? " ${context.l10n.contacts_unread}"
|
||||
: "",
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
final groupsByName = <String, ContactGroup>{};
|
||||
|
|
@ -682,13 +690,13 @@ class _ContactsScreenState extends State<ContactsScreen>
|
|||
..sort((a, b) => a.name.toLowerCase().compareTo(b.name.toLowerCase()));
|
||||
|
||||
final screenWidth = MediaQuery.sizeOf(context).width;
|
||||
final searchExpandedWidth = (screenWidth * 0.52).clamp(
|
||||
final searchExpandedWidth = (screenWidth * 0.72).clamp(
|
||||
97.0,
|
||||
double.infinity,
|
||||
); // allow expansion up to 52% of screen width, but not less than the collapsed width
|
||||
); // allow expansion up to 72% of screen width, but not less than the collapsed width
|
||||
final searchCollapsedWidth = (screenWidth * 0.22).clamp(
|
||||
97.0,
|
||||
120.0,
|
||||
97.0,
|
||||
); //two 48px icon buttons + 1px divider
|
||||
|
||||
return Column(
|
||||
|
|
@ -860,8 +868,11 @@ class _ContactsScreenState extends State<ContactsScreen>
|
|||
if (viewState.contactsTypeFilter != ContactTypeFilter.all) {
|
||||
filtered = filtered
|
||||
.where(
|
||||
(contact) =>
|
||||
_matchesTypeFilter(contact, viewState.contactsTypeFilter),
|
||||
(contact) => _matchesTypeFilter(
|
||||
contact,
|
||||
viewState.contactsTypeFilter,
|
||||
connector,
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
}
|
||||
|
|
@ -901,7 +912,11 @@ class _ContactsScreenState extends State<ContactsScreen>
|
|||
return filtered;
|
||||
}
|
||||
|
||||
bool _matchesTypeFilter(Contact contact, ContactTypeFilter typeFilter) {
|
||||
bool _matchesTypeFilter(
|
||||
Contact contact,
|
||||
ContactTypeFilter typeFilter,
|
||||
MeshCoreConnector connector,
|
||||
) {
|
||||
switch (typeFilter) {
|
||||
case ContactTypeFilter.all:
|
||||
return true;
|
||||
|
|
@ -913,6 +928,8 @@ class _ContactsScreenState extends State<ContactsScreen>
|
|||
return contact.type == advTypeRepeater;
|
||||
case ContactTypeFilter.rooms:
|
||||
return contact.type == advTypeRoom;
|
||||
case ContactTypeFilter.chat:
|
||||
return connector.getMessages(contact).isNotEmpty;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -306,6 +306,12 @@ class _DiscoveryScreenState extends State<DiscoveryScreen> {
|
|||
showUnreadOnly ? " ${context.l10n.contacts_unread}" : "",
|
||||
);
|
||||
break;
|
||||
case ContactTypeFilter.chat:
|
||||
hintText = context.l10n.contacts_searchContacts(
|
||||
filteredAndSorted.length,
|
||||
showUnreadOnly ? " ${context.l10n.contacts_unread}" : "",
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
return Column(
|
||||
|
|
@ -424,6 +430,8 @@ class _DiscoveryScreenState extends State<DiscoveryScreen> {
|
|||
return contact.type == advTypeRepeater;
|
||||
case ContactTypeFilter.rooms:
|
||||
return contact.type == advTypeRoom;
|
||||
case ContactTypeFilter.chat:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
enum ContactSortOption { lastSeen, recentMessages, name }
|
||||
|
||||
enum ContactTypeFilter { all, favorites, users, repeaters, rooms }
|
||||
enum ContactTypeFilter { all, favorites, users, repeaters, rooms, chat }
|
||||
|
|
|
|||
|
|
@ -177,6 +177,11 @@ class ContactsFilterMenu extends StatelessWidget {
|
|||
label: l10n.listFilter_roomServers,
|
||||
checked: typeFilter == ContactTypeFilter.rooms,
|
||||
),
|
||||
SortFilterMenuOption(
|
||||
value: _TypeFilterAction(ContactTypeFilter.chat),
|
||||
label: l10n.map_chat,
|
||||
checked: typeFilter == ContactTypeFilter.chat,
|
||||
),
|
||||
SortFilterMenuOption(
|
||||
value: const _ToggleUnreadAction(),
|
||||
label: l10n.listFilter_unreadOnly,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue