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.
112 lines
4.2 KiB
Dart
112 lines
4.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
|
|
|
class DynamicTextFieldWidget extends StatelessWidget {
|
|
final String labelText;
|
|
final String hintText;
|
|
// final TextEditingController controller;
|
|
final VoidCallback? onTap;
|
|
final IconData? suffixIconData;
|
|
final bool isEnable;
|
|
final TextInputAction? inputAction;
|
|
final bool isReadOnly;
|
|
final bool isPopup;
|
|
final int? lines;
|
|
final bool isInputTypeNum;
|
|
final bool isObscureText;
|
|
final bool isBackgroundEnable;
|
|
final void Function(String)? onChange;
|
|
|
|
DynamicTextFieldWidget(this.labelText, this.hintText, //this.controller,
|
|
{this.isObscureText = false,
|
|
this.onTap,
|
|
this.suffixIconData,
|
|
this.isEnable = true,
|
|
this.isReadOnly = false,
|
|
this.isPopup = false,
|
|
this.lines = 1,
|
|
this.inputAction,
|
|
this.onChange,
|
|
this.isInputTypeNum = false,
|
|
this.isBackgroundEnable = false});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15),
|
|
alignment: Alignment.center,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(15),
|
|
color: isReadOnly ? MyColors.lightGreyEFColor : Colors.white,
|
|
border: Border.all(
|
|
color: MyColors.lightGreyEFColor,
|
|
width: 1,
|
|
),
|
|
),
|
|
child: InkWell(
|
|
onTap: onTap,
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
labelText,
|
|
style: const TextStyle(
|
|
fontSize: 11,
|
|
fontWeight: FontWeight.w600,
|
|
color: Color(0xff2B353E),
|
|
letterSpacing: -0.44,
|
|
),
|
|
),
|
|
TextField(
|
|
enabled: isEnable,
|
|
scrollPadding: EdgeInsets.zero, readOnly: isReadOnly,
|
|
keyboardType: isInputTypeNum ? const TextInputType.numberWithOptions(signed: true) : TextInputType.text,
|
|
textInputAction: TextInputAction.done,
|
|
//controller: controller,
|
|
maxLines: lines,
|
|
obscuringCharacter: "*",
|
|
obscureText: isObscureText,
|
|
onChanged: onChange,
|
|
style: const TextStyle(
|
|
fontSize: 14,
|
|
height: 21 / 14,
|
|
fontWeight: FontWeight.w400,
|
|
color: Color(0xff2B353E),
|
|
letterSpacing: -0.44,
|
|
),
|
|
decoration: InputDecoration(
|
|
isDense: true,
|
|
hintText: hintText,
|
|
fillColor: isReadOnly ? MyColors.borderColor : null,
|
|
hintStyle: const TextStyle(
|
|
fontSize: 14,
|
|
height: 21 / 14,
|
|
fontWeight: FontWeight.w400,
|
|
color: Color(0xff575757),
|
|
letterSpacing: -0.56,
|
|
),
|
|
// suffixIconConstraints: const BoxConstraints(minWidth: 50),
|
|
// suffixIcon: suffixIconData == null ? null : Icon(suffixIconData, color: MyColors.darkTextColor),
|
|
// suffixIcon: suffixTap == null ? null : IconButton(icon: Icon(suffixIconData, color: MyColors.darkTextColor), onPressed: suffixTap),
|
|
contentPadding: EdgeInsets.zero,
|
|
border: InputBorder.none,
|
|
focusedBorder: InputBorder.none,
|
|
enabledBorder: InputBorder.none,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
if (isPopup) const Icon(Icons.keyboard_arrow_down_outlined, color: MyColors.darkIconColor),
|
|
if (onTap != null) Icon(suffixIconData ?? Icons.keyboard_arrow_down_outlined, color: MyColors.darkIconColor),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|