import 'package:flutter/material.dart';

import 'package:pweb/controllers/auth/email.dart';

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


class UsernameField extends StatelessWidget {
  final EmailFieldController controller;

  const UsernameField({
    super.key,
    required this.controller,
  });

  @override
  Widget build(BuildContext context) => TextFormField(
    controller: controller.textController,
    keyboardType: TextInputType.emailAddress,
    decoration: InputDecoration(
      labelText: AppLocalizations.of(context)!.username,
      hintText: AppLocalizations.of(context)!.usernameHint,
    ),
    validator: (value) {
      final locs = AppLocalizations.of(context)!;
      return controller.validate(value, locs.usernameErrorInvalid);
    },
    onChanged: controller.onChanged,
  );
}
