Merge branch 'fatima'

fatima
devmirza121 4 years ago
commit 3d5ba9d995

@ -1,4 +1,3 @@
import 'dart:convert'; import 'dart:convert';
PasswordOTPCompare otpCompareFromJson(String str) => PasswordOTPCompare.fromJson(json.decode(str)); PasswordOTPCompare otpCompareFromJson(String str) => PasswordOTPCompare.fromJson(json.decode(str));
@ -11,8 +10,7 @@ class PasswordOTPCompare {
int? messageStatus; int? messageStatus;
String? message; String? message;
PasswordOTPCompare( PasswordOTPCompare({this.totalItemsCount, this.data, this.messageStatus, this.message});
{this.totalItemsCount, this.data, this.messageStatus, this.message});
PasswordOTPCompare.fromJson(Map<String, dynamic> json) { PasswordOTPCompare.fromJson(Map<String, dynamic> json) {
totalItemsCount = json['totalItemsCount']; totalItemsCount = json['totalItemsCount'];
@ -47,4 +45,4 @@ class Data {
data['userToken'] = this.userToken; data['userToken'] = this.userToken;
return data; return data;
} }
} }

@ -21,14 +21,18 @@ import 'package:flutter/material.dart';
import 'dart:convert'; import 'dart:convert';
import 'package:http/http.dart'; import 'package:http/http.dart';
class ConfirmNewPasswordPage extends StatelessWidget { class ConfirmNewPasswordPage extends StatefulWidget {
String userToken; String userToken;
ConfirmNewPasswordPage(this.userToken, {Key? key}) : super(key: key); 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -42,19 +46,62 @@ class ConfirmNewPasswordPage extends StatelessWidget {
children: [ children: [
"New Password".toText24(), "New Password".toText24(),
12.height, 12.height,
TxtField( TextFormField(
hint: "Inter New Password", decoration: InputDecoration(
value: newPassword, hintText: "Enter New Password",
onChanged: (v) { hintStyle: TextStyle(color: Colors.grey),
newPassword = v; 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, 40.height,
ShowFillButton( ShowFillButton(
title: "Confirm", title: "Confirm",
width: double.infinity, width: double.infinity,
onPressed: () { 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 { Future<void> confirmPasswordOTP(BuildContext context) async {
Utils.showLoading(context); Utils.showLoading(context);
Response res = await UserApiClent().ForgetPassword(userToken, newPassword); Response res = await UserApiClent().ForgetPassword(widget.userToken, newPassword);
Utils.hideLoading(context); Utils.hideLoading(context);
ConfirmPassword data = ConfirmPassword.fromJson(jsonDecode(res.body)); ConfirmPassword data = ConfirmPassword.fromJson(jsonDecode(res.body));
if (data.messageStatus == 1) { if (data.messageStatus == 1) {
Utils.showToast("Password is Updated");
navigateWithName(context, AppRoutes.loginWithPassword); navigateWithName(context, AppRoutes.loginWithPassword);
} else { } else {
Utils.showToast(data.message ?? ""); Utils.showToast(data.message ?? "");

@ -22,13 +22,10 @@ import 'package:car_provider_app/widgets/txt_field.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:car_provider_app/models/user/user.dart'; import 'package:car_provider_app/models/user/user.dart';
import 'dart:convert'; import 'dart:convert';
import 'package:http/http.dart'; import 'package:http/http.dart';
class ForgetPasswordPage extends StatelessWidget { class ForgetPasswordPage extends StatelessWidget {
int otpType = 1; int otpType = 1;
String userName = ""; String userName = "";
@ -121,7 +118,6 @@ class ForgetPasswordPage extends StatelessWidget {
} }
Future<void> forgetPasswordOTP(BuildContext context) async { Future<void> forgetPasswordOTP(BuildContext context) async {
Utils.showLoading(context); Utils.showLoading(context);
Response response = await UserApiClent().ForgetPasswordOTPRequest(userName, otpType); Response response = await UserApiClent().ForgetPasswordOTPRequest(userName, otpType);
Utils.hideLoading(context); Utils.hideLoading(context);
@ -131,16 +127,16 @@ class ForgetPasswordPage extends StatelessWidget {
onClick: (String code) async { onClick: (String code) async {
pop(context); pop(context);
Utils.showLoading(context); Utils.showLoading(context);
Response res = await UserApiClent().ForgetPasswordOTPCompare(otpRequest.data!.userToken??"", code); Response res = await UserApiClent().ForgetPasswordOTPCompare(otpRequest.data!.userToken ?? "", code);
Utils.hideLoading(context); Utils.hideLoading(context);
PasswordOTPCompare otpCompare = PasswordOTPCompare.fromJson(jsonDecode(res.body)); PasswordOTPCompare otpCompare = PasswordOTPCompare.fromJson(jsonDecode(res.body));
if (otpCompare.messageStatus == 1) { if (otpCompare.messageStatus == 1) {
var userToken = otpCompare.data!.userToken; var userToken = otpCompare.data!.userToken;
print("token is ________"); print("token is ________");
print(userToken); print(userToken);
navigateWithName(context, AppRoutes.confirmNewPasswordPage,arguments: userToken); navigateWithName(context, AppRoutes.confirmNewPasswordPage, arguments: userToken);
} else { } else {
Utils.showToast(otpCompare.message??""); Utils.showToast(otpCompare.message ?? "");
} }
}, },
)); ));
@ -162,10 +158,9 @@ class ForgetPasswordPage extends StatelessWidget {
// ); // );
// }, // },
// )); // ));
// navigateWithName(context, AppRoutes.vertifyPassword); // navigateWithName(context, AppRoutes.vertifyPassword);
} else { } else {
Utils.showToast(otpRequest.message ?? ""); Utils.showToast(otpRequest.message ?? "");
} }
} }
} }

Loading…
Cancel
Save