import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:niogu_app/core/constants/app_asset.dart';
import 'package:niogu_app/core/constants/app_color.dart';
import 'package:niogu_app/core/constants/app_font_size.dart';
import 'package:niogu_app/core/router/app_route.dart';
import 'package:niogu_app/core/widgets/custom_text_form_field.dart';
import 'package:sizer/sizer.dart';

class ForgotPasswordScreen extends ConsumerStatefulWidget {
  const ForgotPasswordScreen({super.key});

  @override
  ConsumerState<ForgotPasswordScreen> createState() =>
      _ForgotPasswordScreenState();
}

class _ForgotPasswordScreenState extends ConsumerState<ForgotPasswordScreen> {
  final _formKey = GlobalKey<FormState>();

  final _identifierController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(
      builder: (context, constraints) {
        final bool isTablet = 100.w >= 600;

        return SafeArea(
          top: false,
          bottom: true,
          right: false,
          left: false,
          child: Scaffold(
            backgroundColor: Colors.white,
            body: SafeArea(
              child: SingleChildScrollView(
                padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 5.h),
                child: Form(
                  key: _formKey,
                  child: Column(
                    children: [
                      Image.asset(AppAsset.LOGO_UPDATE, height: 12.h),

                      SizedBox(height: 2.5.h),

                      Text(
                        "Lupa Password",
                        style: TextStyle(
                          fontSize: AppFontSize.large.sp,
                          fontWeight: FontWeight.bold,
                          color: AppColor.primaryColor,
                        ),
                      ),
                      SizedBox(height: 1.h),
                      Text(
                        "Masukkan nomor whatsapp kamu yang terdaftar",
                        textAlign: TextAlign.center,
                        style: TextStyle(
                          fontSize: isTablet
                              ? AppFontSize.medium.sp
                              : AppFontSize.small.sp,
                          color: Colors.grey,
                        ),
                      ),

                      SizedBox(height: 4.h),

                      CustomTextFormField(
                        label: "ID Usaha/Perusahaan",
                        hint: "xxxxxxxx",
                        controller: _identifierController,
                        prefixIcon: Icons.business_outlined,
                      ),

                      SizedBox(height: 2.5.h),

                      CustomTextFormField(
                        label: "No. WhatsApp",
                        hint: "Contoh:081234xxxxxx",
                        controller: _identifierController,
                        prefixIcon: Icons.phone_outlined,
                      ),

                      SizedBox(height: 2.5.h),

                      ElevatedButton(
                        onPressed: () => context.pushNamed(AppRoute.verificationOtpScreen),
                        style: ElevatedButton.styleFrom(
                          backgroundColor: AppColor.primaryColor,
                          minimumSize: Size(double.infinity, 7.h),
                          shape: RoundedRectangleBorder(
                            borderRadius: BorderRadius.circular(3.w),
                          ),
                          elevation: 2,
                        ),
                        child: Text(
                          "Selanjutnya",
                          style: TextStyle(
                            color: Colors.white,
                            fontWeight: FontWeight.bold,
                            fontSize: AppFontSize.medium.sp,
                          ),
                        ),
                      ),

                      SizedBox(height: 4.h),

                      GestureDetector(
                        onTap: () => context.pop(),
                        child: Text(
                          "Kembali Masuk",
                          style: TextStyle(
                            color: AppColor.primaryColor,
                            fontWeight: FontWeight.bold,
                            fontSize: isTablet
                                ? AppFontSize.medium.sp
                                : AppFontSize.small.sp,
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ),
            ),
          ),
        );
      },
    );
  }
}
