diff --git a/mobile/lib/ui/sharing/add_partipant_page.dart b/mobile/lib/ui/sharing/add_partipant_page.dart index 7aa7c6225..36c82b9f2 100644 --- a/mobile/lib/ui/sharing/add_partipant_page.dart +++ b/mobile/lib/ui/sharing/add_partipant_page.dart @@ -31,9 +31,7 @@ class AddParticipantPage extends StatefulWidget { class _AddParticipantPage extends State { final _selectedEmails = {}; - String selectedEmail = ''; - String _email = ''; - bool isEmailListEmpty = false; + String _newEmail = ''; bool _emailIsValid = false; bool isKeypadOpen = false; late CollectionActions collectionActions; @@ -69,7 +67,6 @@ class _AddParticipantPage extends State { isKeypadOpen = MediaQuery.viewInsetsOf(context).bottom > 100; final enteTextTheme = getEnteTextTheme(context); final enteColorScheme = getEnteColorScheme(context); - isEmailListEmpty = _suggestedUsers.isEmpty; return Scaffold( resizeToAvoidBottomInset: isKeypadOpen, appBar: AppBar( @@ -258,7 +255,7 @@ class _AddParticipantPage extends State { void clearFocus() { _textController.clear(); - _email = _textController.text; + _newEmail = _textController.text; _emailIsValid = false; textFieldFocusNode.unfocus(); setState(() => {}); @@ -294,7 +291,7 @@ class _AddParticipantPage extends State { Icons.email_outlined, color: getEnteColorScheme(context).strokeMuted, ), - suffixIcon: _email == '' + suffixIcon: _newEmail == '' ? null : IconButton( onPressed: clearFocus, @@ -305,11 +302,8 @@ class _AddParticipantPage extends State { ), ), onChanged: (value) { - if (selectedEmail != '') { - selectedEmail = ''; - } - _email = value.trim(); - _emailIsValid = EmailValidator.validate(_email); + _newEmail = value.trim(); + _emailIsValid = EmailValidator.validate(_newEmail); setState(() {}); }, autocorrect: false, @@ -328,20 +322,20 @@ class _AddParticipantPage extends State { if (_emailIsValid) { final result = await collectionActions.doesEmailHaveAccount( context, - _email, + _newEmail, ); if (result && mounted) { setState(() { for (var suggestedUser in _suggestedUsers) { - if (suggestedUser.email == _email) { + if (suggestedUser.email == _newEmail) { _selectedEmails.add(suggestedUser.email); clearFocus(); return; } } - _suggestedUsers.insert(0, User(email: _email)); - _selectedEmails.add(_email); + _suggestedUsers.insert(0, User(email: _newEmail)); + _selectedEmails.add(_newEmail); clearFocus(); }); }