import 'package:flutter/material.dart';

import 'package:pweb/generated/i18n/app_localizations.dart';


class EmailField extends StatelessWidget {
  final TextEditingController controller;

  final double borderRadius;
  final EdgeInsetsGeometry contentPadding;

  const EmailField({
    super.key,
    required this.controller,
    this.borderRadius = 12,
    this.contentPadding = const EdgeInsets.symmetric(horizontal: 12, vertical: 14),
  });

  @override
  Widget build(BuildContext context) {
    final loc = AppLocalizations.of(context)!;

    return TextFormField(
      controller: controller,
      decoration: InputDecoration(
        labelText: loc.username,
        border: OutlineInputBorder(
          borderRadius: BorderRadius.circular(borderRadius),
        ),
        contentPadding: contentPadding,
      ),
      validator: (v) =>
          v == null || v.isEmpty ? loc.usernameErrorInvalid : null,
    );
  }
}
