Verify email

fatima
devmirza121 4 years ago
parent 6f3303b5ff
commit 89ffa6c110

@ -163,4 +163,16 @@ class UserApiClent {
return await ApiClient().postJsonForObject((json) => ConfirmEmail.fromJson(json), ApiConsts.ChangeEmail, postParams, token: t); return await ApiClient().postJsonForObject((json) => ConfirmEmail.fromJson(json), ApiConsts.ChangeEmail, postParams, token: t);
} }
Future<MResponse> VerifyEmail(String email, String userId,String token) async {
var postParams = {
"email": email,
"userID": userId,
};
// return await ApiClient().postJsonForResponse(ApiConsts.ChangePassword, postParams);
print("tokeen " + token);
return await ApiClient().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.EmailVerify, postParams);
}
} }

@ -25,6 +25,7 @@ class ApiConsts {
static String ChangeMobileNo = baseUrlServices + "api/Account/ChangeMobileNo"; static String ChangeMobileNo = baseUrlServices + "api/Account/ChangeMobileNo";
static String ChangeEmailOTPRequest = baseUrlServices + "api/Account/ChangeEmailOTPRequest"; static String ChangeEmailOTPRequest = baseUrlServices + "api/Account/ChangeEmailOTPRequest";
static String ChangeEmail = baseUrlServices + "api/Account/ChangeEmail"; static String ChangeEmail = baseUrlServices + "api/Account/ChangeEmail";
static String EmailVerify = baseUrlServices + "api/Account/EmailVerify";
//Profile //Profile
static String GetProviderDocument = baseUrlServices + "api/ServiceProviders/ServiceProviderDocument_Get"; static String GetProviderDocument = baseUrlServices + "api/ServiceProviders/ServiceProviderDocument_Get";

@ -1,6 +1,7 @@
import 'package:car_provider_app/api/client/user_api_client.dart'; import 'package:car_provider_app/api/client/user_api_client.dart';
import 'package:car_provider_app/classes/utils.dart'; import 'package:car_provider_app/classes/utils.dart';
import 'package:car_provider_app/config/routes.dart'; import 'package:car_provider_app/config/routes.dart';
import 'package:car_provider_app/models/m_response.dart';
import 'package:car_provider_app/models/user/basic_otp.dart'; import 'package:car_provider_app/models/user/basic_otp.dart';
import 'package:car_provider_app/models/user/register_user.dart'; import 'package:car_provider_app/models/user/register_user.dart';
import 'package:car_provider_app/utils/navigator.dart'; import 'package:car_provider_app/utils/navigator.dart';
@ -28,6 +29,7 @@ class CompleteProfilePage extends StatefulWidget {
class _CompleteProfilePageState extends State<CompleteProfilePage> { class _CompleteProfilePageState extends State<CompleteProfilePage> {
String? firstName = "", lastName = "", email = "", password = "", confirmPassword = ""; String? firstName = "", lastName = "", email = "", password = "", confirmPassword = "";
bool isChecked = false; bool isChecked = false;
@override @override
void initState() { void initState() {
// TODO: implement initState // TODO: implement initState
@ -68,6 +70,8 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
TxtField( TxtField(
hint: "Email", hint: "Email",
value: email, value: email,
isButtonEnable: email!.length > 0 ? true : false,
buttonTitle: "Verify",
onChanged: (v) { onChanged: (v) {
email = v; email = v;
}, },
@ -108,7 +112,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
title: "Continue", title: "Continue",
width: double.infinity, width: double.infinity,
onPressed: () { onPressed: () {
if(validation()) performCompleteProfile(); if (validation()) performCompleteProfile();
}, },
), ),
], ],
@ -117,17 +121,17 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
), ),
), ),
); );
} }
Widget buildCheckbox() => Checkbox( Widget buildCheckbox() => Checkbox(
value: isChecked, value: isChecked,
activeColor: Colors.blue, activeColor: Colors.blue,
onChanged: (value){ onChanged: (value) {
setState(() { setState(() {
isChecked = value!; isChecked = value!;
}); });
}, },
); );
// Future<void> performCompleteProfile() async { // Future<void> performCompleteProfile() async {
// if(validateStructure(password??"")){ // if(validateStructure(password??"")){
@ -154,33 +158,39 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
// } // }
Future<void> performCompleteProfile() async { Future<void> performCompleteProfile() async {
if (validateStructure(password ?? "")) { if (validateStructure(password ?? "")) {
if (password == confirmPassword) { if (password == confirmPassword) {
print(widget.user.data!.userId ?? "userId"); print(widget.user.data!.userId ?? "userId");
Utils.showLoading(context); Utils.showLoading(context);
RegisterUser user = await UserApiClent().basicComplete(widget.user.data?.userId ?? "", firstName!, lastName!, email!, password!); RegisterUser user = await UserApiClent().basicComplete(widget.user.data?.userId ?? "", firstName!, lastName!, email!, password!);
Utils.hideLoading(context); Utils.hideLoading(context);
if (user.messageStatus == 1) { if (user.messageStatus == 1) {
Utils.showToast("Successfully Registered, Please login once"); Utils.showToast("Successfully Registered, Please login once");
pop(context); pop(context);
// navigateReplaceWithName(context, AppRoutes.dashboard,arguments: user); // navigateReplaceWithName(context, AppRoutes.dashboard,arguments: user);
} else {
Utils.showToast(user.message ?? "");
}
} else {
Utils.showToast("Please enter same password");
}
} else { } else {
Utils.showToast("Password Should contains Character, Number, Capital and small letters"); Utils.showToast(user.message ?? "");
} }
} else {
Utils.showToast("Please enter same password");
}
} 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,}$'; String pattern = r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{6,}$';
RegExp regExp = new RegExp(pattern); RegExp regExp = new RegExp(pattern);
return regExp.hasMatch(value); return regExp.hasMatch(value);
} }
bool isEmail(String em) {
String p = r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$';
RegExp regExp = new RegExp(p);
return regExp.hasMatch(em);
}
bool validation() { bool validation() {
bool isValid = true; bool isValid = true;
if (firstName!.isEmpty) { if (firstName!.isEmpty) {
@ -192,7 +202,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
} else if (password!.isEmpty) { } else if (password!.isEmpty) {
Utils.showToast("Password is mandatory"); Utils.showToast("Password is mandatory");
isValid = false; isValid = false;
}else if (!isChecked) { } else if (!isChecked) {
Utils.showToast("Please accept terms"); Utils.showToast("Please accept terms");
isValid = false; isValid = false;
} }

@ -23,78 +23,75 @@ class OtpDialog extends StatelessWidget {
color: Colors.white, color: Colors.white,
padding: EdgeInsets.all(24), padding: EdgeInsets.all(24),
width: double.infinity, width: double.infinity,
child: Container( child: Column(
color: Colors.yellow, mainAxisSize: MainAxisSize.min,
child: Column( crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min, children: [
crossAxisAlignment: CrossAxisAlignment.start, "Please insert OTP Code".toText24(),
children: [ 20.height,
"Please insert OTP Code".toText24(), Center(
20.height, child: OTPWidget(
Center( autoFocus: true,
child: OTPWidget( controller: _pinPutController,
autoFocus: true, defaultBorderColor: const Color(0xffD8D8D8),
controller: _pinPutController, maxLength: 4,
defaultBorderColor: const Color(0xffD8D8D8), onTextChanged: (text) {},
maxLength: 4, pinBoxColor: Colors.white,
onTextChanged: (text) {}, onDone: (code) => _onOtpCallBack(code, null),
pinBoxColor: Colors.white, textBorderColor: const Color(0xffD8D8D8),
onDone: (code) => _onOtpCallBack(code, null), pinBoxWidth: 48,
textBorderColor: const Color(0xffD8D8D8), pinBoxHeight: 48,
pinBoxWidth: 48, pinTextStyle: const TextStyle(fontSize: 24.0, color: MyColors.darkTextColor),
pinBoxHeight: 48, pinTextAnimatedSwitcherTransition: ProvidedPinBoxTextAnimation.scalingTransition,
pinTextStyle: const TextStyle(fontSize: 24.0, color: MyColors.darkTextColor), pinTextAnimatedSwitcherDuration: const Duration(milliseconds: 300),
pinTextAnimatedSwitcherTransition: ProvidedPinBoxTextAnimation.scalingTransition, pinBoxRadius: 8,
pinTextAnimatedSwitcherDuration: const Duration(milliseconds: 300), keyboardType: TextInputType.number,
pinBoxRadius: 8,
keyboardType: TextInputType.number,
),
), ),
// Row( ),
// children: [ // Row(
// Expanded( // children: [
// child: Container( // Expanded(
// width: double.infinity, // child: Container(
// height: 60, // width: double.infinity,
// color: accentColor.withOpacity(0.3), // height: 60,
// ), // color: accentColor.withOpacity(0.3),
// ), // ),
// 12.width, // ),
// Expanded( // 12.width,
// child: Container( // Expanded(
// width: double.infinity, // child: Container(
// height: 60, // width: double.infinity,
// color: accentColor.withOpacity(0.3), // height: 60,
// ), // color: accentColor.withOpacity(0.3),
// ), // ),
// 12.width, // ),
// Expanded( // 12.width,
// child: Container( // Expanded(
// width: double.infinity, // child: Container(
// height: 60, // width: double.infinity,
// color: accentColor.withOpacity(0.3), // height: 60,
// ), // color: accentColor.withOpacity(0.3),
// ), // ),
// 12.width, // ),
// Expanded( // 12.width,
// child: Container( // Expanded(
// width: double.infinity, // child: Container(
// height: 60, // width: double.infinity,
// color: accentColor.withOpacity(0.3), // height: 60,
// ), // color: accentColor.withOpacity(0.3),
// ), // ),
// ], // ),
// ), // ],
40.height, // ),
ShowFillButton( 40.height,
title: "Check Code", ShowFillButton(
width: double.infinity, title: "Check Code",
onPressed: () { width: double.infinity,
onClick(code); onPressed: () {
}, onClick(code);
) },
], )
), ],
), ),
); );
} }

@ -16,7 +16,7 @@ class TxtField extends StatelessWidget {
bool isNeedClickAll; bool isNeedClickAll;
bool isButtonEnable; bool isButtonEnable;
double? elevation; double? elevation;
Function? onTap; VoidCallback? onTap;
String? buttonTitle; String? buttonTitle;
int? maxLines; int? maxLines;
bool isSidePaddingZero; bool isSidePaddingZero;
@ -47,6 +47,7 @@ class TxtField extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
controller.text = value ?? ""; controller.text = value ?? "";
controller.selection = TextSelection.fromPosition(TextPosition(offset: controller.text.length));
return InkWell( return InkWell(
onTap: isNeedClickAll == false onTap: isNeedClickAll == false
? null ? null
@ -130,7 +131,7 @@ class TxtField extends StatelessWidget {
if (isButtonEnable) if (isButtonEnable)
Material( Material(
child: InkWell( child: InkWell(
onTap: () {}, onTap: onTap,
customBorder: inkWellCorner(), customBorder: inkWellCorner(),
child: Container( child: Container(
height: 55, height: 55,

Loading…
Cancel
Save