Skip to content

Commit

Permalink
TF-2426 Add insert link dialog to composer web
Browse files Browse the repository at this point in the history
  • Loading branch information
hieutbui authored and dab246 committed Jun 13, 2024
1 parent 42a19fd commit 50af513
Show file tree
Hide file tree
Showing 8 changed files with 259 additions and 151 deletions.
37 changes: 36 additions & 1 deletion core/lib/presentation/views/text/text_form_field_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,42 @@ class _TextFieldFormBuilderState extends State<TextFormFieldBuilder> {

@override
Widget build(BuildContext context) {
if (widget.validator != null) {
return TextFormField(
key: widget.key,
controller: _controller,
cursorColor: widget.cursorColor,
autocorrect: widget.autocorrect,
textInputAction: widget.textInputAction,
decoration: widget.decoration,
maxLines: widget.maxLines,
minLines: widget.minLines,
keyboardAppearance: widget.keyboardAppearance,
style: widget.textStyle,
obscureText: widget.obscureText,
keyboardType: widget.keyboardType,
autofocus: widget.autoFocus,
focusNode: widget.focusNode,
textDirection: _textDirection,
readOnly: widget.readOnly,
mouseCursor: widget.mouseCursor,
autofillHints: widget.autofillHints,
onChanged: (value) {
widget.onTextChange?.call(value);
if (value.isNotEmpty) {
final directionByText = DirectionUtils.getDirectionByEndsText(value);
if (directionByText != _textDirection) {
setState(() {
_textDirection = directionByText;
});
}
}
},
onFieldSubmitted: widget.onTextSubmitted,
onTap: widget.onTap,
validator: widget.validator,
);
}
return TextField(
key: widget.key,
controller: _controller,
Expand Down Expand Up @@ -111,7 +147,6 @@ class _TextFieldFormBuilderState extends State<TextFormFieldBuilder> {
},
onSubmitted: widget.onTextSubmitted,
onTap: widget.onTap,
validator: widget.validator,
);
}

Expand Down
22 changes: 22 additions & 0 deletions lib/features/composer/presentation/composer_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import 'package:tmail_ui_user/features/composer/presentation/styles/composer_sty
import 'package:tmail_ui_user/features/composer/presentation/widgets/mobile/from_composer_bottom_sheet_builder.dart';
import 'package:tmail_ui_user/features/composer/presentation/widgets/saving_message_dialog_view.dart';
import 'package:tmail_ui_user/features/composer/presentation/widgets/sending_message_dialog_view.dart';
import 'package:tmail_ui_user/features/composer/presentation/widgets/web/insert_link_dialog_widget.dart';
import 'package:tmail_ui_user/features/email/domain/exceptions/email_exceptions.dart';
import 'package:tmail_ui_user/features/email/domain/state/get_email_content_state.dart';
import 'package:tmail_ui_user/features/email/domain/state/transform_html_email_content_state.dart';
Expand Down Expand Up @@ -2167,4 +2168,25 @@ class ComposerController extends BaseController with DragDropFileMixin {
ccRecipientState.value = isEnabled ? PrefixRecipientState.disabled : PrefixRecipientState.enabled;
bccRecipientState.value = isEnabled ? PrefixRecipientState.disabled : PrefixRecipientState.enabled;
}

void onEditLinkAction(
BuildContext context,
String? text,
String? url,
bool? isOpenNewTab,
String linkTagId
) async {
Get.dialog(
PointerInterceptor(
child: InsertLinkDialogWidget(
responsiveUtils: responsiveUtils,
editorController: richTextWebController?.editorController,
linkTagId: linkTagId,
displayText: text ?? url ?? '',
link: url ?? '',
openNewTab: isOpenNewTab ?? true,
)
)
);
}
}
3 changes: 3 additions & 0 deletions lib/features/composer/presentation/composer_view_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ class ComposerView extends GetWidget<ComposerController> {
width: constraints.maxWidth,
height: constraints.maxHeight,
onDragEnter: controller.handleOnDragEnterHtmlEditorWeb,
onEditLink: (text, url, isOpenNewTab, linkTagId) => controller.onEditLinkAction(context, text, url, isOpenNewTab, linkTagId),
)),
),
),
Expand Down Expand Up @@ -432,6 +433,7 @@ class ComposerView extends GetWidget<ComposerController> {
width: constraints.maxWidth,
height: constraints.maxHeight,
onDragEnter: controller.handleOnDragEnterHtmlEditorWeb,
onEditLink: (text, url, isOpenNewTab, linkTagId) => controller.onEditLinkAction(context, text, url, isOpenNewTab, linkTagId),
);
}),
),
Expand Down Expand Up @@ -694,6 +696,7 @@ class ComposerView extends GetWidget<ComposerController> {
width: constraints.maxWidth,
height: constraints.maxHeight,
onDragEnter: controller.handleOnDragEnterHtmlEditorWeb,
onEditLink: (text, url, isOpenNewTab, linkTagId) => controller.onEditLinkAction(context, text, url, isOpenNewTab, linkTagId),
)),
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:flutter/material.dart';

class InsertLinkDialogBuilderStyle {
class InsertLinkDialogWidgetStyle {
static const double actionOverFlowButtonSpacing = 8.0;
static const double elevation = 10.0;
static const double widthRatio = 0.3;
Expand Down

This file was deleted.

Loading

0 comments on commit 50af513

Please sign in to comment.