TF-2191 Fix keyboard disappear when switch focus from subject to body in composer android
(cherry picked from commit 880c7f1ae9e96c5b3dedaca01bf3736e7dd869d4)
This commit is contained in:
@@ -7,6 +7,7 @@ class TextFieldBuilder extends StatefulWidget {
|
||||
final ValueChanged<String>? onTextChange;
|
||||
final ValueChanged<String>? onTextSubmitted;
|
||||
final VoidCallback? onTap;
|
||||
final TapRegionCallback? onTapOutside;
|
||||
final TextStyle? textStyle;
|
||||
final TextInputAction? textInputAction;
|
||||
final InputDecoration? decoration;
|
||||
@@ -45,6 +46,7 @@ class TextFieldBuilder extends StatefulWidget {
|
||||
this.keyboardAppearance,
|
||||
this.mouseCursor,
|
||||
this.onTap,
|
||||
this.onTapOutside,
|
||||
this.onTextChange,
|
||||
this.onTextSubmitted,
|
||||
});
|
||||
@@ -102,6 +104,7 @@ class _TextFieldBuilderState extends State<TextFieldBuilder> {
|
||||
},
|
||||
onSubmitted: widget.onTextSubmitted,
|
||||
onTap: widget.onTap,
|
||||
onTapOutside: widget.onTapOutside,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -386,6 +386,26 @@ class ComposerController extends BaseController {
|
||||
);
|
||||
}
|
||||
|
||||
void onTapOutsideSubject(PointerDownEvent event) {
|
||||
subjectEmailInputFocusNode?.unfocus();
|
||||
}
|
||||
|
||||
void onTapOutsideRecipients(PrefixEmailAddress prefix) {
|
||||
switch(prefix) {
|
||||
case PrefixEmailAddress.to:
|
||||
toAddressFocusNode?.unfocus();
|
||||
break;
|
||||
case PrefixEmailAddress.cc:
|
||||
ccAddressFocusNode?.unfocus();
|
||||
break;
|
||||
case PrefixEmailAddress.bcc:
|
||||
bccAddressFocusNode?.unfocus();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void onLoadCompletedMobileEditorAction(HtmlEditorApi editorApi, WebUri? url) {
|
||||
if (identitySelected == null) {
|
||||
_getAllIdentities();
|
||||
@@ -1836,18 +1856,8 @@ class ComposerController extends BaseController {
|
||||
}
|
||||
|
||||
void _onEditorFocusOnMobile() {
|
||||
if (Platform.isAndroid) {
|
||||
_collapseAllRecipient();
|
||||
_autoCreateEmailTag();
|
||||
removeFocusAllInputEditorHeader();
|
||||
}
|
||||
}
|
||||
|
||||
void removeFocusAllInputEditorHeader() {
|
||||
subjectEmailInputFocusNode?.unfocus();
|
||||
toAddressFocusNode?.unfocus();
|
||||
ccAddressFocusNode?.unfocus();
|
||||
bccAddressFocusNode?.unfocus();
|
||||
_collapseAllRecipient();
|
||||
_autoCreateEmailTag();
|
||||
}
|
||||
|
||||
void _onChangeCursorOnMobile(List<int>? coordinates, BuildContext context) {
|
||||
|
||||
@@ -118,6 +118,7 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
onUpdateListEmailAddressAction: controller.updateListEmailAddress,
|
||||
onSuggestionEmailAddress: controller.getAutoCompleteSuggestion,
|
||||
onFocusNextAddressAction: controller.handleFocusNextAddressAction,
|
||||
onTapOutside: (_) => controller.onTapOutsideRecipients(PrefixEmailAddress.to),
|
||||
),
|
||||
if (controller.ccRecipientState.value == PrefixRecipientState.enabled)
|
||||
RecipientComposerWidget(
|
||||
@@ -138,6 +139,7 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
onUpdateListEmailAddressAction: controller.updateListEmailAddress,
|
||||
onSuggestionEmailAddress: controller.getAutoCompleteSuggestion,
|
||||
onFocusNextAddressAction: controller.handleFocusNextAddressAction,
|
||||
onTapOutside: (_) => controller.onTapOutsideRecipients(PrefixEmailAddress.cc),
|
||||
),
|
||||
if (controller.bccRecipientState.value == PrefixRecipientState.enabled)
|
||||
RecipientComposerWidget(
|
||||
@@ -158,6 +160,7 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
onUpdateListEmailAddressAction: controller.updateListEmailAddress,
|
||||
onSuggestionEmailAddress: controller.getAutoCompleteSuggestion,
|
||||
onFocusNextAddressAction: controller.handleFocusNextAddressAction,
|
||||
onTapOutside: (_) => controller.onTapOutsideRecipients(PrefixEmailAddress.bcc),
|
||||
),
|
||||
],
|
||||
)),
|
||||
@@ -167,6 +170,7 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
onTextChange: controller.setSubjectEmail,
|
||||
padding: ComposerStyle.mobileSubjectPadding,
|
||||
margin: ComposerStyle.mobileSubjectMargin,
|
||||
onTapOutside: controller.onTapOutsideSubject,
|
||||
),
|
||||
Obx(() => Center(
|
||||
child: InsertImageLoadingBarWidget(
|
||||
@@ -175,18 +179,13 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
padding: ComposerStyle.insertImageLoadingBarPadding,
|
||||
),
|
||||
)),
|
||||
Obx(() => GestureDetector(
|
||||
onTapDown: (_) {
|
||||
controller.removeFocusAllInputEditorHeader();
|
||||
},
|
||||
child: Padding(
|
||||
padding: ComposerStyle.mobileEditorPadding,
|
||||
child: MobileEditorView(
|
||||
arguments: controller.composerArguments.value,
|
||||
contentViewState: controller.emailContentsViewState.value,
|
||||
onCreatedEditorAction: controller.onCreatedMobileEditorAction,
|
||||
onLoadCompletedEditorAction: controller.onLoadCompletedMobileEditorAction,
|
||||
),
|
||||
Obx(() => Padding(
|
||||
padding: ComposerStyle.mobileEditorPadding,
|
||||
child: MobileEditorView(
|
||||
arguments: controller.composerArguments.value,
|
||||
contentViewState: controller.emailContentsViewState.value,
|
||||
onCreatedEditorAction: controller.onCreatedMobileEditorAction,
|
||||
onLoadCompletedEditorAction: controller.onLoadCompletedMobileEditorAction,
|
||||
),
|
||||
)),
|
||||
Obx(() {
|
||||
@@ -259,6 +258,7 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
onUpdateListEmailAddressAction: controller.updateListEmailAddress,
|
||||
onSuggestionEmailAddress: controller.getAutoCompleteSuggestion,
|
||||
onFocusNextAddressAction: controller.handleFocusNextAddressAction,
|
||||
onTapOutside: (_) => controller.onTapOutsideRecipients(PrefixEmailAddress.to),
|
||||
),
|
||||
if (controller.ccRecipientState.value == PrefixRecipientState.enabled)
|
||||
RecipientComposerWidget(
|
||||
@@ -279,6 +279,7 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
onUpdateListEmailAddressAction: controller.updateListEmailAddress,
|
||||
onSuggestionEmailAddress: controller.getAutoCompleteSuggestion,
|
||||
onFocusNextAddressAction: controller.handleFocusNextAddressAction,
|
||||
onTapOutside: (_) => controller.onTapOutsideRecipients(PrefixEmailAddress.cc),
|
||||
),
|
||||
if (controller.bccRecipientState.value == PrefixRecipientState.enabled)
|
||||
RecipientComposerWidget(
|
||||
@@ -299,6 +300,7 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
onUpdateListEmailAddressAction: controller.updateListEmailAddress,
|
||||
onSuggestionEmailAddress: controller.getAutoCompleteSuggestion,
|
||||
onFocusNextAddressAction: controller.handleFocusNextAddressAction,
|
||||
onTapOutside: (_) => controller.onTapOutsideRecipients(PrefixEmailAddress.bcc),
|
||||
),
|
||||
],
|
||||
)),
|
||||
@@ -308,6 +310,7 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
onTextChange: controller.setSubjectEmail,
|
||||
padding: ComposerStyle.mobileSubjectPadding,
|
||||
margin: ComposerStyle.mobileSubjectMargin,
|
||||
onTapOutside: controller.onTapOutsideSubject,
|
||||
),
|
||||
Obx(() => Center(
|
||||
child: InsertImageLoadingBarWidget(
|
||||
@@ -316,18 +319,13 @@ class ComposerView extends GetWidget<ComposerController> {
|
||||
padding: ComposerStyle.insertImageLoadingBarPadding,
|
||||
),
|
||||
)),
|
||||
Obx(() => GestureDetector(
|
||||
onTapDown: (_) {
|
||||
controller.removeFocusAllInputEditorHeader();
|
||||
},
|
||||
child: Padding(
|
||||
padding: ComposerStyle.mobileEditorPadding,
|
||||
child: MobileEditorView(
|
||||
arguments: controller.composerArguments.value,
|
||||
contentViewState: controller.emailContentsViewState.value,
|
||||
onCreatedEditorAction: controller.onCreatedMobileEditorAction,
|
||||
onLoadCompletedEditorAction: controller.onLoadCompletedMobileEditorAction,
|
||||
),
|
||||
Obx(() => Padding(
|
||||
padding: ComposerStyle.mobileEditorPadding,
|
||||
child: MobileEditorView(
|
||||
arguments: controller.composerArguments.value,
|
||||
contentViewState: controller.emailContentsViewState.value,
|
||||
onCreatedEditorAction: controller.onCreatedMobileEditorAction,
|
||||
onLoadCompletedEditorAction: controller.onLoadCompletedMobileEditorAction,
|
||||
),
|
||||
)),
|
||||
Obx(() {
|
||||
|
||||
@@ -58,6 +58,7 @@ class RecipientComposerWidget extends StatefulWidget {
|
||||
final VoidCallback? onFocusNextAddressAction;
|
||||
final EdgeInsetsGeometry? padding;
|
||||
final EdgeInsetsGeometry? margin;
|
||||
final TapRegionCallback? onTapOutside;
|
||||
|
||||
const RecipientComposerWidget({
|
||||
super.key,
|
||||
@@ -82,6 +83,7 @@ class RecipientComposerWidget extends StatefulWidget {
|
||||
this.onFocusEmailAddressChangeAction,
|
||||
this.onFocusNextAddressAction,
|
||||
this.onRemoveDraggableEmailAddressAction,
|
||||
this.onTapOutside,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -180,6 +182,7 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
||||
onDeleteTagAction: () => _handleDeleteLatestTagAction.call(stateSetter),
|
||||
onSelectOptionAction: (item) => _handleSelectOptionAction.call(item, stateSetter),
|
||||
onSubmitted: (value) => _handleSubmitTagAction.call(value, stateSetter),
|
||||
onTapOutside: widget.onTapOutside,
|
||||
inputDecoration: const InputDecoration(border: InputBorder.none),
|
||||
tagBuilder: (context, index) {
|
||||
final currentEmailAddress = _currentListEmailAddress[index];
|
||||
@@ -253,6 +256,7 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
|
||||
onDeleteTagAction: () => _handleDeleteLatestTagAction.call(stateSetter),
|
||||
onSelectOptionAction: (item) => _handleSelectOptionAction.call(item, stateSetter),
|
||||
onSubmitted: (value) => _handleSubmitTagAction.call(value, stateSetter),
|
||||
onTapOutside: widget.onTapOutside,
|
||||
inputDecoration: const InputDecoration(border: InputBorder.none),
|
||||
tagBuilder: (context, index) {
|
||||
final currentEmailAddress = _currentListEmailAddress[index];
|
||||
|
||||
@@ -11,6 +11,7 @@ class SubjectComposerWidget extends StatelessWidget {
|
||||
final ValueChanged<String>? onTextChange;
|
||||
final EdgeInsetsGeometry? margin;
|
||||
final EdgeInsetsGeometry? padding;
|
||||
final TapRegionCallback? onTapOutside;
|
||||
|
||||
const SubjectComposerWidget({
|
||||
super.key,
|
||||
@@ -19,6 +20,7 @@ class SubjectComposerWidget extends StatelessWidget {
|
||||
required this.onTextChange,
|
||||
this.margin,
|
||||
this.padding,
|
||||
this.onTapOutside,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -50,6 +52,7 @@ class SubjectComposerWidget extends StatelessWidget {
|
||||
textDirection: DirectionUtils.getDirectionByLanguage(context),
|
||||
textStyle: SubjectComposerWidgetStyle.inputTextStyle,
|
||||
controller: textController,
|
||||
onTapOutside: onTapOutside,
|
||||
)
|
||||
)
|
||||
]
|
||||
|
||||
+1
-1
@@ -1553,7 +1553,7 @@ packages:
|
||||
description:
|
||||
path: "."
|
||||
ref: master
|
||||
resolved-ref: "6e066b29659c6d3a2f20686219bb131164ab2e51"
|
||||
resolved-ref: "7a78bff62891a6bfcad08106c2e9034a2c9661d8"
|
||||
url: "https://github.com/dab246/super_tag_editor.git"
|
||||
source: git
|
||||
version: "0.2.0"
|
||||
|
||||
Reference in New Issue
Block a user