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.
mohemm-flutter-app/lib/widgets/txt_field.dart

156 lines
4.9 KiB
Dart

import 'package:mohem_flutter_app/theme/colors.dart';
import 'package:mohem_flutter_app/utils/utils.dart';
import 'package:mohem_flutter_app/widgets/txt.dart';
import 'package:flutter/material.dart';
import 'package:sizer/sizer.dart';
class TxtField extends StatelessWidget {
TextEditingController controller = new TextEditingController();
String? title;
String? hint;
String? lable;
IconData? prefixData;
IconData? postfixData;
bool isNeedFilterButton;
bool isNeedClickAll;
bool isButtonEnable;
double? elevation;
Function? onTap;
String? buttonTitle;
int? maxLines;
bool isSidePaddingZero;
bool isNeedBorder;
TxtField({
this.title,
this.lable,
this.hint,
this.prefixData,
this.postfixData,
this.isNeedClickAll = false,
this.isNeedFilterButton = false,
this.elevation,
this.onTap,
this.isButtonEnable = false,
this.buttonTitle,
this.maxLines,
this.isSidePaddingZero = false,
this.isNeedBorder = true,
});
@override
Widget build(BuildContext context) {
controller.text = title ?? "";
return InkWell(
onTap: isNeedClickAll == false
? null
: () {
onTap!();
},
customBorder: inkWellCorner(),
child: Row(
children: [
Expanded(
child: Card(
elevation: elevation,
margin: isSidePaddingZero ? EdgeInsets.zero : null,
child: TextField(
autofocus: false,
controller: controller,
enabled: isNeedClickAll == true ? false : true,
maxLines: maxLines,
onTap: () {},
decoration: InputDecoration(
labelText: lable,
alignLabelWithHint: true,
fillColor: Colors.white,
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: accentColor, width: isNeedBorder ? 1.0 : 0),
borderRadius: BorderRadius.circular(4.0),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: borderColor, width: isNeedBorder ? 1.0 : 0),
borderRadius: BorderRadius.circular(4.0),
),
disabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: borderColor, width: isNeedBorder ? 1.0 : 0),
borderRadius: BorderRadius.circular(4.0),
),
prefixIcon: prefixData != null
? Icon(
Icons.search,
color: borderColor,
)
: null,
labelStyle: TextStyle(color: borderColor, fontSize: 13.sp),
hintStyle: TextStyle(color: borderColor, fontSize: 9.sp),
hintText: hint ?? "",
contentPadding: prefixData == null
? EdgeInsets.only(
left: 12,
right: 12,
top: maxLines != null ? 12 : 0,
bottom: maxLines != null ? 12 : 0,
)
: EdgeInsets.zero,
),
),
),
),
if (isNeedFilterButton) mWidth(8),
if (isNeedFilterButton)
InkWell(
onTap: isNeedClickAll
? null
: () {
controller.clear();
},
child: Container(
width: 55,
height: 55,
child: Card(
color: accentColor,
// margin: EdgeInsets.all(4),
// shape: cardRadius(0),
child: Icon(
postfixData ?? Icons.filter_alt,
color: Colors.white,
),
),
),
),
if (isButtonEnable)
Material(
child: InkWell(
onTap: () {},
customBorder: inkWellCorner(),
child: Container(
height: 55,
child: Card(
color: accentColor,
// margin: EdgeInsets.all(4),
// shape: cardRadius(0),
child: Center(
child: Padding(
padding: const EdgeInsets.only(left: 12, right: 12),
child: Txt(
buttonTitle ?? "Search",
color: Colors.white,
fontSize: 18,
bold: true,
),
),
),
),
),
),
),
],
),
);
}
}