diff --git a/CHANGELOG.md b/CHANGELOG.md index 85402df..cf998a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 12.0.2 + +* Fix wrong postion of Magnifier + + ## 12.0.1 * Fix issue that wrong cursor position on macos. (https://github.com/fluttercandies/extended_text_field/issues/210) diff --git a/lib/src/extended/material/selectable_text.dart b/lib/src/extended/material/selectable_text.dart index dd1fbaa..1c0732e 100644 --- a/lib/src/extended/material/selectable_text.dart +++ b/lib/src/extended/material/selectable_text.dart @@ -17,7 +17,7 @@ class ExtendedSelectableText extends _SelectableText { 'Use `contextMenuBuilder` instead. ' 'This feature was deprecated after v3.3.0-0.5.pre.', ) - super.toolbarOptions, + super.toolbarOptions, super.minLines, super.maxLines, super.cursorWidth = 2.0, @@ -57,7 +57,7 @@ class ExtendedSelectableText extends _SelectableText { 'Use `contextMenuBuilder` instead. ' 'This feature was deprecated after v3.3.0-0.5.pre.', ) - super.toolbarOptions, + super.toolbarOptions, super.minLines, super.maxLines, super.cursorWidth = 2.0, diff --git a/lib/src/extended/widgets/editable_text.dart b/lib/src/extended/widgets/editable_text.dart index fb3e21d..b78db4d 100644 --- a/lib/src/extended/widgets/editable_text.dart +++ b/lib/src/extended/widgets/editable_text.dart @@ -77,7 +77,7 @@ class ExtendedEditableText extends _EditableText { 'Use `contextMenuBuilder` instead. ' 'This feature was deprecated after v3.3.0-0.5.pre.', ) - ToolbarOptions? toolbarOptions, + ToolbarOptions? toolbarOptions, super.autofillHints = const [], super.autofillClient, super.clipBehavior = Clip.hardEdge, diff --git a/lib/src/extended/widgets/text_field.dart b/lib/src/extended/widgets/text_field.dart index edbd2fd..3bfe892 100644 --- a/lib/src/extended/widgets/text_field.dart +++ b/lib/src/extended/widgets/text_field.dart @@ -46,7 +46,7 @@ class ExtendedTextField extends _TextField { 'Use `contextMenuBuilder` instead. ' 'This feature was deprecated after v3.3.0-0.5.pre.', ) - super.toolbarOptions, + super.toolbarOptions, super.showCursor, super.autofocus = false, super.obscuringCharacter = '•', @@ -98,6 +98,7 @@ class ExtendedTextField extends _TextField { // super.spellCheckConfiguration, this.extendedSpellCheckConfiguration, this.specialTextSpanBuilder, + super.magnifierConfiguration, }); /// build your ccustom text span diff --git a/lib/src/extended/widgets/text_selection.dart b/lib/src/extended/widgets/text_selection.dart index a3aa1ed..197f7c6 100644 --- a/lib/src/extended/widgets/text_selection.dart +++ b/lib/src/extended/widgets/text_selection.dart @@ -35,7 +35,9 @@ class ExtendedTextSelectionOverlay extends _TextSelectionOverlay { TextPosition position = renderObject.getPositionForPoint(adjustedOffset); /// zmtzawqlp - if ((renderObject as ExtendedRenderEditable).hasSpecialInlineSpanBase) { + final bool hasSpecialInlineSpanBase = + (renderObject as ExtendedRenderEditable).hasSpecialInlineSpanBase; + if (hasSpecialInlineSpanBase) { position = ExtendedTextLibraryUtils.convertTextPainterPostionToTextInputPostion( renderObject.text!, position)!; @@ -46,6 +48,7 @@ class ExtendedTextSelectionOverlay extends _TextSelectionOverlay { currentTextPosition: position, globalGesturePosition: details.globalPosition, renderEditable: renderObject, + hasSpecialInlineSpanBase: hasSpecialInlineSpanBase, )); final TextSelection currentSelection = @@ -86,6 +89,7 @@ class ExtendedTextSelectionOverlay extends _TextSelectionOverlay { : newSelection.base, globalGesturePosition: details.globalPosition, renderEditable: renderObject, + hasSpecialInlineSpanBase: hasSpecialInlineSpanBase, )); _handleSelectionHandleChanged(newSelection); @@ -106,8 +110,10 @@ class ExtendedTextSelectionOverlay extends _TextSelectionOverlay { TextPosition position = renderObject.getPositionForPoint(adjustedOffset); - /// zmtzawqlp - if ((renderObject as ExtendedRenderEditable).hasSpecialInlineSpanBase) { + // zmtzawqlp + final bool hasSpecialInlineSpanBase = + (renderObject as ExtendedRenderEditable).hasSpecialInlineSpanBase; + if (hasSpecialInlineSpanBase) { position = ExtendedTextLibraryUtils.convertTextPainterPostionToTextInputPostion( renderObject.text!, position)!; @@ -118,6 +124,7 @@ class ExtendedTextSelectionOverlay extends _TextSelectionOverlay { currentTextPosition: position, globalGesturePosition: details.globalPosition, renderEditable: renderObject, + hasSpecialInlineSpanBase: hasSpecialInlineSpanBase, )); final TextSelection currentSelection = @@ -158,6 +165,37 @@ class ExtendedTextSelectionOverlay extends _TextSelectionOverlay { currentTextPosition: newSelection.extent, globalGesturePosition: details.globalPosition, renderEditable: renderObject, + hasSpecialInlineSpanBase: hasSpecialInlineSpanBase, )); } + + @override + MagnifierInfo _buildMagnifier({ + required _RenderEditable renderEditable, + required ui.Offset globalGesturePosition, + required ui.TextPosition currentTextPosition, + bool hasSpecialInlineSpanBase = false, + }) { + // zmtzawqlp + if (hasSpecialInlineSpanBase) { + currentTextPosition = + ExtendedTextLibraryUtils.convertTextInputPostionToTextPainterPostion( + renderObject.text!, currentTextPosition); + } + return super._buildMagnifier( + renderEditable: renderEditable, + globalGesturePosition: globalGesturePosition, + currentTextPosition: currentTextPosition); + } + + // @override + // void _handleSelectionHandleChanged(TextSelection newSelection) { + // // zmtzawqlp + // if ((renderObject as ExtendedRenderEditable).hasSpecialInlineSpanBase) { + // newSelection = ExtendedTextLibraryUtils + // .convertTextPainterSelectionToTextInputSelection( + // renderObject.text!, newSelection); + // } + // super._handleSelectionHandleChanged(newSelection); + // } } diff --git a/lib/src/official/material/selectable_text.dart b/lib/src/official/material/selectable_text.dart index 0813ea9..988ee1a 100644 --- a/lib/src/official/material/selectable_text.dart +++ b/lib/src/official/material/selectable_text.dart @@ -186,7 +186,7 @@ class _SelectableText extends StatefulWidget { 'Use `contextMenuBuilder` instead. ' 'This feature was deprecated after v3.3.0-0.5.pre.', ) - this.toolbarOptions, + this.toolbarOptions, this.minLines, this.maxLines, this.cursorWidth = 2.0, @@ -235,7 +235,7 @@ class _SelectableText extends StatefulWidget { 'Use `contextMenuBuilder` instead. ' 'This feature was deprecated after v3.3.0-0.5.pre.', ) - this.toolbarOptions, + this.toolbarOptions, this.minLines, this.maxLines, this.cursorWidth = 2.0, diff --git a/lib/src/official/widgets/editable_text.dart b/lib/src/official/widgets/editable_text.dart index 0806943..5f5dc57 100644 --- a/lib/src/official/widgets/editable_text.dart +++ b/lib/src/official/widgets/editable_text.dart @@ -400,7 +400,7 @@ class _EditableText extends StatefulWidget { 'Use `contextMenuBuilder` instead. ' 'This feature was deprecated after v3.3.0-0.5.pre.', ) - ToolbarOptions? toolbarOptions, + ToolbarOptions? toolbarOptions, this.autofillHints = const [], this.autofillClient, this.clipBehavior = Clip.hardEdge, diff --git a/lib/src/official/widgets/text_field.dart b/lib/src/official/widgets/text_field.dart index 6b60102..b7f5f42 100644 --- a/lib/src/official/widgets/text_field.dart +++ b/lib/src/official/widgets/text_field.dart @@ -220,7 +220,7 @@ class _TextField extends StatefulWidget { 'Use `contextMenuBuilder` instead. ' 'This feature was deprecated after v3.3.0-0.5.pre.', ) - this.toolbarOptions, + this.toolbarOptions, this.showCursor, this.autofocus = false, this.obscuringCharacter = '•', diff --git a/lib/src/official/widgets/text_selection.dart b/lib/src/official/widgets/text_selection.dart index 6456a25..5df17a4 100644 --- a/lib/src/official/widgets/text_selection.dart +++ b/lib/src/official/widgets/text_selection.dart @@ -680,7 +680,7 @@ class _SelectionOverlay { 'Use `contextMenuBuilder` in `showToolbar` instead. ' 'This feature was deprecated after v3.3.0-0.5.pre.', ) - required this.selectionDelegate, + required this.selectionDelegate, required this.clipboardStatus, required this.startHandleLayerLink, required this.endHandleLayerLink, @@ -691,7 +691,7 @@ class _SelectionOverlay { 'Use `contextMenuBuilder` in `showToolbar` instead. ' 'This feature was deprecated after v3.3.0-0.5.pre.', ) - Offset? toolbarLocation, + Offset? toolbarLocation, this.magnifierConfiguration = TextMagnifierConfiguration.disabled, }) : _startHandleType = startHandleType, _lineHeightAtStart = lineHeightAtStart, diff --git a/pubspec.yaml b/pubspec.yaml index 2cb3f91..33dfa27 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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: 12.0.1 +version: 12.0.2 homepage: https://github.com/fluttercandies/extended_text_field environment: