Skip to content

Commit

Permalink
## [3.0.1]
Browse files Browse the repository at this point in the history
* Fix issue that text is clipped when maxLine is 1 and width is more than maxWidth.(#67,#76)
* Fix issue that handles are not shown when the height of TextStyle is big than 1.0.(#49)
  • Loading branch information
zmtzawqlp committed Jul 1, 2020
1 parent cd70959 commit a8bfcee
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ build/
ios/.generated/
ios/Flutter/Generated.xcconfig
ios/Runner/GeneratedPluginRegistrant.*
example/ios/Flutter/flutter_export_environment.sh
.vscode/settings.json
pubspec.lock
example/pubspec.lock
example/.flutter-plugins-dependencies
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [3.0.1]

* Fix issue that text is clipped when maxLine is 1 and width is more than maxWidth.(#67,#76)
* Fix issue that handles are not shown when the height of TextStyle is big than 1.0.(#49)

## [3.0.0]

* Breaking change: fix typos [OverflowWidget].
Expand Down
32 changes: 18 additions & 14 deletions lib/src/extended_render_editable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,12 @@ class ExtendedRenderEditable extends ExtendedTextSelectionRenderObject {

void _updateSelectionExtentsVisibility(
Offset effectiveOffset, TextSelection selection) {
///final Rect visibleRegion = Offset.zero & size;
///zmt
///caret may be less than 0, because it's bigger than text
///
final Rect visibleRegion = Offset(0.0, _visibleRegionMinY) & size;
// ///
// issue: #49
// final Rect visibleRegion = Offset(0.0, _visibleRegionMinY) & size;
final Rect visibleRegion = Offset.zero & size;

//getCaretOffset ready has effectiveOffset
final Offset startOffset = getCaretOffset(
Expand All @@ -350,9 +349,8 @@ class ExtendedRenderEditable extends ExtendedTextSelectionRenderObject {
// _applyFloatingPointHack. Ideally, the rounding mismatch will be fixed and
// this can be changed to be a strict check instead of an approximation.
const double visibleRegionSlop = 0.5;
_selectionStartInViewport.value = visibleRegion
.inflate(visibleRegionSlop)
.contains(startOffset);
_selectionStartInViewport.value =
visibleRegion.inflate(visibleRegionSlop).contains(startOffset);

//getCaretOffset ready has effectiveOffset
final Offset endOffset = getCaretOffset(
Expand All @@ -362,15 +360,14 @@ class ExtendedRenderEditable extends ExtendedTextSelectionRenderObject {
handleSpecialText: handleSpecialText,
);

_selectionEndInViewport.value = visibleRegion
.inflate(visibleRegionSlop)
.contains(endOffset);
_selectionEndInViewport.value =
visibleRegion.inflate(visibleRegionSlop).contains(endOffset);
}

///some times _visibleRegionMinY will lower than 0.0;
///that the _selectionStartInViewport and _selectionEndInViewport will not right.
///
final double _visibleRegionMinY = -_kCaretHeightOffset;
//final double _visibleRegionMinY = -_kCaretHeightOffset;

// ///zmt
// void _updateVisibleRegionMinY() {
Expand Down Expand Up @@ -1549,11 +1546,18 @@ class ExtendedRenderEditable extends ExtendedTextSelectionRenderObject {
double get preferredLineHeight => _textPainter.preferredLineHeight;

double _preferredHeight(double width) {
final bool singleLine = maxLines == 1;

// issue: #67,#76
if (singleLine) {
//preferredLineHeight is not right for WidgetSpan.
return _textPainter.size.height;
}
// Lock height to maxLines if needed
final bool lockedMax = maxLines != null && minLines == null;
final bool lockedBoth = minLines != null && minLines == maxLines;
final bool singleLine = maxLines == 1;
if (singleLine || lockedMax || lockedBoth) {

if (lockedMax || lockedBoth) {
return preferredLineHeight * maxLines;
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: extended_text_field
description: Extended official text field to build special text like inline image, @somebody, custom background etc quickly.It also support to build custom seleciton toolbar and handles.
version: 3.0.0
version: 3.0.1
author: zmtzawqlp <zmtzawqlp@live.com>
homepage: https://github.com/fluttercandies/extended_text_field

Expand Down

0 comments on commit a8bfcee

Please sign in to comment.