TF-4011 Support arrow keys on keyboard to get again focus after deleting a recipient

This commit is contained in:
dab246
2025-09-11 16:43:23 +07:00
committed by Dat H. Pham
parent 9abde49c62
commit cf40d22cc8
8 changed files with 51 additions and 55 deletions
@@ -83,7 +83,7 @@ class _DefaultAutocompleteInputFieldWidgetState
extends State<DefaultAutocompleteInputFieldWidget> {
final _imagePaths = Get.find<ImagePaths>();
bool _lastTagFocused = false;
int _tagIndexFocused = -1;
bool _isDragging = false;
late List<EmailAddress> _currentListEmailAddress;
Timer? _gapBetweenTagChangedAndFindSuggestion;
@@ -157,17 +157,14 @@ class _DefaultAutocompleteInputFieldWidgetState
onSubmitted: _handleSubmitTagAction,
tagBuilder: (context, index) {
final currentEmailAddress = _currentListEmailAddress.elementAt(index);
final isLatestEmail =
currentEmailAddress == _currentListEmailAddress.last;
return DefaultAutocompleteTagItemWidget(
field: widget.field,
currentEmailAddress: currentEmailAddress,
currentListEmailAddress: _currentListEmailAddress,
collapsedListEmailAddress: _collapsedListEmailAddress,
iconClose: _imagePaths.icClose,
isLatestEmail: isLatestEmail,
isCollapsed: _isCollapse,
isLatestTagFocused: _lastTagFocused,
isTagFocused: _tagIndexFocused == index,
onDeleteTagAction: _handleDeleteTagAction,
onShowFullAction: widget.onShowFullListEmailAddressAction,
);
@@ -335,13 +332,17 @@ class _DefaultAutocompleteInputFieldWidgetState
);
}
void _handleFocusTagAction(bool focused) {
_setStateSafety(() => _lastTagFocused = focused);
void _handleFocusTagAction(int index) {
_setStateSafety(() => _tagIndexFocused = index);
}
void _handleDeleteLatestTagAction() {
if (_currentListEmailAddress.isNotEmpty) {
_setStateSafety(_currentListEmailAddress.removeLast);
void _handleDeleteLatestTagAction(int index) {
if (_currentListEmailAddress.isNotEmpty &&
index >= 0 &&
index < _currentListEmailAddress.length) {
_setStateSafety(() {
_currentListEmailAddress.removeAt(index);
});
_updateListEmailAddressAction();
}
}
@@ -16,8 +16,7 @@ import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/widgets/ad
class DefaultAutocompleteTagItemWidget extends StatelessWidget {
final bool isCollapsed;
final bool isLatestTagFocused;
final bool isLatestEmail;
final bool isTagFocused;
final FilterField field;
final EmailAddress currentEmailAddress;
final String iconClose;
@@ -34,8 +33,7 @@ class DefaultAutocompleteTagItemWidget extends StatelessWidget {
required this.collapsedListEmailAddress,
required this.iconClose,
this.isCollapsed = false,
this.isLatestTagFocused = false,
this.isLatestEmail = false,
this.isTagFocused = false,
this.onDeleteTagAction,
this.onShowFullAction,
}) : super(key: key);
@@ -141,7 +139,7 @@ class DefaultAutocompleteTagItemWidget extends StatelessWidget {
}
Color _getTagBackgroundColor() {
if (isLatestTagFocused && isLatestEmail) {
if (isTagFocused) {
return AppColor.colorItemRecipientSelected;
} else {
return AppColor.colorEmailAddressTag;
@@ -149,7 +147,7 @@ class DefaultAutocompleteTagItemWidget extends StatelessWidget {
}
BorderSide _getTagBorderSide() {
if (isLatestTagFocused && isLatestEmail) {
if (isTagFocused) {
return const BorderSide(width: 1, color: AppColor.primaryColor);
} else {
return const BorderSide(width: 0, color: AppColor.colorEmailAddressTag);