import 'package:flutter/material.dart';

import 'package:pweb/pages/login/app_bar.dart';
import 'package:pweb/pages/signup/confirmation/card/card.dart';
import 'package:pweb/pages/signup/confirmation/login_prompt.dart';
import 'package:pweb/pages/with_footer.dart';
import 'package:pweb/widgets/vspacer.dart';


class SignUpConfirmationPage extends StatefulWidget {
  final String? email;

  const SignUpConfirmationPage({super.key, this.email});

  @override
  State<SignUpConfirmationPage> createState() => _SignUpConfirmationPageState();
}

class _SignUpConfirmationPageState extends State<SignUpConfirmationPage> {
  @override
  Widget build(BuildContext context) {
    final email = widget.email?.trim();

    return PageWithFooter(
      appBar: const LoginAppBar(),
      child: LayoutBuilder(
        builder: (context, constraints) {
          final isWide = constraints.maxWidth >= 980;

          return ListView(
            padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 32),
            children: [
              Center(
                child: ConstrainedBox(
                  constraints: BoxConstraints(maxWidth: isWide ? 980 : 720),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Card(
                        elevation: 0,
                        shape: RoundedRectangleBorder(
                          borderRadius: BorderRadius.circular(22),
                          side: BorderSide(
                            color: Theme.of(context).dividerColor.withValues(alpha: 0.6),
                          ),
                        ),
                        child: Padding(
                          padding: const EdgeInsets.all(28),
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: [
                              SignupConfirmationCard(
                                email: email,
                                isEmbedded: true,
                              ),
                              const VSpacer(multiplier: 2),
                              Divider(
                                height: 1,
                                color: Theme.of(context).dividerColor.withValues(alpha: 0.6),
                              ),
                              const VSpacer(multiplier: 2),
                              const SignupConfirmationLoginPrompt(isEmbedded: true),
                            ],
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ),
            ],
          );
        },
      ),
    );
  }
}
