Unverified Commit e739ad07 authored by hangyu's avatar hangyu Committed by GitHub

M3 Text field UI update (#113776)

* text field update

* update tests

* lint

* polish template
parent dcc6a4c0
......@@ -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: '
......@@ -202,7 +203,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" : ""})';
}
......
......@@ -4494,17 +4494,20 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme {
@override
BorderSide? get activeIndicatorBorder => MaterialStateBorderSide.resolveWith((Set<MaterialState> 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);
}
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));
}
......@@ -4514,17 +4517,20 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme {
@override
BorderSide? get outlineBorder => MaterialStateBorderSide.resolveWith((Set<MaterialState> 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);
}
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));
}
......@@ -4560,20 +4566,20 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme {
TextStyle? get labelStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> 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));
}
......@@ -4584,20 +4590,20 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme {
TextStyle? get floatingLabelStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> 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));
}
......
......@@ -3453,7 +3453,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 {
......
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