|
|
|
@ -39,8 +39,7 @@ class NumberTextInputFormatter extends TextInputFormatter {
|
|
|
|
final _mobileFormatter = NumberTextInputFormatter();
|
|
|
|
final _mobileFormatter = NumberTextInputFormatter();
|
|
|
|
|
|
|
|
|
|
|
|
class TextFields extends StatefulWidget {
|
|
|
|
class TextFields extends StatefulWidget {
|
|
|
|
TextFields(
|
|
|
|
TextFields({Key key,
|
|
|
|
{Key key,
|
|
|
|
|
|
|
|
this.type,
|
|
|
|
this.type,
|
|
|
|
this.hintText,
|
|
|
|
this.hintText,
|
|
|
|
this.suffixIcon,
|
|
|
|
this.suffixIcon,
|
|
|
|
@ -58,6 +57,7 @@ class TextFields extends StatefulWidget {
|
|
|
|
this.onSubmit,
|
|
|
|
this.onSubmit,
|
|
|
|
this.keepPadding = true,
|
|
|
|
this.keepPadding = true,
|
|
|
|
this.textCapitalization = TextCapitalization.none,
|
|
|
|
this.textCapitalization = TextCapitalization.none,
|
|
|
|
|
|
|
|
this.onTap,
|
|
|
|
this.controller,
|
|
|
|
this.controller,
|
|
|
|
this.keyboardType,
|
|
|
|
this.keyboardType,
|
|
|
|
this.validator,
|
|
|
|
this.validator,
|
|
|
|
@ -68,9 +68,15 @@ class TextFields extends StatefulWidget {
|
|
|
|
this.maxLength,
|
|
|
|
this.maxLength,
|
|
|
|
this.prefixIcon,
|
|
|
|
this.prefixIcon,
|
|
|
|
this.bare = false,
|
|
|
|
this.bare = false,
|
|
|
|
this.fontSize = 16.0,
|
|
|
|
this.fontSize = 14.0,
|
|
|
|
this.fontWeight = FontWeight.w700,
|
|
|
|
this.color = Colors.black,
|
|
|
|
this.autoValidate = false})
|
|
|
|
this.fontWeight = FontWeight.w600,
|
|
|
|
|
|
|
|
this.autoValidate = false,
|
|
|
|
|
|
|
|
this.borderRadiusValue = 8.0,
|
|
|
|
|
|
|
|
this.borderWidth = 1.5,
|
|
|
|
|
|
|
|
this.fieldTextColor,
|
|
|
|
|
|
|
|
this.textAlign = TextAlign.start,
|
|
|
|
|
|
|
|
this.borderRadius})
|
|
|
|
: super(key: key);
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
final String hintText;
|
|
|
|
final String hintText;
|
|
|
|
@ -80,6 +86,7 @@ class TextFields extends StatefulWidget {
|
|
|
|
final IconData suffixIcon;
|
|
|
|
final IconData suffixIcon;
|
|
|
|
final Color suffixIconColor;
|
|
|
|
final Color suffixIconColor;
|
|
|
|
final IconData prefixIcon;
|
|
|
|
final IconData prefixIcon;
|
|
|
|
|
|
|
|
final VoidCallback onTap;
|
|
|
|
final TextEditingController controller;
|
|
|
|
final TextEditingController controller;
|
|
|
|
final TextInputType keyboardType;
|
|
|
|
final TextInputType keyboardType;
|
|
|
|
final FormFieldValidator validator;
|
|
|
|
final FormFieldValidator validator;
|
|
|
|
@ -96,6 +103,7 @@ class TextFields extends StatefulWidget {
|
|
|
|
final TextInputAction inputAction;
|
|
|
|
final TextInputAction inputAction;
|
|
|
|
final double fontSize;
|
|
|
|
final double fontSize;
|
|
|
|
final FontWeight fontWeight;
|
|
|
|
final FontWeight fontWeight;
|
|
|
|
|
|
|
|
final Color color;
|
|
|
|
final bool keepPadding;
|
|
|
|
final bool keepPadding;
|
|
|
|
final TextCapitalization textCapitalization;
|
|
|
|
final TextCapitalization textCapitalization;
|
|
|
|
final List<TextInputFormatter> inputFormatters;
|
|
|
|
final List<TextInputFormatter> inputFormatters;
|
|
|
|
@ -103,6 +111,11 @@ class TextFields extends StatefulWidget {
|
|
|
|
final EdgeInsets padding;
|
|
|
|
final EdgeInsets padding;
|
|
|
|
final bool focus;
|
|
|
|
final bool focus;
|
|
|
|
final bool borderOnlyError;
|
|
|
|
final bool borderOnlyError;
|
|
|
|
|
|
|
|
final double borderRadiusValue;
|
|
|
|
|
|
|
|
final BorderRadius borderRadius;
|
|
|
|
|
|
|
|
final double borderWidth;
|
|
|
|
|
|
|
|
final Color fieldTextColor;
|
|
|
|
|
|
|
|
final TextAlign textAlign;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
_TextFieldsState createState() => _TextFieldsState();
|
|
|
|
_TextFieldsState createState() => _TextFieldsState();
|
|
|
|
@ -138,23 +151,20 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
Widget _buildSuffixIcon() {
|
|
|
|
Widget _buildSuffixIcon() {
|
|
|
|
switch (widget.type) {
|
|
|
|
switch (widget.type) {
|
|
|
|
case "password":
|
|
|
|
case "password":
|
|
|
|
|
|
|
|
{
|
|
|
|
return Padding(
|
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.only(right: 8.0),
|
|
|
|
padding: const EdgeInsets.only(right: 8.0),
|
|
|
|
child: view
|
|
|
|
child: view
|
|
|
|
? InkWell(
|
|
|
|
? InkWell(
|
|
|
|
onTap: () {
|
|
|
|
onTap: () {
|
|
|
|
this.setState(
|
|
|
|
this.setState(() {
|
|
|
|
() {
|
|
|
|
|
|
|
|
view = false;
|
|
|
|
view = false;
|
|
|
|
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
child: Icon(EvaIcons.eye,
|
|
|
|
},
|
|
|
|
size: 24.0, color: Theme
|
|
|
|
child: Icon(
|
|
|
|
.of(context)
|
|
|
|
EvaIcons.eye,
|
|
|
|
.primaryColor))
|
|
|
|
size: 24.0,
|
|
|
|
|
|
|
|
color: Color.fromRGBO(78, 62, 253, 1.0),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
: InkWell(
|
|
|
|
: InkWell(
|
|
|
|
onTap: () {
|
|
|
|
onTap: () {
|
|
|
|
this.setState(() {
|
|
|
|
this.setState(() {
|
|
|
|
@ -162,9 +172,16 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
child: Icon(EvaIcons.eyeOff,
|
|
|
|
child: Icon(EvaIcons.eyeOff,
|
|
|
|
size: 24.0, color: Colors.grey[500]),
|
|
|
|
size: 24.0, color: Colors.grey[500])));
|
|
|
|
),
|
|
|
|
}
|
|
|
|
);
|
|
|
|
case "hourly":
|
|
|
|
|
|
|
|
return Align(
|
|
|
|
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
|
|
'/ hr ',
|
|
|
|
|
|
|
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w700),
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
if (widget.suffixIcon != null)
|
|
|
|
if (widget.suffixIcon != null)
|
|
|
|
return InkWell(
|
|
|
|
return InkWell(
|
|
|
|
@ -173,8 +190,7 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
size: 22.0,
|
|
|
|
size: 22.0,
|
|
|
|
color: widget.suffixIconColor != null
|
|
|
|
color: widget.suffixIconColor != null
|
|
|
|
? widget.suffixIconColor
|
|
|
|
? widget.suffixIconColor
|
|
|
|
: Colors.grey[500]),
|
|
|
|
: Colors.grey[500]));
|
|
|
|
);
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -197,14 +213,18 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
? null
|
|
|
|
? null
|
|
|
|
: BoxDecoration(boxShadow: [
|
|
|
|
: BoxDecoration(boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
BoxShadow(
|
|
|
|
color: Color.fromRGBO(110, 68, 80, focus ? 0.20 : 0),
|
|
|
|
color: Color.fromRGBO(70, 68, 167, focus ? 0.20 : 0),
|
|
|
|
offset: Offset(0.0, 13.0),
|
|
|
|
offset: Offset(0.0, 13.0),
|
|
|
|
blurRadius: focus ? 34.0 : 12.0)
|
|
|
|
blurRadius: focus ? 34.0 : 12.0)
|
|
|
|
]),
|
|
|
|
]),
|
|
|
|
child: TextFormField(
|
|
|
|
child: TextFormField(
|
|
|
|
keyboardAppearance: Theme.of(context).brightness,
|
|
|
|
keyboardAppearance: Theme
|
|
|
|
|
|
|
|
.of(context)
|
|
|
|
|
|
|
|
.brightness,
|
|
|
|
scrollPhysics: BouncingScrollPhysics(),
|
|
|
|
scrollPhysics: BouncingScrollPhysics(),
|
|
|
|
autovalidate: widget.autoValidate,
|
|
|
|
autovalidate: widget.autoValidate,
|
|
|
|
|
|
|
|
onTap: widget.onTap,
|
|
|
|
|
|
|
|
textAlign: widget.textAlign,
|
|
|
|
textCapitalization: widget.textCapitalization,
|
|
|
|
textCapitalization: widget.textCapitalization,
|
|
|
|
onFieldSubmitted: widget.inputAction == TextInputAction.next
|
|
|
|
onFieldSubmitted: widget.inputAction == TextInputAction.next
|
|
|
|
? (widget.onSubmit != null
|
|
|
|
? (widget.onSubmit != null
|
|
|
|
@ -228,10 +248,14 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
autofocus: widget.autoFocus ?? false,
|
|
|
|
autofocus: widget.autoFocus ?? false,
|
|
|
|
validator: widget.validator,
|
|
|
|
validator: widget.validator,
|
|
|
|
onSaved: widget.onSaved,
|
|
|
|
onSaved: widget.onSaved,
|
|
|
|
style: Theme.of(context)
|
|
|
|
style: Theme
|
|
|
|
|
|
|
|
.of(context)
|
|
|
|
.textTheme
|
|
|
|
.textTheme
|
|
|
|
.body2
|
|
|
|
.body2
|
|
|
|
.copyWith(fontSize: widget.fontSize, fontWeight: widget.fontWeight),
|
|
|
|
.copyWith(
|
|
|
|
|
|
|
|
fontSize: widget.fontSize,
|
|
|
|
|
|
|
|
fontWeight: widget.fontWeight,
|
|
|
|
|
|
|
|
color: widget.color),
|
|
|
|
inputFormatters: widget.keyboardType == TextInputType.phone
|
|
|
|
inputFormatters: widget.keyboardType == TextInputType.phone
|
|
|
|
? <TextInputFormatter>[
|
|
|
|
? <TextInputFormatter>[
|
|
|
|
WhitelistingTextInputFormatter.digitsOnly,
|
|
|
|
WhitelistingTextInputFormatter.digitsOnly,
|
|
|
|
@ -244,7 +268,9 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
fontSize: widget.fontSize,
|
|
|
|
fontSize: widget.fontSize,
|
|
|
|
fontWeight: widget.fontWeight,
|
|
|
|
fontWeight: widget.fontWeight,
|
|
|
|
color: Theme.of(context).hintColor),
|
|
|
|
color: Theme
|
|
|
|
|
|
|
|
.of(context)
|
|
|
|
|
|
|
|
.hintColor),
|
|
|
|
contentPadding: widget.padding != null
|
|
|
|
contentPadding: widget.padding != null
|
|
|
|
? widget.padding
|
|
|
|
? widget.padding
|
|
|
|
: EdgeInsets.symmetric(
|
|
|
|
: EdgeInsets.symmetric(
|
|
|
|
@ -253,7 +279,11 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
filled: true,
|
|
|
|
filled: true,
|
|
|
|
fillColor: widget.bare
|
|
|
|
fillColor: widget.bare
|
|
|
|
? Colors.transparent
|
|
|
|
? Colors.transparent
|
|
|
|
: Theme.of(context).backgroundColor,
|
|
|
|
: widget.fieldTextColor != null
|
|
|
|
|
|
|
|
? widget.fieldTextColor
|
|
|
|
|
|
|
|
: Theme
|
|
|
|
|
|
|
|
.of(context)
|
|
|
|
|
|
|
|
.backgroundColor,
|
|
|
|
suffixIcon: _buildSuffixIcon(),
|
|
|
|
suffixIcon: _buildSuffixIcon(),
|
|
|
|
prefixIcon: widget.type != "search"
|
|
|
|
prefixIcon: widget.type != "search"
|
|
|
|
? widget.prefixIcon != null
|
|
|
|
? widget.prefixIcon != null
|
|
|
|
@ -274,41 +304,62 @@ class _TextFieldsState extends State<TextFields> {
|
|
|
|
height: widget.borderOnlyError ? 0.0 : null),
|
|
|
|
height: widget.borderOnlyError ? 0.0 : null),
|
|
|
|
errorBorder: OutlineInputBorder(
|
|
|
|
errorBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(
|
|
|
|
borderSide: BorderSide(
|
|
|
|
color: Theme.of(context)
|
|
|
|
color: Theme
|
|
|
|
|
|
|
|
.of(context)
|
|
|
|
.errorColor
|
|
|
|
.errorColor
|
|
|
|
.withOpacity(widget.bare ? 0.0 : 0.5),
|
|
|
|
.withOpacity(widget.bare ? 0.0 : 0.5),
|
|
|
|
width: 2.0),
|
|
|
|
width: widget.borderWidth),
|
|
|
|
borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0)),
|
|
|
|
borderRadius: widget.bare
|
|
|
|
|
|
|
|
? BorderRadius.circular(0.0)
|
|
|
|
|
|
|
|
: widget.borderRadius != null
|
|
|
|
|
|
|
|
? widget.borderRadius
|
|
|
|
|
|
|
|
: BorderRadius.circular(widget.borderRadiusValue)),
|
|
|
|
focusedErrorBorder: OutlineInputBorder(
|
|
|
|
focusedErrorBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(
|
|
|
|
borderSide: BorderSide(
|
|
|
|
color: Theme.of(context)
|
|
|
|
color: Theme
|
|
|
|
|
|
|
|
.of(context)
|
|
|
|
.errorColor
|
|
|
|
.errorColor
|
|
|
|
.withOpacity(widget.bare ? 0.0 : 0.5),
|
|
|
|
.withOpacity(widget.bare ? 0.0 : 0.5),
|
|
|
|
width: 2.0),
|
|
|
|
width: widget.borderWidth),
|
|
|
|
borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0)),
|
|
|
|
borderRadius: widget.bare
|
|
|
|
|
|
|
|
? BorderRadius.circular(0.0)
|
|
|
|
|
|
|
|
: widget.borderRadius != null
|
|
|
|
|
|
|
|
? widget.borderRadius
|
|
|
|
|
|
|
|
: BorderRadius.circular(widget.borderRadiusValue)),
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(
|
|
|
|
borderSide: BorderSide(
|
|
|
|
color: Theme.of(context)
|
|
|
|
color: Theme
|
|
|
|
|
|
|
|
.of(context)
|
|
|
|
.dividerColor
|
|
|
|
.dividerColor
|
|
|
|
.withOpacity(widget.bare ? 0.0 : 1.0),
|
|
|
|
.withOpacity(widget.bare ? 0.0 : 1.0),
|
|
|
|
width: 2.0),
|
|
|
|
width: widget.borderWidth),
|
|
|
|
borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0)),
|
|
|
|
borderRadius: widget.bare
|
|
|
|
disabledBorder: OutlineInputBorder(
|
|
|
|
? BorderRadius.circular(0.0)
|
|
|
|
borderSide: BorderSide(
|
|
|
|
: widget.borderRadius != null
|
|
|
|
color: Theme.of(context)
|
|
|
|
? widget.borderRadius
|
|
|
|
|
|
|
|
: BorderRadius.circular(widget.borderRadiusValue)),
|
|
|
|
|
|
|
|
disabledBorder:
|
|
|
|
|
|
|
|
OutlineInputBorder(borderSide: BorderSide(color: Theme
|
|
|
|
|
|
|
|
.of(context)
|
|
|
|
.dividerColor
|
|
|
|
.dividerColor
|
|
|
|
.withOpacity(widget.bare ? 0.0 : 1.0),
|
|
|
|
.withOpacity(widget.bare ? 0.0 : 1.0),
|
|
|
|
width: 2.0),
|
|
|
|
width: widget.borderWidth),
|
|
|
|
borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0)),
|
|
|
|
borderRadius: widget.bare ? BorderRadius.circular(0.0) : widget
|
|
|
|
|
|
|
|
.borderRadius != null ? widget.borderRadius : BorderRadius
|
|
|
|
|
|
|
|
.circular(widget.borderRadiusValue)),
|
|
|
|
enabledBorder: OutlineInputBorder(
|
|
|
|
enabledBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(
|
|
|
|
borderSide: BorderSide(
|
|
|
|
color: Theme.of(context)
|
|
|
|
color: Theme
|
|
|
|
|
|
|
|
.of(context)
|
|
|
|
.dividerColor
|
|
|
|
.dividerColor
|
|
|
|
.withOpacity(widget.bare ? 0.0 : 1.0),
|
|
|
|
.withOpacity(widget.bare ? 0.0 : 1.0),
|
|
|
|
width: 2.0),
|
|
|
|
width: widget.borderWidth),
|
|
|
|
borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0),
|
|
|
|
borderRadius: widget.bare
|
|
|
|
),
|
|
|
|
? BorderRadius.circular(0.0)
|
|
|
|
),
|
|
|
|
: widget.borderRadius != null
|
|
|
|
|
|
|
|
? widget.borderRadius
|
|
|
|
|
|
|
|
: BorderRadius.circular(widget.borderRadiusValue),
|
|
|
|
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
));
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|