import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'common/settings.dart'; import 'otp.dart'; class LoginScreen extends StatefulWidget { const LoginScreen({Key? key}) : super(key: key); @override State createState() => _LoginScreenState(); } class _LoginScreenState extends State { final TextEditingController mobileController = TextEditingController(); final TextEditingController passwordController = TextEditingController(); bool isPasswordVisible = false; @override Widget build(BuildContext context) { return Scaffold( resizeToAvoidBottomInset: true, // Important backgroundColor: Colors.white, body: SafeArea( child: SingleChildScrollView( // 👈 FIX child: Padding( padding: const EdgeInsets.symmetric(horizontal: 25), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox(height: 250), Text( "Welcome!", style: fontTextStyle( 26, Colors.black, FontWeight.w700), ), const SizedBox(height: 30), TextField( controller: mobileController, keyboardType: TextInputType.phone, inputFormatters: [ LengthLimitingTextInputFormatter(10), // max 10 digits FilteringTextInputFormatter.digitsOnly, // only digits ], decoration: InputDecoration( border: const OutlineInputBorder(), hintText: "Enter your number", hintStyle: fontTextStyle(14, Color(0xFF2A2A2A), FontWeight.w400), ), ), const SizedBox(height: 15), TextField( controller: passwordController, obscureText: !isPasswordVisible, decoration: InputDecoration( hintText: "Password", border: OutlineInputBorder( borderRadius: BorderRadius.circular(8), ), suffixIcon: IconButton( icon: Icon( isPasswordVisible ? Icons.visibility : Icons.visibility_off, ), onPressed: () { setState(() { isPasswordVisible = !isPasswordVisible; }); }, ), ), ), const SizedBox(height: 10), Text( "Forgot Password?", style: fontTextStyle( 13, const Color(0XFF1D7AFC), FontWeight.w500), ), const SizedBox(height: 25), SizedBox( width: double.infinity, height: 48, child: ElevatedButton( onPressed: () {}, style: ElevatedButton.styleFrom( backgroundColor: const Color(0XFF1D7AFC), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(25), ), ), child: Text( "Login", style: fontTextStyle( 14, Colors.white, FontWeight.w600), ), ), ), const SizedBox(height: 15), SizedBox( width: double.infinity, height: 48, child: OutlinedButton( onPressed: () { String mobile = mobileController.text.trim(); if (mobile.length != 10) { ScaffoldMessenger.of(context).showSnackBar( const SnackBar( content: Text("Enter 10 digit mobile number"), ), ); return; } if (!mobile.startsWith(RegExp(r'[6-9]'))) { ScaffoldMessenger.of(context).showSnackBar( const SnackBar( content: Text("Mobile must start with 6-9"), ), ); return; } Navigator.push( context, MaterialPageRoute( builder: (context) => OtpScreen(mobileNumber: mobile), ), ); }, style: OutlinedButton.styleFrom( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(25), ), ), child: const Text( "Login without Password", style: TextStyle(color: Colors.blue), ), ), ), const SizedBox(height: 30), const Divider(), const SizedBox(height: 20), SizedBox( width: double.infinity, height: 48, child: OutlinedButton( onPressed: () { }, style: OutlinedButton.styleFrom( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(25), ), ), child: const Text( "Sign Up", style: TextStyle(color: Colors.blue), ), ), ), ], ), ), ), ), ); } }