|
|
|
|
@ -18,8 +18,10 @@ import 'package:flutter/material.dart';
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
import 'package:http/http.dart';
|
|
|
|
|
|
|
|
|
|
class ChangePasswordPage extends StatefulWidget {
|
|
|
|
|
import '../../models/m_response.dart';
|
|
|
|
|
|
|
|
|
|
class ChangePasswordPage extends StatefulWidget {
|
|
|
|
|
ChangePasswordPage({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<ChangePasswordPage> createState() => _ChangePasswordPageState();
|
|
|
|
|
@ -27,7 +29,7 @@ class ChangePasswordPage extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
class _ChangePasswordPageState extends State<ChangePasswordPage> {
|
|
|
|
|
String newPassword = "";
|
|
|
|
|
String currentPassword = " ";
|
|
|
|
|
String currentPasswor = '';
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
@ -53,7 +55,7 @@ class _ChangePasswordPageState extends State<ChangePasswordPage> {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
obscureText: true,
|
|
|
|
|
onChanged: (v) => currentPassword = v,
|
|
|
|
|
onChanged: (v) => currentPasswor = v,
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
TextFormField(
|
|
|
|
|
@ -85,24 +87,24 @@ class _ChangePasswordPageState extends State<ChangePasswordPage> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> changePassword(BuildContext context) async {
|
|
|
|
|
if(validateStructure(newPassword??"")){
|
|
|
|
|
if (validateStructure(newPassword ?? "")) {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
Response res = await UserApiClent().ChangePassword(currentPassword, newPassword);
|
|
|
|
|
MResponse res = await UserApiClent().ChangePassword(currentPasswor, newPassword);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
ChangePassword data = ChangePassword.fromJson(jsonDecode(res.body));
|
|
|
|
|
if (data.messageStatus == 1) {
|
|
|
|
|
if (res.messageStatus == 1) {
|
|
|
|
|
Utils.showToast("Password is Updated");
|
|
|
|
|
navigateWithName(context, AppRoutes.dashboard);
|
|
|
|
|
// navigateWithName(context, AppRoutes.loginWithPassword);
|
|
|
|
|
Navigator.of(context)
|
|
|
|
|
.pushNamedAndRemoveUntil(AppRoutes.loginWithPassword, (Route<dynamic> route) => false);
|
|
|
|
|
} else {
|
|
|
|
|
Utils.showToast(data.message ?? "");
|
|
|
|
|
Utils.showToast(res.message ?? "");
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
Utils.showToast("Password Should contains Character, Number, Capital and small letters");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool validateStructure(String value){
|
|
|
|
|
bool validateStructure(String value) {
|
|
|
|
|
String pattern = r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{6,}$';
|
|
|
|
|
RegExp regExp = new RegExp(pattern);
|
|
|
|
|
return regExp.hasMatch(value);
|
|
|
|
|
|