import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/svg.dart';
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
import 'package:syncrow_app/features/menu/view/widgets/securty/bloc/security_bloc.dart';
import 'package:syncrow_app/features/menu/view/widgets/securty/bloc/security_event.dart';
import 'package:syncrow_app/features/menu/view/widgets/securty/bloc/security_state.dart';
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';

import '../../../../../../generated/assets.dart';
import '../../../../../../utils/resource_manager/color_manager.dart';
import '../../../../../shared_widgets/default_scaffold.dart';

class DeleteAccountPage extends StatelessWidget {
  const DeleteAccountPage({super.key});

  @override
  Widget build(BuildContext context) {
    return BlocListener<SecurityBloc, SecurityState>(
      listener: (context, state) {
        if (state is ChangedPassState) {
          AuthCubit.get(context).logout();
        }
      },
      child: DefaultScaffold(
        title: 'Delete Account',
        bottomNavBar: SizedBox(
          height: 150,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              InkWell(
                onTap: () {
                  context.read<SecurityBloc>().add(DeleteAccountEvent());
                },
                child: Container(
                  height: 50,
                  margin: const EdgeInsets.only(right: 20, left: 20),
                  decoration: const BoxDecoration(
                      color: ColorsManager.blueColor,
                      borderRadius: BorderRadius.all(Radius.circular(20))),
                  child: const Center(
                      child: Text(
                    'Delete Account',
                    style: TextStyle(
                        fontSize: 16,
                        fontWeight: FontWeight.w700,
                        color: ColorsManager.onPrimaryColor),
                  )),
                ),
              ),
            ],
          ),
        ),
        child: Column(
          children: [
            Padding(
              padding: const EdgeInsets.only(top: 80, bottom: 30),
              child: SvgPicture.asset(Assets.deleteAccountIcon),
            ),
            const Padding(
              padding: EdgeInsets.all(8.0),
              child: BodyMedium(
                text: 'Account Verification',
                fontWeight: FontWeight.w700,
                fontSize: 18,
              ),
            ),
            const BodyMedium(
              text: 'if you confirm to "delete account",',
              fontWeight: FontWeight.w400,
              fontSize: 16,
            ),
            const SizedBox(
              height: 4,
            ),
            const BodyMedium(
              text: 'the account will be deleted',
              fontWeight: FontWeight.w400,
              fontSize: 16,
            ),
          ],
        ),
      ),
    );
  }
}
