diff --git a/core/lib/presentation/views/html_viewer/html_content_viewer_widget.dart b/core/lib/presentation/views/html_viewer/html_content_viewer_widget.dart index cb8fa2caa9..097432e9e1 100644 --- a/core/lib/presentation/views/html_viewer/html_content_viewer_widget.dart +++ b/core/lib/presentation/views/html_viewer/html_content_viewer_widget.dart @@ -66,7 +66,12 @@ class _HtmlContentViewState extends State { @override void initState() { super.initState(); - _actualHeight = widget.heightContent ?? _minHeight; + if (Platform.isAndroid) { + _actualHeight = widget.heightContent ?? _minHeight; + } else { + _actualHeight = _minHeight; + } + log('_HtmlContentViewState::initState():_actualHeight: $_actualHeight'); _htmlData = generateHtml( widget.contentHtml, direction: widget.direction, @@ -101,6 +106,7 @@ class _HtmlContentViewState extends State { key: ValueKey(_htmlData), initialSettings: InAppWebViewSettings( transparentBackground: true, + verticalScrollBarEnabled: false ), onWebViewCreated: (controller) async { _webViewController = controller; @@ -123,14 +129,11 @@ class _HtmlContentViewState extends State { if (_isLoading) const Align( alignment: Alignment.topCenter, - child: Padding( - padding: EdgeInsets.all(16), - child: SizedBox( - width: 30, - height: 30, - child: CupertinoActivityIndicator( - color: AppColor.colorLoading - ) + child: SizedBox( + width: 30, + height: 30, + child: CupertinoActivityIndicator( + color: AppColor.colorLoading ) ) ) @@ -179,15 +182,19 @@ class _HtmlContentViewState extends State { } Future _setActualHeightView() async { - final scrollHeight = await _webViewController.evaluateJavascript(source: 'document.body.scrollHeight'); - log('_HtmlContentViewState::_setActualHeightView():scrollHeight: $scrollHeight | type: ${scrollHeight.runtimeType}'); + if (Platform.isAndroid) { + await Future.delayed(const Duration(milliseconds: 1000)); + } + final scrollHeight = await _webViewController.getContentHeight(); + log('_HtmlContentViewState::_setActualHeightView():scrollHeight: $scrollHeight'); if (mounted && scrollHeight != null && - scrollHeight is double && scrollHeight > 0 ) { + final newHeight = scrollHeight + _offsetHeight; + log('_HtmlContentViewState::_setActualHeightView():newHeight: $newHeight'); setState(() { - _actualHeight = scrollHeight + _offsetHeight; + _actualHeight = newHeight; _isLoading = false; }); } @@ -205,8 +212,8 @@ class _HtmlContentViewState extends State { if (mounted && scrollWidth != null && offsetWidth != null && - scrollWidth is double && - offsetWidth is double + scrollWidth is num && + offsetWidth is num ) { final isScrollActivated = scrollWidth.round() == offsetWidth.round(); if (isScrollActivated) { diff --git a/lib/features/email/presentation/email_view.dart b/lib/features/email/presentation/email_view.dart index c1cc88ad0d..715dc2abeb 100644 --- a/lib/features/email/presentation/email_view.dart +++ b/lib/features/email/presentation/email_view.dart @@ -121,101 +121,105 @@ class EmailView extends GetWidget { } }), Expanded( - child: Obx(() { - if (controller.emailSupervisorController.supportedPageView.isTrue) { - final currentListEmail = controller.emailSupervisorController.currentListEmail; - return PageView.builder( - physics: controller.emailSupervisorController.scrollPhysicsPageView.value, - itemCount: currentListEmail.length, - allowImplicitScrolling: true, - controller: controller.emailSupervisorController.pageController, - onPageChanged: controller.emailSupervisorController.onPageChanged, - itemBuilder: (context, index) { - final currentEmail = currentListEmail[index]; - if (PlatformInfo.isMobile) { - return SingleChildScrollView( - physics : const ClampingScrollPhysics(), - child: Container( - width: double.infinity, - alignment: Alignment.center, - color: Colors.white, - child: Obx(() => _buildEmailMessage( - context: context, - presentationEmail: currentEmail, - calendarEvent: controller.calendarEvent.value - )) - ) - ); - } else { - return Obx(() { - final calendarEvent = controller.calendarEvent.value; - if (currentEmail.hasCalendarEvent && calendarEvent != null) { - return SingleChildScrollView( - physics : const ClampingScrollPhysics(), - child: Container( - width: double.infinity, - alignment: Alignment.center, - color: Colors.white, - child: _buildEmailMessage( - context: context, - presentationEmail: currentEmail, - calendarEvent: calendarEvent, - emailAddressSender: currentEmail.listEmailAddressSender.getListAddress(), + child: LayoutBuilder(builder: (context, constraints) { + return Obx(() { + if (controller.emailSupervisorController.supportedPageView.isTrue) { + final currentListEmail = controller.emailSupervisorController.currentListEmail; + return PageView.builder( + physics: controller.emailSupervisorController.scrollPhysicsPageView.value, + itemCount: currentListEmail.length, + allowImplicitScrolling: true, + controller: controller.emailSupervisorController.pageController, + onPageChanged: controller.emailSupervisorController.onPageChanged, + itemBuilder: (context, index) { + final currentEmail = currentListEmail[index]; + if (PlatformInfo.isMobile) { + return SingleChildScrollView( + physics : const ClampingScrollPhysics(), + child: Container( + width: double.infinity, + alignment: Alignment.center, + color: Colors.white, + child: Obx(() => _buildEmailMessage( + context: context, + presentationEmail: currentEmail, + calendarEvent: controller.calendarEvent.value, + maxHeight: constraints.maxHeight + )) + ) + ); + } else { + return Obx(() { + final calendarEvent = controller.calendarEvent.value; + if (currentEmail.hasCalendarEvent && calendarEvent != null) { + return SingleChildScrollView( + physics : const ClampingScrollPhysics(), + child: Container( + width: double.infinity, + alignment: Alignment.center, + color: Colors.white, + child: _buildEmailMessage( + context: context, + presentationEmail: currentEmail, + calendarEvent: calendarEvent, + emailAddressSender: currentEmail.listEmailAddressSender.getListAddress(), + ) ) - ) - ); - } else { - return _buildEmailMessage( - context: context, - presentationEmail: currentEmail, - ); - } - }); + ); + } else { + return _buildEmailMessage( + context: context, + presentationEmail: currentEmail, + ); + } + }); + } } - } - ); - } else { - if (PlatformInfo.isMobile) { - return SingleChildScrollView( - physics : const ClampingScrollPhysics(), - child: Container( - width: double.infinity, - alignment: Alignment.center, - color: Colors.white, - child: Obx(() => _buildEmailMessage( - context: context, - presentationEmail: currentEmail, - calendarEvent: controller.calendarEvent.value - )) - ) ); } else { - return Obx(() { - final calendarEvent = controller.calendarEvent.value; - if (currentEmail.hasCalendarEvent && calendarEvent != null) { - return SingleChildScrollView( - physics : const ClampingScrollPhysics(), - child: Container( - width: double.infinity, - alignment: Alignment.center, - color: Colors.white, - child: _buildEmailMessage( - context: context, - presentationEmail: currentEmail, - calendarEvent: calendarEvent, - emailAddressSender: currentEmail.listEmailAddressSender.getListAddress(), + if (PlatformInfo.isMobile) { + return SingleChildScrollView( + physics : const ClampingScrollPhysics(), + child: Container( + width: double.infinity, + alignment: Alignment.center, + color: Colors.white, + child: Obx(() => _buildEmailMessage( + context: context, + presentationEmail: currentEmail, + calendarEvent: controller.calendarEvent.value, + maxHeight: constraints.maxHeight + )) + ) + ); + } else { + return Obx(() { + final calendarEvent = controller.calendarEvent.value; + if (currentEmail.hasCalendarEvent && calendarEvent != null) { + return SingleChildScrollView( + physics : const ClampingScrollPhysics(), + child: Container( + width: double.infinity, + alignment: Alignment.center, + color: Colors.white, + child: _buildEmailMessage( + context: context, + presentationEmail: currentEmail, + calendarEvent: calendarEvent, + emailAddressSender: currentEmail.listEmailAddressSender.getListAddress(), + ) ) - ) - ); - } else { - return _buildEmailMessage( - context: context, - presentationEmail: currentEmail, - ); - } - }); + ); + } else { + return _buildEmailMessage( + context: context, + presentationEmail: currentEmail, + ); + } + }); + } } - } + }); }), ), EmailViewBottomBarWidget( @@ -302,6 +306,7 @@ class EmailView extends GetWidget { required PresentationEmail presentationEmail, CalendarEvent? calendarEvent, List? emailAddressSender, + double? maxHeight, }) { return Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -407,6 +412,7 @@ class EmailView extends GetWidget { ), child: HtmlContentViewer( contentHtml: allEmailContents, + heightContent: maxHeight, mailtoDelegate: controller.openMailToLink, onScrollHorizontalEnd: controller.toggleScrollPhysicsPagerView, onWebViewLoaded: (isScrollPageViewActivated) {