TF-2427: Update height of body composer when changing screen size
This commit is contained in:
@@ -55,17 +55,21 @@ class _WebEditorState extends State<WebEditorWidget> {
|
|||||||
|
|
||||||
static const double _offsetHeight = 50;
|
static const double _offsetHeight = 50;
|
||||||
static const double _offsetWidth = 90;
|
static const double _offsetWidth = 90;
|
||||||
|
static const double _defaultHtmlEditorHeight = 550;
|
||||||
|
|
||||||
late HtmlEditorController _editorController;
|
late HtmlEditorController _editorController;
|
||||||
double? dropZoneWidth;
|
double? dropZoneWidth;
|
||||||
double? dropZoneHeight;
|
double? dropZoneHeight;
|
||||||
|
final ValueNotifier<double> _htmlEditorHeight = ValueNotifier(_defaultHtmlEditorHeight);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_editorController = widget.editorController;
|
_editorController = widget.editorController;
|
||||||
|
log('_WebEditorState::initState:height: ${widget.height} | width: ${widget.width}');
|
||||||
if (widget.height != null) {
|
if (widget.height != null) {
|
||||||
dropZoneHeight = widget.height! - _offsetHeight;
|
dropZoneHeight = widget.height! - _offsetHeight;
|
||||||
|
_htmlEditorHeight.value = widget.height ?? _defaultHtmlEditorHeight;
|
||||||
}
|
}
|
||||||
if (widget.width != null) {
|
if (widget.width != null) {
|
||||||
dropZoneWidth = widget.width! - _offsetWidth;
|
dropZoneWidth = widget.width! - _offsetWidth;
|
||||||
@@ -79,13 +83,28 @@ class _WebEditorState extends State<WebEditorWidget> {
|
|||||||
if (oldWidget.direction != widget.direction) {
|
if (oldWidget.direction != widget.direction) {
|
||||||
_editorController.updateBodyDirection(widget.direction.name);
|
_editorController.updateBodyDirection(widget.direction.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log('_EmailEditorState::didUpdateWidget():Old: ${oldWidget.height} | current: ${widget.height}');
|
||||||
|
|
||||||
|
if (oldWidget.height != widget.height) {
|
||||||
|
_htmlEditorHeight.value = widget.height ?? _defaultHtmlEditorHeight;
|
||||||
|
}
|
||||||
super.didUpdateWidget(oldWidget);
|
super.didUpdateWidget(oldWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_htmlEditorHeight.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
return ValueListenableBuilder(
|
||||||
|
valueListenable: _htmlEditorHeight,
|
||||||
|
builder: (context, height, _) {
|
||||||
return HtmlEditor(
|
return HtmlEditor(
|
||||||
key: const Key('web_editor'),
|
key: Key('web_editor_$height'),
|
||||||
controller: _editorController,
|
controller: _editorController,
|
||||||
htmlEditorOptions: HtmlEditorOptions(
|
htmlEditorOptions: HtmlEditorOptions(
|
||||||
shouldEnsureVisible: true,
|
shouldEnsureVisible: true,
|
||||||
@@ -100,7 +119,7 @@ class _WebEditorState extends State<WebEditorWidget> {
|
|||||||
defaultToolbarButtons: [],
|
defaultToolbarButtons: [],
|
||||||
),
|
),
|
||||||
otherOptions: OtherOptions(
|
otherOptions: OtherOptions(
|
||||||
height: 550,
|
height: height,
|
||||||
dropZoneWidth: dropZoneWidth,
|
dropZoneWidth: dropZoneWidth,
|
||||||
dropZoneHeight: dropZoneHeight,
|
dropZoneHeight: dropZoneHeight,
|
||||||
),
|
),
|
||||||
@@ -119,4 +138,6 @@ class _WebEditorState extends State<WebEditorWidget> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user