// ignore_for_file: must_be_immutable

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../themes.dart';

class Campo extends StatelessWidget {
  final Icon? prefixIcon;
  final Widget? suffixIcon;
  final String? labelText;
  final String? initialValue;
  final String? hintText;
  final TextInputType? keyboardType;
  final TextEditingController? controller;
  final Color? fillColor;
  final void Function()? onTap;
  final bool enabled;
  final bool obscureText;
  final bool readOnly;
  final int? maxLength;
  final int? maxLines;
  final String? errorText;
  final double? textfieldHeight;
  final List<String>? autofillHints;
  final Function(String v)? onChanged;
  List<TextInputFormatter>? inputFormatters;
  final TextCapitalization textCapitalization;
  String? etiqueta;
  String? Function(String?)? validator;
  final double? vertical;

  Campo(
      {super.key,
      this.etiqueta,
      this.labelText,
      this.prefixIcon,
      this.keyboardType,
      this.onTap,
      this.controller,
      this.hintText,
      this.suffixIcon,
      this.inputFormatters,
      this.enabled = true,
      this.readOnly = false,
      this.obscureText = false,
      this.fillColor = Colors.white,
      this.errorText,
      this.textfieldHeight,
      this.autofillHints,
      this.textCapitalization = TextCapitalization.none,
      this.initialValue,
      this.maxLength,
      this.maxLines = 1,
      this.validator,
      this.onChanged,
      this.vertical});

  @override
  Widget build(BuildContext context) {
    etiqueta ??= "";
    return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
      if (etiqueta != '')
        Text(
          etiqueta.toString(),
          style: TextStyle(
              fontSize: 18,
              fontWeight: FontWeight.bold,
              color: enabled ? Colors.black : Colors.grey),
        ),
      if (etiqueta != '')
        const SizedBox(
          height: 5,
        ),
      TextFormField(
          autofillHints: autofillHints,
          validator: validator,
          enabled: enabled,
          maxLength: maxLength,
          maxLines: maxLines,
          inputFormatters: inputFormatters,
          initialValue: initialValue,
          controller: controller,
          onTap: onTap,
          readOnly: readOnly,
          //keyboardType: keyboardType,
          textCapitalization: textCapitalization,
          cursorColor: AppTheme.tertiary,
          obscureText: obscureText,
          autocorrect: true,
          onChanged: onChanged,
          style: const TextStyle(
            height: 0,
            fontSize: 40.0,
            color: Colors.white,
            fontFamily: 'digital-7-mono', // Nombre de la fuente
          ),
          textAlign: TextAlign.center,
          keyboardType: TextInputType.number,
          decoration: InputDecoration(
            filled: true,
            fillColor: Colors.grey.shade800,
            hintText: '00',
            hintStyle: const TextStyle(
              fontSize: 40.0,
              color: Colors.white,
              fontFamily: 'digital-7-mono', // Nombre de la fuente
            ),
            border: OutlineInputBorder(
              borderSide: BorderSide.none,
              borderRadius: BorderRadius.circular(10.0),
            ),
          )),
    ]);
  }
}
