import 'package:flutter/material.dart';
import 'common/settings.dart';
import 'otp.dart';


class SignUpScreen extends StatefulWidget {
  const SignUpScreen({Key? key}) : super(key: key);

  @override
  State<SignUpScreen> createState() => _SignUpScreenState();
}

class _SignUpScreenState extends State<SignUpScreen> {

  TextEditingController mobileController = TextEditingController();
  TextEditingController emailController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: true,
      backgroundColor: Colors.white,
      body: SafeArea(
        child: SingleChildScrollView(
          child: Padding(
            padding: const EdgeInsets.symmetric(horizontal: 25),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [

                const SizedBox(height: 120),

                /// Title
                Text(
                  "Sign Up",
                  style: fontTextStyle(
                      22, Colors.black, FontWeight.w700),
                ),

                const SizedBox(height: 5),

                /// Subtitle
                Text(
                  "Sign up using your mobile number",
                  style: fontTextStyle(
                      13,
                      const Color(0xFF7E7F80),
                      FontWeight.w400),
                ),

                const SizedBox(height: 60),

                /// Mobile Number Field
                TextField(
                  controller: mobileController,
                  keyboardType: TextInputType.phone,
                  decoration: InputDecoration(
                    hintText: "Mobile Number *",
                    hintStyle: fontTextStyle(
                        14,
                        const Color(0xFF7E7F80),
                        FontWeight.w400),
                    contentPadding:
                    const EdgeInsets.symmetric(
                        horizontal: 15,
                        vertical: 18),
                    border: OutlineInputBorder(
                      borderRadius:
                      BorderRadius.circular(8),
                    ),
                  ),
                ),

                const SizedBox(height: 20),

                /// Email Field
                TextField(
                  controller: emailController,
                  keyboardType:
                  TextInputType.emailAddress,
                  decoration: InputDecoration(
                    hintText: "Email ID (optional)",
                    hintStyle: fontTextStyle(
                        14,
                        const Color(0xFF7E7F80),
                        FontWeight.w400),
                    contentPadding:
                    const EdgeInsets.symmetric(
                        horizontal: 15,
                        vertical: 18),
                    border: OutlineInputBorder(
                      borderRadius:
                      BorderRadius.circular(8),
                    ),
                  ),
                ),

                const SizedBox(height: 35),

                /// Sign Up Button
                SizedBox(
                  width: double.infinity,
                  height: 52,
                  child: ElevatedButton(
                    onPressed: () {

                      if (mobileController.text.isEmpty) {
                        ScaffoldMessenger.of(context).showSnackBar(
                          const SnackBar(
                            content: Text("Enter Mobile Number"),
                          ),
                        );
                        return;
                      }

                      Navigator.push(
                        context,
                        MaterialPageRoute(
                          builder: (_) => OtpScreen(
                            mobileNumber: mobileController.text,
                          ),
                        ),
                      );

                    },
                    style: ElevatedButton.styleFrom(
                      backgroundColor: const Color(0XFF1D7AFC),
                      shape: RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(30),
                      ),
                    ),
                    child: Text(
                      "Sign Up",
                      style: fontTextStyle(
                          15,
                          Colors.white,
                          FontWeight.w600),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}