2023-06-17 20:57:57 +03:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
|
|
|
|
class MyTextForm extends StatelessWidget {
|
|
|
|
const MyTextForm({
|
|
|
|
super.key,
|
|
|
|
required this.labelText,
|
|
|
|
required this.type,
|
|
|
|
required this.icon,
|
|
|
|
required this.controller,
|
2023-08-03 21:11:58 +03:00
|
|
|
required this.margin,
|
2023-06-17 20:57:57 +03:00
|
|
|
this.iconButton,
|
|
|
|
this.validator,
|
2023-08-03 21:11:58 +03:00
|
|
|
this.elevation,
|
|
|
|
this.focusNode,
|
2024-07-07 14:49:45 +03:00
|
|
|
this.onChanged,
|
2023-06-17 20:57:57 +03:00
|
|
|
});
|
2025-05-28 17:42:15 +03:00
|
|
|
|
2023-06-17 20:57:57 +03:00
|
|
|
final String labelText;
|
|
|
|
final TextInputType type;
|
|
|
|
final Icon icon;
|
|
|
|
final TextEditingController controller;
|
2023-08-03 21:11:58 +03:00
|
|
|
final EdgeInsets margin;
|
2023-06-17 20:57:57 +03:00
|
|
|
final Widget? iconButton;
|
|
|
|
final String? Function(String?)? validator;
|
2023-08-03 21:11:58 +03:00
|
|
|
final double? elevation;
|
|
|
|
final FocusNode? focusNode;
|
2024-07-07 14:49:45 +03:00
|
|
|
final Function(String)? onChanged;
|
2023-06-17 20:57:57 +03:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-08-03 21:11:58 +03:00
|
|
|
return Card(
|
|
|
|
elevation: elevation,
|
|
|
|
margin: margin,
|
2025-05-28 17:42:15 +03:00
|
|
|
child: _buildTextFormField(context),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildTextFormField(BuildContext context) {
|
|
|
|
return TextFormField(
|
|
|
|
focusNode: focusNode,
|
|
|
|
controller: controller,
|
|
|
|
keyboardType: type,
|
|
|
|
style: context.textTheme.labelLarge,
|
|
|
|
decoration: _buildInputDecoration(),
|
|
|
|
validator: validator,
|
|
|
|
onChanged: onChanged,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
InputDecoration _buildInputDecoration() {
|
|
|
|
return InputDecoration(
|
|
|
|
contentPadding: const EdgeInsets.symmetric(horizontal: 12.5, vertical: 0),
|
|
|
|
prefixIcon: icon,
|
|
|
|
suffixIcon: iconButton,
|
|
|
|
labelText: labelText,
|
2023-06-17 20:57:57 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|