TF-1512 Only use HtmlViewer to display signatures (for both html/text or plain/text formats)
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
|
||||
import 'package:jmap_dart_client/jmap/identities/identity.dart';
|
||||
|
||||
extension IdentityExtension on Identity {
|
||||
|
||||
String get signatureAsString {
|
||||
if (htmlSignature?.value.isNotEmpty == true) {
|
||||
return htmlSignature!.value;
|
||||
} else if (textSignature?.value.isNotEmpty == true) {
|
||||
return textSignature!.value;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -6,7 +6,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get_state_manager/get_state_manager.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/profiles/identities/identities_controller.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/profiles/identities/widgets/identity_list_tile_builder.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/profiles/identities/widgets/signature_of_identity_builder.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/profiles/identities/widgets/signature_builder.dart';
|
||||
|
||||
class IdentitiesRadioListBuilder extends StatelessWidget {
|
||||
|
||||
@@ -46,7 +46,7 @@ class IdentitiesRadioListBuilder extends StatelessWidget {
|
||||
...[
|
||||
_buildListIdentityView(context),
|
||||
Container(height: 1, color: AppColor.attachmentFileBorderColor),
|
||||
Obx(() => SignatureOfIdentityBuilder(identity: controller.identitySelected.value!))
|
||||
Obx(() => SignatureBuilder(identity: controller.identitySelected.value!))
|
||||
]
|
||||
else
|
||||
_buildListIdentityView(context)
|
||||
@@ -63,7 +63,7 @@ class IdentitiesRadioListBuilder extends StatelessWidget {
|
||||
_buildListIdentityView(context),
|
||||
Container(width: 1, color: AppColor.attachmentFileBorderColor),
|
||||
Expanded(
|
||||
child: Obx(() => SignatureOfIdentityBuilder(identity: controller.identitySelected.value!)),
|
||||
child: Obx(() => SignatureBuilder(identity: controller.identitySelected.value!)),
|
||||
)
|
||||
]
|
||||
else
|
||||
|
||||
+22
-22
@@ -1,38 +1,36 @@
|
||||
import 'package:core/presentation/views/html_viewer/html_content_viewer_on_web_widget.dart';
|
||||
import 'package:core/presentation/views/html_viewer/html_content_viewer_widget.dart';
|
||||
import 'package:core/presentation/views/html_viewer/html_viewer_controller_for_web.dart';
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:core/utils/build_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:html_unescape/html_unescape_small.dart';
|
||||
import 'package:jmap_dart_client/jmap/identities/identity.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/extensions/identity_extension.dart';
|
||||
|
||||
class SignatureBuilder extends StatelessWidget {
|
||||
|
||||
const SignatureBuilder({
|
||||
Key? key,
|
||||
required this.identity,
|
||||
this.width,
|
||||
this.height,
|
||||
this.htmlSignature,
|
||||
this.textSignature,
|
||||
this.height = 256
|
||||
}) : super(key: key);
|
||||
|
||||
final Signature? htmlSignature;
|
||||
final Signature? textSignature;
|
||||
final Identity identity;
|
||||
final double? width;
|
||||
final double? height;
|
||||
final double height;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final signatureWidth = width ?? constraints.biggest.width;
|
||||
final signatureHeight = height ?? constraints.biggest.height;
|
||||
final signatureHeight = height;
|
||||
return Container(
|
||||
width: signatureWidth,
|
||||
color: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 16.0),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
),
|
||||
child: _buildSignature(signatureWidth, signatureHeight),
|
||||
);
|
||||
}
|
||||
@@ -40,25 +38,27 @@ class SignatureBuilder extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildSignature(double width, double height) {
|
||||
Widget signature;
|
||||
if (htmlSignature != null && htmlSignature!.value.isNotEmpty) {
|
||||
final htmlSignatureDecoded = _decodeHtml(htmlSignature!.value);
|
||||
final signature = identity.signatureAsString;
|
||||
log('SignatureBuilder::_buildSignature():signature: $signature');
|
||||
if (signature.isNotEmpty) {
|
||||
final htmlSignatureDecoded = _decodeHtml(signature);
|
||||
if (BuildUtils.isWeb) {
|
||||
signature = HtmlContentViewerOnWeb(
|
||||
return HtmlContentViewerOnWeb(
|
||||
contentHtml: htmlSignatureDecoded,
|
||||
widthContent: width,
|
||||
heightContent: height,
|
||||
widthContent: width,
|
||||
heightContent: height,
|
||||
controller: HtmlViewerControllerForWeb(),
|
||||
allowResizeToDocumentSize: false);
|
||||
allowResizeToDocumentSize: false
|
||||
);
|
||||
} else {
|
||||
signature = HtmlContentViewer(contentHtml: htmlSignatureDecoded, heightContent: height);
|
||||
return HtmlContentViewer(
|
||||
contentHtml: htmlSignatureDecoded,
|
||||
heightContent: height
|
||||
);
|
||||
}
|
||||
} else if (textSignature != null) {
|
||||
signature = Text(textSignature!.value);
|
||||
} else {
|
||||
signature = SizedBox.fromSize(size: Size(width, height));
|
||||
return SizedBox(width: width, height: height);
|
||||
}
|
||||
return signature;
|
||||
}
|
||||
|
||||
String _decodeHtml(String htmlString) {
|
||||
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:jmap_dart_client/jmap/identities/identity.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/profiles/identities/widgets/signature_builder.dart';
|
||||
|
||||
class SignatureOfIdentityBuilder extends StatelessWidget {
|
||||
|
||||
const SignatureOfIdentityBuilder({Key? key, required this.identity}) : super(key: key);
|
||||
|
||||
final Identity identity;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SignatureBuilder(
|
||||
height: 256,
|
||||
htmlSignature: identity.htmlSignature,
|
||||
textSignature: identity.textSignature
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user