TF-1330 Fix can not swipe left/right in email view on mobile
This commit is contained in:
@@ -58,6 +58,7 @@ class _HtmlContentViewState extends State<HtmlContentViewer> {
|
||||
String? _htmlData;
|
||||
late WebViewController _webViewController;
|
||||
bool _isLoading = true;
|
||||
bool horizontalGestureActivated = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -114,7 +115,10 @@ class _HtmlContentViewState extends State<HtmlContentViewer> {
|
||||
navigationDelegate: _onNavigation,
|
||||
gestureRecognizers: {
|
||||
Factory<LongPressGestureRecognizer>(() => LongPressGestureRecognizer()),
|
||||
Factory<ScaleGestureRecognizer>(() => ScaleGestureRecognizer()),
|
||||
if (Platform.isIOS && horizontalGestureActivated)
|
||||
Factory<HorizontalDragGestureRecognizer>(() => HorizontalDragGestureRecognizer()),
|
||||
if (Platform.isAndroid)
|
||||
Factory<ScaleGestureRecognizer>(() => ScaleGestureRecognizer()),
|
||||
},
|
||||
javascriptChannels: {
|
||||
JavascriptChannel(
|
||||
@@ -122,14 +126,11 @@ class _HtmlContentViewState extends State<HtmlContentViewer> {
|
||||
onMessageReceived: _onHandleScrollEvent
|
||||
)
|
||||
},
|
||||
gestureNavigationEnabled: true,
|
||||
debuggingEnabled: true,
|
||||
);
|
||||
}
|
||||
|
||||
void _onPageFinished(String url) async {
|
||||
await Future.wait([
|
||||
_webViewController.runJavascript(HtmlUtils.runScriptsHandleScrollEvent),
|
||||
_setActualHeightView(),
|
||||
_setActualWidthView(),
|
||||
]);
|
||||
@@ -183,6 +184,18 @@ class _HtmlContentViewState extends State<HtmlContentViewer> {
|
||||
if (scrollWidth != null && offsetWidth != null && mounted) {
|
||||
final isScrollActivated = scrollWidth.round() == offsetWidth.round();
|
||||
log('_HtmlContentViewState::_setActualWidthView():isScrollActivated: $isScrollActivated');
|
||||
if (isScrollActivated) {
|
||||
setState(() {
|
||||
horizontalGestureActivated = false;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
horizontalGestureActivated = true;
|
||||
});
|
||||
|
||||
await _webViewController.runJavascript(HtmlUtils.runScriptsHandleScrollEvent);
|
||||
}
|
||||
|
||||
widget.onWebViewLoaded?.call(isScrollActivated);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,13 +61,11 @@ class EmailSupervisorController extends GetxController {
|
||||
void createPageControllerAndJumpToEmailById(EmailId currentEmailId) {
|
||||
_currentEmailIndex = _currentListEmail.matchedIndex(currentEmailId);
|
||||
if (pageController != null && pageController?.hasClients == true) {
|
||||
_jumpToPage(_currentEmailIndex);
|
||||
pageController?.jumpToPage(_currentEmailIndex);
|
||||
} else {
|
||||
pageController = PageController(initialPage: _currentEmailIndex);
|
||||
}
|
||||
if (BuildUtils.isWeb) {
|
||||
_updateStatePageViewNavigator();
|
||||
}
|
||||
_updateStatePageViewNavigator();
|
||||
}
|
||||
|
||||
void onPageChanged(int index) {
|
||||
@@ -120,7 +118,7 @@ class EmailSupervisorController extends GetxController {
|
||||
pageController?.animateToPage(
|
||||
page,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
curve: Curves.easeInToLinear);
|
||||
curve: Curves.linear);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,6 @@ import 'package:tmail_ui_user/features/email/domain/usecases/mark_as_star_email_
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/move_to_mailbox_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/send_receipt_to_sender_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/model/composer_arguments.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/model/page_view_navigator_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/email_address_bottom_sheet_builder.dart';
|
||||
import 'package:tmail_ui_user/features/email/presentation/widgets/email_address_dialog_builder.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_actions.dart';
|
||||
@@ -1133,16 +1132,11 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
}
|
||||
|
||||
void toggleScrollPhysicsPagerView(bool leftDirection) {
|
||||
final navigatorState = emailSupervisorController.pageViewNavigatorState.value;
|
||||
|
||||
log('SingleEmailController::toggleScrollPhysicsPagerView():leftDirection: $leftDirection');
|
||||
if (leftDirection) {
|
||||
if (navigatorState == PageViewNavigatorState.next) {
|
||||
emailSupervisorController.moveToNextEmail();
|
||||
}
|
||||
emailSupervisorController.moveToNextEmail();
|
||||
} else {
|
||||
if (navigatorState == PageViewNavigatorState.previous) {
|
||||
emailSupervisorController.backToPreviousEmail();
|
||||
}
|
||||
emailSupervisorController.backToPreviousEmail();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user