sc-android-app/lib/screens/forgot_password_screen.dart

148 lines
6.2 KiB
Dart

import 'package:cheminova/provider/forgot_password_provider.dart';
import 'package:cheminova/screens/login_screen.dart';
import 'package:cheminova/widgets/common_background.dart';
import 'package:cheminova/widgets/common_elevated_button.dart';
import 'package:cheminova/widgets/common_text_form_field.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class ForgotPasswordScreen extends StatefulWidget {
const ForgotPasswordScreen({super.key});
@override
State<ForgotPasswordScreen> createState() => _ForgotPasswordScreenState();
}
class _ForgotPasswordScreenState extends State<ForgotPasswordScreen> {
final _formKey = GlobalKey<FormState>();
late ForgotPasswordProvider forgotPasswordProvider;
@override
void initState() {
forgotPasswordProvider = ForgotPasswordProvider();
super.initState();
}
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider<ForgotPasswordProvider>(
create: (_) => forgotPasswordProvider,
builder: (context, child) {
return CommonBackground(
isFullWidth: false,
child: Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(leading: InkWell(onTap:() {
Navigator.pop(context);
},child: Image.asset('assets/Back_attendance.png')),backgroundColor: Colors.transparent,),
body: Center(
child: SingleChildScrollView(
child: Container(
padding: const EdgeInsets.all(20.0).copyWith(top: 30, bottom: 30),
margin: const EdgeInsets.symmetric(horizontal: 30.0),
decoration: BoxDecoration(
border: Border.all(color: Colors.white),
color: const Color(0xffB4D1E5).withOpacity(0.9),
borderRadius: BorderRadius.circular(26.0),
),
child: Form(
key: _formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Align(
alignment: Alignment.topLeft,
child: Image.asset(
'assets/lock_logo2.png',
height: 50.0, // Adjust the height as needed
width: 50.0, // Adjust the width as needed
),
),
const Text(
'Forgot Password',
style: TextStyle(
fontSize: 30,
color: Colors.black,
fontWeight: FontWeight.w500,
fontFamily: 'Anek',
),
),
const Text(
'Enter Registered Email ID to generate new password',
style: TextStyle(
fontSize: 14,
color: Colors.black,
fontWeight: FontWeight.w300,
fontFamily: 'Roboto',
),
),
const SizedBox(height: 20),
Consumer<ForgotPasswordProvider>(
builder: (context, value, child) => CommonTextFormField(
controller: value.emailController,
title: ' Enter Your Email ID'),
),
const SizedBox(height: 20),
Align(
alignment: Alignment.center,
child: TextButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text('Back to Login',
style: TextStyle(
fontSize: 20,
color: Colors.black,
fontWeight: FontWeight.w400,
fontFamily: 'Roboto')),
),
),
const SizedBox(height: 15),
Align(
alignment: Alignment.center,
child: Consumer<ForgotPasswordProvider>(
builder: (context, value, child) => CommonElevatedButton(
backgroundColor: const Color(0xff004791),
borderRadius: 30,
width: double.infinity,
height: kToolbarHeight - 10,
text: 'SEND',
onPressed: value.isLoading
? null
: () async {
if (_formKey.currentState!.validate()) {
value.forgotPassword().then((result) {
var (status, message) = result;
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(
content: Text(message)));
if (status) {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) =>
const LoginPage()));
}
});
}
},
),
),
),
],
),
),
),
),
),
),
);
}
);
}
}