TF-56 Send email with attachment
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/email_bindings.dart';
|
||||
@@ -15,8 +16,11 @@ class MailboxDashBoardBindings extends Bindings {
|
||||
Get.lazyPut(() => CredentialRepositoryImpl(Get.find<SharedPreferences>()));
|
||||
Get.lazyPut<CredentialRepository>(() => Get.find<CredentialRepositoryImpl>());
|
||||
Get.lazyPut(() => GetUserProfileInteractor(Get.find<CredentialRepository>()));
|
||||
Get.lazyPut(() => AppToast());
|
||||
|
||||
Get.put(MailboxDashBoardController(Get.find<GetUserProfileInteractor>()));
|
||||
Get.put(MailboxDashBoardController(
|
||||
Get.find<GetUserProfileInteractor>(),
|
||||
Get.find<AppToast>()));
|
||||
|
||||
MailboxBindings().dependencies();
|
||||
ThreadBindings().dependencies();
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -6,13 +8,16 @@ import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_controller.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/state/send_email_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/email_controller.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/state/get_user_profile_state.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/usecases/get_user_profile_interactor.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
class MailboxDashBoardController extends BaseController {
|
||||
|
||||
final GetUserProfileInteractor _getUserProfileInteractor;
|
||||
final AppToast _appToast;
|
||||
|
||||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
final selectedMailbox = Rxn<PresentationMailbox>();
|
||||
@@ -23,7 +28,7 @@ class MailboxDashBoardController extends BaseController {
|
||||
Session? sessionCurrent;
|
||||
Map<Role, MailboxId> mapMailboxId = Map();
|
||||
|
||||
MailboxDashBoardController(this._getUserProfileInteractor);
|
||||
MailboxDashBoardController(this._getUserProfileInteractor, this._appToast);
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
@@ -33,14 +38,41 @@ class MailboxDashBoardController extends BaseController {
|
||||
}
|
||||
|
||||
@override
|
||||
void onDone() {
|
||||
void onData(Either<Failure, Success> newState) {
|
||||
super.onData(newState);
|
||||
viewState.value.map((success) {
|
||||
if (success is GetUserProfileSuccess) {
|
||||
userProfile.value = success.userProfile;
|
||||
if (success is SendingEmailState) {
|
||||
if (Get.context != null) {
|
||||
_appToast.showToast(AppLocalizations.of(Get.context!).your_email_being_sent);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onDone() {
|
||||
viewState.value.fold(
|
||||
(failure) {
|
||||
if (failure is SendEmailFailure) {
|
||||
if (Get.context != null) {
|
||||
_appToast.showSuccessToast(AppLocalizations.of(Get.context!).error_message_sent);
|
||||
clearState();
|
||||
}
|
||||
}
|
||||
},
|
||||
(success) {
|
||||
if (success is GetUserProfileSuccess) {
|
||||
userProfile.value = success.userProfile;
|
||||
} else if (success is SendEmailSuccess) {
|
||||
if (Get.context != null) {
|
||||
_appToast.showSuccessToast(AppLocalizations.of(Get.context!).message_sent);
|
||||
clearState();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void onError(error) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user