|
|
|
|
@ -21,14 +21,18 @@ import 'package:flutter/material.dart';
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
import 'package:http/http.dart';
|
|
|
|
|
|
|
|
|
|
class ConfirmNewPasswordPage extends StatelessWidget {
|
|
|
|
|
class ConfirmNewPasswordPage extends StatefulWidget {
|
|
|
|
|
String userToken;
|
|
|
|
|
|
|
|
|
|
ConfirmNewPasswordPage(this.userToken, {Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
String newPassword = "";
|
|
|
|
|
@override
|
|
|
|
|
State<ConfirmNewPasswordPage> createState() => _ConfirmNewPasswordPageState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// String userToken = "";
|
|
|
|
|
class _ConfirmNewPasswordPageState extends State<ConfirmNewPasswordPage> {
|
|
|
|
|
String newPassword = "";
|
|
|
|
|
String confirmPassword = '';
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
@ -42,19 +46,62 @@ class ConfirmNewPasswordPage extends StatelessWidget {
|
|
|
|
|
children: [
|
|
|
|
|
"New Password".toText24(),
|
|
|
|
|
12.height,
|
|
|
|
|
TxtField(
|
|
|
|
|
hint: "Inter New Password",
|
|
|
|
|
value: newPassword,
|
|
|
|
|
onChanged: (v) {
|
|
|
|
|
newPassword = v;
|
|
|
|
|
},
|
|
|
|
|
TextFormField(
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
hintText: "Enter New Password",
|
|
|
|
|
hintStyle: TextStyle(color: Colors.grey),
|
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
|
borderRadius: const BorderRadius.all(
|
|
|
|
|
const Radius.circular(5.0),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
obscureText: true,
|
|
|
|
|
onChanged: (v) => newPassword = v,
|
|
|
|
|
),
|
|
|
|
|
12.height,
|
|
|
|
|
TextFormField(
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
hintText: "Confirm Password",
|
|
|
|
|
hintStyle: TextStyle(color: Colors.grey),
|
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
|
borderRadius: const BorderRadius.all(
|
|
|
|
|
const Radius.circular(5.0),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
obscureText: true,
|
|
|
|
|
onChanged: (v) => confirmPassword = v,
|
|
|
|
|
),
|
|
|
|
|
// TxtField(
|
|
|
|
|
// hint: "Inter New Password",
|
|
|
|
|
// value: newPassword,
|
|
|
|
|
// isPasswordEnabled: true,
|
|
|
|
|
// maxLines: 1,
|
|
|
|
|
// onChanged: (v) {
|
|
|
|
|
// newPassword = v;
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
// 12.height,
|
|
|
|
|
// TxtField(
|
|
|
|
|
// hint: "Confirm New Password",
|
|
|
|
|
// value: newPassword,
|
|
|
|
|
// isPasswordEnabled: true,
|
|
|
|
|
// maxLines: 1,
|
|
|
|
|
// onChanged: (v) {
|
|
|
|
|
// newPassword = newPassword;
|
|
|
|
|
// },
|
|
|
|
|
// ),
|
|
|
|
|
40.height,
|
|
|
|
|
ShowFillButton(
|
|
|
|
|
title: "Confirm",
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
confirmPasswordOTP(context);
|
|
|
|
|
if(newPassword == confirmPassword ){
|
|
|
|
|
confirmPasswordOTP(context);}
|
|
|
|
|
else{
|
|
|
|
|
Utils.showToast("Confirmation password does not match the entered password");
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
@ -65,10 +112,11 @@ class ConfirmNewPasswordPage extends StatelessWidget {
|
|
|
|
|
|
|
|
|
|
Future<void> confirmPasswordOTP(BuildContext context) async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
Response res = await UserApiClent().ForgetPassword(userToken, newPassword);
|
|
|
|
|
Response res = await UserApiClent().ForgetPassword(widget.userToken, newPassword);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
ConfirmPassword data = ConfirmPassword.fromJson(jsonDecode(res.body));
|
|
|
|
|
if (data.messageStatus == 1) {
|
|
|
|
|
Utils.showToast("Password is Updated");
|
|
|
|
|
navigateWithName(context, AppRoutes.loginWithPassword);
|
|
|
|
|
} else {
|
|
|
|
|
Utils.showToast(data.message ?? "");
|
|
|
|
|
|