Skip to content

Commit

Permalink
Merge pull request #70 from fluttercandies/dev
Browse files Browse the repository at this point in the history
## [1.0.1]
  • Loading branch information
zmtzawqlp authored Jun 1, 2020
2 parents dc9de71 + 7786578 commit 182c552
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [1.0.1]

* Fix wrong calculation about selection handles.

## [1.0.0]

* Merge code from 1.17.0
Expand Down
36 changes: 19 additions & 17 deletions lib/src/extended_render_editable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -330,16 +330,17 @@ class ExtendedRenderEditable extends ExtendedTextSelectionRenderObject {
///
final Rect visibleRegion = Offset(0.0, _visibleRegionMinY) & size;


//getCaretOffset ready has effectiveOffset
final Offset startOffset = getCaretOffset(
TextPosition(
offset: selection.start,
affinity: selection.affinity,
),
effectiveOffset: effectiveOffset,
caretPrototype: _caretPrototype,
handleSpecialText: handleSpecialText,
);
TextPosition(
offset: selection.start,
affinity: selection.affinity,
),
effectiveOffset: effectiveOffset,
caretPrototype: _caretPrototype,
handleSpecialText: handleSpecialText,
);

// (justinmc): https://github.com/flutter/flutter/issues/31495
// Check if the selection is visible with an approximation because a
Expand All @@ -351,18 +352,19 @@ class ExtendedRenderEditable extends ExtendedTextSelectionRenderObject {
const double visibleRegionSlop = 0.5;
_selectionStartInViewport.value = visibleRegion
.inflate(visibleRegionSlop)
.contains(startOffset + effectiveOffset);

.contains(startOffset);

//getCaretOffset ready has effectiveOffset
final Offset endOffset = getCaretOffset(
TextPosition(offset: selection.end, affinity: selection.affinity),
effectiveOffset: effectiveOffset,
caretPrototype: _caretPrototype,
handleSpecialText: handleSpecialText,
);
TextPosition(offset: selection.end, affinity: selection.affinity),
effectiveOffset: effectiveOffset,
caretPrototype: _caretPrototype,
handleSpecialText: handleSpecialText,
);

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

///some times _visibleRegionMinY will lower than 0.0;
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: 1.0.0
version: 1.0.1
author: zmtzawqlp <zmtzawqlp@live.com>
homepage: https://github.com/fluttercandies/extended_text_field

Expand Down

0 comments on commit 182c552

Please sign in to comment.