Browse Source

Filter email list

Neeraj Gupta 2 years ago
parent
commit
36466b0797
1 changed files with 10 additions and 8 deletions
  1. 10 8
      lib/ui/sharing/add_partipant_page.dart

+ 10 - 8
lib/ui/sharing/add_partipant_page.dart

@@ -54,6 +54,7 @@ class _AddParticipantPage extends State<AddParticipantPage> {
     final enteTextTheme = getEnteTextTheme(context);
     final enteTextTheme = getEnteTextTheme(context);
     final List<User> suggestedUsers = _getSuggestedUser();
     final List<User> suggestedUsers = _getSuggestedUser();
     hideListOfEmails = suggestedUsers.isEmpty;
     hideListOfEmails = suggestedUsers.isEmpty;
+    debugPrint("hide list $hideListOfEmails");
     return Scaffold(
     return Scaffold(
       resizeToAvoidBottomInset: isKeypadOpen,
       resizeToAvoidBottomInset: isKeypadOpen,
       appBar: AppBar(
       appBar: AppBar(
@@ -76,7 +77,7 @@ class _AddParticipantPage extends State<AddParticipantPage> {
             padding: const EdgeInsets.symmetric(horizontal: 16.0),
             padding: const EdgeInsets.symmetric(horizontal: 16.0),
             child: _getEmailField(),
             child: _getEmailField(),
           ),
           ),
-          (hideListOfEmails || isKeypadOpen)
+          (hideListOfEmails)
               ? const Expanded(child: SizedBox())
               ? const Expanded(child: SizedBox())
               : Expanded(
               : Expanded(
                   child: Padding(
                   child: Padding(
@@ -281,13 +282,8 @@ class _AddParticipantPage extends State<AddParticipantPage> {
           selectedEmail = '';
           selectedEmail = '';
         }
         }
         _email = value.trim();
         _email = value.trim();
-        if (_emailIsValid != EmailValidator.validate(_email)) {
-          setState(() {
-            _emailIsValid = EmailValidator.validate(_email);
-          });
-        } else if (_email.length < 2) {
-          setState(() {});
-        }
+        _emailIsValid = EmailValidator.validate(_email);
+        setState(() {});
       },
       },
       autocorrect: false,
       autocorrect: false,
       keyboardType: TextInputType.emailAddress,
       keyboardType: TextInputType.emailAddress,
@@ -320,7 +316,13 @@ class _AddParticipantPage extends State<AddParticipantPage> {
         suggestedUsers.add(c.owner!);
         suggestedUsers.add(c.owner!);
       }
       }
     }
     }
+    if (_textController.text.trim().isNotEmpty) {
+      suggestedUsers.removeWhere((element) => !element.email
+          .toLowerCase()
+          .contains(_textController.text.trim().toLowerCase()));
+    }
     suggestedUsers.sort((a, b) => a.email.compareTo(b.email));
     suggestedUsers.sort((a, b) => a.email.compareTo(b.email));
+
     return suggestedUsers;
     return suggestedUsers;
   }
   }
 }
 }