Unverified Commit 5be898a3 authored by Tomasz Gucio's avatar Tomasz Gucio Committed by GitHub

Move MagnifierBuilder, MagnifierOverlayInfoBearer from text_selection.dart (#108956)

parent b89580fb
...@@ -20,7 +20,7 @@ import 'package:flutter/widgets.dart'; ...@@ -20,7 +20,7 @@ import 'package:flutter/widgets.dart';
/// - has some vertical drag resistance; i.e. if a gesture is detected k units below the field, /// - has some vertical drag resistance; i.e. if a gesture is detected k units below the field,
/// then has vertical offset [dragResistance] * k. /// then has vertical offset [dragResistance] * k.
class CupertinoTextMagnifier extends StatefulWidget { class CupertinoTextMagnifier extends StatefulWidget {
/// Construct a [RawMagnifier] in the Cupertino style, positioning with respect to /// Constructs a [RawMagnifier] in the Cupertino style, positioning with respect to
/// [magnifierOverlayInfoBearer]. /// [magnifierOverlayInfoBearer].
/// ///
/// The default constructor parameters and constants were eyeballed on /// The default constructor parameters and constants were eyeballed on
......
...@@ -786,11 +786,11 @@ class CupertinoTextField extends StatefulWidget { ...@@ -786,11 +786,11 @@ class CupertinoTextField extends StatefulWidget {
/// {@macro flutter.services.TextInputConfiguration.enableIMEPersonalizedLearning} /// {@macro flutter.services.TextInputConfiguration.enableIMEPersonalizedLearning}
final bool enableIMEPersonalizedLearning; final bool enableIMEPersonalizedLearning;
/// {@macro flutter.widgets.text_selection.TextMagnifierConfiguration.intro} /// {@macro flutter.widgets.magnifier.TextMagnifierConfiguration.intro}
/// ///
/// {@macro flutter.widgets.magnifier.intro} /// {@macro flutter.widgets.magnifier.intro}
/// ///
/// {@macro flutter.widgets.text_selection.TextMagnifierConfiguration.details} /// {@macro flutter.widgets.magnifier.TextMagnifierConfiguration.details}
/// ///
/// By default, builds a [CupertinoTextMagnifier] on iOS and Android nothing on all other /// By default, builds a [CupertinoTextMagnifier] on iOS and Android nothing on all other
/// platforms. If it is desired to supress the magnifier, consider passing /// platforms. If it is desired to supress the magnifier, consider passing
......
...@@ -149,8 +149,8 @@ class _TextMagnifierState extends State<TextMagnifier> { ...@@ -149,8 +149,8 @@ class _TextMagnifierState extends State<TextMagnifier> {
// to always stay between line start and end. // to always stay between line start and end.
final double magnifierX = clampDouble( final double magnifierX = clampDouble(
selectionInfo.globalGesturePosition.dx, selectionInfo.globalGesturePosition.dx,
selectionInfo.currentLineBoundries.left, selectionInfo.currentLineBoundaries.left,
selectionInfo.currentLineBoundries.right); selectionInfo.currentLineBoundaries.right);
// Place the magnifier at the previously calculated X, and the Y should be // Place the magnifier at the previously calculated X, and the Y should be
// exactly at the center of the handle. // exactly at the center of the handle.
...@@ -160,7 +160,7 @@ class _TextMagnifierState extends State<TextMagnifier> { ...@@ -160,7 +160,7 @@ class _TextMagnifierState extends State<TextMagnifier> {
// Shift the magnifier so that, if we are ever out of the screen, we become in bounds. // Shift the magnifier so that, if we are ever out of the screen, we become in bounds.
// This probably won't have much of an effect on the X, since it is already bound // This probably won't have much of an effect on the X, since it is already bound
// to the currentLineBoundries, but will shift vertically if the magnifier is out of bounds. // to the currentLineBoundaries, but will shift vertically if the magnifier is out of bounds.
final Rect screenBoundsAdjustedMagnifierRect = final Rect screenBoundsAdjustedMagnifierRect =
MagnifierController.shiftWithinBounds( MagnifierController.shiftWithinBounds(
bounds: screenRect, rect: unadjustedMagnifierRect); bounds: screenRect, rect: unadjustedMagnifierRect);
......
...@@ -430,11 +430,11 @@ class SelectableText extends StatefulWidget { ...@@ -430,11 +430,11 @@ class SelectableText extends StatefulWidget {
/// {@macro flutter.widgets.editableText.onSelectionChanged} /// {@macro flutter.widgets.editableText.onSelectionChanged}
final SelectionChangedCallback? onSelectionChanged; final SelectionChangedCallback? onSelectionChanged;
/// {@macro flutter.widgets.text_selection.TextMagnifierConfiguration.intro} /// {@macro flutter.widgets.magnifier.TextMagnifierConfiguration.intro}
/// ///
/// {@macro flutter.widgets.magnifier.intro} /// {@macro flutter.widgets.magnifier.intro}
/// ///
/// {@macro flutter.widgets.text_selection.TextMagnifierConfiguration.details} /// {@macro flutter.widgets.magnifier.TextMagnifierConfiguration.details}
/// ///
/// By default, builds a [CupertinoTextMagnifier] on iOS and [TextMagnifier] on /// By default, builds a [CupertinoTextMagnifier] on iOS and [TextMagnifier] on
/// Android, and builds nothing on all other platforms. If it is desired to supress /// Android, and builds nothing on all other platforms. If it is desired to supress
......
...@@ -39,11 +39,11 @@ class SelectionArea extends StatefulWidget { ...@@ -39,11 +39,11 @@ class SelectionArea extends StatefulWidget {
required this.child, required this.child,
}); });
/// {@macro flutter.widgets.text_selection.TextMagnifierConfiguration.intro} /// {@macro flutter.widgets.magnifier.TextMagnifierConfiguration.intro}
/// ///
/// {@macro flutter.widgets.magnifier.intro} /// {@macro flutter.widgets.magnifier.intro}
/// ///
/// {@macro flutter.widgets.text_selection.TextMagnifierConfiguration.details} /// {@macro flutter.widgets.magnifier.TextMagnifierConfiguration.details}
/// ///
/// By default, builds a [CupertinoTextMagnifier] on iOS and [TextMagnifier] on /// By default, builds a [CupertinoTextMagnifier] on iOS and [TextMagnifier] on
/// Android, and builds nothing on all other platforms. If it is desired to supress /// Android, and builds nothing on all other platforms. If it is desired to supress
......
...@@ -393,11 +393,11 @@ class TextField extends StatefulWidget { ...@@ -393,11 +393,11 @@ class TextField extends StatefulWidget {
paste: true, paste: true,
))); )));
/// {@macro flutter.widgets.text_selection.TextMagnifierConfiguration.intro} /// {@macro flutter.widgets.magnifier.TextMagnifierConfiguration.intro}
/// ///
/// {@macro flutter.widgets.magnifier.intro} /// {@macro flutter.widgets.magnifier.intro}
/// ///
/// {@macro flutter.widgets.text_selection.TextMagnifierConfiguration.details} /// {@macro flutter.widgets.magnifier.TextMagnifierConfiguration.details}
/// ///
/// By default, builds a [CupertinoTextMagnifier] on iOS and [TextMagnifier] on /// By default, builds a [CupertinoTextMagnifier] on iOS and [TextMagnifier] on
/// Android, and builds nothing on all other platforms. If it is desired to supress /// Android, and builds nothing on all other platforms. If it is desired to supress
......
...@@ -27,6 +27,7 @@ import 'focus_scope.dart'; ...@@ -27,6 +27,7 @@ import 'focus_scope.dart';
import 'focus_traversal.dart'; import 'focus_traversal.dart';
import 'framework.dart'; import 'framework.dart';
import 'localizations.dart'; import 'localizations.dart';
import 'magnifier.dart';
import 'media_query.dart'; import 'media_query.dart';
import 'scroll_configuration.dart'; import 'scroll_configuration.dart';
import 'scroll_controller.dart'; import 'scroll_controller.dart';
...@@ -1549,11 +1550,11 @@ class EditableText extends StatefulWidget { ...@@ -1549,11 +1550,11 @@ class EditableText extends StatefulWidget {
/// {@macro flutter.services.TextInputConfiguration.enableIMEPersonalizedLearning} /// {@macro flutter.services.TextInputConfiguration.enableIMEPersonalizedLearning}
final bool enableIMEPersonalizedLearning; final bool enableIMEPersonalizedLearning;
/// {@macro flutter.widgets.text_selection.TextMagnifierConfiguration.intro} /// {@macro flutter.widgets.magnifier.TextMagnifierConfiguration.intro}
/// ///
/// {@macro flutter.widgets.magnifier.intro} /// {@macro flutter.widgets.magnifier.intro}
/// ///
/// {@macro flutter.widgets.text_selection.TextMagnifierConfiguration.details} /// {@macro flutter.widgets.magnifier.TextMagnifierConfiguration.details}
final TextMagnifierConfiguration magnifierConfiguration; final TextMagnifierConfiguration magnifierConfiguration;
bool get _userSelectionEnabled => enableInteractiveSelection && (!readOnly || !obscureText); bool get _userSelectionEnabled => enableInteractiveSelection && (!readOnly || !obscureText);
......
...@@ -15,6 +15,122 @@ import 'inherited_theme.dart'; ...@@ -15,6 +15,122 @@ import 'inherited_theme.dart';
import 'navigator.dart'; import 'navigator.dart';
import 'overlay.dart'; import 'overlay.dart';
/// {@template flutter.widgets.magnifier.MagnifierBuilder}
/// Signature for a builder that builds a [Widget] with a [MagnifierController].
///
/// Consuming [MagnifierController] or [ValueNotifier]<[MagnifierOverlayInfoBearer]> is not
/// required, although if a Widget intends to have entry or exit animations, it should take
/// [MagnifierController] and provide it an [AnimationController], so that [MagnifierController]
/// can wait before removing it from the overlay.
/// {@endtemplate}
///
/// See also:
///
/// - [MagnifierOverlayInfoBearer], the data class that updates the
/// magnifier.
typedef MagnifierBuilder = Widget? Function(
BuildContext context,
MagnifierController controller,
ValueNotifier<MagnifierOverlayInfoBearer> magnifierOverlayInfoBearer,
);
/// A data class that contains the geometry information of text layouts
/// and selection gestures, used to position magnifiers.
@immutable
class MagnifierOverlayInfoBearer {
/// Constructs a [MagnifierOverlayInfoBearer] from provided geometry values.
const MagnifierOverlayInfoBearer({
required this.globalGesturePosition,
required this.caretRect,
required this.fieldBounds,
required this.currentLineBoundaries,
});
/// Const [MagnifierOverlayInfoBearer] with all values set to 0.
static const MagnifierOverlayInfoBearer empty = MagnifierOverlayInfoBearer(
globalGesturePosition: Offset.zero,
caretRect: Rect.zero,
currentLineBoundaries: Rect.zero,
fieldBounds: Rect.zero,
);
/// The offset of the gesture position that the magnifier should be shown at.
final Offset globalGesturePosition;
/// The rect of the current line the magnifier should be shown at,
/// without taking into account any padding of the field; only the position
/// of the first and last character.
final Rect currentLineBoundaries;
/// The rect of the handle that the magnifier should follow.
final Rect caretRect;
/// The bounds of the entire text field that the magnifier is bound to.
final Rect fieldBounds;
@override
bool operator ==(Object other) {
if (identical(this, other)) {
return true;
}
return other is MagnifierOverlayInfoBearer
&& other.globalGesturePosition == globalGesturePosition
&& other.caretRect == caretRect
&& other.currentLineBoundaries == currentLineBoundaries
&& other.fieldBounds == fieldBounds;
}
@override
int get hashCode => Object.hash(
globalGesturePosition,
caretRect,
fieldBounds,
currentLineBoundaries,
);
}
/// {@template flutter.widgets.magnifier.TextMagnifierConfiguration.intro}
/// A configuration object for a magnifier.
/// {@endtemplate}
///
/// {@macro flutter.widgets.magnifier.intro}
///
/// {@template flutter.widgets.magnifier.TextMagnifierConfiguration.details}
/// In general, most features of the magnifier can be configured through
/// [MagnifierBuilder]. [TextMagnifierConfiguration] is used to configure
/// the magnifier's behavior through the [SelectionOverlay].
/// {@endtemplate}
class TextMagnifierConfiguration {
/// Constructs a [TextMagnifierConfiguration] from parts.
///
/// If [magnifierBuilder] is null, a default [MagnifierBuilder] will be used
/// that never builds a magnifier.
const TextMagnifierConfiguration({
MagnifierBuilder? magnifierBuilder,
this.shouldDisplayHandlesInMagnifier = true
}) : _magnifierBuilder = magnifierBuilder;
/// The passed in [MagnifierBuilder].
///
/// This is nullable because [disabled] needs to be static const,
/// so that it can be used as a default parameter. If left null,
/// the [magnifierBuilder] getter will be a function that always returns
/// null.
final MagnifierBuilder? _magnifierBuilder;
/// {@macro flutter.widgets.magnifier.MagnifierBuilder}
MagnifierBuilder get magnifierBuilder => _magnifierBuilder ?? (_, __, ___) => null;
/// Determines whether a magnifier should show the text editing handles or not.
final bool shouldDisplayHandlesInMagnifier;
/// A constant for a [TextMagnifierConfiguration] that is disabled.
///
/// In particular, this [TextMagnifierConfiguration] is considered disabled
/// because it never builds anything, regardless of platform.
static const TextMagnifierConfiguration disabled = TextMagnifierConfiguration();
}
/// [MagnifierController]'s main benefit over holding a raw [OverlayEntry] is that /// [MagnifierController]'s main benefit over holding a raw [OverlayEntry] is that
/// [MagnifierController] will handle logic around waiting for a magnifier to animate in or out. /// [MagnifierController] will handle logic around waiting for a magnifier to animate in or out.
/// ///
...@@ -429,29 +545,24 @@ class _DonutClip extends CustomClipper<Path> { ...@@ -429,29 +545,24 @@ class _DonutClip extends CustomClipper<Path> {
} }
class _Magnifier extends SingleChildRenderObjectWidget { class _Magnifier extends SingleChildRenderObjectWidget {
/// Construct a [_Magnifier].
const _Magnifier({ const _Magnifier({
super.child, super.child,
required this.shape, required this.shape,
this.magnificationScale = 1, this.magnificationScale = 1,
this.focalPointOffset = Offset.zero, this.focalPointOffset = Offset.zero,
}); });
/// [focalPointOffset] is the area the center of the // The Offset that the center of the _Magnifier points to, relative
/// [_Magnifier] points to, relative to the center of the magnifier. // to the center of the magnifier.
///
/// {@macro flutter.widgets.magnifier.offset}
final Offset focalPointOffset; final Offset focalPointOffset;
/// The scale of the magnification. // The enlarge multiplier of the magnification.
/// //
/// A [magnificationScale] of 1 means that the content in the magnifier // If equal to 1.0, the content in the magnifier is true to its real size.
/// is true to it's real size. Anything greater than one will appear bigger // If greater than 1.0, the content appears bigger in the magnifier.
/// in the magnifier, and anything less than one will appear smaller in
/// the magnifier.
final double magnificationScale; final double magnificationScale;
/// The shape of the magnifier is dictated by [shape.getOuterPath]. // Shape of the magnifier.
final ShapeBorder shape; final ShapeBorder shape;
@override @override
......
...@@ -18,6 +18,7 @@ import 'focus_manager.dart'; ...@@ -18,6 +18,7 @@ import 'focus_manager.dart';
import 'focus_scope.dart'; import 'focus_scope.dart';
import 'framework.dart'; import 'framework.dart';
import 'gesture_detector.dart'; import 'gesture_detector.dart';
import 'magnifier.dart';
import 'media_query.dart'; import 'media_query.dart';
import 'overlay.dart'; import 'overlay.dart';
import 'platform_selectable_region_context_menu.dart'; import 'platform_selectable_region_context_menu.dart';
...@@ -184,13 +185,13 @@ class SelectableRegion extends StatefulWidget { ...@@ -184,13 +185,13 @@ class SelectableRegion extends StatefulWidget {
this.magnifierConfiguration = TextMagnifierConfiguration.disabled, this.magnifierConfiguration = TextMagnifierConfiguration.disabled,
}); });
/// {@macro flutter.widgets.text_selection.TextMagnifierConfiguration.intro} /// {@macro flutter.widgets.magnifier.TextMagnifierConfiguration.intro}
/// ///
/// {@macro flutter.widgets.magnifier.intro} /// {@macro flutter.widgets.magnifier.intro}
/// ///
/// By default, [SelectableRegion]'s [TextMagnifierConfiguration] is disabled. /// By default, [SelectableRegion]'s [TextMagnifierConfiguration] is disabled.
/// ///
/// {@macro flutter.widgets.text_selection.TextMagnifierConfiguration.details} /// {@macro flutter.widgets.magnifier.TextMagnifierConfiguration.details}
final TextMagnifierConfiguration magnifierConfiguration; final TextMagnifierConfiguration magnifierConfiguration;
/// {@macro flutter.widgets.Focus.focusNode} /// {@macro flutter.widgets.Focus.focusNode}
...@@ -542,7 +543,7 @@ class _SelectableRegionState extends State<SelectableRegion> with TextSelectionD ...@@ -542,7 +543,7 @@ class _SelectableRegionState extends State<SelectableRegion> with TextSelectionD
globalGesturePosition: globalGesturePosition, globalGesturePosition: globalGesturePosition,
caretRect: caretRect, caretRect: caretRect,
fieldBounds: globalTransformAsOffset & _selectable!.size, fieldBounds: globalTransformAsOffset & _selectable!.size,
currentLineBoundries: globalTransformAsOffset & _selectable!.size, currentLineBoundaries: globalTransformAsOffset & _selectable!.size,
); );
} }
......
...@@ -79,7 +79,7 @@ void main() { ...@@ -79,7 +79,7 @@ void main() {
final ValueNotifier<MagnifierOverlayInfoBearer> magnifier = final ValueNotifier<MagnifierOverlayInfoBearer> magnifier =
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(
MagnifierOverlayInfoBearer( MagnifierOverlayInfoBearer(
currentLineBoundries: fakeTextFieldRect, currentLineBoundaries: fakeTextFieldRect,
fieldBounds: fakeTextFieldRect, fieldBounds: fakeTextFieldRect,
caretRect: fakeTextFieldRect, caretRect: fakeTextFieldRect,
// The tap position is dragBelow units below the text field. // The tap position is dragBelow units below the text field.
...@@ -112,7 +112,7 @@ void main() { ...@@ -112,7 +112,7 @@ void main() {
tester, tester,
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(
MagnifierOverlayInfoBearer( MagnifierOverlayInfoBearer(
currentLineBoundries: reasonableTextField, currentLineBoundaries: reasonableTextField,
fieldBounds: reasonableTextField, fieldBounds: reasonableTextField,
caretRect: reasonableTextField, caretRect: reasonableTextField,
// The tap position is far out of the right side of the app. // The tap position is far out of the right side of the app.
...@@ -145,7 +145,7 @@ void main() { ...@@ -145,7 +145,7 @@ void main() {
tester, tester,
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(
MagnifierOverlayInfoBearer( MagnifierOverlayInfoBearer(
currentLineBoundries: reasonableTextField, currentLineBoundaries: reasonableTextField,
fieldBounds: reasonableTextField, fieldBounds: reasonableTextField,
caretRect: reasonableTextField, caretRect: reasonableTextField,
// The tap position is dragBelow units below the text field. // The tap position is dragBelow units below the text field.
...@@ -179,7 +179,7 @@ void main() { ...@@ -179,7 +179,7 @@ void main() {
final ValueNotifier<MagnifierOverlayInfoBearer> magnifierinfo = final ValueNotifier<MagnifierOverlayInfoBearer> magnifierinfo =
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(
MagnifierOverlayInfoBearer( MagnifierOverlayInfoBearer(
currentLineBoundries: reasonableTextField, currentLineBoundaries: reasonableTextField,
fieldBounds: reasonableTextField, fieldBounds: reasonableTextField,
caretRect: reasonableTextField, caretRect: reasonableTextField,
// The tap position is dragBelow units below the text field. // The tap position is dragBelow units below the text field.
...@@ -193,7 +193,7 @@ void main() { ...@@ -193,7 +193,7 @@ void main() {
// Move the gesture to one that should hide it. // Move the gesture to one that should hide it.
magnifierinfo.value = MagnifierOverlayInfoBearer( magnifierinfo.value = MagnifierOverlayInfoBearer(
currentLineBoundries: reasonableTextField, currentLineBoundaries: reasonableTextField,
fieldBounds: reasonableTextField, fieldBounds: reasonableTextField,
caretRect: reasonableTextField, caretRect: reasonableTextField,
globalGesturePosition: magnifierinfo.value.globalGesturePosition + const Offset(0, 100), globalGesturePosition: magnifierinfo.value.globalGesturePosition + const Offset(0, 100),
...@@ -219,7 +219,7 @@ void main() { ...@@ -219,7 +219,7 @@ void main() {
final ValueNotifier<MagnifierOverlayInfoBearer> magnifierInfo = final ValueNotifier<MagnifierOverlayInfoBearer> magnifierInfo =
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(
MagnifierOverlayInfoBearer( MagnifierOverlayInfoBearer(
currentLineBoundries: reasonableTextField, currentLineBoundaries: reasonableTextField,
fieldBounds: reasonableTextField, fieldBounds: reasonableTextField,
caretRect: reasonableTextField, caretRect: reasonableTextField,
// The tap position is dragBelow units below the text field. // The tap position is dragBelow units below the text field.
...@@ -232,7 +232,7 @@ void main() { ...@@ -232,7 +232,7 @@ void main() {
// Move the gesture to one that should hide it. // Move the gesture to one that should hide it.
magnifierInfo.value = MagnifierOverlayInfoBearer( magnifierInfo.value = MagnifierOverlayInfoBearer(
currentLineBoundries: reasonableTextField, currentLineBoundaries: reasonableTextField,
fieldBounds: reasonableTextField, fieldBounds: reasonableTextField,
caretRect: reasonableTextField, caretRect: reasonableTextField,
globalGesturePosition: globalGesturePosition:
...@@ -244,7 +244,7 @@ void main() { ...@@ -244,7 +244,7 @@ void main() {
// Return the gesture to one that shows it. // Return the gesture to one that shows it.
magnifierInfo.value = MagnifierOverlayInfoBearer( magnifierInfo.value = MagnifierOverlayInfoBearer(
currentLineBoundries: reasonableTextField, currentLineBoundaries: reasonableTextField,
fieldBounds: reasonableTextField, fieldBounds: reasonableTextField,
caretRect: reasonableTextField, caretRect: reasonableTextField,
globalGesturePosition: Offset(MediaQuery.of(context).size.width / 2, globalGesturePosition: Offset(MediaQuery.of(context).size.width / 2,
......
...@@ -5985,11 +5985,9 @@ void main() { ...@@ -5985,11 +5985,9 @@ void main() {
defaultCupertinoTextField.magnifierConfiguration!.magnifierBuilder( defaultCupertinoTextField.magnifierConfiguration!.magnifierBuilder(
context, context,
MagnifierController(), MagnifierController(),
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(MagnifierOverlayInfoBearer.empty),
const MagnifierOverlayInfoBearer.empty(), ),
)), isA<Widget>().having((Widget widget) => widget.key, 'key', equals(customMagnifier.key)));
isA<Widget>().having(
(Widget widget) => widget.key, 'key', equals(customMagnifier.key)));
}); });
group('defaults', () { group('defaults', () {
...@@ -6005,9 +6003,8 @@ void main() { ...@@ -6005,9 +6003,8 @@ void main() {
editableText.magnifierConfiguration.magnifierBuilder( editableText.magnifierConfiguration.magnifierBuilder(
context, context,
MagnifierController(), MagnifierController(),
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(MagnifierOverlayInfoBearer.empty),
const MagnifierOverlayInfoBearer.empty(), ),
)),
isA<CupertinoTextMagnifier>()); isA<CupertinoTextMagnifier>());
}, },
variant: const TargetPlatformVariant( variant: const TargetPlatformVariant(
...@@ -6026,9 +6023,8 @@ void main() { ...@@ -6026,9 +6023,8 @@ void main() {
editableText.magnifierConfiguration.magnifierBuilder( editableText.magnifierConfiguration.magnifierBuilder(
context, context,
MagnifierController(), MagnifierController(),
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(MagnifierOverlayInfoBearer.empty),
const MagnifierOverlayInfoBearer.empty(), ),
)),
isNull); isNull);
}, },
variant: TargetPlatformVariant.all( variant: TargetPlatformVariant.all(
......
...@@ -55,16 +55,12 @@ void main() { ...@@ -55,16 +55,12 @@ void main() {
home: Placeholder(), home: Placeholder(),
)); ));
final BuildContext context = final BuildContext context = tester.firstElement(find.byType(Placeholder));
tester.firstElement(find.byType(Placeholder));
final Widget? builtWidget = final Widget? builtWidget = TextMagnifier.adaptiveMagnifierConfiguration.magnifierBuilder(
TextMagnifier.adaptiveMagnifierConfiguration.magnifierBuilder(
context, context,
MagnifierController(), MagnifierController(),
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(MagnifierOverlayInfoBearer.empty),
const MagnifierOverlayInfoBearer.empty(),
),
); );
expect(builtWidget, isA<TextMagnifier>()); expect(builtWidget, isA<TextMagnifier>());
...@@ -76,15 +72,13 @@ void main() { ...@@ -76,15 +72,13 @@ void main() {
home: Placeholder(), home: Placeholder(),
)); ));
final BuildContext context = final BuildContext context = tester.firstElement(find.byType(Placeholder));
tester.firstElement(find.byType(Placeholder));
final Widget? builtWidget = final Widget? builtWidget = TextMagnifier.adaptiveMagnifierConfiguration.magnifierBuilder(
TextMagnifier.adaptiveMagnifierConfiguration.magnifierBuilder( context,
context, MagnifierController(),
MagnifierController(), ValueNotifier<MagnifierOverlayInfoBearer>(MagnifierOverlayInfoBearer.empty),
ValueNotifier<MagnifierOverlayInfoBearer>( );
const MagnifierOverlayInfoBearer.empty()));
expect(builtWidget, isA<CupertinoTextMagnifier>()); expect(builtWidget, isA<CupertinoTextMagnifier>());
}, variant: TargetPlatformVariant.only(TargetPlatform.iOS)); }, variant: TargetPlatformVariant.only(TargetPlatform.iOS));
...@@ -95,17 +89,13 @@ void main() { ...@@ -95,17 +89,13 @@ void main() {
home: Placeholder(), home: Placeholder(),
)); ));
final BuildContext context = final BuildContext context = tester.firstElement(find.byType(Placeholder));
tester.firstElement(find.byType(Placeholder));
final Widget? builtWidget = final Widget? builtWidget = TextMagnifier.adaptiveMagnifierConfiguration.magnifierBuilder(
TextMagnifier.adaptiveMagnifierConfiguration.magnifierBuilder( context,
context, MagnifierController(),
MagnifierController(), ValueNotifier<MagnifierOverlayInfoBearer>(MagnifierOverlayInfoBearer.empty),
ValueNotifier<MagnifierOverlayInfoBearer>( );
const MagnifierOverlayInfoBearer.empty(),
),
);
expect(builtWidget, isNull); expect(builtWidget, isNull);
}, },
...@@ -157,7 +147,7 @@ void main() { ...@@ -157,7 +147,7 @@ void main() {
final ValueNotifier<MagnifierOverlayInfoBearer> magnifierInfo = final ValueNotifier<MagnifierOverlayInfoBearer> magnifierInfo =
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(
MagnifierOverlayInfoBearer( MagnifierOverlayInfoBearer(
currentLineBoundries: fakeTextFieldRect, currentLineBoundaries: fakeTextFieldRect,
fieldBounds: fakeTextFieldRect, fieldBounds: fakeTextFieldRect,
caretRect: fakeTextFieldRect, caretRect: fakeTextFieldRect,
// The tap position is dragBelow units below the text field. // The tap position is dragBelow units below the text field.
...@@ -191,9 +181,9 @@ void main() { ...@@ -191,9 +181,9 @@ void main() {
tester, tester,
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(
MagnifierOverlayInfoBearer( MagnifierOverlayInfoBearer(
currentLineBoundries: reasonableTextField, currentLineBoundaries: reasonableTextField,
// Inflate these two to make sure we're bounding on the // Inflate these two to make sure we're bounding on the
// current line boundries, not anything else. // current line boundaries, not anything else.
fieldBounds: reasonableTextField.inflate(gestureOutsideLine), fieldBounds: reasonableTextField.inflate(gestureOutsideLine),
caretRect: reasonableTextField.inflate(gestureOutsideLine), caretRect: reasonableTextField.inflate(gestureOutsideLine),
// The tap position is far out of the right side of the app. // The tap position is far out of the right side of the app.
...@@ -224,9 +214,9 @@ void main() { ...@@ -224,9 +214,9 @@ void main() {
tester, tester,
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(
MagnifierOverlayInfoBearer( MagnifierOverlayInfoBearer(
currentLineBoundries: reasonableTextField, currentLineBoundaries: reasonableTextField,
// Inflate these two to make sure we're bounding on the // Inflate these two to make sure we're bounding on the
// current line boundries, not anything else. // current line boundaries, not anything else.
fieldBounds: reasonableTextField.inflate(gestureOutsideLine), fieldBounds: reasonableTextField.inflate(gestureOutsideLine),
caretRect: reasonableTextField.inflate(gestureOutsideLine), caretRect: reasonableTextField.inflate(gestureOutsideLine),
// The tap position is far out of the left side of the app. // The tap position is far out of the left side of the app.
...@@ -252,7 +242,7 @@ void main() { ...@@ -252,7 +242,7 @@ void main() {
tester, tester,
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(
MagnifierOverlayInfoBearer( MagnifierOverlayInfoBearer(
currentLineBoundries: reasonableTextField, currentLineBoundaries: reasonableTextField,
fieldBounds: reasonableTextField, fieldBounds: reasonableTextField,
caretRect: reasonableTextField, caretRect: reasonableTextField,
globalGesturePosition: reasonableTextField.center, globalGesturePosition: reasonableTextField.center,
...@@ -279,7 +269,7 @@ void main() { ...@@ -279,7 +269,7 @@ void main() {
tester, tester,
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(
MagnifierOverlayInfoBearer( MagnifierOverlayInfoBearer(
currentLineBoundries: topOfScreenTextFieldRect, currentLineBoundaries: topOfScreenTextFieldRect,
fieldBounds: topOfScreenTextFieldRect, fieldBounds: topOfScreenTextFieldRect,
caretRect: topOfScreenTextFieldRect, caretRect: topOfScreenTextFieldRect,
globalGesturePosition: topOfScreenTextFieldRect.topCenter, globalGesturePosition: topOfScreenTextFieldRect.topCenter,
...@@ -312,7 +302,7 @@ void main() { ...@@ -312,7 +302,7 @@ void main() {
tester, tester,
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(
MagnifierOverlayInfoBearer( MagnifierOverlayInfoBearer(
currentLineBoundries: reasonableTextField, currentLineBoundaries: reasonableTextField,
fieldBounds: reasonableTextField, fieldBounds: reasonableTextField,
caretRect: reasonableTextField, caretRect: reasonableTextField,
// Gesture on the far right of the magnifier. // Gesture on the far right of the magnifier.
...@@ -343,7 +333,7 @@ void main() { ...@@ -343,7 +333,7 @@ void main() {
tester, tester,
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(
MagnifierOverlayInfoBearer( MagnifierOverlayInfoBearer(
currentLineBoundries: topOfScreenTextFieldRect, currentLineBoundaries: topOfScreenTextFieldRect,
fieldBounds: topOfScreenTextFieldRect, fieldBounds: topOfScreenTextFieldRect,
caretRect: topOfScreenTextFieldRect, caretRect: topOfScreenTextFieldRect,
globalGesturePosition: topOfScreenTextFieldRect.topCenter, globalGesturePosition: topOfScreenTextFieldRect.topCenter,
...@@ -376,7 +366,7 @@ void main() { ...@@ -376,7 +366,7 @@ void main() {
tester, tester,
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(
MagnifierOverlayInfoBearer( MagnifierOverlayInfoBearer(
currentLineBoundries: reasonableTextField, currentLineBoundaries: reasonableTextField,
fieldBounds: reasonableTextField, fieldBounds: reasonableTextField,
caretRect: reasonableTextField, caretRect: reasonableTextField,
globalGesturePosition: reasonableTextField.center, globalGesturePosition: reasonableTextField.center,
...@@ -399,7 +389,7 @@ void main() { ...@@ -399,7 +389,7 @@ void main() {
final ValueNotifier<MagnifierOverlayInfoBearer> magnifierPositioner = final ValueNotifier<MagnifierOverlayInfoBearer> magnifierPositioner =
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(
MagnifierOverlayInfoBearer( MagnifierOverlayInfoBearer(
currentLineBoundries: reasonableTextField, currentLineBoundaries: reasonableTextField,
fieldBounds: reasonableTextField, fieldBounds: reasonableTextField,
caretRect: reasonableTextField, caretRect: reasonableTextField,
globalGesturePosition: reasonableTextField.center, globalGesturePosition: reasonableTextField.center,
...@@ -410,7 +400,7 @@ void main() { ...@@ -410,7 +400,7 @@ void main() {
// New position has a horizontal shift. // New position has a horizontal shift.
magnifierPositioner.value = MagnifierOverlayInfoBearer( magnifierPositioner.value = MagnifierOverlayInfoBearer(
currentLineBoundries: reasonableTextField, currentLineBoundaries: reasonableTextField,
fieldBounds: reasonableTextField, fieldBounds: reasonableTextField,
caretRect: reasonableTextField, caretRect: reasonableTextField,
globalGesturePosition: globalGesturePosition:
...@@ -435,7 +425,7 @@ void main() { ...@@ -435,7 +425,7 @@ void main() {
final ValueNotifier<MagnifierOverlayInfoBearer> magnifierPositioner = final ValueNotifier<MagnifierOverlayInfoBearer> magnifierPositioner =
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(
MagnifierOverlayInfoBearer( MagnifierOverlayInfoBearer(
currentLineBoundries: reasonableTextField, currentLineBoundaries: reasonableTextField,
fieldBounds: reasonableTextField, fieldBounds: reasonableTextField,
caretRect: reasonableTextField, caretRect: reasonableTextField,
globalGesturePosition: reasonableTextField.center, globalGesturePosition: reasonableTextField.center,
...@@ -446,7 +436,7 @@ void main() { ...@@ -446,7 +436,7 @@ void main() {
// New position has a vertical shift. // New position has a vertical shift.
magnifierPositioner.value = MagnifierOverlayInfoBearer( magnifierPositioner.value = MagnifierOverlayInfoBearer(
currentLineBoundries: reasonableTextField.shift(verticalShift), currentLineBoundaries: reasonableTextField.shift(verticalShift),
fieldBounds: Rect.fromPoints(reasonableTextField.topLeft, fieldBounds: Rect.fromPoints(reasonableTextField.topLeft,
reasonableTextField.bottomRight + verticalShift), reasonableTextField.bottomRight + verticalShift),
caretRect: reasonableTextField.shift(verticalShift), caretRect: reasonableTextField.shift(verticalShift),
...@@ -471,7 +461,7 @@ void main() { ...@@ -471,7 +461,7 @@ void main() {
final ValueNotifier<MagnifierOverlayInfoBearer> magnifierPositioner = final ValueNotifier<MagnifierOverlayInfoBearer> magnifierPositioner =
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(
MagnifierOverlayInfoBearer( MagnifierOverlayInfoBearer(
currentLineBoundries: reasonableTextField, currentLineBoundaries: reasonableTextField,
fieldBounds: reasonableTextField, fieldBounds: reasonableTextField,
caretRect: reasonableTextField, caretRect: reasonableTextField,
globalGesturePosition: reasonableTextField.center, globalGesturePosition: reasonableTextField.center,
...@@ -482,7 +472,7 @@ void main() { ...@@ -482,7 +472,7 @@ void main() {
// New position has a vertical shift. // New position has a vertical shift.
magnifierPositioner.value = MagnifierOverlayInfoBearer( magnifierPositioner.value = MagnifierOverlayInfoBearer(
currentLineBoundries: reasonableTextField.shift(verticalShift), currentLineBoundaries: reasonableTextField.shift(verticalShift),
fieldBounds: Rect.fromPoints(reasonableTextField.topLeft, fieldBounds: Rect.fromPoints(reasonableTextField.topLeft,
reasonableTextField.bottomRight + verticalShift), reasonableTextField.bottomRight + verticalShift),
caretRect: reasonableTextField.shift(verticalShift), caretRect: reasonableTextField.shift(verticalShift),
......
...@@ -11896,9 +11896,8 @@ void main() { ...@@ -11896,9 +11896,8 @@ void main() {
textField.magnifierConfiguration!.magnifierBuilder( textField.magnifierConfiguration!.magnifierBuilder(
context, context,
MagnifierController(), MagnifierController(),
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(MagnifierOverlayInfoBearer.empty),
const MagnifierOverlayInfoBearer.empty(), ),
)),
isA<Widget>().having( isA<Widget>().having(
(Widget widget) => widget.key, (Widget widget) => widget.key,
'built magnifier key equal to passed in magnifier key', 'built magnifier key equal to passed in magnifier key',
...@@ -11918,9 +11917,8 @@ void main() { ...@@ -11918,9 +11917,8 @@ void main() {
editableText.magnifierConfiguration.magnifierBuilder( editableText.magnifierConfiguration.magnifierBuilder(
context, context,
MagnifierController(), MagnifierController(),
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(MagnifierOverlayInfoBearer.empty),
const MagnifierOverlayInfoBearer.empty(), ),
)),
isA<TextMagnifier>()); isA<TextMagnifier>());
}, variant: TargetPlatformVariant.only(TargetPlatform.android)); }, variant: TargetPlatformVariant.only(TargetPlatform.android));
...@@ -11937,9 +11935,8 @@ void main() { ...@@ -11937,9 +11935,8 @@ void main() {
editableText.magnifierConfiguration.magnifierBuilder( editableText.magnifierConfiguration.magnifierBuilder(
context, context,
MagnifierController(), MagnifierController(),
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(MagnifierOverlayInfoBearer.empty),
const MagnifierOverlayInfoBearer.empty(), ),
)),
isA<CupertinoTextMagnifier>()); isA<CupertinoTextMagnifier>());
}, variant: TargetPlatformVariant.only(TargetPlatform.iOS)); }, variant: TargetPlatformVariant.only(TargetPlatform.iOS));
...@@ -11956,9 +11953,8 @@ void main() { ...@@ -11956,9 +11953,8 @@ void main() {
editableText.magnifierConfiguration.magnifierBuilder( editableText.magnifierConfiguration.magnifierBuilder(
context, context,
MagnifierController(), MagnifierController(),
ValueNotifier<MagnifierOverlayInfoBearer>( ValueNotifier<MagnifierOverlayInfoBearer>(MagnifierOverlayInfoBearer.empty),
const MagnifierOverlayInfoBearer.empty(), ),
)),
isNull); isNull);
}, },
variant: TargetPlatformVariant.all(excluding: <TargetPlatform>{ variant: TargetPlatformVariant.all(excluding: <TargetPlatform>{
......
...@@ -12667,12 +12667,12 @@ void main() { ...@@ -12667,12 +12667,12 @@ void main() {
final BuildContext context = tester.firstElement(find.byType(EditableText)); final BuildContext context = tester.firstElement(find.byType(EditableText));
expect( expect(
editableText.magnifierConfiguration.magnifierBuilder( editableText.magnifierConfiguration.magnifierBuilder(
context, context,
MagnifierController(), MagnifierController(),
ValueNotifier<MagnifierOverlayInfoBearer>(const MagnifierOverlayInfoBearer.empty()) ValueNotifier<MagnifierOverlayInfoBearer>(MagnifierOverlayInfoBearer.empty)
), ),
isNull isNull,
); );
}); });
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment