import 'package:flutter/material.dart';

import 'package:pweb/pages/signup/buttons.dart';
import 'package:pweb/pages/signup/form/controllers.dart';
import 'package:pweb/pages/signup/form/feilds.dart';
import 'package:pweb/widgets/constrained_form.dart';


class SignUpFormContent extends StatelessWidget {
  final GlobalKey<FormState> formKey;
  final SignUpFormControllers controllers;
  final bool autoValidateMode;
  final VoidCallback onSignUp;
  final VoidCallback onLogin;

  const SignUpFormContent({
    required this.formKey,
    required this.controllers,
    required this.autoValidateMode,
    required this.onSignUp,
    required this.onLogin,
    super.key,
  });

  @override
  Widget build(BuildContext context) => Align(
    alignment: Alignment.center,
    child: ConstrainedBox(
      constraints: const BoxConstraints(maxWidth: 500, maxHeight: 700),
      child: Card(
        child: SingleChildScrollView(
          child: Column(
            children: [
              Row(
                children: [
                  IconButton(
                    onPressed: onLogin,
                    icon: Icon(Icons.arrow_back),
                  ),
                ],
              ),
              ConstrainedForm(
                formKey: formKey,
                autovalidateMode: autoValidateMode
                    ? AutovalidateMode.onUserInteraction
                    : AutovalidateMode.disabled,
                children: [
                  SignUpFormFields(controllers: controllers),
                  SignUpButtonsRow(
                    onLogin: onLogin,
                    signUp: onSignUp,
                    isEnabled: true,
                  ),
                ],
              ),
            ],
          ),
        ),
      ),
    ),
  );
}
