Fix display content full screen in Email Detailed
This commit is contained in:
@@ -6,7 +6,7 @@ import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/utils/html_transformer/html_template.dart';
|
||||
import 'package:core/presentation/views/html_viewer/html_viewer_controller_for_web.dart';
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:universal_html/html.dart' as html;
|
||||
import 'package:core/presentation/utils/shims/dart_ui.dart' as ui;
|
||||
|
||||
@@ -227,7 +227,7 @@ class _HtmlContentViewerOnWebState extends State<HtmlContentViewerOnWeb> {
|
||||
width: actualWidth,
|
||||
child: _buildWebView(),
|
||||
),
|
||||
if (_isLoading) Align(alignment: Alignment.center, child: _buildLoadingView())
|
||||
if (_isLoading) Align(alignment: Alignment.topCenter, child: _buildLoadingView())
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -238,7 +238,7 @@ class _HtmlContentViewerOnWebState extends State<HtmlContentViewerOnWeb> {
|
||||
child: SizedBox(
|
||||
width: 30,
|
||||
height: 30,
|
||||
child: CircularProgressIndicator(color: AppColor.colorTextButton)));
|
||||
child: CupertinoActivityIndicator(color: AppColor.colorLoading)));
|
||||
}
|
||||
|
||||
Widget _buildWebView() {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -11,8 +12,7 @@ import 'dart:developer' as developer;
|
||||
class HtmlContentViewer extends StatefulWidget {
|
||||
|
||||
final String contentHtml;
|
||||
final double widthContent;
|
||||
final Widget? loadingWidget;
|
||||
final double heightContent;
|
||||
|
||||
/// Register this callback if you want a reference to the [WebViewController].
|
||||
final void Function(WebViewController controller)? onCreated;
|
||||
@@ -28,8 +28,7 @@ class HtmlContentViewer extends StatefulWidget {
|
||||
const HtmlContentViewer({
|
||||
Key? key,
|
||||
required this.contentHtml,
|
||||
required this.widthContent,
|
||||
this.loadingWidget,
|
||||
required this.heightContent,
|
||||
this.onCreated,
|
||||
this.urlLauncherDelegate,
|
||||
this.mailtoDelegate,
|
||||
@@ -41,8 +40,7 @@ class HtmlContentViewer extends StatefulWidget {
|
||||
|
||||
class _HtmlContentViewState extends State<HtmlContentViewer> {
|
||||
|
||||
double? _webViewHeight = 1.0;
|
||||
double? _webViewWidth = 1.0;
|
||||
late double actualHeight;
|
||||
double minHeight = 100;
|
||||
double minWidth = 300;
|
||||
String? _htmlData;
|
||||
@@ -52,7 +50,7 @@ class _HtmlContentViewState extends State<HtmlContentViewer> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_webViewWidth = widget.widthContent;
|
||||
actualHeight = widget.heightContent;
|
||||
_htmlData = _generateHtmlDocument(widget.contentHtml);
|
||||
}
|
||||
|
||||
@@ -63,29 +61,27 @@ class _HtmlContentViewState extends State<HtmlContentViewer> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: _webViewHeight,
|
||||
width: _webViewWidth,
|
||||
child: _buildWebView(),
|
||||
),
|
||||
if (_isLoading) Align(alignment: Alignment.center, child: _buildLoadingView())
|
||||
],
|
||||
);
|
||||
return LayoutBuilder(builder: (context, constraints) {
|
||||
log('_HtmlContentViewState::build(): maxWidth: ${constraints.maxWidth}');
|
||||
return Stack(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: actualHeight,
|
||||
width: constraints.maxWidth,
|
||||
child: _buildWebView()),
|
||||
if (_isLoading) Align(alignment: Alignment.center, child: _buildLoadingView())
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildLoadingView() {
|
||||
if (widget.loadingWidget != null) {
|
||||
return widget.loadingWidget!;
|
||||
} else {
|
||||
return Padding(
|
||||
return Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: SizedBox(
|
||||
width: 30,
|
||||
height: 30,
|
||||
child: CircularProgressIndicator(color: AppColor.primaryColor)));
|
||||
}
|
||||
child: CupertinoActivityIndicator(color: AppColor.colorLoading)));
|
||||
}
|
||||
|
||||
Widget _buildWebView() {
|
||||
@@ -110,7 +106,7 @@ class _HtmlContentViewState extends State<HtmlContentViewer> {
|
||||
final scrollHeightWithBuffer = scrollHeight + 30.0;
|
||||
if (scrollHeightWithBuffer > minHeight) {
|
||||
setState(() {
|
||||
_webViewHeight = scrollHeightWithBuffer;
|
||||
actualHeight = scrollHeightWithBuffer;
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user