From 260737cfe11d848f84cc74495dd4ec249021b009 Mon Sep 17 00:00:00 2001 From: hangyu <108393416+hangyujin@users.noreply.github.com> Date: Fri, 21 Oct 2022 01:07:49 +0800 Subject: [PATCH 1/4] text field update --- .../lib/input_decorator_template.dart | 96 +++++++++---------- dev/tools/gen_defaults/lib/template.dart | 2 +- .../lib/src/material/bottom_sheet.dart | 2 +- .../lib/src/material/input_decorator.dart | 36 +++---- 4 files changed, 68 insertions(+), 68 deletions(-) diff --git a/dev/tools/gen_defaults/lib/input_decorator_template.dart b/dev/tools/gen_defaults/lib/input_decorator_template.dart index efe3129e9aa5d..aa020d21035f2 100644 --- a/dev/tools/gen_defaults/lib/input_decorator_template.dart +++ b/dev/tools/gen_defaults/lib/input_decorator_template.dart @@ -40,21 +40,21 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { @override BorderSide? get activeIndicatorBorder => MaterialStateBorderSide.resolveWith((Set states) { - if (states.contains(MaterialState.error)) { - if (states.contains(MaterialState.hovered)) { - return ${border('md.comp.filled-text-field.error.hover.active-indicator')}; - }${border('md.comp.filled-text-field.error.focus.active-indicator') == border('md.comp.filled-text-field.error.active-indicator') ? '' : ''' + if (states.contains(MaterialState.error)) {${border('md.comp.filled-text-field.error.focus.active-indicator') == border('md.comp.filled-text-field.error.active-indicator') ? '' : ''' if (states.contains(MaterialState.focused)) { return ${border('md.comp.filled-text-field.error.focus.active-indicator')}; }'''} + if (states.contains(MaterialState.hovered)) { + return ${border('md.comp.filled-text-field.error.hover.active-indicator')}; + } return ${border('md.comp.filled-text-field.error.active-indicator')}; } - if (states.contains(MaterialState.hovered)) { - return ${border('md.comp.filled-text-field.hover.active-indicator')}; - } if (states.contains(MaterialState.focused)) { return ${border('md.comp.filled-text-field.focus.active-indicator')}; } + if (states.contains(MaterialState.hovered)) { + return ${border('md.comp.filled-text-field.hover.active-indicator')}; + } if (states.contains(MaterialState.disabled)) { return ${border('md.comp.filled-text-field.disabled.active-indicator')}; } @@ -63,21 +63,21 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { @override BorderSide? get outlineBorder => MaterialStateBorderSide.resolveWith((Set states) { - if (states.contains(MaterialState.error)) { - if (states.contains(MaterialState.hovered)) { - return ${border('md.comp.outlined-text-field.error.hover.outline')}; - }${border('md.comp.outlined-text-field.error.focus.outline') == border('md.comp.outlined-text-field.error.outline') ? '' : ''' + if (states.contains(MaterialState.error)) {${border('md.comp.outlined-text-field.error.focus.outline') == border('md.comp.outlined-text-field.error.outline') ? '' : ''' if (states.contains(MaterialState.focused)) { return ${border('md.comp.outlined-text-field.error.focus.outline')}; }'''} + if (states.contains(MaterialState.hovered)) { + return ${border('md.comp.outlined-text-field.error.hover.outline')}; + } return ${border('md.comp.outlined-text-field.error.outline')}; } - if (states.contains(MaterialState.hovered)) { - return ${border('md.comp.outlined-text-field.hover.outline')}; - } if (states.contains(MaterialState.focused)) { return ${border('md.comp.outlined-text-field.focus.outline')}; } + if (states.contains(MaterialState.hovered)) { + return ${border('md.comp.outlined-text-field.hover.outline')}; + } if (states.contains(MaterialState.disabled)) { return ${border('md.comp.outlined-text-field.disabled.outline')}; } @@ -90,19 +90,19 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { @override Color? get prefixIconColor => MaterialStateColor.resolveWith((Set states) {${componentColor('md.comp.filled-text-field.error.leading-icon') == componentColor('md.comp.filled-text-field.leading-icon') ? '' : ''' if(states.contains(MaterialState.error)) { - if (states.contains(MaterialState.hovered)) { - return ${componentColor('md.comp.filled-text-field.error.hover.leading-icon')}; - } if (states.contains(MaterialState.focused)) { return ${componentColor('md.comp.filled-text-field.error.focus.leading-icon')}; } + if (states.contains(MaterialState.hovered)) { + return ${componentColor('md.comp.filled-text-field.error.hover.leading-icon')}; + } return ${componentColor('md.comp.filled-text-field.error.leading-icon')}; - }'''}${componentColor('md.comp.filled-text-field.hover.leading-icon') == componentColor('md.comp.filled-text-field.leading-icon') ? '' : ''' - if (states.contains(MaterialState.hovered)) { - return ${componentColor('md.comp.filled-text-field.hover.leading-icon')}; }'''}${componentColor('md.comp.filled-text-field.focus.leading-icon') == componentColor('md.comp.filled-text-field.leading-icon') ? '' : ''' if (states.contains(MaterialState.focused)) { return ${componentColor('md.comp.filled-text-field.focus.leading-icon')}; + }'''}${componentColor('md.comp.filled-text-field.hover.leading-icon') == componentColor('md.comp.filled-text-field.leading-icon') ? '' : ''' + if (states.contains(MaterialState.hovered)) { + return ${componentColor('md.comp.filled-text-field.hover.leading-icon')}; }'''} if (states.contains(MaterialState.disabled)) { return ${componentColor('md.comp.filled-text-field.disabled.leading-icon')}; @@ -112,20 +112,20 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { @override Color? get suffixIconColor => MaterialStateColor.resolveWith((Set states) { - if(states.contains(MaterialState.error)) { - if (states.contains(MaterialState.hovered)) { - return ${componentColor('md.comp.filled-text-field.error.hover.trailing-icon')}; - }${componentColor('md.comp.filled-text-field.error.trailing-icon') == componentColor('md.comp.filled-text-field.error.focus.trailing-icon') ? '' : ''' + if(states.contains(MaterialState.error)) {${componentColor('md.comp.filled-text-field.error.trailing-icon') == componentColor('md.comp.filled-text-field.error.focus.trailing-icon') ? '' : ''' if (states.contains(MaterialState.focused)) { return ${componentColor('md.comp.filled-text-field.error.focus.trailing-icon')}; }'''} + if (states.contains(MaterialState.hovered)) { + return ${componentColor('md.comp.filled-text-field.error.hover.trailing-icon')}; + } return ${componentColor('md.comp.filled-text-field.error.trailing-icon')}; - }${componentColor('md.comp.filled-text-field.hover.trailing-icon') == componentColor('md.comp.filled-text-field.trailing-icon') ? '' : ''' - if (states.contains(MaterialState.hovered)) { - return ${componentColor('md.comp.filled-text-field.hover.trailing-icon')}; - }'''}${componentColor('md.comp.filled-text-field.focus.trailing-icon') == componentColor('md.comp.filled-text-field.trailing-icon') ? '' : ''' + }${componentColor('md.comp.filled-text-field.focus.trailing-icon') == componentColor('md.comp.filled-text-field.trailing-icon') ? '' : ''' if (states.contains(MaterialState.focused)) { return ${componentColor('md.comp.filled-text-field.focus.trailing-icon')}; + }'''}${componentColor('md.comp.filled-text-field.hover.trailing-icon') == componentColor('md.comp.filled-text-field.trailing-icon') ? '' : ''' + if (states.contains(MaterialState.hovered)) { + return ${componentColor('md.comp.filled-text-field.hover.trailing-icon')}; }'''} if (states.contains(MaterialState.disabled)) { return ${componentColor('md.comp.filled-text-field.disabled.trailing-icon')}; @@ -137,20 +137,20 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { TextStyle? get labelStyle => MaterialStateTextStyle.resolveWith((Set states) { final TextStyle textStyle= ${textStyle("md.comp.filled-text-field.label-text")} ?? const TextStyle(); if(states.contains(MaterialState.error)) { - if (states.contains(MaterialState.hovered)) { - return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.error.hover.label-text')}); - } if (states.contains(MaterialState.focused)) { return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.error.focus.label-text')}); } + if (states.contains(MaterialState.hovered)) { + return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.error.hover.label-text')}); + } return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.error.label-text')}); } - if (states.contains(MaterialState.hovered)) { - return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.hover.label-text')}); - } if (states.contains(MaterialState.focused)) { return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.focus.label-text')}); } + if (states.contains(MaterialState.hovered)) { + return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.hover.label-text')}); + } if (states.contains(MaterialState.disabled)) { return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.disabled.label-text')}); } @@ -161,20 +161,20 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { TextStyle? get floatingLabelStyle => MaterialStateTextStyle.resolveWith((Set states) { final TextStyle textStyle= ${textStyle("md.comp.filled-text-field.label-text")} ?? const TextStyle(); if(states.contains(MaterialState.error)) { - if (states.contains(MaterialState.hovered)) { - return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.error.hover.label-text')}); - } if (states.contains(MaterialState.focused)) { return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.error.focus.label-text')}); } + if (states.contains(MaterialState.hovered)) { + return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.error.hover.label-text')}); + } return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.error.label-text')}); } - if (states.contains(MaterialState.hovered)) { - return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.hover.label-text')}); - } if (states.contains(MaterialState.focused)) { return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.focus.label-text')}); } + if (states.contains(MaterialState.hovered)) { + return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.hover.label-text')}); + } if (states.contains(MaterialState.disabled)) { return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.disabled.label-text')}); } @@ -183,12 +183,12 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { @override TextStyle? get helperStyle => MaterialStateTextStyle.resolveWith((Set states) { - final TextStyle textStyle= ${textStyle("md.comp.filled-text-field.supporting-text")} ?? const TextStyle();${componentColor('md.comp.filled-text-field.hover.supporting-text') == componentColor('md.comp.filled-text-field.supporting-text') ? '' : ''' - if (states.contains(MaterialState.hovered)) { - return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.hover.supporting-text')}); - }'''}${componentColor('md.comp.filled-text-field.focus.supporting-text') == componentColor('md.comp.filled-text-field.supporting-text') ? '' : ''' + final TextStyle textStyle= ${textStyle("md.comp.filled-text-field.supporting-text")} ?? const TextStyle();${componentColor('md.comp.filled-text-field.focus.supporting-text') == componentColor('md.comp.filled-text-field.supporting-text') ? '' : ''' if (states.contains(MaterialState.focused)) { return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.focus.supporting-text')}); + }'''}${componentColor('md.comp.filled-text-field.hover.supporting-text') == componentColor('md.comp.filled-text-field.supporting-text') ? '' : ''' + if (states.contains(MaterialState.hovered)) { + return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.hover.supporting-text')}); }'''} if (states.contains(MaterialState.disabled)) { return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.disabled.supporting-text')}); @@ -198,12 +198,12 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { @override TextStyle? get errorStyle => MaterialStateTextStyle.resolveWith((Set states) { - final TextStyle textStyle= ${textStyle("md.comp.filled-text-field.supporting-text")} ?? const TextStyle();${componentColor('md.comp.filled-text-field.error.hover.supporting-text') == componentColor('md.comp.filled-text-field.error.supporting-text') ? '' : ''' - if (states.contains(MaterialState.hovered)) { - return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.error.hover.supporting-text')}); - }'''}${componentColor('md.comp.filled-text-field.error.focus.supporting-text') == componentColor('md.comp.filled-text-field.error.supporting-text') ? '' : ''' + final TextStyle textStyle= ${textStyle("md.comp.filled-text-field.supporting-text")} ?? const TextStyle();${componentColor('md.comp.filled-text-field.error.focus.supporting-text') == componentColor('md.comp.filled-text-field.error.supporting-text') ? '' : ''' if (states.contains(MaterialState.focused)) { return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.error.focus.supporting-text')}); + }'''}${componentColor('md.comp.filled-text-field.error.hover.supporting-text') == componentColor('md.comp.filled-text-field.error.supporting-text') ? '' : ''' + if (states.contains(MaterialState.hovered)) { + return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.error.hover.supporting-text')}); }'''} return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.error.supporting-text')}); }); diff --git a/dev/tools/gen_defaults/lib/template.dart b/dev/tools/gen_defaults/lib/template.dart index 093688747a1d0..d3ecebb485897 100644 --- a/dev/tools/gen_defaults/lib/template.dart +++ b/dev/tools/gen_defaults/lib/template.dart @@ -202,7 +202,7 @@ abstract class TokenTemplate { return 'null'; } final String borderColor = componentColor(componentToken); - final double width = (tokens['$componentToken.width'] ?? 1.0) as double; + final double width = (tokens['$componentToken.width'] ?? tokens['$componentToken.height'] ?? 1.0) as double; return 'BorderSide(color: $borderColor${width != 1.0 ? ", width: $width" : ""})'; } diff --git a/packages/flutter/lib/src/material/bottom_sheet.dart b/packages/flutter/lib/src/material/bottom_sheet.dart index 5702d8e3a1a3f..c74fc71db0dee 100644 --- a/packages/flutter/lib/src/material/bottom_sheet.dart +++ b/packages/flutter/lib/src/material/bottom_sheet.dart @@ -946,7 +946,7 @@ class _BottomSheetDefaultsM3 extends BottomSheetThemeData { : super( elevation: 1.0, modalElevation: 1.0, - shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(28.0))), + shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(28.0),)), ); final BuildContext context; diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index f93a3524c2e1a..aa3c504aa215d 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -4490,12 +4490,12 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme { } return BorderSide(color: _colors.error); } + if (states.contains(MaterialState.focused)) { + return BorderSide(color: _colors.primary, width: 2.0); + } if (states.contains(MaterialState.hovered)) { return BorderSide(color: _colors.onSurface); } - if (states.contains(MaterialState.focused)) { - return BorderSide(color: _colors.primary); - } if (states.contains(MaterialState.disabled)) { return BorderSide(color: _colors.onSurface.withOpacity(0.38)); } @@ -4510,12 +4510,12 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme { } return BorderSide(color: _colors.error); } - if (states.contains(MaterialState.hovered)) { - return BorderSide(color: _colors.onSurface); - } if (states.contains(MaterialState.focused)) { return BorderSide(color: _colors.primary, width: 2.0); } + if (states.contains(MaterialState.hovered)) { + return BorderSide(color: _colors.onSurface); + } if (states.contains(MaterialState.disabled)) { return BorderSide(color: _colors.onSurface.withOpacity(0.12)); } @@ -4551,20 +4551,20 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme { TextStyle? get labelStyle => MaterialStateTextStyle.resolveWith((Set states) { final TextStyle textStyle= _textTheme.bodyLarge ?? const TextStyle(); if(states.contains(MaterialState.error)) { - if (states.contains(MaterialState.hovered)) { - return textStyle.copyWith(color:_colors.onErrorContainer); - } if (states.contains(MaterialState.focused)) { return textStyle.copyWith(color:_colors.error); } + if (states.contains(MaterialState.hovered)) { + return textStyle.copyWith(color:_colors.onErrorContainer); + } return textStyle.copyWith(color:_colors.error); } - if (states.contains(MaterialState.hovered)) { - return textStyle.copyWith(color:_colors.onSurfaceVariant); - } if (states.contains(MaterialState.focused)) { return textStyle.copyWith(color:_colors.primary); } + if (states.contains(MaterialState.hovered)) { + return textStyle.copyWith(color:_colors.onSurfaceVariant); + } if (states.contains(MaterialState.disabled)) { return textStyle.copyWith(color:_colors.onSurface.withOpacity(0.38)); } @@ -4575,20 +4575,20 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme { TextStyle? get floatingLabelStyle => MaterialStateTextStyle.resolveWith((Set states) { final TextStyle textStyle= _textTheme.bodyLarge ?? const TextStyle(); if(states.contains(MaterialState.error)) { - if (states.contains(MaterialState.hovered)) { - return textStyle.copyWith(color:_colors.onErrorContainer); - } if (states.contains(MaterialState.focused)) { return textStyle.copyWith(color:_colors.error); } + if (states.contains(MaterialState.hovered)) { + return textStyle.copyWith(color:_colors.onErrorContainer); + } return textStyle.copyWith(color:_colors.error); } - if (states.contains(MaterialState.hovered)) { - return textStyle.copyWith(color:_colors.onSurfaceVariant); - } if (states.contains(MaterialState.focused)) { return textStyle.copyWith(color:_colors.primary); } + if (states.contains(MaterialState.hovered)) { + return textStyle.copyWith(color:_colors.onSurfaceVariant); + } if (states.contains(MaterialState.disabled)) { return textStyle.copyWith(color:_colors.onSurface.withOpacity(0.38)); } From eac3418167f76226e371885036212f286e6c1410 Mon Sep 17 00:00:00 2001 From: hangyu <108393416+hangyujin@users.noreply.github.com> Date: Fri, 21 Oct 2022 01:25:21 +0800 Subject: [PATCH 2/4] update tests --- .../gen_defaults/lib/input_decorator_template.dart | 12 ++++++------ dev/tools/gen_defaults/lib/template.dart | 7 +++++++ .../flutter/lib/src/material/input_decorator.dart | 6 ++++++ .../flutter/test/material/input_decorator_test.dart | 2 +- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/dev/tools/gen_defaults/lib/input_decorator_template.dart b/dev/tools/gen_defaults/lib/input_decorator_template.dart index aa020d21035f2..d53007f8082d1 100644 --- a/dev/tools/gen_defaults/lib/input_decorator_template.dart +++ b/dev/tools/gen_defaults/lib/input_decorator_template.dart @@ -40,10 +40,10 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { @override BorderSide? get activeIndicatorBorder => MaterialStateBorderSide.resolveWith((Set states) { - if (states.contains(MaterialState.error)) {${border('md.comp.filled-text-field.error.focus.active-indicator') == border('md.comp.filled-text-field.error.active-indicator') ? '' : ''' + if (states.contains(MaterialState.error)) { if (states.contains(MaterialState.focused)) { - return ${border('md.comp.filled-text-field.error.focus.active-indicator')}; - }'''} + return ${mergedBorder('md.comp.filled-text-field.error.focus.active-indicator','md.comp.filled-text-field.focus.active-indicator')}; + } if (states.contains(MaterialState.hovered)) { return ${border('md.comp.filled-text-field.error.hover.active-indicator')}; } @@ -63,10 +63,10 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { @override BorderSide? get outlineBorder => MaterialStateBorderSide.resolveWith((Set states) { - if (states.contains(MaterialState.error)) {${border('md.comp.outlined-text-field.error.focus.outline') == border('md.comp.outlined-text-field.error.outline') ? '' : ''' + if (states.contains(MaterialState.error)) { if (states.contains(MaterialState.focused)) { - return ${border('md.comp.outlined-text-field.error.focus.outline')}; - }'''} + return ${mergedBorder('md.comp.outlined-text-field.error.focus.outline','md.comp.outlined-text-field.focus.outline')}; + } if (states.contains(MaterialState.hovered)) { return ${border('md.comp.outlined-text-field.error.hover.outline')}; } diff --git a/dev/tools/gen_defaults/lib/template.dart b/dev/tools/gen_defaults/lib/template.dart index d3ecebb485897..949338a810024 100644 --- a/dev/tools/gen_defaults/lib/template.dart +++ b/dev/tools/gen_defaults/lib/template.dart @@ -206,6 +206,13 @@ abstract class TokenTemplate { return 'BorderSide(color: $borderColor${width != 1.0 ? ", width: $width" : ""})'; } + /// Generate a [BorderSide] for the given components. + String mergedBorder(String componentToken1, String componentToken2) { + final String borderColor = componentColor(componentToken1)!='null' ? componentColor(componentToken1) :componentColor(componentToken2); + final double width = (tokens['$componentToken1.width'] ?? tokens['$componentToken1.height'] ?? tokens['$componentToken2.width'] ?? tokens['$componentToken2.height'] ?? 1.0) as double; + return 'BorderSide(color: $borderColor${width != 1.0 ? ", width: $width" : ""})'; + } + /// Generate a [TextTheme] text style name for the given component token. String textStyle(String componentToken) { return '$textThemePrefix${tokens["$componentToken.text-style"]}'; diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index aa3c504aa215d..fa0470557f619 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -4485,6 +4485,9 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme { @override BorderSide? get activeIndicatorBorder => MaterialStateBorderSide.resolveWith((Set states) { if (states.contains(MaterialState.error)) { + if (states.contains(MaterialState.focused)) { + return BorderSide(color: _colors.error, width: 2.0); + } if (states.contains(MaterialState.hovered)) { return BorderSide(color: _colors.onErrorContainer); } @@ -4505,6 +4508,9 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme { @override BorderSide? get outlineBorder => MaterialStateBorderSide.resolveWith((Set states) { if (states.contains(MaterialState.error)) { + if (states.contains(MaterialState.focused)) { + return BorderSide(color: _colors.error, width: 2.0); + } if (states.contains(MaterialState.hovered)) { return BorderSide(color: _colors.onErrorContainer); } diff --git a/packages/flutter/test/material/input_decorator_test.dart b/packages/flutter/test/material/input_decorator_test.dart index 90edae922dd98..0e7be331fe1c5 100644 --- a/packages/flutter/test/material/input_decorator_test.dart +++ b/packages/flutter/test/material/input_decorator_test.dart @@ -3404,7 +3404,7 @@ void main() { expect(tester.getTopRight(find.text('text')).dx, lessThanOrEqualTo(tester.getTopLeft(find.text('s')).dx)); expect(getBorderBottom(tester), 32.0); - expect(getBorderWeight(tester), useMaterial3 ? 1.0 : 2.0); + expect(getBorderWeight(tester), 2.0); }); testWidgets('InputDecorator with empty InputDecoration', (WidgetTester tester) async { From 1e224f9f905124913fe1ade2624dc9b8d0367532 Mon Sep 17 00:00:00 2001 From: hangyu <108393416+hangyujin@users.noreply.github.com> Date: Fri, 21 Oct 2022 01:37:30 +0800 Subject: [PATCH 3/4] lint --- dev/tools/gen_defaults/lib/template.dart | 16 ++++++++++++---- .../flutter/lib/src/material/bottom_sheet.dart | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/dev/tools/gen_defaults/lib/template.dart b/dev/tools/gen_defaults/lib/template.dart index 949338a810024..d7b1f976e47ec 100644 --- a/dev/tools/gen_defaults/lib/template.dart +++ b/dev/tools/gen_defaults/lib/template.dart @@ -179,8 +179,9 @@ abstract class TokenTemplate { } if (topLeft == topRight && bottomLeft == bottomRight) { return '${prefix}RoundedRectangleBorder(borderRadius: BorderRadius.vertical(' - '${topLeft > 0 ? 'top: Radius.circular($topLeft),':''}' - '${bottomLeft > 0 ? 'bottom: Radius.circular($bottomLeft),':''}' + '${topLeft > 0 ? 'top: Radius.circular($topLeft)':''}' + '${topLeft > 0 && bottomLeft > 0 ? ',':''}' + '${bottomLeft > 0 ? 'bottom: Radius.circular($bottomLeft)':''}' '))'; } return '${prefix}RoundedRectangleBorder(borderRadius: ' @@ -208,8 +209,15 @@ abstract class TokenTemplate { /// Generate a [BorderSide] for the given components. String mergedBorder(String componentToken1, String componentToken2) { - final String borderColor = componentColor(componentToken1)!='null' ? componentColor(componentToken1) :componentColor(componentToken2); - final double width = (tokens['$componentToken1.width'] ?? tokens['$componentToken1.height'] ?? tokens['$componentToken2.width'] ?? tokens['$componentToken2.height'] ?? 1.0) as double; + final String borderColor = componentColor(componentToken1) != 'null' + ? componentColor(componentToken1) + : componentColor(componentToken2); + final double width = ( + tokens['$componentToken1.width'] ?? + tokens['$componentToken1.height'] ?? + tokens['$componentToken2.width'] ?? + tokens['$componentToken2.height'] ?? + 1.0) as double; return 'BorderSide(color: $borderColor${width != 1.0 ? ", width: $width" : ""})'; } diff --git a/packages/flutter/lib/src/material/bottom_sheet.dart b/packages/flutter/lib/src/material/bottom_sheet.dart index c74fc71db0dee..5702d8e3a1a3f 100644 --- a/packages/flutter/lib/src/material/bottom_sheet.dart +++ b/packages/flutter/lib/src/material/bottom_sheet.dart @@ -946,7 +946,7 @@ class _BottomSheetDefaultsM3 extends BottomSheetThemeData { : super( elevation: 1.0, modalElevation: 1.0, - shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(28.0),)), + shape: const RoundedRectangleBorder(borderRadius: BorderRadius.vertical(top: Radius.circular(28.0))), ); final BuildContext context; From 401d62bfeb93d1a1cfc367d3ddf43d6d6768f3f9 Mon Sep 17 00:00:00 2001 From: hangyu <108393416+hangyujin@users.noreply.github.com> Date: Tue, 25 Oct 2022 17:11:42 +0800 Subject: [PATCH 4/4] polish template --- .../gen_defaults/lib/input_decorator_template.dart | 14 ++++++++++++++ dev/tools/gen_defaults/lib/template.dart | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/dev/tools/gen_defaults/lib/input_decorator_template.dart b/dev/tools/gen_defaults/lib/input_decorator_template.dart index d53007f8082d1..5c0260997adfe 100644 --- a/dev/tools/gen_defaults/lib/input_decorator_template.dart +++ b/dev/tools/gen_defaults/lib/input_decorator_template.dart @@ -209,4 +209,18 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { }); } '''; + + /// Generate a [BorderSide] for the given components. + String mergedBorder(String componentToken1, String componentToken2) { + final String borderColor = componentColor(componentToken1)!= 'null' + ? componentColor(componentToken1) + : componentColor(componentToken2); + final double width = ( + tokens['$componentToken1.width'] ?? + tokens['$componentToken1.height'] ?? + tokens['$componentToken2.width'] ?? + tokens['$componentToken2.height'] ?? + 1.0) as double; + return 'BorderSide(color: $borderColor${width != 1.0 ? ", width: $width" : ""})'; + } } diff --git a/dev/tools/gen_defaults/lib/template.dart b/dev/tools/gen_defaults/lib/template.dart index d7b1f976e47ec..807c6c5bba14e 100644 --- a/dev/tools/gen_defaults/lib/template.dart +++ b/dev/tools/gen_defaults/lib/template.dart @@ -207,20 +207,6 @@ abstract class TokenTemplate { return 'BorderSide(color: $borderColor${width != 1.0 ? ", width: $width" : ""})'; } - /// Generate a [BorderSide] for the given components. - String mergedBorder(String componentToken1, String componentToken2) { - final String borderColor = componentColor(componentToken1) != 'null' - ? componentColor(componentToken1) - : componentColor(componentToken2); - final double width = ( - tokens['$componentToken1.width'] ?? - tokens['$componentToken1.height'] ?? - tokens['$componentToken2.width'] ?? - tokens['$componentToken2.height'] ?? - 1.0) as double; - return 'BorderSide(color: $borderColor${width != 1.0 ? ", width: $width" : ""})'; - } - /// Generate a [TextTheme] text style name for the given component token. String textStyle(String componentToken) { return '$textThemePrefix${tokens["$componentToken.text-style"]}';