Unverified Commit 25526f1b authored by hangyu's avatar hangyu Committed by GitHub

Optimize closure in input_decorator_theme (#108379)

parent f82178e2
...@@ -43,10 +43,10 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { ...@@ -43,10 +43,10 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
if (states.contains(MaterialState.error)) { if (states.contains(MaterialState.error)) {
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return ${border('md.comp.filled-text-field.error.hover.active-indicator')}; 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.focused)) { if (states.contains(MaterialState.focused)) {
return ${border('md.comp.filled-text-field.error.focus.active-indicator')}; return ${border('md.comp.filled-text-field.error.focus.active-indicator')};
} }'''}
return ${border('md.comp.filled-text-field.error.active-indicator')}; return ${border('md.comp.filled-text-field.error.active-indicator')};
} }
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
...@@ -66,10 +66,10 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { ...@@ -66,10 +66,10 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
if (states.contains(MaterialState.error)) { if (states.contains(MaterialState.error)) {
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return ${border('md.comp.outlined-text-field.error.hover.outline')}; 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.focused)) { if (states.contains(MaterialState.focused)) {
return ${border('md.comp.outlined-text-field.error.focus.outline')}; return ${border('md.comp.outlined-text-field.error.focus.outline')};
} }'''}
return ${border('md.comp.outlined-text-field.error.outline')}; return ${border('md.comp.outlined-text-field.error.outline')};
} }
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
...@@ -88,7 +88,7 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { ...@@ -88,7 +88,7 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
Color? get iconColor => ${componentColor("md.comp.filled-text-field.leading-icon")}; Color? get iconColor => ${componentColor("md.comp.filled-text-field.leading-icon")};
@override @override
Color? get prefixIconColor => MaterialStateColor.resolveWith((Set<MaterialState> states) { Color? get prefixIconColor => MaterialStateColor.resolveWith((Set<MaterialState> 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.error)) {
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor('md.comp.filled-text-field.error.hover.leading-icon')}; return ${componentColor('md.comp.filled-text-field.error.hover.leading-icon')};
...@@ -97,13 +97,13 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { ...@@ -97,13 +97,13 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
return ${componentColor('md.comp.filled-text-field.error.focus.leading-icon')}; return ${componentColor('md.comp.filled-text-field.error.focus.leading-icon')};
} }
return ${componentColor('md.comp.filled-text-field.error.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)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor('md.comp.filled-text-field.hover.leading-icon')}; 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)) { if (states.contains(MaterialState.focused)) {
return ${componentColor('md.comp.filled-text-field.focus.leading-icon')}; return ${componentColor('md.comp.filled-text-field.focus.leading-icon')};
} }'''}
if (states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.disabled)) {
return ${componentColor('md.comp.filled-text-field.disabled.leading-icon')}; return ${componentColor('md.comp.filled-text-field.disabled.leading-icon')};
} }
...@@ -115,18 +115,18 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { ...@@ -115,18 +115,18 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
if(states.contains(MaterialState.error)) { if(states.contains(MaterialState.error)) {
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor('md.comp.filled-text-field.error.hover.trailing-icon')}; 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.focused)) { if (states.contains(MaterialState.focused)) {
return ${componentColor('md.comp.filled-text-field.error.focus.trailing-icon')}; return ${componentColor('md.comp.filled-text-field.error.focus.trailing-icon')};
} }'''}
return ${componentColor('md.comp.filled-text-field.error.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)) { if (states.contains(MaterialState.hovered)) {
return ${componentColor('md.comp.filled-text-field.hover.trailing-icon')}; 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') ? '' : '''
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return ${componentColor('md.comp.filled-text-field.focus.trailing-icon')}; return ${componentColor('md.comp.filled-text-field.focus.trailing-icon')};
} }'''}
if (states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.disabled)) {
return ${componentColor('md.comp.filled-text-field.disabled.trailing-icon')}; return ${componentColor('md.comp.filled-text-field.disabled.trailing-icon')};
} }
...@@ -183,13 +183,13 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { ...@@ -183,13 +183,13 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
@override @override
TextStyle? get helperStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) { TextStyle? get helperStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
final TextStyle textStyle= ${textStyle("md.comp.filled-text-field.supporting-text")} ?? const TextStyle(); 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)) { if (states.contains(MaterialState.hovered)) {
return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.hover.supporting-text')}); 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') ? '' : '''
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.focus.supporting-text')}); return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.focus.supporting-text')});
} }'''}
if (states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.disabled)) {
return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.disabled.supporting-text')}); return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.disabled.supporting-text')});
} }
...@@ -198,13 +198,13 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme { ...@@ -198,13 +198,13 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
@override @override
TextStyle? get errorStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) { TextStyle? get errorStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
final TextStyle textStyle= ${textStyle("md.comp.filled-text-field.supporting-text")} ?? const TextStyle(); 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)) { 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.hover.supporting-text')});
} }'''}${componentColor('md.comp.filled-text-field.error.focus.supporting-text') == componentColor('md.comp.filled-text-field.error.supporting-text') ? '' : '''
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.error.focus.supporting-text')}); return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.error.focus.supporting-text')});
} }'''}
return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.error.supporting-text')}); return textStyle.copyWith(color:${componentColor('md.comp.filled-text-field.error.supporting-text')});
}); });
} }
......
...@@ -4476,9 +4476,6 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme { ...@@ -4476,9 +4476,6 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme {
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return BorderSide(color: _colors.onErrorContainer); return BorderSide(color: _colors.onErrorContainer);
} }
if (states.contains(MaterialState.focused)) {
return BorderSide(color: _colors.error);
}
return BorderSide(color: _colors.error); return BorderSide(color: _colors.error);
} }
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
...@@ -4499,9 +4496,6 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme { ...@@ -4499,9 +4496,6 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme {
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return BorderSide(color: _colors.onErrorContainer); return BorderSide(color: _colors.onErrorContainer);
} }
if (states.contains(MaterialState.focused)) {
return BorderSide(color: _colors.error);
}
return BorderSide(color: _colors.error); return BorderSide(color: _colors.error);
} }
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
...@@ -4521,21 +4515,6 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme { ...@@ -4521,21 +4515,6 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme {
@override @override
Color? get prefixIconColor => MaterialStateColor.resolveWith((Set<MaterialState> states) { Color? get prefixIconColor => MaterialStateColor.resolveWith((Set<MaterialState> states) {
if(states.contains(MaterialState.error)) {
if (states.contains(MaterialState.hovered)) {
return _colors.onSurfaceVariant;
}
if (states.contains(MaterialState.focused)) {
return _colors.onSurfaceVariant;
}
return _colors.onSurfaceVariant;
}
if (states.contains(MaterialState.hovered)) {
return _colors.onSurfaceVariant;
}
if (states.contains(MaterialState.focused)) {
return _colors.onSurfaceVariant;
}
if (states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.disabled)) {
return _colors.onSurface.withOpacity(0.38); return _colors.onSurface.withOpacity(0.38);
} }
...@@ -4548,17 +4527,8 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme { ...@@ -4548,17 +4527,8 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme {
if (states.contains(MaterialState.hovered)) { if (states.contains(MaterialState.hovered)) {
return _colors.onErrorContainer; return _colors.onErrorContainer;
} }
if (states.contains(MaterialState.focused)) {
return _colors.error;
}
return _colors.error; return _colors.error;
} }
if (states.contains(MaterialState.hovered)) {
return _colors.onSurfaceVariant;
}
if (states.contains(MaterialState.focused)) {
return _colors.onSurfaceVariant;
}
if (states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.disabled)) {
return _colors.onSurface.withOpacity(0.38); return _colors.onSurface.withOpacity(0.38);
} }
...@@ -4616,12 +4586,6 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme { ...@@ -4616,12 +4586,6 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme {
@override @override
TextStyle? get helperStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) { TextStyle? get helperStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
final TextStyle textStyle= _textTheme.bodySmall ?? const TextStyle(); final TextStyle textStyle= _textTheme.bodySmall ?? const TextStyle();
if (states.contains(MaterialState.hovered)) {
return textStyle.copyWith(color:_colors.onSurfaceVariant);
}
if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color:_colors.onSurfaceVariant);
}
if (states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.disabled)) {
return textStyle.copyWith(color:_colors.onSurface.withOpacity(0.38)); return textStyle.copyWith(color:_colors.onSurface.withOpacity(0.38));
} }
...@@ -4631,12 +4595,6 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme { ...@@ -4631,12 +4595,6 @@ class _InputDecoratorDefaultsM3 extends InputDecorationTheme {
@override @override
TextStyle? get errorStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) { TextStyle? get errorStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
final TextStyle textStyle= _textTheme.bodySmall ?? const TextStyle(); final TextStyle textStyle= _textTheme.bodySmall ?? const TextStyle();
if (states.contains(MaterialState.hovered)) {
return textStyle.copyWith(color:_colors.error);
}
if (states.contains(MaterialState.focused)) {
return textStyle.copyWith(color:_colors.error);
}
return textStyle.copyWith(color:_colors.error); return textStyle.copyWith(color:_colors.error);
}); });
} }
......
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