import 'dart:ui';

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

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

  @override
  State<LoginScreen> createState() => _LoginScreenState();
}

class _LoginScreenState extends State<LoginScreen> {
  TextEditingController phonecontroller = TextEditingController();
  bool isValidPhoneNumber(String phoneNumber) {
    final RegExp phoneNumberExpression = RegExp(r"^0{10}$");

    return !phoneNumberExpression.hasMatch(phoneNumber);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      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: [
                    SizedBox(
                      height: 20.h,
                    ),
                    const Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Text(
                          "Traders Circuit",
                          style: TextStyle(
                              color: Colors.white,
                              fontSize: 25,
                              fontWeight: FontWeight.w600),
                        ),
                      ],
                    ),
                    SizedBox(
                      height: 42.h,
                    ),
                    const Text(
                      "Lets get started ",
                      style: TextStyle(
                          color: Colors.white,
                          fontSize: 24,
                          fontWeight: FontWeight.w700),
                    ),
                    SizedBox(
                      height: 10.h,
                    ),
                    text18W800("Enter your mobile number to get otp"),
                    SizedBox(
                      height: 35.h,
                    ),
                    Row(
                      children: [
                        GlassmorphicContainer(
                          width: 60,
                          height: 50,
                          borderRadius: 8,
                          blur: 10,
                          alignment: Alignment.center,
                          border: 0.8,
                          linearGradient: LinearGradient(
                              begin: Alignment.topLeft,
                              end: Alignment.bottomRight,
                              colors: [
                                Colors.white.withOpacity(0.1),
                                Color(0xFFFFFFFF).withOpacity(0.05),
                              ],
                              stops: [
                                0.1,
                                1,
                              ]),
                          borderGradient: LinearGradient(
                            begin: Alignment.topLeft,
                            end: Alignment.bottomRight,
                            colors: [
                              Color(0xff9A0000).withOpacity(0.5),
                              Color(0xFFffffff).withOpacity(0.5),
                            ],
                          ),
                          child: Row(
                            crossAxisAlignment: CrossAxisAlignment.center,
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: [
                              // SvgPicture.asset("assets/images/svg/india.svg"),
                              Image.asset(
                                "assets/images/png/india.png",
                                height: 25.h,
                                width: 25.h,
                              ),
                              SizedBox(
                                width: 2,
                              ),
                              Text(
                                "+91",
                                style: TextStyle(
                                  fontSize: 15,
                                  color: Colors.white,
                                ),
                              )
                            ],
                          ),
                        ),
                        SizedBox(
                          width: 10,
                        ),
                        Container(
                          width: 285.w,
                          child: CustomTextFormField(
                            texttype: TextInputType.phone,
                            textEditingController: phonecontroller,
                            // validator: (value) {
                            //   if (value.isEmpty) {
                            //     return 'Enter your phone number';
                            //   } else if (!RegExp(r'(^(?:[+0]9)?[0-9]{10}$)')
                            //       .hasMatch(value)) {
                            //     return 'Enter a valid phone number';
                            //   } else if (!isValidPhoneNumber(value)) {
                            //     return 'Phone number cannot contain 10 zeros';
                            //   }
                            //   return null;
                            // },
                            inputFormatters: [
                              LengthLimitingTextInputFormatter(10),
                              FilteringTextInputFormatter.allow(
                                  RegExp('[0-9]')),
                            ],
                          ),
                        )
                      ],
                    ),
                    SizedBox(
                      height: 10,
                    ),
                    text14W300(
                        "We’ll send six digit code to the registered number. Standard data rates may apply"),
                    SizedBox(
                      height: 65.h,
                    ),
                    CommonBtn(
                        text: "Login/Signup",
                        onTap: () {
                          Get.toNamed(RouteName.verifyotp);
                        }),
                    SizedBox(
                      height: 10.h,
                    ),
                    text14W300(
                        "By continuing, you agree to our Terms & Conditions"),
                    SizedBox(
                      height: 45.h,
                    ),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Container(
                          height: 0.2.h,
                          width: 108.w,
                          color: Colors.white,
                        ),
                        SizedBox(
                          width: 22.w,
                        ),
                        text18W600("OR"),
                        SizedBox(
                          width: 22.w,
                        ),
                        Container(
                          height: 0.2.h,
                          width: 108.w,
                          color: Colors.white,
                        ),
                      ],
                    ),
                    SizedBox(
                      height: 40.h,
                    ),
                    GlassmorphicContainer(
                      width: double.infinity,
                      height: 55.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.3,
                      blur: 10,
                      borderGradient: LinearGradient(
                          begin: Alignment.topLeft,
                          end: Alignment.bottomRight,
                          colors: [
                            Color(0xFFAF2E89).withOpacity(0.2),
                            Color(0xFFA23E31).withOpacity(0.2),
                            Color(0xFF0000).withOpacity(0.2),
                          ],
                          stops: [
                            0.3,
                            0.6,
                            1,
                          ]),
                      child: Center(
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                            Image.asset(
                              "assets/images/png/apple.png",
                              height: 30.h,
                              width: 30.w,
                            ),
                            SizedBox(
                              width: 7.h,
                            ),
                            text16W400("Continue with apple"),
                          ],
                        ),
                      ),
                    ),
                    SizedBox(
                      height: 15.h,
                    ),
                    GlassmorphicContainer(
                      width: double.infinity,
                      height: 55.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.5,
                      blur: 10,
                      borderGradient: LinearGradient(
                          begin: Alignment.topLeft,
                          end: Alignment.bottomRight,
                          colors: [
                            Color(0xFFAF2E89).withOpacity(0.2),
                            Color(0xFFA23E31).withOpacity(0.2),
                            Color(0xFF0000).withOpacity(0.2),
                          ],
                          stops: [
                            0.3,
                            0.6,
                            1,
                          ]),
                      child: Center(
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                            Image.asset(
                              "assets/images/png/google.png",
                              height: 30.h,
                              width: 30.w,
                            ),
                            SizedBox(
                              width: 7.h,
                            ),
                            text16W400(
                              "Continue with google",
                            ),
                          ],
                        ),
                      ),
                    ),
                    SizedBox(
                      height: 45.h,
                    ),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        text16W700(
                          "Continue as guest",
                        ),
                      ],
                    )
                  ],
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
