Your changes

This commit is contained in:
divya abdar
2025-12-11 18:36:11 +05:30
parent 3bf27cc29d
commit 9faf983b95
36 changed files with 4677 additions and 1046 deletions

View File

@@ -26,27 +26,27 @@ class _LoginScreenState extends State<LoginScreen> {
Future<void> _login() async {
final auth = Provider.of<AuthProvider>(context, listen: false);
final loginId = cLoginId.text.trim();
final password = cPassword.text.trim();
final id = cLoginId.text.trim();
final pass = cPassword.text.trim();
if (loginId.isEmpty || password.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Please enter login id and password')),
);
if (id.isEmpty || pass.isEmpty) {
ScaffoldMessenger.of(context)
.showSnackBar(const SnackBar(content: Text("Please fill all fields")));
return;
}
final res = await auth.login(context, loginId, password);
final res = await auth.login(context, id, pass);
if (res['success'] == true) {
if (!mounted) return;
Navigator.of(context).pushReplacement(
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (_) => const MainBottomNav()),
);
} else {
final msg = res['message']?.toString() ?? 'Login failed';
if (!mounted) return;
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(msg)));
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(res['message'] ?? "Login failed")),
);
}
}
@@ -55,38 +55,113 @@ class _LoginScreenState extends State<LoginScreen> {
final auth = Provider.of<AuthProvider>(context);
final width = MediaQuery.of(context).size.width;
return Scaffold(
appBar: AppBar(
leading: IconButton(
icon: const Icon(Icons.arrow_back),
onPressed: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (_) => const WelcomeScreen()),
);
},
),
title: const Text('Login'),
),
/// ⭐ RESPONSIVE SCALE
final scale = (width / 390).clamp(0.85, 1.25);
body: Padding(
padding: EdgeInsets.symmetric(horizontal: width * 0.06, vertical: 20),
child: Column(
children: [
RoundedInput(
controller: cLoginId,
hint: 'Email / Mobile / Customer ID',
return Scaffold(
backgroundColor: const Color(0xFFE8F0FF),
body: Stack(
children: [
/// 🔵 Floating Back Button (Responsive Position + Size)
Positioned(
top: 40 * scale,
left: 12 * scale,
child: Material(
elevation: 6 * scale,
color: Colors.indigo.shade700,
shape: const CircleBorder(),
child: InkWell(
onTap: () {
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (_) => const WelcomeScreen()),
);
},
child: Padding(
padding: EdgeInsets.all(10 * scale),
child: Icon(Icons.arrow_back,
color: Colors.white, size: 20 * scale),
),
),
),
const SizedBox(height: 12),
RoundedInput(
controller: cPassword,
hint: 'Password',
obscure: true,
),
/// 📦 Center White Card (Responsive)
Center(
child: Container(
width: width * 0.87,
padding: EdgeInsets.symmetric(
vertical: 28 * scale,
horizontal: 20 * scale,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(22 * scale),
boxShadow: [
BoxShadow(
color: Colors.black12,
blurRadius: 18 * scale,
spreadRadius: 1,
offset: Offset(0, 6 * scale),
),
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"Login",
style: TextStyle(
fontSize: 26 * scale,
fontWeight: FontWeight.bold,
color: Colors.indigo.shade700,
),
),
SizedBox(height: 25 * scale),
/// Login ID Input
Container(
decoration: BoxDecoration(
color: const Color(0xFFD8E7FF),
borderRadius: BorderRadius.circular(14 * scale),
),
child: RoundedInput(
controller: cLoginId,
hint: "Email / Mobile / Customer ID",
),
),
SizedBox(height: 16 * scale),
/// Password Input
Container(
decoration: BoxDecoration(
color: const Color(0xFFD8E7FF),
borderRadius: BorderRadius.circular(14 * scale),
),
child: RoundedInput(
controller: cPassword,
hint: "Password",
obscure: true,
),
),
SizedBox(height: 25 * scale),
/// Login Button
PrimaryButton(
label: "Login",
onTap: _login,
busy: auth.loading,
),
],
),
),
const SizedBox(height: 18),
PrimaryButton(label: 'Login', onTap: _login, busy: auth.loading),
],
),
),
],
),
);
}