TF-1203 Fix can not scroll horizontal email content

This commit is contained in:
dab246
2022-11-29 13:40:28 +07:00
committed by Dat H. Pham
parent 430171de53
commit d088b8b962
6 changed files with 247 additions and 49 deletions
@@ -21,6 +21,7 @@ class EmailSupervisorController extends BaseController {
final canGetNewerEmail = true.obs;
final canGetOlderEmail = true.obs;
final supportedPageView = RxBool(true);
final scrollPhysicsPageView = Rxn<ScrollPhysics>();
Rxn<PresentationEmail> get selectedEmail => mailboxDashBoardController.selectedEmail;
Session? get sessionCurrent => mailboxDashBoardController.sessionCurrent;
@@ -34,6 +35,12 @@ class EmailSupervisorController extends BaseController {
}
}
@override
void onInit() {
super.onInit();
updateScrollPhysicPageView();
}
@override
void onClose() {
pageController?.dispose();
@@ -51,6 +58,7 @@ class EmailSupervisorController extends BaseController {
}
void onPageChanged(int index) {
updateScrollPhysicPageView();
mailboxDashBoardController.selectedEmail.value = listEmail[index];
}
@@ -61,12 +69,31 @@ class EmailSupervisorController extends BaseController {
void getNewerEmail() {
currentIndexPageView = currentIndexPageView - 1;
pageController?.jumpToPage(currentIndexPageView);
_jumpToPage();
}
void getOlderEmail() {
currentIndexPageView = currentIndexPageView + 1;
pageController?.jumpToPage(currentIndexPageView);
_jumpToPage();
}
void _jumpToPage() {
if (BuildUtils.isWeb) {
pageController?.jumpToPage(currentIndexPageView);
} else {
pageController?.animateToPage(
currentIndexPageView,
duration: const Duration(milliseconds: 500),
curve: Curves.easeInToLinear);
}
}
void updateScrollPhysicPageView({bool isScrollPageViewActivated = false}) {
if (BuildUtils.isWeb || !isScrollPageViewActivated) {
scrollPhysicsPageView.value = const NeverScrollableScrollPhysics();
} else {
scrollPhysicsPageView.value = null;
}
}
@override
@@ -1116,4 +1116,20 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
}
}
}
void toggleScrollPhysicsPagerView(bool leftDirection) {
log('SingleEmailController::toggleScrollPhysicsPagerView():leftDirection: $leftDirection');
log('SingleEmailController::toggleScrollPhysicsPagerView():canGetOlderEmail: ${emailSupervisorController.canGetOlderEmail.isTrue}');
log('SingleEmailController::toggleScrollPhysicsPagerView():canGetNewerEmail: ${emailSupervisorController.canGetNewerEmail.isTrue}');
if (leftDirection) {
if (emailSupervisorController.canGetNewerEmail.isTrue) {
emailSupervisorController.getNewerEmail();
}
} else {
if (emailSupervisorController.canGetOlderEmail.isTrue) {
emailSupervisorController.getOlderEmail();
}
}
}
}