import 'package:flutter/material.dart';

class VInput extends StatelessWidget {
  final String? placeholder;
  final String? initialValue;
  final TextEditingController? controller;
  final FocusNode? focusNode;
  final ValueChanged<String>? onChanged;

  const VInput({
    super.key,
    this.initialValue,
    this.controller,
    this.focusNode,
    this.placeholder,
    this.onChanged,
  });

  @override
  Widget build(BuildContext context) {
    final c = controller ?? TextEditingController(text: initialValue);
    const borderRadius = BorderRadius.all(Radius.zero);
    return TextField(
      controller: c,
      textAlign: TextAlign.start,
      textAlignVertical: TextAlignVertical.center,
      decoration: InputDecoration(
        enabledBorder: const OutlineInputBorder(
          borderRadius: borderRadius,
          borderSide: BorderSide(color: Colors.grey),
        ),
        focusedBorder: OutlineInputBorder(
          borderRadius: borderRadius,
          borderSide: BorderSide(color: Theme.of(context).primaryColor),
        ),
        errorBorder: OutlineInputBorder(
          borderRadius: borderRadius,
          borderSide: BorderSide(color: Theme.of(context).colorScheme.error),
        ),
        // errorText: "112323",
        errorMaxLines: 1,
        fillColor: Colors.white,
        filled: true,
        hintText: placeholder,
        hintStyle: const TextStyle(
          fontSize: 16,
          color: Colors.black54,
        ),
        contentPadding: const EdgeInsets.symmetric(horizontal: 8, vertical: 0),
        // isDense: true,
        isCollapsed: false,
      ),
      onChanged: (value) {
        onChanged?.call(value);
      },
    );
  }
}
