123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312 |
- import 'dart:convert';
-
- import 'package:flutter/material.dart';
- import 'package:fluttertoast/fluttertoast.dart';
- import 'package:google_fonts/google_fonts.dart';
- import 'package:employee_selfservice_mobile/Screens/ForgotPassword/resetPassword_post.dart';
- import 'package:employee_selfservice_mobile/Screens/Login/background.dart';
- import 'package:employee_selfservice_mobile/Screens/Login/inputWidget.dart';
- import 'package:employee_selfservice_mobile/Screens/Login/login_screen.dart';
- import 'package:progress_dialog_null_safe/progress_dialog_null_safe.dart';
-
- class ForgotPasswordView extends StatefulWidget {
- @override
- _ForgotPasswordView createState() => _ForgotPasswordView();
- }
-
- class _ForgotPasswordView extends State<ForgotPasswordView> {
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- resizeToAvoidBottomInset: false,
- backgroundColor: Colors.white,
- body: Stack(
- children: <Widget>[
- Background(),
- ForgotPasswordScreen(),
- ],
- ));
- }
- }
-
- class ForgotPasswordScreen extends StatelessWidget {
- const ForgotPasswordScreen({Key? key}) : super(key: key);
-
- @override
- Widget build(BuildContext context) {
- ProgressDialog loading = ProgressDialog(context);
- loading = ProgressDialog(context,
- type: ProgressDialogType.normal, isDismissible: false, showLogs: true);
- loading.style(
- message: 'Please Wait .....',
- borderRadius: 5,
- backgroundColor: Colors.white,
- progressWidget: CircularProgressIndicator(),
- elevation: 10.0,
- padding: EdgeInsets.all(10),
- insetAnimCurve: Curves.easeInOut,
- progress: 0.0,
- maxProgress: 100.0,
- progressTextStyle: TextStyle(
- color: Colors.black, fontSize: 10.0, fontWeight: FontWeight.w400),
- messageTextStyle: TextStyle(
- color: Colors.black, fontSize: 15.0, fontWeight: FontWeight.w600));
- return Column(
- children: <Widget>[
- Padding(
- padding:
- EdgeInsets.only(top: MediaQuery.of(context).size.height / 2.45),
- ),
- Column(
- children: <Widget>[
- Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: <Widget>[
- Padding(
- padding: EdgeInsets.only(top: 0),
- child: Text(
- "Forgot Password",
- style: GoogleFonts.knewave(
- color: Colors.blueAccent, fontSize: 25),
- ),
- ),
- ],
- ),
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Padding(
- padding: EdgeInsets.only(left: 40, bottom: 5, top: 20),
- child: Text(
- "Email",
- style: TextStyle(fontSize: 16, color: Colors.black87),
- ),
- ),
- Stack(
- alignment: Alignment.bottomRight,
- children: <Widget>[
- InputWidgetEmail(20.0, 20.0),
- Padding(
- padding: EdgeInsets.only(right: 15),
- child: Row(
- children: <Widget>[
- Expanded(
- child: Padding(
- padding: EdgeInsets.only(top: 0),
- )),
- InkWell(
- child: Container(
- padding: EdgeInsets.all(10),
- decoration: ShapeDecoration(
- shape: CircleBorder(),
- gradient: LinearGradient(
- colors: Gradients2,
- begin: Alignment.topLeft,
- end: Alignment.bottomRight),
- ),
- child: ImageIcon(
- AssetImage("assets/images/ic_forward.png"),
- size: 40,
- color: Colors.white,
- ),
- ),
- onTap: () async {
- if (emailController.text.toString().isEmpty){
- Fluttertoast.showToast(
- msg: "Email Required",
- toastLength: Toast.LENGTH_SHORT,
- gravity: ToastGravity.CENTER,
- timeInSecForIosWeb: 1,
- textColor: Colors.white,
- fontSize: 16.0);
- } else {
- await loading.show();
- ResetPassword_Post.connectToAPI(emailController.text.toString())
- .then((valueResult) async{
- Map<String, dynamic> object = json.decode(valueResult);
- if (object.containsKey("result").toString() == "true") {
- String status = object['result']['status'].toString();
- String message = object['result']['message'].toString();
- if (status == "success") {
- emailController.clear();
- await loading.hide();
- Widget okButton = TextButton(
- child: Text("OK"),
- onPressed: () {
- Navigator.of(context, rootNavigator: true).pop();
- Navigator.pushAndRemoveUntil(
- context,
- MaterialPageRoute(
- builder: (context) => LoginView()),
- (route) => false);
- },
- );
-
- // set up the AlertDialog
- AlertDialog alert = AlertDialog(
- title: Text("Employee Self Service"),
- //content: Text(message),
- content: Text("Link to reset password has been sent to your email address"),
- actions: [
- okButton,
- ],
- );
- // show the dialog
- showDialog(
- context: context,
- barrierDismissible: false,
- builder: (BuildContext context) {
- return alert;
- },
- );
- } else if (status == "failed") {
- await loading.hide();
- Widget okButton = TextButton(
- child: Text("Back"),
- onPressed: () {
- Navigator.of(context, rootNavigator: true).pop();
- },
- );
-
- // set up the AlertDialog
- AlertDialog alert = AlertDialog(
- title: Text("Employee Self Service"),
- //content: Text(message),
- content: Text("Your email has not been registered"),
- actions: [
- okButton,
- ],
- );
- // show the dialog
- showDialog(
- context: context,
- barrierDismissible: false,
- builder: (BuildContext context) {
- return alert;
- },
- );
- /*Fluttertoast.showToast(
- msg: message,
- toastLength: Toast.LENGTH_SHORT,
- gravity: ToastGravity.CENTER,
- timeInSecForIosWeb: 1,
- textColor: Colors.white,
- fontSize: 16.0);*/
- }
- } else {
- Fluttertoast.showToast(
- msg: "Server Response Error",
- toastLength: Toast.LENGTH_SHORT,
- gravity: ToastGravity.CENTER,
- timeInSecForIosWeb: 1,
- textColor: Colors.white,
- fontSize: 16.0);
- await loading.hide();
- }
- });
- }
- },
- )
- ],
- ),
- ),
- ],
- ),
- ],
- ),
- Padding(
- padding: EdgeInsets.only(bottom: 10),
- ),
- ],
- )
- ],
- );
- }
- }
-
- Widget roundedRectButton(
- String title, List<Color> gradient, bool isEndIconVisible) {
- return Builder(builder: (BuildContext mContext) {
- return Align(
- alignment: Alignment.centerLeft,
- child: Stack(
- children: <Widget>[
- Container(
- alignment: Alignment.centerRight,
- width: MediaQuery.of(mContext).size.width / 2.5,
- decoration: ShapeDecoration(
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.only(
- topRight: Radius.circular(20.0),
- bottomRight: Radius.circular(20.0))),
- gradient: LinearGradient(
- colors: gradient,
- begin: Alignment.topLeft,
- end: Alignment.bottomRight),
- ),
- child: Text(title,
- style: TextStyle(
- color: Colors.white,
- fontSize: 15,
- fontWeight: FontWeight.w500)),
- padding: EdgeInsets.all(10),
- ),
- Visibility(
- visible: isEndIconVisible,
- child: Padding(
- padding: EdgeInsets.only(right: 10),
- child: ImageIcon(
- AssetImage("assets/images/ic_forward.png"),
- size: 30,
- color: Colors.white,
- )),
- ),
- ],
- ),
- );
- });
- }
-
- //Alert Dialog
- showAlertDialog(BuildContext context) {
- // set up the button
- Widget okButton = TextButton(
- child: Text("OK"),
- onPressed: () {
- Navigator.of(context, rootNavigator: true).pop();
- Navigator.pushAndRemoveUntil(
- context,
- MaterialPageRoute(
- builder: (context) => LoginView()),
- (route) => false);
- },
- );
-
- // set up the AlertDialog
- AlertDialog alert = AlertDialog(
- title: Text("Employee Self Service"),
- content: Text("Please check your email."),
- actions: [
- okButton,
- ],
- );
-
- // show the dialog
- showDialog(
- context: context,
- barrierDismissible: false,
- builder: (BuildContext context) {
- return alert;
- },
- );
- }
-
- const List<Color> Gradients1 = [
- Color(0xFF0EDED2),
- Color(0xFF03A0FE),
- ];
-
- const List<Color> Gradients2 = [
- Color(0xFFFF9945),
- Color(0xFFFc6076),
- ];
|