TF-996: add previous / Next message of a mailbox on Web

This commit is contained in:
ManhNTX
2022-10-27 18:02:00 +07:00
committed by Dat H. Pham
parent bc102dd9ec
commit 8a931019ed
8 changed files with 90 additions and 4 deletions
@@ -93,6 +93,9 @@ class EmailController extends BaseController with AppLoaderMixin {
late Worker emailWorker;
final Map<EmailId, EmailLoaded> presentationEmailsLoaded = {};
PageController? pageController;
int currentIndexPageView = 0;
final canGetNewerEmail = true.obs;
final canGetOlderEmail = true.obs;
final StreamController<Either<Failure, Success>> _downloadProgressStateController =
StreamController<Either<Failure, Success>>.broadcast();
Stream<Either<Failure, Success>> get downloadProgressState => _downloadProgressStateController.stream;
@@ -144,12 +147,29 @@ class EmailController extends BaseController with AppLoaderMixin {
void _setCurrentPositionEmailInListEmail() {
pageController ??= PageController(initialPage: mailboxDashBoardController.emailList.indexOf(mailboxDashBoardController.selectedEmail.value));
currentIndexPageView = mailboxDashBoardController.emailList.indexOf(mailboxDashBoardController.selectedEmail.value);
_checkEnableNavigatorPageView();
}
void onPageChanged(int index) {
mailboxDashBoardController.selectedEmail.value = mailboxDashBoardController.emailList[index];
}
void _checkEnableNavigatorPageView() {
canGetNewerEmail.value = currentIndexPageView > 0;
canGetOlderEmail.value = mailboxDashBoardController.emailList.length > 1 && currentIndexPageView < mailboxDashBoardController.emailList.length - 1;
}
void getNewerEmail() {
currentIndexPageView = currentIndexPageView - 1;
pageController?.jumpToPage(currentIndexPageView);
}
void getOlderEmail() {
currentIndexPageView = currentIndexPageView + 1;
pageController?.jumpToPage(currentIndexPageView);
}
void _initWorker() {
emailWorker = ever(mailboxDashBoardController.selectedEmail, (presentationEmail) {
log('EmailController::_initWorker(): $presentationEmail');