FTextFieldStyle.inherit constructor
FTextFieldStyle.inherit({
- required FColors colors,
- required FTypography typography,
- required FStyle style,
Creates a FTextFieldStyle that inherits its properties.
Implementation
factory FTextFieldStyle.inherit({required FColors colors, required FTypography typography, required FStyle style}) {
final label = FLabelStyles.inherit(style: style).verticalStyle;
final ghost = FButtonStyles.inherit(
colors: colors,
typography: typography,
style: style,
).resolve({FButtonVariant.ghost}).resolve({FButtonSizeVariant.sm});
final textStyle = typography.sm.copyWith(fontFamily: typography.defaultFontFamily);
final iconStyle = FVariants<FTextFieldVariantConstraint, FTextFieldVariant, IconThemeData, IconThemeDataDelta>.from(
IconThemeData(color: colors.mutedForeground, size: 16),
variants: {
[.disabled]: .delta(color: colors.disable(colors.mutedForeground)),
},
);
final bounceableButtonStyle = ghost.copyWith(
iconContentStyle: ghost.iconContentStyle.copyWith(iconStyle: iconStyle.cast()),
);
return .new(
keyboardAppearance: colors.brightness,
color: FVariants(
colors.card,
variants: {
[.disabled]: colors.disable(colors.card),
},
),
cursorColor: colors.primary,
iconStyle: iconStyle,
clearButtonStyle: bounceableButtonStyle,
obscureButtonStyle: bounceableButtonStyle.copyWith(
tappableStyle: const .delta(motion: .delta(bounceTween: FTappableMotion.noBounceTween)),
),
contentTextStyle: FVariants.from(
textStyle.copyWith(color: colors.foreground),
variants: {
[.disabled]: .delta(color: colors.disable(colors.foreground)),
},
),
hintTextStyle: FVariants.from(
textStyle.copyWith(color: colors.mutedForeground),
variants: {
[.disabled]: .delta(color: colors.disable(colors.mutedForeground)),
},
),
counterTextStyle: FVariants.from(
textStyle.copyWith(color: colors.foreground),
variants: {
[.disabled]: .delta(color: colors.disable(colors.foreground)),
},
),
border: FVariants(
OutlineInputBorder(
borderSide: BorderSide(color: colors.border, width: style.borderWidth),
borderRadius: style.borderRadius,
),
variants: {
[.focused]: OutlineInputBorder(
borderSide: BorderSide(color: colors.primary, width: style.borderWidth),
borderRadius: style.borderRadius,
),
//
[.disabled]: OutlineInputBorder(
borderSide: BorderSide(color: colors.disable(colors.border), width: style.borderWidth),
borderRadius: style.borderRadius,
),
//
[.error]: OutlineInputBorder(
borderSide: BorderSide(color: colors.error, width: style.borderWidth),
borderRadius: style.borderRadius,
),
[.error.and(.disabled)]: OutlineInputBorder(
borderSide: BorderSide(color: colors.disable(colors.error), width: style.borderWidth),
borderRadius: style.borderRadius,
),
},
),
labelTextStyle: style.formFieldStyle.labelTextStyle,
descriptionTextStyle: style.formFieldStyle.descriptionTextStyle,
errorTextStyle: style.formFieldStyle.errorTextStyle,
labelPadding: label.labelPadding,
descriptionPadding: label.descriptionPadding,
errorPadding: label.errorPadding,
childPadding: label.childPadding,
);
}