Skip to content

Commit

Permalink
Add ValueKey to compose email flow
Browse files Browse the repository at this point in the history
  • Loading branch information
tddang-linagora committed Aug 26, 2024
1 parent a70f118 commit 9587853
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 8 deletions.
8 changes: 8 additions & 0 deletions lib/features/base/key_values/composer_key_values.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class ComposerKeyValues {
static const String openComposerButton = 'tmail_open_composer_button';
static const String composerView = 'tmail_composer_view';
static const String composerToField = 'tmail_composer_to_field';
static const String composerSubjectField = 'tmail_composer_subject_field';
static const String composerContentField = 'tmail_composer_content_field';
static const String composerSendButton = 'tmail_composer_send_button';
}
6 changes: 6 additions & 0 deletions lib/features/base/key_values/login_key_values.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class LoginKeyValues {
static const String loginView = 'tmail_login_view';
static const String loginEmailField = 'tmail_login_email_field';
static const String loginHostUrlField = 'tmail_login_host_url_field';
static const String loginNextButton = 'tmail_login_next_button';
}
10 changes: 10 additions & 0 deletions lib/features/composer/presentation/composer_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import 'package:model/email/prefix_email_address.dart';
import 'package:tmail_ui_user/features/base/key_values/composer_key_values.dart';
import 'package:tmail_ui_user/features/base/widget/popup_item_widget.dart';
import 'package:tmail_ui_user/features/composer/presentation/composer_controller.dart';
import 'package:tmail_ui_user/features/composer/presentation/model/prefix_recipient_state.dart';
Expand Down Expand Up @@ -48,6 +49,7 @@ class ComposerView extends GetWidget<ComposerController> {
children: [
if (controller.responsiveUtils.isLandscapeMobile(context))
Obx(() => LandscapeAppBarComposerWidget(
key: const ValueKey(ComposerKeyValues.composerSendButton),
isSendButtonEnabled: controller.isEnableEmailSendButton.value,
onCloseViewAction: () => controller.handleClickCloseComposer(context),
sendMessageAction: () => controller.handleClickSendButton(context),
Expand All @@ -73,6 +75,7 @@ class ComposerView extends GetWidget<ComposerController> {
))
else
Obx(() => AppBarComposerWidget(
key: const ValueKey(ComposerKeyValues.composerSendButton),
isSendButtonEnabled: controller.isEnableEmailSendButton.value,
onCloseViewAction: () => controller.handleClickCloseComposer(context),
sendMessageAction: () => controller.handleClickSendButton(context),
Expand Down Expand Up @@ -120,6 +123,7 @@ class ComposerView extends GetWidget<ComposerController> {
}
}),
Obx(() => RecipientComposerWidget(
key: const ValueKey(ComposerKeyValues.composerToField),
prefix: PrefixEmailAddress.to,
listEmailAddress: controller.listToEmailAddress,
imagePaths: controller.imagePaths,
Expand Down Expand Up @@ -196,6 +200,7 @@ class ComposerView extends GetWidget<ComposerController> {
}
}),
SubjectComposerWidget(
key: const ValueKey(ComposerKeyValues.composerSubjectField),
focusNode: controller.subjectEmailInputFocusNode,
textController: controller.subjectEmailInputController,
onTextChange: controller.setSubjectEmail,
Expand All @@ -222,6 +227,7 @@ class ComposerView extends GetWidget<ComposerController> {
Obx(() => Padding(
padding: ComposerStyle.mobileEditorPadding,
child: MobileEditorView(
key: const ValueKey(ComposerKeyValues.composerContentField),
arguments: controller.composerArguments.value,
contentViewState: controller.emailContentsViewState.value,
onCreatedEditorAction: controller.onCreatedMobileEditorAction,
Expand Down Expand Up @@ -276,6 +282,7 @@ class ComposerView extends GetWidget<ComposerController> {
onChangeIdentity: controller.onChangeIdentity,
),
RecipientComposerWidget(
key: const ValueKey(ComposerKeyValues.composerToField),
prefix: PrefixEmailAddress.to,
listEmailAddress: controller.listToEmailAddress,
imagePaths: controller.imagePaths,
Expand Down Expand Up @@ -344,6 +351,7 @@ class ComposerView extends GetWidget<ComposerController> {
],
)),
SubjectComposerWidget(
key: const ValueKey(ComposerKeyValues.composerSubjectField),
focusNode: controller.subjectEmailInputFocusNode,
textController: controller.subjectEmailInputController,
onTextChange: controller.setSubjectEmail,
Expand All @@ -370,6 +378,7 @@ class ComposerView extends GetWidget<ComposerController> {
Obx(() => Padding(
padding: ComposerStyle.mobileEditorPadding,
child: MobileEditorView(
key: const ValueKey(ComposerKeyValues.composerContentField),
arguments: controller.composerArguments.value,
contentViewState: controller.emailContentsViewState.value,
onCreatedEditorAction: controller.onCreatedMobileEditorAction,
Expand All @@ -382,6 +391,7 @@ class ComposerView extends GetWidget<ComposerController> {
)
),
Obx(() => TabletBottomBarComposerWidget(
key: const ValueKey(ComposerKeyValues.composerSendButton),
hasReadReceipt: controller.hasRequestReadReceipt.value,
deleteComposerAction: () => controller.handleClickDeleteComposer(context),
saveToDraftAction: () => controller.handleClickSaveAsDraftsButton(context),
Expand Down
5 changes: 4 additions & 1 deletion lib/features/login/presentation/login_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:core/presentation/utils/theme_utils.dart';
import 'package:core/presentation/views/text/type_ahead_form_field_builder.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tmail_ui_user/features/base/key_values/login_key_values.dart';
import 'package:tmail_ui_user/features/base/widget/recent_item_tile_widget.dart';
import 'package:tmail_ui_user/features/login/domain/model/recent_login_url.dart';
import 'package:tmail_ui_user/features/login/presentation/base_login_view.dart';
Expand Down Expand Up @@ -89,6 +90,7 @@ class LoginView extends BaseLoginView {
switch (controller.loginFormType.value) {
case LoginFormType.dnsLookupForm:
return DNSLookupInputForm(
key: const ValueKey(LoginKeyValues.loginEmailField),
textEditingController: controller.usernameInputController,
onTextChange: controller.onUsernameChange,
onTextSubmitted: (_) => controller.invokeDNSLookupToGetJmapUrl(),
Expand Down Expand Up @@ -126,6 +128,7 @@ class LoginView extends BaseLoginView {
return Padding(
padding: const EdgeInsets.only(right: 24, left: 24, bottom: 24),
child: TypeAheadFormFieldBuilder<RecentLoginUrl>(
key: const ValueKey(LoginKeyValues.loginHostUrlField),
controller: controller.urlInputController,
textInputAction: TextInputAction.next,
keyboardType: TextInputType.url,
Expand Down Expand Up @@ -161,7 +164,7 @@ class LoginView extends BaseLoginView {
margin: const EdgeInsets.only(bottom: 16, left: 24, right: 24),
width: controller.responsiveUtils.getDeviceWidth(context),height: 48,
child: ElevatedButton(
key: const Key('nextToCredentialForm'),
key: const ValueKey(LoginKeyValues.loginNextButton),
style: ElevatedButton.styleFrom(
foregroundColor: Colors.white,
backgroundColor: AppColor.primaryColor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import 'package:model/model.dart';
import 'package:pointer_interceptor/pointer_interceptor.dart';
import 'package:rxdart/transformers.dart';
import 'package:tmail_ui_user/features/base/action/ui_action.dart';
import 'package:tmail_ui_user/features/base/key_values/composer_key_values.dart';
import 'package:tmail_ui_user/features/base/reloadable/reloadable_controller.dart';
import 'package:tmail_ui_user/features/base/state/button_state.dart';
import 'package:tmail_ui_user/features/composer/domain/exceptions/set_method_exception.dart';
Expand Down Expand Up @@ -1430,7 +1431,7 @@ class MailboxDashBoardController extends ReloadableController with UserSettingPo
}

result = await Get.to(
() => const ComposerView(),
() => const ComposerView(key: ValueKey(ComposerKeyValues.composerView)),
binding: ComposerBindings(),
opaque: false,
arguments: argumentsWithIdentity);
Expand Down
2 changes: 2 additions & 0 deletions lib/features/thread/presentation/thread_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
import 'package:model/model.dart';
import 'package:tmail_ui_user/features/base/key_values/composer_key_values.dart';
import 'package:tmail_ui_user/features/base/mixin/app_loader_mixin.dart';
import 'package:tmail_ui_user/features/base/mixin/popup_menu_widget_mixin.dart';
import 'package:tmail_ui_user/features/base/widget/compose_floating_button.dart';
Expand Down Expand Up @@ -281,6 +282,7 @@ class ThreadView extends GetWidget<ThreadController>
? EdgeInsets.only(bottom: controller.responsiveUtils.isTabletLarge(context) ? 85 : 70)
: EdgeInsets.zero,
child: ComposeFloatingButton(
key: const ValueKey(ComposerKeyValues.openComposerButton),
scrollController: controller.listEmailController,
onTap: () => controller.mailboxDashBoardController.goToComposer(ComposerArguments())
),
Expand Down
5 changes: 1 addition & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:core/presentation/utils/theme_utils.dart';
import 'package:core/utils/app_logger.dart';
import 'package:core/utils/platform_info.dart';
import 'package:flutter/material.dart';
import 'package:flutter/semantics.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
Expand All @@ -19,9 +18,7 @@ import 'package:worker_manager/worker_manager.dart';
void main() async {
initLogger(() async {
WidgetsFlutterBinding.ensureInitialized();
if (PlatformInfo.isWeb) {
SemanticsBinding.instance.ensureSemantics();
}
SemanticsBinding.instance.ensureSemantics();
ThemeUtils.setSystemLightUIStyle();

await Future.wait([
Expand Down
9 changes: 7 additions & 2 deletions lib/main/pages/app_pages.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import 'dart:io';

import 'package:core/core.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_navigation/src/routes/get_route.dart';
import 'package:tmail_ui_user/features/base/key_values/composer_key_values.dart';
import 'package:tmail_ui_user/features/base/key_values/login_key_values.dart';
import 'package:tmail_ui_user/features/composer/presentation/composer_bindings.dart';
import 'package:tmail_ui_user/features/composer/presentation/composer_view.dart' deferred as composer;
import 'package:tmail_ui_user/features/contact/presentation/contact_bindings.dart';
Expand Down Expand Up @@ -43,7 +46,9 @@ class AppPages {
binding: HomeBindings()),
GetPage(
name: AppRoutes.login,
page: () => DeferredWidget(login.loadLibrary, () => login.LoginView()),
page: () => DeferredWidget(login.loadLibrary, () => login.LoginView(
key: const ValueKey(LoginKeyValues.loginView),
)),
binding: LoginBindings()),
GetPage(
name: AppRoutes.dashboard,
Expand Down Expand Up @@ -87,7 +92,7 @@ class AppPages {
name: AppRoutes.composer,
page: () => DeferredWidget(
composer.loadLibrary,
() => composer.ComposerView()),
() => composer.ComposerView(key: const ValueKey(ComposerKeyValues.composerView))),
binding: ComposerBindings()),
GetPage(
name: AppRoutes.destinationPicker,
Expand Down

0 comments on commit 9587853

Please sign in to comment.