You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
141 lines
4.5 KiB
Dart
141 lines
4.5 KiB
Dart
import 'package:doctor_app_flutter/config/size_config.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'app_texts_widget.dart';
|
|
|
|
class AppTextFieldCustom extends StatefulWidget {
|
|
final double height;
|
|
final Function onClick;
|
|
final String hintText;
|
|
final TextEditingController controller;
|
|
final bool isDropDown;
|
|
final Icon suffixIcon;
|
|
final Color dropDownColor;
|
|
|
|
AppTextFieldCustom(
|
|
{this.height = 0,
|
|
this.onClick,
|
|
this.hintText,
|
|
this.controller,
|
|
this.isDropDown = false,
|
|
this.suffixIcon,
|
|
this.dropDownColor});
|
|
|
|
@override
|
|
_AppTextFieldCustomState createState() => _AppTextFieldCustomState();
|
|
}
|
|
|
|
class _AppTextFieldCustomState extends State<AppTextFieldCustom> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
height: widget.height != 0 ? widget.height : null,
|
|
decoration:
|
|
containerBorderDecoration(Color(0Xffffffff), Color(0xFFEFEFEF)),
|
|
padding: EdgeInsets.only(top: 4.0, bottom: 4.0, left: 8.0, right: 8.0),
|
|
child: InkWell(
|
|
onTap: widget.onClick ?? null,
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
if (widget.controller.text != "")
|
|
AppText(
|
|
widget.hintText,
|
|
fontFamily: 'Poppins',
|
|
fontSize: SizeConfig.textMultiplier * 1.4,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
TextField(
|
|
textAlign: TextAlign.left,
|
|
decoration: textFieldSelectorDecoration(
|
|
widget.hintText, null, true),
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
color: Colors.grey.shade600,
|
|
),
|
|
controller: widget.controller,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
widget.isDropDown
|
|
? widget.suffixIcon != null
|
|
? widget.suffixIcon
|
|
: Icon(
|
|
Icons.arrow_drop_down,
|
|
color: widget.dropDownColor != null
|
|
? widget.dropDownColor
|
|
: Colors.black,
|
|
)
|
|
: Container(),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
BoxDecoration containerBorderDecoration(
|
|
Color containerColor, Color borderColor,
|
|
{double borderWidth = -1}) {
|
|
return BoxDecoration(
|
|
color: containerColor,
|
|
shape: BoxShape.rectangle,
|
|
borderRadius: BorderRadius.all(Radius.circular(8)),
|
|
border: Border.fromBorderSide(BorderSide(
|
|
color: borderColor,
|
|
width: borderWidth == -1 ? 2.0 : borderWidth,
|
|
)),
|
|
);
|
|
}
|
|
|
|
static InputDecoration textFieldSelectorDecoration(
|
|
String hintText, String selectedText, bool isDropDown,
|
|
{Icon suffixIcon, Color dropDownColor}) {
|
|
return InputDecoration(
|
|
isDense: true,
|
|
contentPadding: EdgeInsets.symmetric(horizontal: 0, vertical: 0),
|
|
enabledBorder: UnderlineInputBorder(
|
|
borderSide: BorderSide(color: Color(0Xffffffff)),
|
|
),
|
|
focusedBorder: UnderlineInputBorder(
|
|
borderSide: BorderSide(color: Color(0Xffffffff)),
|
|
),
|
|
border: UnderlineInputBorder(
|
|
borderSide: BorderSide(color: Color(0Xffffffff)),
|
|
),
|
|
/*focusedBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
disabledBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),*/
|
|
hintText: selectedText != null ? selectedText : hintText,
|
|
hintStyle: TextStyle(
|
|
fontSize: 14,
|
|
color: Colors.grey.shade600,
|
|
),
|
|
/*suffixIcon: isDropDown
|
|
? suffixIcon != null
|
|
? suffixIcon
|
|
: Icon(
|
|
Icons.arrow_drop_down,
|
|
color: dropDownColor != null ? dropDownColor : Colors.black,
|
|
)
|
|
: null,*/
|
|
// labelText:
|
|
// labelStyle:
|
|
);
|
|
}
|
|
}
|