import 'package:flutter/material.dart';

class CommonFormItem extends StatelessWidget {
  final String? label;
  final Widget Function(BuildContext context)? contentBuilder;
  final Widget? suffix;
  final String? suffixText;
  final String? hitText;
  final bool readOnly;
  final ValueChanged? onChanged;
  final GestureTapCallback? onTap;
  final String? Function(String?)? validator;
  final TextEditingController? controller;

  const CommonFormItem(
      {Key? key,
      this.label,
      this.contentBuilder,
      this.suffix,
      this.suffixText,
      this.hitText,
      this.readOnly = false,
      this.onChanged,
      this.onTap,
      this.validator,
      this.controller})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
        padding: const EdgeInsets.only(left: 14.0, right: 14.0, top: 20),
        child: contentBuilder != null
            ? contentBuilder!(context)
            : TextFormField(
                readOnly: readOnly,
                controller: controller,
                onTap: onTap,
                validator: validator,
                decoration: InputDecoration(
                    border: const OutlineInputBorder(),
                    labelText: label,
                    hintText: hitText,
                    suffixText: suffixText),
              ));
  }
}
