Skip to content

Commit

Permalink
Update Text field counter error style to material 3 (#108704)
Browse files Browse the repository at this point in the history
* M3 counter error style

* polish

* Update text_field_template.dart

* Roll Flutter Engine from 3cba105ed0bd to cf0db3e54687 (1 revision) (#108716)

* resolve comments

* Roll Plugins from 257eacb to a6d42f1 (3 revisions) (#108738)

* Override PlaceholderDimensions equality operator to avoid unnecessary TextPainter re-layouts (#108623)

* Roll Flutter Engine from cf0db3e54687 to aa9004449786 (1 revision) (#108734)

* Roll Flutter Engine from aa9004449786 to 6d2fd23404b8 (5 revisions) (#108744)

* Fix lerp to eccentric circle. (#108743)

* Roll Flutter Engine from 6d2fd23404b8 to f182794500dc (4 revisions) (#108749)

* Roll Flutter Engine from f182794500dc to 25e8021c91e4 (1 revision) (#108751)

* Sync with flutter/.github#13 (#108754)

* Roll Flutter Engine from 25e8021c91e4 to e771729efdde (2 revisions) (#108755)

* clean-up analysis_options.yaml (#108747)

* Fix ExpansionTile shows children background when expanded (#107834)

* Create `containsSemantics` to allow for partial matching of semantics in tests. (#108573)

* Roll Flutter Engine from e771729efdde to 7d0f6d2f11df (2 revisions) (#108757)

* Enable conditional_uri_does_not_exist (#108652)

* Roll Flutter Engine from 7d0f6d2f11df to b257966d8daa (3 revisions) (#108763)

* Roll Flutter Engine from b257966d8daa to 60e5eb6f3c2c (3 revisions) (#108766)

* Reland `Linux_samsung_a02 openpay_benchmarks__scroll_perf` (#108466) (#108769)

* [SelectionOverlay]Move the debug statement to the scope of the assertion. (#108508)

* Roll Flutter Engine from 60e5eb6f3c2c to 1c3b1b305ef3 (11 revisions) (#108780)

* Roll Flutter Engine from 1c3b1b305ef3 to b6078110efda (1 revision) (#108782)

* Roll Flutter Engine from b6078110efda to 3b2bd24a1e0b (1 revision) (#108784)

* Roll Flutter Engine from 3b2bd24a1e0b to 0e5392c4c248 (1 revision) (#108788)

* Roll Flutter Engine from 0e5392c4c248 to 4b192569797f (1 revision) (#108793)

* Roll Flutter Engine from 4b192569797f to e0b5edc1131b (2 revisions) (#108798)

* Roll Flutter Engine from e0b5edc1131b to b164c5c86d1c (1 revision) (#108814)

* Update text_field.dart

* Roll Flutter Engine from b164c5c86d1c to eb2b57bdb7bc (4 revisions) (#108821)

* Roll Plugins from a6d42f1 to 0d6d03a (1 revision) (#108822)

* Roll Flutter Engine from eb2b57bdb7bc to 978d8e2dbe35 (2 revisions) (#108825)

* Loupe Android + iOS (#107477)

* added Magnifier for iOS and Android

* Mark `Mac_ios microbenchmarks_ios_flaky` flaky (#108820)

* Deprecate `toggleableActiveColor` (#97972)

* Roll Flutter Engine from 978d8e2dbe35 to 2b3173254281 (4 revisions) (#108830)

* [flutter_tools] Test that DAP process terminates at the end of a session (#108301)

* Roll Flutter Engine from 2b3173254281 to 4e9c8699468a (1 revision) (#108833)

* fix noop toString() diagnostics (#108836)

* [flutter_tools] Migrate more tool tests to null-safety (#108639)

* Revert "Fix ExpansionTile shows children background when expanded" (#108844)

* Roll Flutter Engine from 4e9c8699468a to 6724561b1cf4 (2 revisions) (#108838)

* Marks Linux_android clipper_cache_perf__e2e_summary to be unflaky (#104088)

* Update documentation to match implementation (#108843)

* Reland "Add shadowColor and surfaceTintColor to Dialog and DialogTheme." #108718

* Roll Flutter Engine from 6724561b1cf4 to f3deaba5a359 (8 revisions) (#108847)

* Roll Flutter Engine from f3deaba5a359 to c07e1acfadda (2 revisions) (#108849)

* Roll Flutter Engine from c07e1acfadda to a1e77ae885a0 (5 revisions) (#108850)

* Roll Flutter Engine from a1e77ae885a0 to c4564762773f (2 revisions) (#108853)

* Roll Flutter Engine from c4564762773f to 6cd744bb9706 (1 revision) (#108857)

* Roll Flutter Engine from 6cd744bb9706 to 51296a62d98c (1 revision) (#108860)

* Roll Flutter Engine from 51296a62d98c to 05228ad454bc (1 revision) (#108862)

* Revert "Roll Flutter Engine from 51296a62d98c to 05228ad454bc (1 revision) (#108862)" (#108882)

This reverts commit a880c4e.

* Roll Plugins from 0d6d03a to e74c420 (5 revisions) (#108887)

* Roll Flutter Engine from 51296a62d98c to 2c282981d849 (6 revisions) (#108899)

* [flutter_test] Add flag to send device pointer events to the framework (#108430)

* Roll Flutter Engine from 2c282981d849 to adba70232a61 (2 revisions) (#108903)

* fix flutter not finding custom device (#108884)

* Force a11y services to off for complex_layout_semantics_perf test (#108906)

* Update `equalsIgnoringHashCodes` to take a list of Strings (#108507)

* [macOS] Use editing intents from engine (#105407)

* Added `IconButtonTheme` and apply it to `IconButton` in M3 (#108332)

* Created IconButtonTheme and apply it to IconButton

* [web] Add onEntrypointLoaded to FlutterLoader. (#108776)

* Roll pub packages (#108919)

* [flutter_test] perf: find.ancestor (#108868)

* Roll Flutter Engine from adba70232a61 to 1188a808e1e0 (4 revisions) (#108922)

* Bump github/codeql-action from 2.1.17 to 2.1.18 (#108923)

* Remove some outdated ignores from framework (#108915)

* Roll Flutter Engine from 1188a808e1e0 to 1743d1db1dda (1 revision) (#108925)

* Clean up ScrollbarPainter (#107179)

* Remove outdated ignores (#108924)

* Add more logs to diagnose Gold flake (#108930)

* M3 counter error style

* polish

* Update text_field_template.dart

* resolve comments

* Update text_field.dart

Co-authored-by: engine-flutter-autoroll <[email protected]>
Co-authored-by: Tomasz Gucio <[email protected]>
Co-authored-by: Greg Spencer <[email protected]>
Co-authored-by: Ian Hickson <[email protected]>
Co-authored-by: Michael Goderbauer <[email protected]>
Co-authored-by: Bruno Leroux <[email protected]>
Co-authored-by: pdblasi-google <[email protected]>
Co-authored-by: Kaushik Iska <[email protected]>
Co-authored-by: xubaolin <[email protected]>
Co-authored-by: Anthony Oleinik <[email protected]>
Co-authored-by: keyonghan <[email protected]>
Co-authored-by: Taha Tesser <[email protected]>
Co-authored-by: Danny Tuppeny <[email protected]>
Co-authored-by: Phil Quitslund <[email protected]>
Co-authored-by: Christopher Fujino <[email protected]>
Co-authored-by: Kate Lovett <[email protected]>
Co-authored-by: Flutter GitHub Bot <[email protected]>
Co-authored-by: parkershepherd <[email protected]>
Co-authored-by: Darren Austin <[email protected]>
Co-authored-by: Zachary Anderson <[email protected]>
Co-authored-by: Jia Hao <[email protected]>
Co-authored-by: Hannes Winkler <[email protected]>
Co-authored-by: Matej Knopp <[email protected]>
Co-authored-by: Qun Cheng <[email protected]>
Co-authored-by: David Iglesias <[email protected]>
Co-authored-by: Pascal Welsch <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
1 parent abbc0be commit 00ee316
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
3 changes: 3 additions & 0 deletions dev/tools/gen_defaults/lib/text_field_template.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ class TextFieldTemplate extends TokenTemplate {
// Generated version ${tokens["version"]}
TextStyle _m3InputStyle(BuildContext context) => ${textStyle("md.comp.filled-text-field.label-text")}!;
TextStyle _m3CounterErrorStyle(BuildContext context) =>
${textStyle("md.comp.filled-text-field.supporting-text")}!.copyWith(color:${componentColor('md.comp.filled-text-field.error.supporting-text')});
''';
}
8 changes: 7 additions & 1 deletion packages/flutter/lib/src/material/text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ class _TextFieldState extends State<TextField> with RestorationMixin implements
return effectiveDecoration.copyWith(
errorText: effectiveDecoration.errorText ?? '',
counterStyle: effectiveDecoration.errorStyle
?? themeData.textTheme.caption!.copyWith(color: themeData.errorColor),
?? (themeData.useMaterial3 ? _m3CounterErrorStyle(context): _m2CounterErrorStyle(context)),
counterText: counterText,
semanticCounterText: semanticCounterText,
);
Expand Down Expand Up @@ -1401,6 +1401,9 @@ class _TextFieldState extends State<TextField> with RestorationMixin implements
}
}

TextStyle _m2CounterErrorStyle(BuildContext context) =>
Theme.of(context).textTheme.caption!.copyWith(color: Theme.of(context).errorColor);

// BEGIN GENERATED TOKEN PROPERTIES - TextField

// Do not edit by hand. The code between the "BEGIN GENERATED" and
Expand All @@ -1414,4 +1417,7 @@ class _TextFieldState extends State<TextField> with RestorationMixin implements

TextStyle _m3InputStyle(BuildContext context) => Theme.of(context).textTheme.bodyLarge!;

TextStyle _m3CounterErrorStyle(BuildContext context) =>
Theme.of(context).textTheme.bodySmall!.copyWith(color:Theme.of(context).colorScheme.error);

// END GENERATED TOKEN PROPERTIES - TextField
35 changes: 34 additions & 1 deletion packages/flutter/test/material/text_field_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ Widget overlayWithEntry(OverlayEntry entry) {
);
}

Widget boilerplate({ required Widget child }) {
Widget boilerplate({ required Widget child, ThemeData? theme }) {
return MaterialApp(
theme: theme,
home: Localizations(
locale: const Locale('en', 'US'),
delegates: <LocalizationsDelegate<dynamic>>[
Expand Down Expand Up @@ -4655,6 +4656,38 @@ void main() {
expect(counterTextWidget.style!.color, isNot(equals(Colors.deepPurpleAccent)));
});

testWidgets('maxLength shows warning in Material 3', (WidgetTester tester) async {
final TextEditingController textController = TextEditingController();
final ThemeData theme = ThemeData.from(
colorScheme: const ColorScheme.light().copyWith(error: Colors.deepPurpleAccent),
useMaterial3: true,
);
await tester.pumpWidget(boilerplate(
theme: theme,
child: TextField(
controller: textController,
maxLength: 10,
maxLengthEnforcement: MaxLengthEnforcement.none,
),
));

await tester.enterText(find.byType(TextField), '0123456789101112');
await tester.pump();

expect(textController.text, '0123456789101112');
expect(find.text('16/10'), findsOneWidget);
Text counterTextWidget = tester.widget(find.text('16/10'));
expect(counterTextWidget.style!.color, equals(Colors.deepPurpleAccent));

await tester.enterText(find.byType(TextField), '0123456789');
await tester.pump();

expect(textController.text, '0123456789');
expect(find.text('10/10'), findsOneWidget);
counterTextWidget = tester.widget(find.text('10/10'));
expect(counterTextWidget.style!.color, isNot(equals(Colors.deepPurpleAccent)));
});

testWidgets('maxLength shows warning when maxLengthEnforcement.none with surrogate pairs.', (WidgetTester tester) async {
final TextEditingController textController = TextEditingController();
const TextStyle testStyle = TextStyle(color: Colors.deepPurpleAccent);
Expand Down

0 comments on commit 00ee316

Please sign in to comment.