-
Notifications
You must be signed in to change notification settings - Fork 44
TW-2928 Reorder contacts list #2929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tddang-linagora
wants to merge
1
commit into
sprint/march26
Choose a base branch
from
TW-2928/Reorder-contacts-list
base: sprint/march26
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
119 changes: 119 additions & 0 deletions
119
lib/pages/contacts_tab/widgets/sliver_contacts_with_matrix_id.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| import 'package:fluffychat/domain/app_state/contact/get_contacts_state.dart'; | ||
| import 'package:fluffychat/pages/contacts_tab/contacts_tab.dart'; | ||
| import 'package:fluffychat/pages/contacts_tab/contacts_tab_view_style.dart'; | ||
| import 'package:fluffychat/pages/new_private_chat/widget/expansion_contact_list_tile.dart'; | ||
| import 'package:fluffychat/presentation/model/contact/presentation_contact.dart'; | ||
| import 'package:fluffychat/presentation/model/contact/presentation_contact_success.dart'; | ||
| import 'package:fluffychat/utils/platform_infos.dart'; | ||
| import 'package:fluffychat/widgets/sliver_expandable_list.dart'; | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:fluffychat/generated/l10n/app_localizations.dart'; | ||
|
|
||
| class SliverContactsWithMatrixId extends StatelessWidget { | ||
| const SliverContactsWithMatrixId({required this.controller, super.key}); | ||
|
|
||
| final ContactsTabController controller; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| const empty = SliverToBoxAdapter(); | ||
| return ValueListenableBuilder( | ||
| valueListenable: controller.presentationContactNotifier, | ||
| builder: (context, state, _) { | ||
| return state.fold((_) => empty, (success) { | ||
| if (success is ContactsLoading) { | ||
| return empty; | ||
| } | ||
|
|
||
| if (success is PresentationExternalContactSuccess) { | ||
| if (controller.presentationRecentContactNotifier.value.isNotEmpty) { | ||
| return empty; | ||
| } | ||
| if (!PlatformInfos.isWeb) { | ||
| if (controller.phoneBookFilterSuccess) { | ||
| return empty; | ||
| } | ||
| } | ||
| return _ExternalContactTile( | ||
| controller: controller, | ||
| contact: success.contact, | ||
| ); | ||
| } | ||
|
|
||
| if (success is PresentationContactsSuccess) { | ||
| final contacts = success.contacts | ||
| .where((c) => c.matrixId != null && c.matrixId!.isNotEmpty) | ||
| .toList(); | ||
| if (contacts.isEmpty) { | ||
| return empty; | ||
| } | ||
| return SliverExpandableList( | ||
| title: L10n.of(context)!.linagoraContactsCount(contacts.length), | ||
| itemCount: contacts.length, | ||
| itemBuilder: (context, index) => _ContactTile( | ||
| contact: contacts[index], | ||
| controller: controller, | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| return empty; | ||
| }); | ||
| }, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class _ExternalContactTile extends StatelessWidget { | ||
| const _ExternalContactTile({required this.controller, required this.contact}); | ||
|
|
||
| final ContactsTabController controller; | ||
| final PresentationContact contact; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return SliverToBoxAdapter( | ||
| child: Padding( | ||
| padding: const EdgeInsets.symmetric( | ||
| horizontal: ContactsTabViewStyle.padding, | ||
| ), | ||
| child: ExpansionContactListTile( | ||
| contact: contact, | ||
| highlightKeyword: controller.textEditingController.text, | ||
| enableInvitation: controller.supportInvitation(), | ||
| onContactTap: () => controller.onContactTap( | ||
| context: context, | ||
| path: 'rooms', | ||
| contact: contact, | ||
| ), | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class _ContactTile extends StatelessWidget { | ||
| const _ContactTile({required this.contact, required this.controller}); | ||
|
|
||
| final PresentationContact contact; | ||
| final ContactsTabController controller; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Padding( | ||
| padding: const EdgeInsets.symmetric( | ||
| horizontal: ContactsTabViewStyle.padding, | ||
| ), | ||
| child: ExpansionContactListTile( | ||
| contact: contact, | ||
| highlightKeyword: controller.textEditingController.text, | ||
| enableInvitation: controller.supportInvitation(), | ||
| onContactTap: () => controller.onContactTap( | ||
| context: context, | ||
| path: 'rooms', | ||
| contact: contact, | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } |
75 changes: 75 additions & 0 deletions
75
lib/pages/contacts_tab/widgets/sliver_contacts_without_matrix_id.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import 'package:fluffychat/domain/app_state/contact/get_contacts_state.dart'; | ||
| import 'package:fluffychat/pages/contacts_tab/contacts_tab.dart'; | ||
| import 'package:fluffychat/pages/contacts_tab/contacts_tab_view_style.dart'; | ||
| import 'package:fluffychat/pages/new_private_chat/widget/expansion_contact_list_tile.dart'; | ||
| import 'package:fluffychat/presentation/model/contact/presentation_contact.dart'; | ||
| import 'package:fluffychat/presentation/model/contact/presentation_contact_success.dart'; | ||
| import 'package:fluffychat/widgets/sliver_expandable_list.dart'; | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:fluffychat/generated/l10n/app_localizations.dart'; | ||
|
|
||
| class SliverContactsWithoutMatrixId extends StatelessWidget { | ||
| const SliverContactsWithoutMatrixId({required this.controller, super.key}); | ||
|
|
||
| final ContactsTabController controller; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| const empty = SliverToBoxAdapter(); | ||
| return ValueListenableBuilder( | ||
| valueListenable: controller.presentationContactNotifier, | ||
| builder: (context, state, _) { | ||
| return state.fold((_) => empty, (success) { | ||
| if (success is ContactsLoading) { | ||
| return empty; | ||
| } | ||
|
|
||
| if (success is PresentationContactsSuccess) { | ||
| final contacts = success.contacts | ||
| .where((c) => c.matrixId == null || c.matrixId!.isEmpty) | ||
| .toList(); | ||
| if (contacts.isEmpty) { | ||
| return empty; | ||
| } | ||
| return SliverExpandableList( | ||
| title: L10n.of(context)!.linagoraContactsCount(contacts.length), | ||
| itemCount: contacts.length, | ||
| itemBuilder: (context, index) => _ContactTile( | ||
| contact: contacts[index], | ||
| controller: controller, | ||
| ), | ||
| ); | ||
| } | ||
|
|
||
| return empty; | ||
| }); | ||
| }, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class _ContactTile extends StatelessWidget { | ||
| const _ContactTile({required this.contact, required this.controller}); | ||
|
|
||
| final PresentationContact contact; | ||
| final ContactsTabController controller; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Padding( | ||
| padding: const EdgeInsets.symmetric( | ||
| horizontal: ContactsTabViewStyle.padding, | ||
| ), | ||
| child: ExpansionContactListTile( | ||
| contact: contact, | ||
| highlightKeyword: controller.textEditingController.text, | ||
| enableInvitation: controller.supportInvitation(), | ||
| onContactTap: () => controller.onContactTap( | ||
| context: context, | ||
| path: 'rooms', | ||
| contact: contact, | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import 'package:fluffychat/domain/app_state/contact/get_contacts_state.dart'; | ||
| import 'package:fluffychat/pages/contacts_tab/contacts_tab.dart'; | ||
| import 'package:fluffychat/pages/contacts_tab/contacts_tab_view_style.dart'; | ||
| import 'package:fluffychat/pages/contacts_tab/empty_contacts_body.dart'; | ||
| import 'package:fluffychat/pages/new_private_chat/widget/no_contacts_found.dart'; | ||
| import 'package:fluffychat/presentation/model/contact/presentation_contact_success.dart'; | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| class SliverEmptyContacts extends StatelessWidget { | ||
| const SliverEmptyContacts({required this.controller, super.key}); | ||
|
|
||
| final ContactsTabController controller; | ||
|
|
||
| bool _isLoading() => controller.presentationContactNotifier.value.fold( | ||
| (_) => false, | ||
| (s) => s is ContactsLoading, | ||
| ); | ||
|
|
||
| bool _hasContactsData() => controller.presentationContactNotifier.value.fold( | ||
| (_) => false, | ||
| (s) => | ||
| (s is PresentationContactsSuccess && s.contacts.isNotEmpty) || | ||
| s is PresentationExternalContactSuccess, | ||
| ); | ||
|
|
||
| bool _hasPhonebookData() => | ||
| controller.presentationPhonebookContactNotifier.value.fold( | ||
| (_) => false, | ||
| (s) => s is PresentationContactsSuccess && s.contacts.isNotEmpty, | ||
| ); | ||
|
|
||
| bool _hasRecentData() => | ||
| controller.presentationRecentContactNotifier.value.isNotEmpty; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return ListenableBuilder( | ||
| listenable: Listenable.merge([ | ||
| controller.presentationContactNotifier, | ||
| controller.presentationPhonebookContactNotifier, | ||
| controller.presentationRecentContactNotifier, | ||
| ]), | ||
| builder: (context, _) { | ||
| if (_isLoading() || | ||
| _hasContactsData() || | ||
| _hasPhonebookData() || | ||
| _hasRecentData()) { | ||
| return const SliverToBoxAdapter(); | ||
| } | ||
| final keyword = controller.textEditingController.text; | ||
| if (keyword.isEmpty) { | ||
| return const SliverToBoxAdapter(child: EmptyContactBody()); | ||
| } | ||
| return SliverToBoxAdapter( | ||
| child: Padding( | ||
| padding: const EdgeInsets.only( | ||
| left: ContactsTabViewStyle.padding, | ||
| top: ContactsTabViewStyle.padding, | ||
| ), | ||
| child: NoContactsFound(keyword: keyword), | ||
| ), | ||
| ); | ||
| }, | ||
| ); | ||
| } | ||
| } | ||
25 changes: 25 additions & 0 deletions
25
lib/pages/contacts_tab/widgets/sliver_loading_contacts.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import 'package:fluffychat/domain/app_state/contact/get_contacts_state.dart'; | ||
| import 'package:fluffychat/pages/contacts_tab/contacts_tab.dart'; | ||
| import 'package:fluffychat/pages/new_private_chat/widget/loading_contact_widget.dart'; | ||
| import 'package:flutter/material.dart'; | ||
|
|
||
| class SliverLoadingContacts extends StatelessWidget { | ||
| const SliverLoadingContacts({required this.controller, super.key}); | ||
|
|
||
| final ContactsTabController controller; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return ValueListenableBuilder( | ||
| valueListenable: controller.presentationContactNotifier, | ||
| builder: (context, state, _) { | ||
| return state.fold((_) => const SliverToBoxAdapter(), (success) { | ||
| if (success is ContactsLoading) { | ||
| return const SliverToBoxAdapter(child: LoadingContactWidget()); | ||
| } | ||
| return const SliverToBoxAdapter(); | ||
| }); | ||
| }, | ||
| ); | ||
| } | ||
| } |
75 changes: 75 additions & 0 deletions
75
lib/pages/contacts_tab/widgets/sliver_phonebook_contacts_with_matrix_id.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import 'package:fluffychat/pages/contacts_tab/contacts_tab.dart'; | ||
| import 'package:fluffychat/pages/contacts_tab/contacts_tab_view_style.dart'; | ||
| import 'package:fluffychat/pages/new_private_chat/widget/expansion_phonebook_contact_list_tile.dart'; | ||
| import 'package:fluffychat/presentation/model/contact/presentation_contact.dart'; | ||
| import 'package:fluffychat/presentation/model/contact/presentation_contact_success.dart'; | ||
| import 'package:fluffychat/widgets/sliver_expandable_list.dart'; | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:fluffychat/generated/l10n/app_localizations.dart'; | ||
|
|
||
| class SliverPhonebookContactsWithMatrixId extends StatelessWidget { | ||
| const SliverPhonebookContactsWithMatrixId({ | ||
| required this.controller, | ||
| super.key, | ||
| }); | ||
|
|
||
| final ContactsTabController controller; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| const empty = SliverToBoxAdapter(); | ||
| return ValueListenableBuilder( | ||
| valueListenable: controller.presentationPhonebookContactNotifier, | ||
| builder: (context, state, _) { | ||
| return state.fold((_) => empty, (success) { | ||
| if (success is PresentationContactsSuccess) { | ||
| final contacts = success.contacts | ||
| .where((c) => c.matrixId != null && c.matrixId!.isNotEmpty) | ||
| .toList(); | ||
| if (contacts.isEmpty) { | ||
| return empty; | ||
| } | ||
| return SliverExpandableList( | ||
| title: L10n.of(context)!.contactsCount(contacts.length), | ||
| itemCount: contacts.length, | ||
| itemBuilder: (context, index) => _PhonebookContactTile( | ||
| contact: contacts[index], | ||
| controller: controller, | ||
| ), | ||
| ); | ||
| } | ||
| return empty; | ||
| }); | ||
| }, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class _PhonebookContactTile extends StatelessWidget { | ||
| const _PhonebookContactTile({ | ||
| required this.contact, | ||
| required this.controller, | ||
| }); | ||
|
|
||
| final PresentationContact contact; | ||
| final ContactsTabController controller; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Padding( | ||
| padding: const EdgeInsets.symmetric( | ||
| horizontal: ContactsTabViewStyle.padding, | ||
| ), | ||
| child: ExpansionPhonebookContactListTile( | ||
| contact: contact, | ||
| highlightKeyword: controller.textEditingController.text, | ||
| enableInvitation: controller.supportInvitation(), | ||
| onContactTap: () => controller.onContactTap( | ||
| context: context, | ||
| path: 'rooms', | ||
| contact: contact, | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include phonebook loading in
_isLoadingto prevent premature empty-state rendering.Right now, loading is inferred only from
presentationContactNotifier. When phonebook data is still loading, the widget can briefly showEmptyContactBody/NoContactsFoundbefore data arrives.🐛 Proposed fix
🤖 Prompt for AI Agents