import 'package:auth/src/features/sign_up/presentation/state/sign_up_view_model.dart';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:navigation/navigation.dart';
import 'package:sf_localizations/sf_localizations.dart';

class AccountCreatedScreen extends ConsumerWidget {
  final NavigationContract navigationContract;

  const AccountCreatedScreen({super.key, required this.navigationContract});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final theme = ref.watch(themePortProvider);

    final state = ref.watch(signUpViewModelProvider);

    final String email = state.email;
    final String fullName = '${state.firstName} ${state.lastName}'.trim();

    return Scaffold(
      backgroundColor: theme.getColorFor(ThemeCode.backgroundPrimary),
      body: Container(
        margin: const EdgeInsets.all(30),
        child: Center(
          child: Column(
            children: [
              const Spacer(flex: 10),
              Icon(
                Icons.check,
                color: theme.getColorFor(ThemeCode.buttonPrimary),
                size: 50,
              ),
              const SizedBox(height: 20),
              Text(
                context.translate(I18n.accountCreatedTitle),
                style: const TextStyle(
                  fontSize: 30,
                  fontWeight: FontWeight.bold,
                ),
              ),
              const SizedBox(height: 20),

              Text.rich(
                textAlign: TextAlign.center,
                TextSpan(
                  text: '${context.translate(I18n.accountCreatedForLabel)}\n',
                  children: [
                    TextSpan(
                      text: fullName,
                      style: const TextStyle(fontWeight: FontWeight.bold),
                    ),
                  ],
                ),
              ),

              const SizedBox(height: 16),
              Text.rich(
                textAlign: TextAlign.center,
                TextSpan(
                  text:
                      '${context.translate(I18n.accountCreatedEmailVerificationSentLabel)}\n',
                  children: [
                    TextSpan(
                      text: email,
                      style: const TextStyle(fontWeight: FontWeight.bold),
                    ),
                  ],
                ),
              ),

              const SizedBox(height: 20),
              Text(
                context.translate(I18n.accountCreatedChildSetupHint),
                textAlign: TextAlign.center,
              ),

              const SizedBox(height: 20),
              PrimaryButton(
                onPressed: () => navigationContract.goTo(AppRoutes.login),
                text: context.translate(I18n.accountCreatedContinue),
                color: Color.fromRGBO(88, 142, 165, 1),
              ),
              const Spacer(flex: 8),
            ],
          ),
        ),
      ),
    );
  }
}
