|
|
|
|
@ -18,10 +18,10 @@ import 'package:flutter/material.dart';
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
import 'package:http/http.dart';
|
|
|
|
|
|
|
|
|
|
class ChangePasswordPage extends StatefulWidget {
|
|
|
|
|
String userToken;
|
|
|
|
|
import '../../models/m_response.dart';
|
|
|
|
|
|
|
|
|
|
ChangePasswordPage(this.userToken, {Key? key}) : super(key: key);
|
|
|
|
|
class ChangePasswordPage extends StatefulWidget {
|
|
|
|
|
ChangePasswordPage({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<ChangePasswordPage> createState() => _ChangePasswordPageState();
|
|
|
|
|
@ -48,7 +48,7 @@ class _ChangePasswordPageState extends State<ChangePasswordPage> {
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
hintText: "Enter Old Password",
|
|
|
|
|
hintStyle: TextStyle(color: Colors.grey),
|
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
|
borderRadius: const BorderRadius.all(
|
|
|
|
|
const Radius.circular(5.0),
|
|
|
|
|
),
|
|
|
|
|
@ -62,7 +62,7 @@ class _ChangePasswordPageState extends State<ChangePasswordPage> {
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
hintText: "Inter New Password",
|
|
|
|
|
hintStyle: TextStyle(color: Colors.grey),
|
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
|
borderRadius: const BorderRadius.all(
|
|
|
|
|
const Radius.circular(5.0),
|
|
|
|
|
),
|
|
|
|
|
@ -75,7 +75,8 @@ class _ChangePasswordPageState extends State<ChangePasswordPage> {
|
|
|
|
|
ShowFillButton(
|
|
|
|
|
title: "Confirm",
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
onPressed: () {changePassword(context);
|
|
|
|
|
onPressed: () {
|
|
|
|
|
changePassword(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
@ -86,25 +87,25 @@ 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(currentPasswor, 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.loginWithPassword);
|
|
|
|
|
// 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){
|
|
|
|
|
String pattern = r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{6,}$';
|
|
|
|
|
bool validateStructure(String value) {
|
|
|
|
|
String pattern = r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{6,}$';
|
|
|
|
|
RegExp regExp = new RegExp(pattern);
|
|
|
|
|
return regExp.hasMatch(value);
|
|
|
|
|
}
|
|
|
|
|
|