Skip to content
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

TF-3007 [SEARCH] Support drag and drop between From & To field #3154

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:super_tag_editor/tag_editor.dart';
import 'package:tmail_ui_user/features/base/base_controller.dart';
import 'package:tmail_ui_user/features/composer/domain/state/get_autocomplete_state.dart';
import 'package:tmail_ui_user/features/composer/domain/usecases/get_autocomplete_interactor.dart';
import 'package:tmail_ui_user/features/composer/presentation/model/draggable_email_address.dart';
import 'package:tmail_ui_user/features/destination_picker/presentation/model/destination_picker_arguments.dart';
import 'package:tmail_ui_user/features/mailbox/presentation/extensions/presentation_mailbox_extension.dart';
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_actions.dart';
Expand Down Expand Up @@ -477,6 +478,24 @@ class AdvancedFilterController extends BaseController {
}
}

void removeDraggableEmailAddress(DraggableEmailAddress draggableEmailAddress) {
log('AdvancedFilterController::removeDraggableEmailAddress:removeDraggableEmailAddress: $draggableEmailAddress');
switch(draggableEmailAddress.prefix) {
case PrefixEmailAddress.to:
listToEmailAddress.remove(draggableEmailAddress.emailAddress);
toAddressExpandMode.value = ExpandMode.EXPAND;
toAddressExpandMode.refresh();
break;
case PrefixEmailAddress.from:
listFromEmailAddress.remove(draggableEmailAddress.emailAddress);
fromAddressExpandMode.value = ExpandMode.EXPAND;
fromAddressExpandMode.refresh();
break;
default:
break;
}
}

@override
void onClose() {
_removeFocusListener();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:core/core.dart';
import 'package:flutter/cupertino.dart';
import 'package:model/email/prefix_email_address.dart';
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';

enum AdvancedSearchFilterField {
Expand Down Expand Up @@ -64,6 +65,17 @@ enum AdvancedSearchFilterField {
color: AppColor.colorContentEmail);
}

PrefixEmailAddress getPrefixEmailAddress() {
switch (this) {
case AdvancedSearchFilterField.from:
return PrefixEmailAddress.from;
case AdvancedSearchFilterField.to:
return PrefixEmailAddress.to;
default:
return PrefixEmailAddress.cc;
}
}

TextStyle getHintTextStyle() {
return const TextStyle(
fontSize: 16,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class AdvancedSearchInputForm extends GetWidget<AdvancedFilterController>
onUpdateListEmailAddressAction: controller.updateListEmailAddress,
onSuggestionEmailAddress: controller.getAutoCompleteSuggestion,
onSearchAction: controller.onSearchAction,
onRemoveDraggableEmailAddressAction: controller.removeDraggableEmailAddress,
)),
Obx(() => TextFieldAutocompleteEmailAddressWeb(
field: AdvancedSearchFilterField.to,
Expand All @@ -52,6 +53,7 @@ class AdvancedSearchInputForm extends GetWidget<AdvancedFilterController>
onUpdateListEmailAddressAction: controller.updateListEmailAddress,
onSuggestionEmailAddress: controller.getAutoCompleteSuggestion,
onSearchAction: controller.onSearchAction,
onRemoveDraggableEmailAddressAction: controller.removeDraggableEmailAddress,
)),
_buildFilterField(
textEditingController: controller.subjectFilterInputController,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
import 'package:model/extensions/email_address_extension.dart';
import 'package:tmail_ui_user/features/composer/presentation/model/draggable_email_address.dart';
import 'package:tmail_ui_user/features/composer/presentation/widgets/draggable_recipient_tag_widget.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/model/search/advanced_search_filter.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/styles/autocomplete_tag_item_web_style.dart';
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/widgets/advanced_search/avatar_tag_item_widget.dart';
Expand Down Expand Up @@ -48,39 +50,47 @@ class AutoCompleteTagItemWidgetWeb extends StatelessWidget {
top: AutoCompleteTagItemWebStyle.paddingTop,
end: isCollapsed ? AutoCompleteTagItemWebStyle.paddingEnd : 0,
),
child: TextFieldTapRegion(
child: InkWell(
onTap: () => isCollapsed
? onShowFullAction?.call(field)
: null,
child: MouseRegion(
cursor: SystemMouseCursors.grab,
child: Chip(
labelPadding: EdgeInsetsDirectional.symmetric(
horizontal: AutoCompleteTagItemWebStyle.labelPaddingHorizontal,
vertical: DirectionUtils.isDirectionRTLByHasAnyRtl(currentEmailAddress.asString()) ? 0 : 2
),
label: Text(
currentEmailAddress.asString(),
maxLines: 1,
overflow: CommonTextStyle.defaultTextOverFlow,
softWrap: CommonTextStyle.defaultSoftWrap,
),
deleteIcon: SvgPicture.asset(
_imagePaths.icClose,
fit: BoxFit.fill,
),
padding: EdgeInsets.zero,
labelStyle: AutoCompleteTagItemWebStyle.labelTextStyle,
backgroundColor: _getTagBackgroundColor(),
shape: RoundedRectangleBorder(
borderRadius: AutoCompleteTagItemWebStyle.shapeBorderRadius,
side: _getTagBorderSide(),
child: Draggable<DraggableEmailAddress>(
data: DraggableEmailAddress(
emailAddress: currentEmailAddress,
prefix: field.getPrefixEmailAddress()
),
feedback: DraggableRecipientTagWidget(emailAddress: currentEmailAddress),
childWhenDragging: DraggableRecipientTagWidget(emailAddress: currentEmailAddress),
child: TextFieldTapRegion(
child: InkWell(
onTap: () => isCollapsed
? onShowFullAction?.call(field)
: null,
child: MouseRegion(
cursor: SystemMouseCursors.grab,
child: Chip(
labelPadding: EdgeInsetsDirectional.symmetric(
horizontal: AutoCompleteTagItemWebStyle.labelPaddingHorizontal,
vertical: DirectionUtils.isDirectionRTLByHasAnyRtl(currentEmailAddress.asString()) ? 0 : 2
),
label: Text(
currentEmailAddress.asString(),
maxLines: 1,
overflow: CommonTextStyle.defaultTextOverFlow,
softWrap: CommonTextStyle.defaultSoftWrap,
),
deleteIcon: SvgPicture.asset(
_imagePaths.icClose,
fit: BoxFit.fill,
),
padding: EdgeInsets.zero,
labelStyle: AutoCompleteTagItemWebStyle.labelTextStyle,
backgroundColor: _getTagBackgroundColor(),
shape: RoundedRectangleBorder(
borderRadius: AutoCompleteTagItemWebStyle.shapeBorderRadius,
side: _getTagBorderSide(),
),
avatar: currentEmailAddress.emailAddress.isNotEmpty
? AvatarTagItemWidget(tagName: currentEmailAddress.emailAddress)
: null,
onDeleted: () => onDeleteTagAction?.call(currentEmailAddress),
),
avatar: currentEmailAddress.emailAddress.isNotEmpty
? AvatarTagItemWidget(tagName: currentEmailAddress.emailAddress)
: null,
onDeleted: () => onDeleteTagAction?.call(currentEmailAddress),
),
),
),
Expand Down
Loading
Loading