import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:glassmorphism/glassmorphism.dart';
import 'package:traderscircuit/Utils/Common/CommonAppbar.dart';
import 'package:traderscircuit/Utils/Common/CommonDropdown.dart';
import 'package:traderscircuit/Utils/Common/CustomTextFormField.dart';
import 'package:traderscircuit/Utils/Common/commonBotton.dart';
import 'package:traderscircuit/Utils/text.dart';
import 'package:traderscircuit/resources/routes/route_name.dart';
import 'package:traderscircuit/view/onBoarding/splashScreen1.dart';

class Kyc extends StatefulWidget {
  const Kyc({super.key});

  @override
  State<Kyc> createState() => _KycState();
}

class _KycState extends State<Kyc> {
  TextEditingController pincode = TextEditingController();
  TextEditingController dobcontroller = TextEditingController();
  Color primaryColor = Colors.transparent.withOpacity(0.2);
  Color secondaryColor = Colors.grey.shade800;

  bool isSwitched = false;

  void _toggleSwitch(bool value) {
    setState(() {
      isSwitched = value;
    });
  }

  DateTime timebackPressed = DateTime.now();

  Future<void> _selectDate(BuildContext context) async {
    final DateTime? picked = await showDatePicker(
        context: context,
        initialDate: DateTime.now(),
        firstDate: DateTime(1900),
        lastDate: DateTime.now(),
        builder: (context, child) {
          return Theme(
              data: Theme.of(context).copyWith(
                colorScheme: ColorScheme.light(
                  surface: Colors.black,
                  onSurface: Colors.white,
                  primary: Color(0xff9A0000),
                  onPrimary: Colors.white,
                ),
                textButtonTheme: TextButtonThemeData(
                  style: TextButton.styleFrom(
                    foregroundColor: Colors.white,
                  ),
                ),
              ),
              child: child!);
        });

    if (picked != null && picked != DateTime.now()) {
      setState(() {
        dobcontroller.text = "${picked.toLocal()}".split(' ')[0];
        final birthDate = DateTime(
          picked.year,
          picked.month,
          picked.day,
        );
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CommonAppbar(
        titleTxt: "KYC",
        customActionWidget: text16W400("skip"),
      ),
      backgroundColor: Colors.black,
      extendBody: true,
      body: Stack(
        children: [
          CommonBlurLeft(),
          CommonBlurRight(),
          Stack(
            children: [
              Padding(
                padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16),
                child: ListView(
                  physics: BouncingScrollPhysics(),
                  // mainAxisAlignment: MainAxisAlignment.start,
                  // crossAxisAlignment: CrossAxisAlignment.start,

                  children: [
                    //  CommonDropdownBtn(hint: "hint", items: ["hi", "hii"]),
                    Row(
                      children: [
                        text18W400("Full Name"),
                      ],
                    ),
                    SizedBox(
                      height: 15.h,
                    ),
                    CustomTextFormField(),
                    SizedBox(
                      height: 30.h,
                    ),
                    Row(
                      children: [
                        text18W400("Email Address"),
                      ],
                    ),
                    SizedBox(
                      height: 15.h,
                    ),
                    CustomTextFormField(),
                    SizedBox(
                      height: 30.h,
                    ),
                    Row(
                      children: [
                        text18W400("Phone Number"),
                      ],
                    ),
                    SizedBox(
                      height: 15.h,
                    ),
                    CustomTextFormField(),
                    SizedBox(
                      height: 30.h,
                    ),
                    Row(
                      children: [
                        text18W400("Date Of Birth"),
                      ],
                    ),
                    SizedBox(
                      height: 15.h,
                    ),
                    CustomTextFormField(
                      suffixIcon: Icon(
                        Icons.calendar_month_outlined,
                        color: Colors.white,
                      ),
                      readonly: true,
                      onTap: () {
                        _selectDate(context);
                      },
                    ),
                    SizedBox(
                      height: 30.h,
                    ),
                    Row(
                      children: [
                        text18W400("City"),
                      ],
                    ),
                    SizedBox(
                      height: 15.h,
                    ),
                    CustomTextFormField(),
                    SizedBox(
                      height: 30.h,
                    ),
                    Row(
                      children: [
                        text18W400("Upload pan card image"),
                      ],
                    ),
                    SizedBox(
                      height: 15.h,
                    ),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        GlassmorphicContainer(
                          width: 170.w,
                          height: 105.h,
                          borderRadius: 8,
                          linearGradient: LinearGradient(
                              begin: Alignment.topLeft,
                              end: Alignment.bottomRight,
                              colors: [
                                Color(0xFFffffff).withOpacity(0.1),
                                Color(0xFFFFFFFF).withOpacity(0.05),
                              ],
                              stops: [
                                0.1,
                                1,
                              ]),
                          border: 0.8,
                          blur: 10,
                          borderGradient: LinearGradient(
                            begin: Alignment.topLeft,
                            end: Alignment.bottomRight,
                            colors: [
                              Color(0xff9A0000).withOpacity(0.5),
                              Color(0xFFffffff).withOpacity(0.5),
                            ],
                          ),
                          child: Center(
                            child: Column(
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: [
                                Icon(
                                  Icons.file_upload_outlined,
                                  size: 42,
                                  color: Colors.white,
                                ),
                                SizedBox(
                                  height: 10.h,
                                ),
                                text14W400("Front Side")
                              ],
                            ),
                          ),
                        ),
                        GlassmorphicContainer(
                          width: 170.w,
                          height: 105.h,
                          borderRadius: 8,
                          linearGradient: LinearGradient(
                              begin: Alignment.topLeft,
                              end: Alignment.bottomRight,
                              colors: [
                                Color(0xFFffffff).withOpacity(0.1),
                                Color(0xFFFFFFFF).withOpacity(0.05),
                              ],
                              stops: [
                                0.1,
                                1,
                              ]),
                          border: 0.8,
                          blur: 10,
                          borderGradient: LinearGradient(
                            begin: Alignment.topLeft,
                            end: Alignment.bottomRight,
                            colors: [
                              Color(0xff9A0000).withOpacity(0.5),
                              Color(0xFFffffff).withOpacity(0.5),
                            ],
                          ),
                          child: Center(
                            child: Column(
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: [
                                Icon(
                                  Icons.file_upload_outlined,
                                  size: 42,
                                  color: Colors.white,
                                ),
                                SizedBox(
                                  height: 10.h,
                                ),
                                text14W400("Back Side")
                              ],
                            ),
                          ),
                        )
                      ],
                    ),
                    SizedBox(
                      height: 30.h,
                    ),
                    Row(
                      children: [
                        text18W400("Aadhaar Number"),
                      ],
                    ),
                    SizedBox(
                      height: 15.h,
                    ),
                    CustomTextFormField(),
                    SizedBox(
                      height: 30.h,
                    ),
                    Row(
                      children: [
                        text18W400("Upload Aadhaar card image"),
                      ],
                    ),
                    SizedBox(
                      height: 15.h,
                    ),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        GlassmorphicContainer(
                          width: 170.w,
                          height: 105.h,
                          borderRadius: 8,
                          linearGradient: LinearGradient(
                              begin: Alignment.topLeft,
                              end: Alignment.bottomRight,
                              colors: [
                                Color(0xFFffffff).withOpacity(0.1),
                                Color(0xFFFFFFFF).withOpacity(0.05),
                              ],
                              stops: [
                                0.1,
                                1,
                              ]),
                          border: 0.8,
                          blur: 10,
                          borderGradient: LinearGradient(
                            begin: Alignment.topLeft,
                            end: Alignment.bottomRight,
                            colors: [
                              Color(0xff9A0000).withOpacity(0.5),
                              Color(0xFFffffff).withOpacity(0.5),
                            ],
                          ),
                          child: Center(
                            child: Column(
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: [
                                Icon(
                                  Icons.file_upload_outlined,
                                  size: 42,
                                  color: Colors.white,
                                ),
                                SizedBox(
                                  height: 10.h,
                                ),
                                text14W400("Front Side")
                              ],
                            ),
                          ),
                        ),
                        GlassmorphicContainer(
                          width: 170.w,
                          height: 105.h,
                          borderRadius: 8,
                          linearGradient: LinearGradient(
                              begin: Alignment.topLeft,
                              end: Alignment.bottomRight,
                              colors: [
                                Color(0xFFffffff).withOpacity(0.1),
                                Color(0xFFFFFFFF).withOpacity(0.05),
                              ],
                              stops: [
                                0.1,
                                1,
                              ]),
                          border: 0.8,
                          blur: 10,
                          borderGradient: LinearGradient(
                            begin: Alignment.topLeft,
                            end: Alignment.bottomRight,
                            colors: [
                              Color(0xff9A0000).withOpacity(0.5),
                              Color(0xFFffffff).withOpacity(0.5),
                            ],
                          ),
                          child: Center(
                            child: Column(
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: [
                                Icon(
                                  Icons.file_upload_outlined,
                                  size: 42,
                                  color: Colors.white,
                                ),
                                SizedBox(
                                  height: 10.h,
                                ),
                                text14W400("Back Side")
                              ],
                            ),
                          ),
                        )
                      ],
                    ),
                    SizedBox(
                      height: 70.h,
                    ),
                    CommonBtn(
                      text: "Next",
                      onTap: () {
                        Get.toNamed(RouteName.updateriskprofile);
                      },
                    ),
                    SizedBox(
                      height: 10.h,
                    ),
                  ],
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
