From 13885e7d87757c9821d783d6b455b6d779d19e15 Mon Sep 17 00:00:00 2001 From: creativecreatorormaybenot Date: Tue, 31 Aug 2021 17:51:02 +0000 Subject: [PATCH] Fix text field naming (#89117) --- .../lib/src/cupertino/search_field.dart | 4 +- .../lib/src/widgets/text_selection.dart | 14 +- .../test/cupertino/text_field_test.dart | 128 +++++++++--------- 3 files changed, 73 insertions(+), 73 deletions(-) diff --git a/packages/flutter/lib/src/cupertino/search_field.dart b/packages/flutter/lib/src/cupertino/search_field.dart index 15b2d2e7e5..e95068b3d1 100644 --- a/packages/flutter/lib/src/cupertino/search_field.dart +++ b/packages/flutter/lib/src/cupertino/search_field.dart @@ -97,7 +97,7 @@ class CupertinoSearchTextField extends StatefulWidget { // TODO(DanielEdrisian): Localize the 'Search' placeholder. /// /// The [style] and [placeholderStyle] properties allow changing the style of - /// the text and placeholder of the textfield. [placeholderStyle] defaults + /// the text and placeholder of the text field. [placeholderStyle] defaults /// to the gray [CupertinoColors.secondaryLabel] iOS color. /// /// To set the text field's background color and border radius, pass a @@ -199,7 +199,7 @@ class CupertinoSearchTextField extends StatefulWidget { /// Defaults to 'Search' localized in each supported language. final String? placeholder; - /// Sets the style of the placeholder of the textfield. + /// Sets the style of the placeholder of the text field. /// /// Defaults to the gray [CupertinoColors.secondaryLabel] iOS color. final TextStyle? placeholderStyle; diff --git a/packages/flutter/lib/src/widgets/text_selection.dart b/packages/flutter/lib/src/widgets/text_selection.dart index be4e416d25..45c527e530 100644 --- a/packages/flutter/lib/src/widgets/text_selection.dart +++ b/packages/flutter/lib/src/widgets/text_selection.dart @@ -871,27 +871,27 @@ class _TextSelectionHandleOverlayState /// Delegate interface for the [TextSelectionGestureDetectorBuilder]. /// -/// The interface is usually implemented by textfield implementations wrapping +/// The interface is usually implemented by text field implementations wrapping /// [EditableText], that use a [TextSelectionGestureDetectorBuilder] to build a /// [TextSelectionGestureDetector] for their [EditableText]. The delegate provides -/// the builder with information about the current state of the textfield. +/// the builder with information about the current state of the text field. /// Based on these information, the builder adds the correct gesture handlers /// to the gesture detector. /// /// See also: /// -/// * [TextField], which implements this delegate for the Material textfield. +/// * [TextField], which implements this delegate for the Material text field. /// * [CupertinoTextField], which implements this delegate for the Cupertino -/// textfield. +/// text field. abstract class TextSelectionGestureDetectorBuilderDelegate { /// [GlobalKey] to the [EditableText] for which the /// [TextSelectionGestureDetectorBuilder] will build a [TextSelectionGestureDetector]. GlobalKey get editableTextKey; - /// Whether the textfield should respond to force presses. + /// Whether the text field should respond to force presses. bool get forcePressEnabled; - /// Whether the user may select text in the textfield. + /// Whether the user may select text in the text field. bool get selectionEnabled; } @@ -924,7 +924,7 @@ class TextSelectionGestureDetectorBuilder { /// The delegate for this [TextSelectionGestureDetectorBuilder]. /// /// The delegate provides the builder with information about what actions can - /// currently be performed on the textfield. Based on this, the builder adds + /// currently be performed on the text field. Based on this, the builder adds /// the correct gesture handlers to the gesture detector. @protected final TextSelectionGestureDetectorBuilderDelegate delegate; diff --git a/packages/flutter/test/cupertino/text_field_test.dart b/packages/flutter/test/cupertino/text_field_test.dart index 698032124b..d35379755e 100644 --- a/packages/flutter/test/cupertino/text_field_test.dart +++ b/packages/flutter/test/cupertino/text_field_test.dart @@ -1628,9 +1628,9 @@ void main() { ), ); - final Offset textfieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); + final Offset textFieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); - await tester.tapAt(textfieldStart + const Offset(50.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(50.0, 5.0)); await tester.pump(); // We moved the cursor. @@ -1660,11 +1660,11 @@ void main() { ), ); - final Offset textfieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); + final Offset textFieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); - await tester.tapAt(textfieldStart + const Offset(50.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(50.0, 5.0)); await tester.pump(const Duration(milliseconds: 500)); - await tester.tapAt(textfieldStart + const Offset(50.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(50.0, 5.0)); await tester.pump(); // Plain collapsed selection. @@ -1753,19 +1753,19 @@ void main() { ), ); - final Offset textfieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); + final Offset textFieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); - await tester.tapAt(textfieldStart + const Offset(50.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(50.0, 5.0)); await tester.pump(const Duration(milliseconds: 500)); - await tester.tapAt(textfieldStart + const Offset(150.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(150.0, 5.0)); await tester.pump(const Duration(milliseconds: 50)); // First tap moved the cursor. expect( controller.selection, const TextSelection.collapsed(offset: 8, affinity: TextAffinity.downstream), ); - await tester.tapAt(textfieldStart + const Offset(150.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(150.0, 5.0)); await tester.pumpAndSettle(); // Second tap selects the word around the cursor. @@ -1795,12 +1795,12 @@ void main() { ), ); - final Offset textfieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); + final Offset textFieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); - await tester.tapAt(textfieldStart + const Offset(150.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(150.0, 5.0)); await tester.pump(const Duration(milliseconds: 50)); final TestGesture gesture = - await tester.startGesture(textfieldStart + const Offset(150.0, 5.0)); + await tester.startGesture(textFieldStart + const Offset(150.0, 5.0)); // Hold the press. await tester.pumpAndSettle(); @@ -1840,19 +1840,19 @@ void main() { ), ); - final Offset textfieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); + final Offset textFieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); - await tester.tapAt(textfieldStart + const Offset(150.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(150.0, 5.0)); await tester.pump(const Duration(milliseconds: 50)); // First tap moved the cursor. expect( controller.selection, const TextSelection.collapsed(offset: 8, affinity: TextAffinity.downstream), ); - await tester.tapAt(textfieldStart + const Offset(150.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(150.0, 5.0)); await tester.pump(const Duration(milliseconds: 500)); - await tester.tapAt(textfieldStart + const Offset(100.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(100.0, 5.0)); await tester.pump(); // Plain collapsed selection at the edge of first word. In iOS 12, the @@ -2075,12 +2075,12 @@ void main() { ), ); - final Offset textfieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); + final Offset textFieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); - await tester.tapAt(textfieldStart + const Offset(150.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(150.0, 5.0)); await tester.pump(const Duration(milliseconds: 50)); final TestGesture gesture = - await tester.startGesture(textfieldStart + const Offset(150.0, 5.0)); + await tester.startGesture(textFieldStart + const Offset(150.0, 5.0)); // Hold the press. await tester.pump(const Duration(milliseconds: 500)); @@ -2122,12 +2122,12 @@ void main() { ), ); - final Offset textfieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); + final Offset textFieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); - await tester.tapAt(textfieldStart + const Offset(150.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(150.0, 5.0)); await tester.pump(const Duration(milliseconds: 50)); final TestGesture gesture = - await tester.startGesture(textfieldStart + const Offset(150.0, 5.0)); + await tester.startGesture(textFieldStart + const Offset(150.0, 5.0)); // Hold the press. await tester.pumpAndSettle(); @@ -2168,11 +2168,11 @@ void main() { ), ); - final Offset textfieldStart = tester.getCenter(find.byType(CupertinoTextField)); + final Offset textFieldStart = tester.getCenter(find.byType(CupertinoTextField)); - await tester.tapAt(textfieldStart + const Offset(150.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(150.0, 5.0)); await tester.pump(const Duration(milliseconds: 50)); - await tester.longPressAt(textfieldStart + const Offset(150.0, 5.0)); + await tester.longPressAt(textFieldStart + const Offset(150.0, 5.0)); await tester.pump(); // Should only have paste option when whole obscure text is selected. @@ -2182,11 +2182,11 @@ void main() { expect(find.text('Select All'), findsNothing); // Tap to cancel selection. - final Offset textfieldEnd = tester.getTopRight(find.byType(CupertinoTextField)); - await tester.tapAt(textfieldEnd + const Offset(-10.0, 5.0)); + final Offset textFieldEnd = tester.getTopRight(find.byType(CupertinoTextField)); + await tester.tapAt(textFieldEnd + const Offset(-10.0, 5.0)); await tester.pump(const Duration(milliseconds: 50)); // Long tap at the end. - await tester.longPressAt(textfieldEnd + const Offset(-10.0, 5.0)); + await tester.longPressAt(textFieldEnd + const Offset(-10.0, 5.0)); await tester.pump(); // Should have paste and select all options when collapse. @@ -2212,9 +2212,9 @@ void main() { ), ); - final Offset textfieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); + final Offset textFieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); - await tester.longPressAt(textfieldStart + const Offset(50.0, 5.0)); + await tester.longPressAt(textFieldStart + const Offset(50.0, 5.0)); await tester.pumpAndSettle(); // Collapsed cursor for iOS long press. @@ -2244,12 +2244,12 @@ void main() { ), ); - final Offset textfieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); + final Offset textFieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); - await tester.longPressAt(textfieldStart + const Offset(50.0, 5.0)); + await tester.longPressAt(textFieldStart + const Offset(50.0, 5.0)); await tester.pump(const Duration(milliseconds: 50)); - await tester.tapAt(textfieldStart + const Offset(50.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(50.0, 5.0)); await tester.pump(); // We ended up moving the cursor to the edge of the same word and dismissed @@ -2280,10 +2280,10 @@ void main() { ), ); - final Offset textfieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); + final Offset textFieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); final TestGesture gesture = - await tester.startGesture(textfieldStart + const Offset(50.0, 5.0)); + await tester.startGesture(textFieldStart + const Offset(50.0, 5.0)); await tester.pump(const Duration(milliseconds: 500)); // Long press on iOS shows collapsed selection cursor. @@ -2355,10 +2355,10 @@ void main() { // the right side of the screen. expect(lastCharEndpoint[0].point.dx, moreOrLessEquals(1094.73, epsilon: 0.25)); - final Offset textfieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); + final Offset textFieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); final TestGesture gesture = - await tester.startGesture(textfieldStart + const Offset(300, 5)); + await tester.startGesture(textFieldStart + const Offset(300, 5)); await tester.pump(const Duration(milliseconds: 500)); expect( @@ -2432,19 +2432,19 @@ void main() { ), ); - final Offset textfieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); + final Offset textFieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); - await tester.tapAt(textfieldStart + const Offset(150.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(150.0, 5.0)); await tester.pump(const Duration(milliseconds: 50)); // First tap moved the cursor to the beginning of the second word. expect( controller.selection, const TextSelection.collapsed(offset: 8, affinity: TextAffinity.downstream), ); - await tester.tapAt(textfieldStart + const Offset(150.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(150.0, 5.0)); await tester.pump(const Duration(milliseconds: 500)); - await tester.longPressAt(textfieldStart + const Offset(100.0, 5.0)); + await tester.longPressAt(textFieldStart + const Offset(100.0, 5.0)); await tester.pumpAndSettle(); // Plain collapsed selection at the exact tap position. @@ -2474,19 +2474,19 @@ void main() { ), ); - final Offset textfieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); + final Offset textFieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); - await tester.longPressAt(textfieldStart + const Offset(50.0, 5.0)); + await tester.longPressAt(textFieldStart + const Offset(50.0, 5.0)); await tester.pump(const Duration(milliseconds: 50)); - await tester.tapAt(textfieldStart + const Offset(150.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(150.0, 5.0)); await tester.pump(const Duration(milliseconds: 50)); // First tap moved the cursor. expect( controller.selection, const TextSelection.collapsed(offset: 8, affinity: TextAffinity.downstream), ); - await tester.tapAt(textfieldStart + const Offset(150.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(150.0, 5.0)); await tester.pumpAndSettle(); // Double tap selection. @@ -2515,15 +2515,15 @@ void main() { ), ); - final Offset textfieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); + final Offset textFieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); - await tester.tapAt(textfieldStart + const Offset(50.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(50.0, 5.0)); await tester.pump(const Duration(milliseconds: 50)); expect( controller.selection, const TextSelection.collapsed(offset: 7, affinity: TextAffinity.upstream), ); - await tester.tapAt(textfieldStart + const Offset(50.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(50.0, 5.0)); await tester.pumpAndSettle(); expect( controller.selection, @@ -2532,14 +2532,14 @@ void main() { expect(find.byType(CupertinoButton), isContextMenuProvidedByPlatform ? findsNothing : findsNWidgets(3)); // Double tap selecting the same word somewhere else is fine. - await tester.tapAt(textfieldStart + const Offset(100.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(100.0, 5.0)); await tester.pump(const Duration(milliseconds: 50)); // First tap moved the cursor. expect( controller.selection, const TextSelection.collapsed(offset: 7, affinity: TextAffinity.upstream), ); - await tester.tapAt(textfieldStart + const Offset(100.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(100.0, 5.0)); await tester.pumpAndSettle(); expect( controller.selection, @@ -2547,14 +2547,14 @@ void main() { ); expect(find.byType(CupertinoButton), isContextMenuProvidedByPlatform ? findsNothing : findsNWidgets(3)); - await tester.tapAt(textfieldStart + const Offset(150.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(150.0, 5.0)); await tester.pump(const Duration(milliseconds: 50)); // First tap moved the cursor. expect( controller.selection, const TextSelection.collapsed(offset: 8, affinity: TextAffinity.downstream), ); - await tester.tapAt(textfieldStart + const Offset(150.0, 5.0)); + await tester.tapAt(textFieldStart + const Offset(150.0, 5.0)); await tester.pumpAndSettle(); expect( controller.selection, @@ -2578,15 +2578,15 @@ void main() { ), ); - final Offset textfieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); + final Offset textFieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); final int pointerValue = tester.nextPointer; final TestGesture gesture = await tester.createGesture(); await gesture.downWithCustomEvent( - textfieldStart + const Offset(150.0, 5.0), + textFieldStart + const Offset(150.0, 5.0), PointerDownEvent( pointer: pointerValue, - position: textfieldStart + const Offset(150.0, 5.0), + position: textFieldStart + const Offset(150.0, 5.0), pressure: 3.0, pressureMax: 6.0, pressureMin: 0.0, @@ -2618,15 +2618,15 @@ void main() { ), ); - final Offset textfieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); + final Offset textFieldStart = tester.getTopLeft(find.byType(CupertinoTextField)); final int pointerValue = tester.nextPointer; final TestGesture gesture = await tester.createGesture(); await gesture.downWithCustomEvent( - textfieldStart + const Offset(150.0, 5.0), + textFieldStart + const Offset(150.0, 5.0), PointerDownEvent( pointer: pointerValue, - position: textfieldStart + const Offset(150.0, 5.0), + position: textFieldStart + const Offset(150.0, 5.0), // iPhone 6 and below report 0 across the board. pressure: 0, pressureMax: 0, @@ -4463,12 +4463,12 @@ void main() { ), ); - final Offset textfieldStart = tester.getTopLeft(find.byKey(const Key('field0'))); + final Offset textFieldStart = tester.getTopLeft(find.byKey(const Key('field0'))); - await tester.longPressAt(textfieldStart + const Offset(50.0, 2.0)); + await tester.longPressAt(textFieldStart + const Offset(50.0, 2.0)); await tester.pump(const Duration(milliseconds: 150)); // Tap the Select All button. - await tester.tapAt(textfieldStart + const Offset(20.0, 100.0)); + await tester.tapAt(textFieldStart + const Offset(20.0, 100.0)); await tester.pump(const Duration(milliseconds: 300)); await expectLater( @@ -4510,12 +4510,12 @@ void main() { ), ); - final Offset textfieldStart = tester.getTopLeft(find.byKey(const Key('field0'))); + final Offset textFieldStart = tester.getTopLeft(find.byKey(const Key('field0'))); - await tester.longPressAt(textfieldStart + const Offset(50.0, 2.0)); + await tester.longPressAt(textFieldStart + const Offset(50.0, 2.0)); await tester.pump(const Duration(milliseconds: 150)); // Tap the Select All button. - await tester.tapAt(textfieldStart + const Offset(20.0, 100.0)); + await tester.tapAt(textFieldStart + const Offset(20.0, 100.0)); await tester.pump(const Duration(milliseconds: 300)); await expectLater(