From a2b3f49e24b24ad4e58811956594181a3779c48d Mon Sep 17 00:00:00 2001 From: dab246 Date: Wed, 20 Sep 2023 16:27:06 +0700 Subject: [PATCH] TF-2157 Remove `collapsed/expanded` signature in EmailView (cherry picked from commit c8b233e1d9e8f0b50236e36cf40fd890100851e4) --- .../utils/html_transformer/html_template.dart | 39 ---------- .../utils/html_transformer/html_utils.dart | 75 ------------------- core/lib/presentation/utils/icon_utils.dart | 8 -- .../html_content_viewer_on_web_widget.dart | 30 -------- .../html_content_viewer_widget.dart | 11 +-- 5 files changed, 2 insertions(+), 161 deletions(-) diff --git a/core/lib/presentation/utils/html_transformer/html_template.dart b/core/lib/presentation/utils/html_transformer/html_template.dart index 8b6952ceb..44e303de1 100644 --- a/core/lib/presentation/utils/html_transformer/html_template.dart +++ b/core/lib/presentation/utils/html_transformer/html_template.dart @@ -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; - } diff --git a/core/lib/presentation/utils/html_transformer/html_utils.dart b/core/lib/presentation/utils/html_transformer/html_utils.dart index 52f35b43f..eafee3a71 100644 --- a/core/lib/presentation/utils/html_transformer/html_utils.dart +++ b/core/lib/presentation/utils/html_transformer/html_utils.dart @@ -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 { '''; - 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 = ''' - - '''; - static String customCssStyleHtmlEditor({TextDirection direction = TextDirection.ltr}) { if (PlatformInfo.isWeb) { return ''' diff --git a/core/lib/presentation/utils/icon_utils.dart b/core/lib/presentation/utils/icon_utils.dart index e865d8738..49ea41ccd 100644 --- a/core/lib/presentation/utils/icon_utils.dart +++ b/core/lib/presentation/utils/icon_utils.dart @@ -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") - '''; } \ No newline at end of file diff --git a/core/lib/presentation/views/html_viewer/html_content_viewer_on_web_widget.dart b/core/lib/presentation/views/html_viewer/html_content_viewer_on_web_widget.dart index 85d0cfb5d..d753739e6 100644 --- a/core/lib/presentation/views/html_viewer/html_content_viewer_on_web_widget.dart +++ b/core/lib/presentation/views/html_viewer/html_content_viewer_on_web_widget.dart @@ -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 { 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 { 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}`; - } - } - } '''; @@ -210,7 +191,6 @@ class _HtmlContentViewerOnWebState extends State { ..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 { html.window.postMessage(jsonGetWidth, '*'); } - - void _sendMessageToWebViewForShowSignature() { - final dataShowSignature = { - 'type': 'toIframe: showSignature', - 'view' : createdViewId - }; - final jsonShowSignature = jsonEncoder.convert(dataShowSignature); - - html.window.postMessage(jsonShowSignature, '*'); - } } \ No newline at end of file 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 0d64f577e..d09c374d5 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 @@ -68,7 +68,7 @@ class _HtmlContentViewState extends State { _htmlData = generateHtml( widget.contentHtml, direction: widget.direction, - javaScripts: HtmlUtils.scriptLazyLoadImage + HtmlUtils.scriptCollapsedExpandedSignatureOnMobile, + javaScripts: HtmlUtils.scriptLazyLoadImage ); } @@ -81,7 +81,7 @@ class _HtmlContentViewState extends State { _htmlData = generateHtml( widget.contentHtml, direction: widget.direction, - javaScripts: HtmlUtils.scriptLazyLoadImage + HtmlUtils.scriptCollapsedExpandedSignatureOnMobile, + javaScripts: HtmlUtils.scriptLazyLoadImage ); } } @@ -142,7 +142,6 @@ class _HtmlContentViewState extends State { await Future.wait([ _setActualHeightView(), _setActualWidthView(), - _showSignature(), ]); _hideLoadingProgress(); @@ -207,12 +206,6 @@ class _HtmlContentViewState extends State { } } - Future _showSignature() async { - await _webViewController.evaluateJavascript( - source: 'showSignature();' - ); - } - void _hideLoadingProgress() { if (mounted && _isLoading) { setState(() {