97 lines
2.6 KiB
Dart
97 lines
2.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_application_1/core/theme/app_colors.dart';
|
|
|
|
class CustomTextField extends StatefulWidget {
|
|
final String hintText;
|
|
final IconData prefixIcon;
|
|
final bool obscureText;
|
|
final TextInputType keyboardType;
|
|
final TextEditingController? controller;
|
|
|
|
const CustomTextField({
|
|
super.key,
|
|
required this.hintText,
|
|
required this.prefixIcon,
|
|
this.obscureText = false,
|
|
this.keyboardType = TextInputType.text,
|
|
this.controller,
|
|
});
|
|
|
|
@override
|
|
State<CustomTextField> createState() => _CustomTextFieldState();
|
|
}
|
|
|
|
class _CustomTextFieldState extends State<CustomTextField> {
|
|
late bool _obscure;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_obscure = widget.obscureText;
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SizedBox(
|
|
height: 56,
|
|
child: TextField(
|
|
controller: widget.controller,
|
|
obscureText: _obscure,
|
|
keyboardType: widget.keyboardType,
|
|
style: const TextStyle(
|
|
fontSize: 14,
|
|
color: AppColors.textDark,
|
|
),
|
|
decoration: InputDecoration(
|
|
hintText: widget.hintText,
|
|
hintStyle: const TextStyle(
|
|
color: AppColors.textMuted,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
prefixIcon: Icon(
|
|
widget.prefixIcon,
|
|
color: AppColors.textMuted,
|
|
size: 20,
|
|
),
|
|
suffixIcon: widget.obscureText
|
|
? IconButton(
|
|
onPressed: () {
|
|
setState(() {
|
|
_obscure = !_obscure;
|
|
});
|
|
},
|
|
icon: Icon(
|
|
_obscure
|
|
? Icons.visibility_outlined
|
|
: Icons.visibility_off_outlined,
|
|
color: AppColors.textMuted,
|
|
size: 20,
|
|
),
|
|
)
|
|
: null,
|
|
filled: true,
|
|
fillColor: AppColors.white,
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
horizontal: 16,
|
|
vertical: 16,
|
|
),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(16),
|
|
borderSide: const BorderSide(
|
|
color: AppColors.inputBorder,
|
|
width: 1.2,
|
|
),
|
|
),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(16),
|
|
borderSide: const BorderSide(
|
|
color: AppColors.primaryBlue,
|
|
width: 1.4,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
} |