import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/common/text_field/custom_web_textfield.dart';

class NameAndEmailFields extends StatelessWidget {
  final TextEditingController nameController;
  final TextEditingController emailController;
  final String? Function(String?)? nameValidator;
  final String? Function(String?)? emailValidator;

  const NameAndEmailFields({
    super.key,
    required this.nameController,
    required this.emailController,
    required this.nameValidator,
    required this.emailValidator,
  });

  @override
  Widget build(BuildContext context) {
    Size size = MediaQuery.of(context).size;
    return Container(
      width: size.width,
      child: size.width < 800
          ? Column(
              children: [
                CustomWebTextField(
                  validator: nameValidator,
                  controller: nameController,
                  isRequired: true,
                  textFieldName: 'Name',
                  description: '',
                ),
                const SizedBox(height: 15),
                CustomWebTextField(
                  validator: emailValidator,
                  controller: emailController,
                  isRequired: true,
                  textFieldName: 'Email Address',
                  description:
                      'The password will be sent to the visitor’s email address.',
                ),
              ],
            )
          : Row(
              children: [
                Expanded(
                  flex: 2,
                  child: CustomWebTextField(
                    validator: nameValidator,
                    controller: nameController,
                    isRequired: true,
                    textFieldName: 'Name',
                    description: '',
                  ),
                ),
                const Spacer(),
                Expanded(
                  flex: 2,
                  child: CustomWebTextField(
                    validator: emailValidator,
                    controller: emailController,
                    isRequired: true,
                    textFieldName: 'Email Address',
                    description:
                        'The password will be sent to the visitor’s email address.',
                  ),
                ),
                const Spacer(),
              ],
            ),
    );
  }
}
