TF-105 [BUG] Fix long line should be wrapped

This commit is contained in:
dab246
2021-10-12 16:51:30 +07:00
committed by Dat H. Pham
parent cb2c889fe2
commit dd5e8e4519
22 changed files with 243 additions and 286 deletions
@@ -1,5 +0,0 @@
class EmailConstants {
static const HTML_TEXT = 'text/html';
static const PLAIN_TEXT = 'text/plain';
}
@@ -3,7 +3,10 @@ import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:tmail_ui_user/features/composer/domain/usecases/send_email_interactor.dart';
import 'package:tmail_ui_user/features/email/data/datasource/email_datasource.dart';
import 'package:tmail_ui_user/features/email/data/datasource/html_datasource.dart';
import 'package:tmail_ui_user/features/email/data/datasource_impl/email_datasource_impl.dart';
import 'package:tmail_ui_user/features/email/data/datasource_impl/html_datasource_impl.dart';
import 'package:tmail_ui_user/features/email/data/local/html_analyzer.dart';
import 'package:tmail_ui_user/features/email/data/network/email_api.dart';
import 'package:tmail_ui_user/features/email/data/repository/email_repository_impl.dart';
import 'package:tmail_ui_user/features/email/domain/repository/email_repository.dart';
@@ -22,7 +25,11 @@ class EmailBindings extends Bindings {
void dependencies() {
Get.lazyPut(() => EmailDataSourceImpl(Get.find<EmailAPI>()));
Get.lazyPut<EmailDataSource>(() => Get.find<EmailDataSourceImpl>());
Get.lazyPut(() => EmailRepositoryImpl(Get.find<EmailDataSource>()));
Get.lazyPut(() => HtmlDataSourceImpl(Get.find<HtmlAnalyzer>()));
Get.lazyPut<HtmlDataSource>(() => Get.find<HtmlDataSourceImpl>());
Get.lazyPut(() => EmailRepositoryImpl(
Get.find<EmailDataSource>(),
Get.find<HtmlDataSource>()));
Get.lazyPut<EmailRepository>(() => Get.find<EmailRepositoryImpl>());
Get.put(SendEmailInteractor(Get.find<EmailRepository>()));
Get.lazyPut(() => GetEmailContentInteractor(Get.find<EmailRepository>()));
@@ -49,7 +49,7 @@ class EmailController extends BaseController {
final emailAddressExpandMode = ExpandMode.COLLAPSE.obs;
final attachmentsExpandMode = ExpandMode.COLLAPSE.obs;
final emailContents = <EmailContent>[].obs;
final emailContent = Rxn<EmailContent>();
final attachments = <Attachment>[].obs;
EmailId? _currentEmailId;
@@ -129,9 +129,9 @@ class EmailController extends BaseController {
}
void _getEmailContentSuccess(GetEmailContentSuccess success) {
emailContents.value = success.emailContents;
emailContent.value = success.emailContent;
attachments.value = success.attachments;
if (emailContents.isNotEmpty) {
if (emailContent.value != null && emailContent.value!.type == EmailContentType.textHtml) {
dispatchState(Right(WebViewLoadingState()));
}
}
@@ -139,7 +139,7 @@ class EmailController extends BaseController {
void _clearEmailContent() {
toggleDisplayEmailAddressAction(expandMode: ExpandMode.COLLAPSE);
attachmentsExpandMode.value = ExpandMode.COLLAPSE;
emailContents.clear();
emailContent.value = null;
attachments.clear();
}
@@ -347,24 +347,17 @@ class EmailController extends BaseController {
&& mailboxDashBoardController.selectedEmail.value != null;
void backToThreadView() {
if (emailContents.isNotEmpty) {
dispatchState(Right(WebViewLoadCompletedState()));
}
popBack();
}
void pressEmailAction(EmailActionType emailActionType) {
if (canComposeEmail()) {
if (emailContents.isNotEmpty) {
clearState();
}
push(
AppRoutes.COMPOSER,
arguments: ComposerArguments(
emailActionType: emailActionType,
presentationEmail: mailboxDashBoardController.selectedEmail.value!,
emailContents: emailContents,
emailContent: emailContent.value,
attachments: attachments,
mailboxRole: mailboxDashBoardController.selectedMailbox.value?.role,
session: mailboxDashBoardController.sessionCurrent!,
+22 -11
View File
@@ -27,11 +27,6 @@ class EmailView extends GetView {
@override
Widget build(BuildContext context) {
emailController.viewState.value.map((success) {
if (success is WebViewLoadCompletedState && emailController.emailContents.isNotEmpty) {
emailController.dispatchState(Right(WebViewLoadingState()));
}
});
return Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: AppColor.primaryLightColor,
@@ -279,11 +274,27 @@ class EmailView extends GetView {
}
Widget _buildEmailContent() {
return Obx(() => emailController.emailContents.isNotEmpty
? HtmlContentViewer(
message: emailController.emailContents.first.content,
onWebViewLoadStop: (webController, uri) => emailController.dispatchState(Right(WebViewLoadCompletedState())),
mailtoDelegate: (uri) async {})
: SizedBox.shrink());
return Obx(() {
if (emailController.emailContent.value != null) {
switch(emailController.emailContent.value!.type) {
case EmailContentType.textHtml:
return HtmlContentViewer(
contentHtml: emailController.emailContent.value!.content,
onLoadStart: (webController, uri) => emailController.dispatchState(Right(WebViewLoadingState())),
onLoadStop: (webController, uri) => emailController.dispatchState(Right(WebViewLoadCompletedState())),
mailtoDelegate: (uri) async {});
case EmailContentType.textPlain:
return Padding(
padding: EdgeInsets.only(top: 16),
child: Text(
emailController.emailContent.value!.content,
style: TextStyle(fontSize: 14, color: AppColor.nameUserColor)));
case EmailContentType.other:
return SizedBox.shrink();
}
} else {
return SizedBox.shrink();
}
});
}
}
@@ -7,7 +7,7 @@ import 'package:model/model.dart';
class ComposerArguments with EquatableMixin {
final EmailActionType emailActionType;
final PresentationEmail? presentationEmail;
final List<EmailContent>? emailContents;
final EmailContent? emailContent;
final List<Attachment>? attachments;
final Session session;
final UserProfile userProfile;
@@ -17,7 +17,7 @@ class ComposerArguments with EquatableMixin {
ComposerArguments({
this.emailActionType = EmailActionType.compose,
this.presentationEmail,
this.emailContents,
this.emailContent,
this.attachments,
this.mailboxRole,
required this.session,
@@ -29,7 +29,7 @@ class ComposerArguments with EquatableMixin {
List<Object?> get props => [
emailActionType,
presentationEmail,
emailContents,
emailContent,
attachments,
mailboxRole,
session,