116 lines
3.3 KiB
Dart
116 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
|
|
class CustomTextField extends StatelessWidget {
|
|
final TextEditingController controller;
|
|
final String labelText;
|
|
final String hintText;
|
|
final IconData? prefixIcon;
|
|
final Widget? suffixIcon;
|
|
final bool obscureText;
|
|
final TextInputType keyboardType;
|
|
final String? Function(String?)? validator;
|
|
final VoidCallback? onTap;
|
|
final bool readOnly;
|
|
|
|
const CustomTextField({
|
|
super.key,
|
|
required this.controller,
|
|
required this.labelText,
|
|
required this.hintText,
|
|
this.prefixIcon,
|
|
this.suffixIcon,
|
|
this.obscureText = false,
|
|
this.keyboardType = TextInputType.text,
|
|
this.validator,
|
|
this.onTap,
|
|
this.readOnly = false,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
labelText,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w500,
|
|
color: Colors.grey[700],
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
TextFormField(
|
|
controller: controller,
|
|
obscureText: obscureText,
|
|
keyboardType: keyboardType,
|
|
validator: validator,
|
|
onTap: onTap,
|
|
readOnly: readOnly,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 16,
|
|
color: Colors.grey[800],
|
|
),
|
|
decoration: InputDecoration(
|
|
hintText: hintText,
|
|
hintStyle: GoogleFonts.poppins(
|
|
fontSize: 16,
|
|
color: Colors.grey[400],
|
|
),
|
|
prefixIcon: prefixIcon != null
|
|
? Icon(
|
|
prefixIcon,
|
|
color: Colors.grey[600],
|
|
size: 20,
|
|
)
|
|
: null,
|
|
suffixIcon: suffixIcon,
|
|
filled: true,
|
|
fillColor: Colors.white,
|
|
border: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
borderSide: BorderSide(
|
|
color: Colors.grey[300]!,
|
|
width: 1,
|
|
),
|
|
),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
borderSide: BorderSide(
|
|
color: Colors.grey[300]!,
|
|
width: 1,
|
|
),
|
|
),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
borderSide: BorderSide(
|
|
color: Theme.of(context).primaryColor,
|
|
width: 2,
|
|
),
|
|
),
|
|
errorBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
borderSide: const BorderSide(
|
|
color: Colors.red,
|
|
width: 1,
|
|
),
|
|
),
|
|
focusedErrorBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
borderSide: const BorderSide(
|
|
color: Colors.red,
|
|
width: 2,
|
|
),
|
|
),
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
horizontal: 16,
|
|
vertical: 16,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|