TF-2157 Remove collapsed/expanded signature in EmailView
(cherry picked from commit c8b233e1d9e8f0b50236e36cf40fd890100851e4)
This commit is contained in:
@@ -53,45 +53,6 @@ String generateHtml(String content, {
|
||||
}
|
||||
''' : ''}
|
||||
${styleCSS ?? ''}
|
||||
|
||||
.tmail-signature {
|
||||
text-align: ${direction == TextDirection.rtl ? 'right' : 'left'};
|
||||
margin: 16px 0px 16px 0px;
|
||||
}
|
||||
|
||||
.tmail-signature-button,
|
||||
.tmail-signature-button * {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.tmail-signature-button {
|
||||
padding: 6px 40px 6px 16px;
|
||||
border-radius: 4px;
|
||||
color: #fff;
|
||||
background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10.0003 11.8319L5.53383 8.1098C5.18027 7.81516 4.6548 7.86293 4.36016 8.21649C4.06553 8.57006 4.1133 9.09553 4.46686 9.39016L9.46686 13.5568C9.7759 13.8144 10.2248 13.8144 10.5338 13.5568L15.5338 9.39016C15.8874 9.09553 15.9352 8.57006 15.6405 8.21649C15.3459 7.86293 14.8204 7.81516 14.4669 8.1098L10.0003 11.8319Z' fill='%23AEAEC0'/%3E%3C/svg%3E%0A");
|
||||
background-repeat: no-repeat;
|
||||
background-position: right 16px center;
|
||||
background-color: #FFFFFF;
|
||||
border-radius: 36px;
|
||||
border-style: solid;
|
||||
border-color: var(--m-3-syslight-outline-shadow-outline-variant, #cac4d0);
|
||||
border-width: 0.5px;
|
||||
flex-direction: row;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
flex-shrink: 0;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
color: var(--m-3-syslight-tetirary-tertiary, #8c9caf);
|
||||
text-align: left;
|
||||
font: var(--m-3-body-large-2, 400 17px/24px "Inter", sans-serif);
|
||||
}
|
||||
|
||||
.tmail-signature-content {
|
||||
padding: 12px;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body ${direction == TextDirection.rtl ? 'dir="rtl"' : ''} style = "overflow-x: hidden">
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
|
||||
import 'package:core/presentation/utils/html_transformer/html_event_action.dart';
|
||||
import 'package:core/presentation/utils/icon_utils.dart';
|
||||
import 'package:core/utils/platform_info.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -95,80 +94,6 @@ class HtmlUtils {
|
||||
</script>
|
||||
''';
|
||||
|
||||
static const runScriptsCollapsedExpandedSignature = '''
|
||||
const signatureNode = document.querySelector('.tmail-content > .tmail-signature');
|
||||
if (signatureNode) {
|
||||
const signatureContainer = document.createElement('div');
|
||||
signatureContainer.setAttribute('class', 'tmail-signature');
|
||||
|
||||
const signatureContent = document.createElement('div');
|
||||
signatureContent.setAttribute('class', 'tmail-signature-content');
|
||||
signatureContent.innerHTML = signatureNode.innerHTML;
|
||||
signatureContent.style.display = 'none';
|
||||
|
||||
const signatureButton = document.createElement('button');
|
||||
signatureButton.setAttribute('class', 'tmail-signature-button');
|
||||
signatureButton.textContent = 'Signature';
|
||||
signatureButton.style.backgroundImage = `${IconUtils.chevronDownSVGIconUrlEncoded}`;
|
||||
signatureButton.setAttribute('onclick', 'handleOnClickSignature()');
|
||||
|
||||
signatureContainer.appendChild(signatureButton);
|
||||
signatureContainer.appendChild(signatureContent);
|
||||
|
||||
if (signatureNode.outerHTML) {
|
||||
signatureNode.outerHTML = signatureContainer.outerHTML;
|
||||
} else {
|
||||
signatureNode.parentNode.replaceChild(signatureContainer, signatureNode);
|
||||
}
|
||||
}
|
||||
''';
|
||||
|
||||
static const scriptCollapsedExpandedSignatureOnMobile = '''
|
||||
<script type="text/javascript">
|
||||
function showSignature() {
|
||||
const signatureNode = document.querySelector('.tmail-content > .tmail-signature');
|
||||
if (signatureNode) {
|
||||
const signatureContainer = document.createElement('div');
|
||||
signatureContainer.setAttribute('class', 'tmail-signature');
|
||||
|
||||
const signatureContent = document.createElement('div');
|
||||
signatureContent.setAttribute('class', 'tmail-signature-content');
|
||||
signatureContent.innerHTML = signatureNode.innerHTML;
|
||||
signatureContent.style.display = 'none';
|
||||
|
||||
const signatureButton = document.createElement('button');
|
||||
signatureButton.setAttribute('class', 'tmail-signature-button');
|
||||
signatureButton.textContent = 'Signature';
|
||||
signatureButton.style.backgroundImage = `${IconUtils.chevronDownSVGIconUrlEncoded}`;
|
||||
signatureButton.setAttribute('onclick', 'handleOnClickSignature()');
|
||||
|
||||
signatureContainer.appendChild(signatureButton);
|
||||
signatureContainer.appendChild(signatureContent);
|
||||
|
||||
if (signatureNode.outerHTML) {
|
||||
signatureNode.outerHTML = signatureContainer.outerHTML;
|
||||
} else {
|
||||
signatureNode.parentNode.replaceChild(signatureContainer, signatureNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleOnClickSignature() {
|
||||
const contentElement = document.querySelector('.tmail-content > .tmail-signature > .tmail-signature-content');
|
||||
const buttonElement = document.querySelector('.tmail-content > .tmail-signature > .tmail-signature-button');
|
||||
if (contentElement && buttonElement) {
|
||||
if (contentElement.style.display === 'block') {
|
||||
contentElement.style.display = 'none';
|
||||
buttonElement.style.backgroundImage = `${IconUtils.chevronDownSVGIconUrlEncoded}`;
|
||||
} else {
|
||||
contentElement.style.display = 'block';
|
||||
buttonElement.style.backgroundImage = `${IconUtils.chevronUpSVGIconUrlEncoded}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
''';
|
||||
|
||||
static String customCssStyleHtmlEditor({TextDirection direction = TextDirection.ltr}) {
|
||||
if (PlatformInfo.isWeb) {
|
||||
return '''
|
||||
|
||||
@@ -3,12 +3,4 @@ import 'package:core/utils/platform_info.dart';
|
||||
|
||||
class IconUtils {
|
||||
static const double defaultIconSize = PlatformInfo.isWeb ? 20.0 : 24.0;
|
||||
|
||||
static const String chevronUpSVGIconUrlEncoded = '''
|
||||
url("data:image/svg+xml,%3Csvg class='chevron-down' width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath d='M14.5352 11.9709C14.8347 12.2276 15.2857 12.193 15.5424 11.8934C15.7991 11.5939 15.7644 11.143 15.4649 10.8863L10.4649 6.60054C10.1974 6.37127 9.8027 6.37127 9.53521 6.60054L4.53521 10.8863C4.23569 11.143 4.201 11.5939 4.45773 11.8934C4.71446 12.193 5.16539 12.2276 5.46491 11.9709L10.0001 8.08364L14.5352 11.9709Z' fill='%23AEAEC0' /%3E%3C/svg%3E")
|
||||
''';
|
||||
|
||||
static const String chevronDownSVGIconUrlEncoded = '''
|
||||
url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10.0003 11.8319L5.53383 8.1098C5.18027 7.81516 4.6548 7.86293 4.36016 8.21649C4.06553 8.57006 4.1133 9.09553 4.46686 9.39016L9.46686 13.5568C9.7759 13.8144 10.2248 13.8144 10.5338 13.5568L15.5338 9.39016C15.8874 9.09553 15.9352 8.57006 15.6405 8.21649C15.3459 7.86293 14.8204 7.81516 14.4669 8.1098L10.0003 11.8319Z' fill='%23AEAEC0'/%3E%3C/svg%3E%0A")
|
||||
''';
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import 'dart:math' as math;
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:core/presentation/utils/html_transformer/html_template.dart';
|
||||
import 'package:core/presentation/utils/html_transformer/html_utils.dart';
|
||||
import 'package:core/presentation/utils/icon_utils.dart';
|
||||
import 'package:core/presentation/views/html_viewer/html_viewer_controller_for_web.dart';
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
@@ -103,10 +102,6 @@ class _HtmlContentViewerOnWebState extends State<HtmlContentViewerOnWeb> {
|
||||
if (e && e.data && e.data.includes("toIframe:")) {
|
||||
var data = JSON.parse(e.data);
|
||||
if (data["view"].includes("$createdViewId")) {
|
||||
if (data["type"].includes("showSignature")) {
|
||||
${HtmlUtils.runScriptsCollapsedExpandedSignature}
|
||||
}
|
||||
|
||||
if (data["type"].includes("getHeight")) {
|
||||
var height = document.body.scrollHeight;
|
||||
window.parent.postMessage(JSON.stringify({"view": "$createdViewId", "type": "toDart: htmlHeight", "height": height}), "*");
|
||||
@@ -149,20 +144,6 @@ class _HtmlContentViewerOnWebState extends State<HtmlContentViewerOnWeb> {
|
||||
|
||||
return url.protocol === "mailto:";
|
||||
}
|
||||
|
||||
function handleOnClickSignature() {
|
||||
const contentElement = document.querySelector('.tmail-content > .tmail-signature > .tmail-signature-content');
|
||||
const buttonElement = document.querySelector('.tmail-content > .tmail-signature > .tmail-signature-button');
|
||||
if (contentElement && buttonElement) {
|
||||
if (contentElement.style.display === 'block') {
|
||||
contentElement.style.display = 'none';
|
||||
buttonElement.style.backgroundImage = `${IconUtils.chevronDownSVGIconUrlEncoded}`;
|
||||
} else {
|
||||
contentElement.style.display = 'block';
|
||||
buttonElement.style.backgroundImage = `${IconUtils.chevronUpSVGIconUrlEncoded}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
''';
|
||||
|
||||
@@ -210,7 +191,6 @@ class _HtmlContentViewerOnWebState extends State<HtmlContentViewerOnWeb> {
|
||||
..onLoad.listen((event) async {
|
||||
_sendMessageToWebViewForGetHeight();
|
||||
_sendMessageToWebViewForGetWidth();
|
||||
_sendMessageToWebViewForShowSignature();
|
||||
|
||||
html.window.onMessage.listen((event) {
|
||||
var data = json.decode(event.data);
|
||||
@@ -328,14 +308,4 @@ class _HtmlContentViewerOnWebState extends State<HtmlContentViewerOnWeb> {
|
||||
|
||||
html.window.postMessage(jsonGetWidth, '*');
|
||||
}
|
||||
|
||||
void _sendMessageToWebViewForShowSignature() {
|
||||
final dataShowSignature = <String, Object>{
|
||||
'type': 'toIframe: showSignature',
|
||||
'view' : createdViewId
|
||||
};
|
||||
final jsonShowSignature = jsonEncoder.convert(dataShowSignature);
|
||||
|
||||
html.window.postMessage(jsonShowSignature, '*');
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class _HtmlContentViewState extends State<HtmlContentViewer> {
|
||||
_htmlData = generateHtml(
|
||||
widget.contentHtml,
|
||||
direction: widget.direction,
|
||||
javaScripts: HtmlUtils.scriptLazyLoadImage + HtmlUtils.scriptCollapsedExpandedSignatureOnMobile,
|
||||
javaScripts: HtmlUtils.scriptLazyLoadImage
|
||||
);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ class _HtmlContentViewState extends State<HtmlContentViewer> {
|
||||
_htmlData = generateHtml(
|
||||
widget.contentHtml,
|
||||
direction: widget.direction,
|
||||
javaScripts: HtmlUtils.scriptLazyLoadImage + HtmlUtils.scriptCollapsedExpandedSignatureOnMobile,
|
||||
javaScripts: HtmlUtils.scriptLazyLoadImage
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -142,7 +142,6 @@ class _HtmlContentViewState extends State<HtmlContentViewer> {
|
||||
await Future.wait([
|
||||
_setActualHeightView(),
|
||||
_setActualWidthView(),
|
||||
_showSignature(),
|
||||
]);
|
||||
|
||||
_hideLoadingProgress();
|
||||
@@ -207,12 +206,6 @@ class _HtmlContentViewState extends State<HtmlContentViewer> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _showSignature() async {
|
||||
await _webViewController.evaluateJavascript(
|
||||
source: 'showSignature();'
|
||||
);
|
||||
}
|
||||
|
||||
void _hideLoadingProgress() {
|
||||
if (mounted && _isLoading) {
|
||||
setState(() {
|
||||
|
||||
Reference in New Issue
Block a user