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;
  final double maxWidth = 500;

  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: BoxConstraints(maxWidth: maxWidth),
      child: Card(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          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,
                ),
              ],
            ),
          ],
        ),
      ),
    ),
  );
}
