|
@@ -26,32 +26,32 @@ class _RInputTextState extends State<RInputText> {
|
|
|
double _lineWidth = 136.0;
|
|
|
double _fontSize = 22.0;
|
|
|
double _height = 22.0;
|
|
|
- bool? _textWrap = false;
|
|
|
+ double _allHeight = 0.0;
|
|
|
+ bool _textWrap = false;
|
|
|
Color _fontColor = const Color.fromARGB(255, 0, 0, 0);
|
|
|
Color _backgroundColor = const Color.fromARGB(255, 255, 255, 255);
|
|
|
- int? _lineLength = 1;
|
|
|
+ int _lineLength = 1;
|
|
|
TextStyle? _textStyle;
|
|
|
InputTextInfo? _inputTextInfo;
|
|
|
bool _isReadOnly = false;
|
|
|
- String _text = '';
|
|
|
+ bool _widthLock = false;
|
|
|
+ int _rowCount = 1;
|
|
|
|
|
|
@override
|
|
|
initState() {
|
|
|
- ReportInfo.instance.onReloadFinsh.addListener((sender, e) {
|
|
|
- _initDatas();
|
|
|
- });
|
|
|
super.initState();
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
- _syncStyle();
|
|
|
_checkInputTextInfo();
|
|
|
+ _initStyle();
|
|
|
+
|
|
|
return Column(
|
|
|
children: [
|
|
|
Container(
|
|
|
width: _lineWidth,
|
|
|
- height: _textWrap! ? _height * 4 : (_height - 2),
|
|
|
+ height: _allHeight,
|
|
|
padding: const EdgeInsets.only(right: 5, left: 5),
|
|
|
decoration: BoxDecoration(
|
|
|
border: Border.all(
|
|
@@ -67,18 +67,18 @@ class _RInputTextState extends State<RInputText> {
|
|
|
textAlignVertical: AlignmentConvert.verticalAlignmentConvert(
|
|
|
widget.inputText.verticalAlignment),
|
|
|
minLines: 1,
|
|
|
- maxLines: _textWrap! ? 6 : 1,
|
|
|
+ maxLines: _rowCount,
|
|
|
controller: _controller,
|
|
|
textAlign: TextAlign.start,
|
|
|
style: _textStyle,
|
|
|
onChanged: (v) {
|
|
|
- // _onInputChanged(_textStyle!, v);
|
|
|
+ // _onInputChanged(_textStyle!, _controller.text);
|
|
|
},
|
|
|
onEditingComplete: () {
|
|
|
_onInputChanged(_textStyle!, _controller.text);
|
|
|
}),
|
|
|
),
|
|
|
- const SizedBox(height: 5),
|
|
|
+ const SizedBox(height: 3),
|
|
|
if (_inputTextInfo!.tag != null &&
|
|
|
_inputTextInfo!.tag!.elementTagType ==
|
|
|
ElementTagType.DiagnosticEntry) ...[
|
|
@@ -111,12 +111,9 @@ class _RInputTextState extends State<RInputText> {
|
|
|
|
|
|
//onchange 事件
|
|
|
void _onInputChanged(TextStyle _textStyle, String value) {
|
|
|
- final inputText = widget.inputText;
|
|
|
if (_inputTextInfo != null) {
|
|
|
_inputTextInfo!.text = value;
|
|
|
}
|
|
|
-
|
|
|
- _syncWidth(inputText, value);
|
|
|
}
|
|
|
|
|
|
@override
|
|
@@ -177,12 +174,14 @@ class _RInputTextState extends State<RInputText> {
|
|
|
setState(() {
|
|
|
if (width < 480) {
|
|
|
_lineWidth = width;
|
|
|
+ _widthLock = true;
|
|
|
}
|
|
|
});
|
|
|
} else if (_controller.text.isEmpty) {
|
|
|
setState(() {
|
|
|
//重置长度
|
|
|
- _lineWidth = inputText.lineWidth ?? 100;
|
|
|
+ _lineWidth = PtToPxConverter.ptToPx(inputText.lineWidth);
|
|
|
+ _widthLock = false;
|
|
|
});
|
|
|
} else if (TextSizeConvert.getTextSize(_controller.text, _textStyle!)
|
|
|
.width >
|
|
@@ -190,14 +189,14 @@ class _RInputTextState extends State<RInputText> {
|
|
|
setState(() {
|
|
|
if (width < 480) {
|
|
|
_lineWidth = width;
|
|
|
+ _widthLock = true;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- inputText.lineWidth = _lineWidth;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- void _syncStyle() {
|
|
|
+ void _initStyle() {
|
|
|
final inputText = widget.inputText;
|
|
|
_textStyle ??= TextStyle(
|
|
|
fontSize: PtToPxConverter.ptToPx(inputText.fontSize),
|
|
@@ -208,11 +207,35 @@ class _RInputTextState extends State<RInputText> {
|
|
|
final fontName = inputText.fontName;
|
|
|
//TODO(Loki):常规模板暂未设置fontStyles,后续再支持
|
|
|
final fontStyles = inputText.fontStyles;
|
|
|
- _lineLength = inputText.lineLength;
|
|
|
- _lineWidth = PtToPxConverter.ptToPx(inputText.lineWidth);
|
|
|
- _textWrap = inputText.textWrap;
|
|
|
+ _lineLength = inputText.lineLength ?? 7;
|
|
|
+ if (!_widthLock) {
|
|
|
+ _lineWidth = PtToPxConverter.ptToPx(inputText.lineWidth);
|
|
|
+ }
|
|
|
+ _widthLock = false;
|
|
|
+ _textWrap = inputText.textWrap ?? false;
|
|
|
+ _rowCount = _textWrap ? 6 : 1;
|
|
|
+
|
|
|
+ if (_inputTextInfo != null && _inputTextInfo!.text.isNotEmpty) {
|
|
|
+ final text = _inputTextInfo!.text;
|
|
|
+ if (text.contains('\r\n')) {
|
|
|
+ final rowList = text.split('\r\n');
|
|
|
+ _rowCount = rowList.length > _rowCount ? rowList.length : _rowCount;
|
|
|
+ }
|
|
|
+ }
|
|
|
_fontSize = PtToPxConverter.ptToPx(inputText.fontSize);
|
|
|
_height = _fontSize > 30 ? 44 : 22;
|
|
|
+ _allHeight = _textWrap
|
|
|
+ ? _height * (_rowCount - 1)
|
|
|
+ : _fontSize > 30
|
|
|
+ ? (_height - 2)
|
|
|
+ : _height;
|
|
|
+ if (_inputTextInfo != null && _textWrap) {
|
|
|
+ final height =
|
|
|
+ TextSizeConvert.getTextSize(_controller.text, _textStyle!).height + 5;
|
|
|
+ if (height > _allHeight) {
|
|
|
+ _allHeight = height;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void _checkInputTextInfo() {
|