|
|
|
|
@ -4,6 +4,7 @@ import 'package:car_provider_app/api/shared_prefrence.dart';
|
|
|
|
|
import 'package:car_provider_app/classes/utils.dart';
|
|
|
|
|
import 'package:car_provider_app/config/constants.dart';
|
|
|
|
|
import 'package:car_provider_app/config/routes.dart';
|
|
|
|
|
import 'package:car_provider_app/models/user/country.dart';
|
|
|
|
|
import 'package:car_provider_app/models/user/forget_password_otp_compare.dart';
|
|
|
|
|
import 'package:car_provider_app/models/user/forget_password_otp_request.dart';
|
|
|
|
|
import 'package:car_provider_app/pages/user/vertify_password_page.dart';
|
|
|
|
|
@ -14,10 +15,12 @@ import 'package:car_provider_app/widgets/button/show_image_button.dart';
|
|
|
|
|
import 'package:car_provider_app/widgets/dialog/dialogs.dart';
|
|
|
|
|
import 'package:car_provider_app/widgets/dialog/message_dialog.dart';
|
|
|
|
|
import 'package:car_provider_app/widgets/dialog/otp_dialog.dart';
|
|
|
|
|
import 'package:car_provider_app/widgets/dropdown/dropdow_field.dart';
|
|
|
|
|
import 'package:car_provider_app/widgets/show_fill_button.dart';
|
|
|
|
|
import 'package:car_provider_app/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:car_provider_app/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:car_provider_app/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:car_provider_app/widgets/tab/login_email_tab.dart';
|
|
|
|
|
import 'package:car_provider_app/widgets/txt_field.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:car_provider_app/models/user/user.dart';
|
|
|
|
|
@ -36,6 +39,20 @@ class _ForgetPasswordPageState extends State<ForgetPasswordPage> {
|
|
|
|
|
String userName = "";
|
|
|
|
|
bool _email = true;
|
|
|
|
|
bool _mobile = true;
|
|
|
|
|
ClassType type = ClassType.NUMBER;
|
|
|
|
|
Country? _country;
|
|
|
|
|
String countryCode = "";
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
getCountryList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getCountryList() async {
|
|
|
|
|
_country = await UserApiClent().getAllCountries();
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -46,64 +63,43 @@ class _ForgetPasswordPageState extends State<ForgetPasswordPage> {
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
height: double.infinity,
|
|
|
|
|
padding: EdgeInsets.all(40),
|
|
|
|
|
child: Column(
|
|
|
|
|
child:Column(
|
|
|
|
|
children: [
|
|
|
|
|
"Verify New Password".toText24(),
|
|
|
|
|
mFlex(1),
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
RaisedButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
setState(() {
|
|
|
|
|
_mobile = true;
|
|
|
|
|
_email = false;
|
|
|
|
|
});
|
|
|
|
|
},child:
|
|
|
|
|
Text("Mobile Number",
|
|
|
|
|
style: TextStyle(fontSize: 14,
|
|
|
|
|
fontWeight: FontWeight.w600,),
|
|
|
|
|
),color: _mobile ? Colors.blue : Colors.transparent,textColor: _mobile ? Colors.white : Colors.blue,
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 18, vertical: 12),),
|
|
|
|
|
|
|
|
|
|
RaisedButton(onPressed: () {
|
|
|
|
|
setState(() {
|
|
|
|
|
_mobile = false;
|
|
|
|
|
_email = true;
|
|
|
|
|
});
|
|
|
|
|
},child:
|
|
|
|
|
Text("Email Address",
|
|
|
|
|
style: TextStyle(fontSize: 14,
|
|
|
|
|
fontWeight: FontWeight.w600,),),color: _email? Colors.blue : Colors.transparent
|
|
|
|
|
,textColor: _email ? Colors.white : Colors.blue,
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 18, vertical: 12),),
|
|
|
|
|
],
|
|
|
|
|
LoginEmailTab(
|
|
|
|
|
onSelection: (ClassType type) {
|
|
|
|
|
setState(() {
|
|
|
|
|
this.type = type;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
50.height,
|
|
|
|
|
"Retrieve Password".toText24(),
|
|
|
|
|
12.height,
|
|
|
|
|
_mobile ? TxtField(
|
|
|
|
|
hint: "Phone Number" ,
|
|
|
|
|
value: userName,
|
|
|
|
|
onChanged: (v) {
|
|
|
|
|
userName = v;
|
|
|
|
|
},
|
|
|
|
|
):
|
|
|
|
|
_email ? TxtField(
|
|
|
|
|
type == ClassType.NUMBER ? Column(children: [
|
|
|
|
|
getCountry(),
|
|
|
|
|
TxtField(
|
|
|
|
|
hint: "5********",
|
|
|
|
|
value: userName,
|
|
|
|
|
onChanged: (v) {
|
|
|
|
|
userName = v;
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
],) : TxtField(
|
|
|
|
|
hint: "Email Address",
|
|
|
|
|
value: userName,
|
|
|
|
|
onChanged: (v) {
|
|
|
|
|
userName = v;
|
|
|
|
|
},
|
|
|
|
|
): Container(),
|
|
|
|
|
),
|
|
|
|
|
50.height,
|
|
|
|
|
ShowFillButton(
|
|
|
|
|
title: "Continue",
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
if(userName.isNum() && _mobile) {
|
|
|
|
|
if (userName.isNum()&& !userName.isValidEmail() && type==ClassType.NUMBER) {
|
|
|
|
|
forgetPasswordPhoneOTP(context);
|
|
|
|
|
}else if (!userName.isNum() && _email) {
|
|
|
|
|
} else if (userName.isValidEmail() && type==ClassType.EMAIL) {
|
|
|
|
|
forgetPasswordEmailOTP(context);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@ -115,9 +111,29 @@ class _ForgetPasswordPageState extends State<ForgetPasswordPage> {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Widget getCountry() {
|
|
|
|
|
if (_country != null) {
|
|
|
|
|
List<DropValue> dropList = [];
|
|
|
|
|
_country!.data?.forEach((element) {
|
|
|
|
|
dropList.add(new DropValue(element.id ?? 0, (element.countryName ?? "") + " " + (element.countryCode ?? ""), element.countryCode ?? ""));
|
|
|
|
|
});
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: const EdgeInsets.all(2.0),
|
|
|
|
|
child: DropdownField((DropValue value) {
|
|
|
|
|
countryCode = value.subValue;
|
|
|
|
|
}, list: dropList, hint: "Chose Country"),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
return Center(
|
|
|
|
|
child: CircularProgressIndicator(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> forgetPasswordPhoneOTP(BuildContext context) async {
|
|
|
|
|
Utils.showLoading(context);
|
|
|
|
|
Response response = await UserApiClent().ForgetPasswordOTPRequest(userName, otpType);
|
|
|
|
|
Response response = await UserApiClent().ForgetPasswordOTPRequest(countryCode+userName, otpType);
|
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
|
PasswordOTPRequest otpRequest = PasswordOTPRequest.fromJson(jsonDecode(response.body));
|
|
|
|
|
if (otpRequest.messageStatus == 1) {
|
|
|
|
|
|