mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-25 11:50:16 +08:00
@@ -15,7 +15,12 @@ import 'package:PiliPlus/common/widgets/flutter/text_field/editable.dart';
|
||||
import 'package:PiliPlus/common/widgets/flutter/text_field/editable_text.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart' hide EditableText, EditableTextState;
|
||||
import 'package:flutter/material.dart'
|
||||
hide
|
||||
EditableText,
|
||||
EditableTextState,
|
||||
TextSelectionOverlay,
|
||||
TextSelectionGestureDetectorBuilder;
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
@@ -577,9 +582,9 @@ class TextSelectionGestureDetectorBuilder {
|
||||
.getPositionForPoint(
|
||||
details.globalPosition,
|
||||
);
|
||||
final bool isAffinityTheSame =
|
||||
final isAffinityTheSame =
|
||||
textPosition.affinity == previousSelection.affinity;
|
||||
final bool wordAtCursorIndexIsMisspelled =
|
||||
final wordAtCursorIndexIsMisspelled =
|
||||
editableText.findSuggestionSpanAtCursorIndex(
|
||||
textPosition.offset,
|
||||
) !=
|
||||
@@ -661,7 +666,7 @@ class TextSelectionGestureDetectorBuilder {
|
||||
cause: SelectionChangedCause.longPress,
|
||||
);
|
||||
// Show the floating cursor.
|
||||
final RawFloatingCursorPoint cursorPoint = RawFloatingCursorPoint(
|
||||
final cursorPoint = RawFloatingCursorPoint(
|
||||
state: FloatingCursorDragState.Start,
|
||||
startLocation: (
|
||||
renderEditable.globalToLocal(details.globalPosition),
|
||||
@@ -705,7 +710,7 @@ class TextSelectionGestureDetectorBuilder {
|
||||
return;
|
||||
}
|
||||
// Adjust the drag start offset for possible viewport offset changes.
|
||||
final Offset editableOffset = renderEditable.maxLines == 1
|
||||
final editableOffset = renderEditable.maxLines == 1
|
||||
? Offset(renderEditable.offset.pixels - _dragStartViewportOffset, 0.0)
|
||||
: Offset(0.0, renderEditable.offset.pixels - _dragStartViewportOffset);
|
||||
final Offset scrollableOffset = switch (axisDirectionToAxis(
|
||||
@@ -733,7 +738,7 @@ class TextSelectionGestureDetectorBuilder {
|
||||
cause: SelectionChangedCause.longPress,
|
||||
);
|
||||
// Update the floating cursor.
|
||||
final RawFloatingCursorPoint cursorPoint = RawFloatingCursorPoint(
|
||||
final cursorPoint = RawFloatingCursorPoint(
|
||||
state: FloatingCursorDragState.Update,
|
||||
offset: details.offsetFromOrigin,
|
||||
);
|
||||
@@ -869,7 +874,7 @@ class TextSelectionGestureDetectorBuilder {
|
||||
delegate.selectionEnabled &&
|
||||
editableText.textEditingValue.selection.isCollapsed) {
|
||||
// Update the floating cursor.
|
||||
final RawFloatingCursorPoint cursorPoint = RawFloatingCursorPoint(
|
||||
final cursorPoint = RawFloatingCursorPoint(
|
||||
state: FloatingCursorDragState.End,
|
||||
);
|
||||
editableText.updateFloatingCursor(cursorPoint);
|
||||
@@ -956,7 +961,7 @@ class TextSelectionGestureDetectorBuilder {
|
||||
: _moveToTextBoundary(toPosition, boundary);
|
||||
final bool isFromBoundaryBeforeToBoundary = fromRange.start < toRange.end;
|
||||
|
||||
final TextSelection newSelection = isFromBoundaryBeforeToBoundary
|
||||
final newSelection = isFromBoundaryBeforeToBoundary
|
||||
? TextSelection(baseOffset: fromRange.start, extentOffset: toRange.end)
|
||||
: TextSelection(baseOffset: fromRange.end, extentOffset: toRange.start);
|
||||
|
||||
@@ -1119,7 +1124,7 @@ class TextSelectionGestureDetectorBuilder {
|
||||
|
||||
if (!_isShiftPressed) {
|
||||
// Adjust the drag start offset for possible viewport offset changes.
|
||||
final Offset editableOffset = renderEditable.maxLines == 1
|
||||
final editableOffset = renderEditable.maxLines == 1
|
||||
? Offset(renderEditable.offset.pixels - _dragStartViewportOffset, 0.0)
|
||||
: Offset(
|
||||
0.0,
|
||||
@@ -2129,21 +2134,21 @@ class TextSelectionOverlay {
|
||||
final TextSelection lineAtOffset = renderEditable.getLineAtOffset(
|
||||
currentTextPosition,
|
||||
);
|
||||
final TextPosition positionAtEndOfLine = TextPosition(
|
||||
final positionAtEndOfLine = TextPosition(
|
||||
offset: lineAtOffset.extentOffset,
|
||||
affinity: TextAffinity.upstream,
|
||||
);
|
||||
|
||||
// Default affinity is downstream.
|
||||
final TextPosition positionAtBeginningOfLine = TextPosition(
|
||||
final positionAtBeginningOfLine = TextPosition(
|
||||
offset: lineAtOffset.baseOffset,
|
||||
);
|
||||
|
||||
final Rect localLineBoundaries = Rect.fromPoints(
|
||||
final localLineBoundaries = Rect.fromPoints(
|
||||
renderEditable.getLocalRectForCaret(positionAtBeginningOfLine).topCenter,
|
||||
renderEditable.getLocalRectForCaret(positionAtEndOfLine).bottomCenter,
|
||||
);
|
||||
final RenderBox? overlay =
|
||||
final overlay =
|
||||
Overlay.of(context, rootOverlay: true).context.findRenderObject()
|
||||
as RenderBox?;
|
||||
final Matrix4 transformToOverlay = renderEditable.getTransformTo(overlay);
|
||||
@@ -2253,7 +2258,7 @@ class TextSelectionOverlay {
|
||||
/// line height is used, and the return value is in local coordinates as well.
|
||||
double _getHandleDy(double dragDy, double handleDy) {
|
||||
final double distanceDragged = dragDy - handleDy;
|
||||
final int dragDirection = distanceDragged < 0.0 ? -1 : 1;
|
||||
final dragDirection = distanceDragged < 0.0 ? -1 : 1;
|
||||
final int linesDragged =
|
||||
dragDirection *
|
||||
(distanceDragged.abs() / renderObject.preferredLineHeight).floor();
|
||||
@@ -2279,7 +2284,7 @@ class TextSelectionOverlay {
|
||||
.localToGlobal(Offset(0.0, nextEndHandleDragPositionLocal))
|
||||
.dy;
|
||||
|
||||
final Offset handleTargetGlobal = Offset(
|
||||
final handleTargetGlobal = Offset(
|
||||
details.globalPosition.dx,
|
||||
_endHandleDragPosition + _endHandleDragTarget,
|
||||
);
|
||||
@@ -2306,9 +2311,7 @@ class TextSelectionOverlay {
|
||||
),
|
||||
);
|
||||
|
||||
final TextSelection currentSelection = TextSelection.fromPosition(
|
||||
position,
|
||||
);
|
||||
final currentSelection = TextSelection.fromPosition(position);
|
||||
_handleSelectionHandleChanged(currentSelection);
|
||||
return;
|
||||
}
|
||||
@@ -2336,9 +2339,7 @@ class TextSelectionOverlay {
|
||||
),
|
||||
);
|
||||
|
||||
final TextSelection currentSelection = TextSelection.fromPosition(
|
||||
position,
|
||||
);
|
||||
final currentSelection = TextSelection.fromPosition(position);
|
||||
_handleSelectionHandleChanged(currentSelection);
|
||||
return;
|
||||
}
|
||||
@@ -2426,7 +2427,7 @@ class TextSelectionOverlay {
|
||||
_startHandleDragPosition = renderObject
|
||||
.localToGlobal(Offset(0.0, nextStartHandleDragPositionLocal))
|
||||
.dy;
|
||||
final Offset handleTargetGlobal = Offset(
|
||||
final handleTargetGlobal = Offset(
|
||||
details.globalPosition.dx,
|
||||
_startHandleDragPosition + _startHandleDragTarget,
|
||||
);
|
||||
@@ -2452,9 +2453,7 @@ class TextSelectionOverlay {
|
||||
),
|
||||
);
|
||||
|
||||
final TextSelection currentSelection = TextSelection.fromPosition(
|
||||
position,
|
||||
);
|
||||
final currentSelection = TextSelection.fromPosition(position);
|
||||
_handleSelectionHandleChanged(currentSelection);
|
||||
return;
|
||||
}
|
||||
@@ -2482,9 +2481,7 @@ class TextSelectionOverlay {
|
||||
),
|
||||
);
|
||||
|
||||
final TextSelection currentSelection = TextSelection.fromPosition(
|
||||
position,
|
||||
);
|
||||
final currentSelection = TextSelection.fromPosition(position);
|
||||
_handleSelectionHandleChanged(currentSelection);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user