TF-2253 Fix missing email content on mobile
(cherry picked from commit 505658435e6c835250fc218baa12df86f5234998)
This commit is contained in:
@@ -66,7 +66,12 @@ class _HtmlContentViewState extends State<HtmlContentViewer> {
|
||||
@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<HtmlContentViewer> {
|
||||
key: ValueKey(_htmlData),
|
||||
initialSettings: InAppWebViewSettings(
|
||||
transparentBackground: true,
|
||||
verticalScrollBarEnabled: false
|
||||
),
|
||||
onWebViewCreated: (controller) async {
|
||||
_webViewController = controller;
|
||||
@@ -123,14 +129,11 @@ class _HtmlContentViewState extends State<HtmlContentViewer> {
|
||||
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<HtmlContentViewer> {
|
||||
}
|
||||
|
||||
Future<void> _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<HtmlContentViewer> {
|
||||
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) {
|
||||
|
||||
@@ -121,101 +121,105 @@ class EmailView extends GetWidget<SingleEmailController> {
|
||||
}
|
||||
}),
|
||||
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<SingleEmailController> {
|
||||
required PresentationEmail presentationEmail,
|
||||
CalendarEvent? calendarEvent,
|
||||
List<String>? emailAddressSender,
|
||||
double? maxHeight,
|
||||
}) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -407,6 +412,7 @@ class EmailView extends GetWidget<SingleEmailController> {
|
||||
),
|
||||
child: HtmlContentViewer(
|
||||
contentHtml: allEmailContents,
|
||||
heightContent: maxHeight,
|
||||
mailtoDelegate: controller.openMailToLink,
|
||||
onScrollHorizontalEnd: controller.toggleScrollPhysicsPagerView,
|
||||
onWebViewLoaded: (isScrollPageViewActivated) {
|
||||
|
||||
Reference in New Issue
Block a user