diff --git a/lib/api/client/user_api_client.dart b/lib/api/client/user_api_client.dart index 6cceb1e..dec7764 100644 --- a/lib/api/client/user_api_client.dart +++ b/lib/api/client/user_api_client.dart @@ -163,4 +163,16 @@ class UserApiClent { return await ApiClient().postJsonForObject((json) => ConfirmEmail.fromJson(json), ApiConsts.ChangeEmail, postParams, token: t); } + Future 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); + + } + } diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index 87ed1bd..ae08cbb 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -25,6 +25,7 @@ class ApiConsts { static String ChangeMobileNo = baseUrlServices + "api/Account/ChangeMobileNo"; static String ChangeEmailOTPRequest = baseUrlServices + "api/Account/ChangeEmailOTPRequest"; static String ChangeEmail = baseUrlServices + "api/Account/ChangeEmail"; + static String EmailVerify = baseUrlServices + "api/Account/EmailVerify"; //Profile static String GetProviderDocument = baseUrlServices + "api/ServiceProviders/ServiceProviderDocument_Get"; diff --git a/lib/pages/user/complete_profile_page.dart b/lib/pages/user/complete_profile_page.dart index 1a8fdf2..a63aeaf 100644 --- a/lib/pages/user/complete_profile_page.dart +++ b/lib/pages/user/complete_profile_page.dart @@ -1,6 +1,7 @@ import 'package:car_provider_app/api/client/user_api_client.dart'; import 'package:car_provider_app/classes/utils.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/register_user.dart'; import 'package:car_provider_app/utils/navigator.dart'; @@ -28,6 +29,7 @@ class CompleteProfilePage extends StatefulWidget { class _CompleteProfilePageState extends State { String? firstName = "", lastName = "", email = "", password = "", confirmPassword = ""; bool isChecked = false; + @override void initState() { // TODO: implement initState @@ -68,6 +70,8 @@ class _CompleteProfilePageState extends State { TxtField( hint: "Email", value: email, + isButtonEnable: email!.length > 0 ? true : false, + buttonTitle: "Verify", onChanged: (v) { email = v; }, @@ -108,7 +112,7 @@ class _CompleteProfilePageState extends State { title: "Continue", width: double.infinity, onPressed: () { - if(validation()) performCompleteProfile(); + if (validation()) performCompleteProfile(); }, ), ], @@ -117,17 +121,17 @@ class _CompleteProfilePageState extends State { ), ), ); - } + Widget buildCheckbox() => Checkbox( - value: isChecked, - activeColor: Colors.blue, - onChanged: (value){ - setState(() { - isChecked = value!; - }); - }, - ); + value: isChecked, + activeColor: Colors.blue, + onChanged: (value) { + setState(() { + isChecked = value!; + }); + }, + ); // Future performCompleteProfile() async { // if(validateStructure(password??"")){ @@ -154,33 +158,39 @@ class _CompleteProfilePageState extends State { // } Future performCompleteProfile() async { - if (validateStructure(password ?? "")) { - if (password == confirmPassword) { - print(widget.user.data!.userId ?? "userId"); - Utils.showLoading(context); - RegisterUser user = await UserApiClent().basicComplete(widget.user.data?.userId ?? "", firstName!, lastName!, email!, password!); - Utils.hideLoading(context); - if (user.messageStatus == 1) { - Utils.showToast("Successfully Registered, Please login once"); - pop(context); - // navigateReplaceWithName(context, AppRoutes.dashboard,arguments: user); - } else { - Utils.showToast(user.message ?? ""); - } - } else { - Utils.showToast("Please enter same password"); - } + if (validateStructure(password ?? "")) { + if (password == confirmPassword) { + print(widget.user.data!.userId ?? "userId"); + Utils.showLoading(context); + RegisterUser user = await UserApiClent().basicComplete(widget.user.data?.userId ?? "", firstName!, lastName!, email!, password!); + Utils.hideLoading(context); + if (user.messageStatus == 1) { + Utils.showToast("Successfully Registered, Please login once"); + pop(context); + // navigateReplaceWithName(context, AppRoutes.dashboard,arguments: user); } 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){ - 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); } + 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 isValid = true; if (firstName!.isEmpty) { @@ -192,7 +202,7 @@ class _CompleteProfilePageState extends State { } else if (password!.isEmpty) { Utils.showToast("Password is mandatory"); isValid = false; - }else if (!isChecked) { + } else if (!isChecked) { Utils.showToast("Please accept terms"); isValid = false; } diff --git a/lib/widgets/dialog/otp_dialog.dart b/lib/widgets/dialog/otp_dialog.dart index 8962f29..5dffc7a 100644 --- a/lib/widgets/dialog/otp_dialog.dart +++ b/lib/widgets/dialog/otp_dialog.dart @@ -23,78 +23,75 @@ class OtpDialog extends StatelessWidget { color: Colors.white, padding: EdgeInsets.all(24), width: double.infinity, - child: Container( - color: Colors.yellow, - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - "Please insert OTP Code".toText24(), - 20.height, - Center( - child: OTPWidget( - autoFocus: true, - controller: _pinPutController, - defaultBorderColor: const Color(0xffD8D8D8), - maxLength: 4, - onTextChanged: (text) {}, - pinBoxColor: Colors.white, - onDone: (code) => _onOtpCallBack(code, null), - textBorderColor: const Color(0xffD8D8D8), - pinBoxWidth: 48, - pinBoxHeight: 48, - pinTextStyle: const TextStyle(fontSize: 24.0, color: MyColors.darkTextColor), - pinTextAnimatedSwitcherTransition: ProvidedPinBoxTextAnimation.scalingTransition, - pinTextAnimatedSwitcherDuration: const Duration(milliseconds: 300), - pinBoxRadius: 8, - keyboardType: TextInputType.number, - ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + "Please insert OTP Code".toText24(), + 20.height, + Center( + child: OTPWidget( + autoFocus: true, + controller: _pinPutController, + defaultBorderColor: const Color(0xffD8D8D8), + maxLength: 4, + onTextChanged: (text) {}, + pinBoxColor: Colors.white, + onDone: (code) => _onOtpCallBack(code, null), + textBorderColor: const Color(0xffD8D8D8), + pinBoxWidth: 48, + pinBoxHeight: 48, + pinTextStyle: const TextStyle(fontSize: 24.0, color: MyColors.darkTextColor), + pinTextAnimatedSwitcherTransition: ProvidedPinBoxTextAnimation.scalingTransition, + pinTextAnimatedSwitcherDuration: const Duration(milliseconds: 300), + pinBoxRadius: 8, + keyboardType: TextInputType.number, ), - // Row( - // children: [ - // Expanded( - // child: Container( - // width: double.infinity, - // height: 60, - // color: accentColor.withOpacity(0.3), - // ), - // ), - // 12.width, - // Expanded( - // child: Container( - // width: double.infinity, - // height: 60, - // color: accentColor.withOpacity(0.3), - // ), - // ), - // 12.width, - // Expanded( - // child: Container( - // width: double.infinity, - // height: 60, - // color: accentColor.withOpacity(0.3), - // ), - // ), - // 12.width, - // Expanded( - // child: Container( - // width: double.infinity, - // height: 60, - // color: accentColor.withOpacity(0.3), - // ), - // ), - // ], - // ), - 40.height, - ShowFillButton( - title: "Check Code", - width: double.infinity, - onPressed: () { - onClick(code); - }, - ) - ], - ), + ), + // Row( + // children: [ + // Expanded( + // child: Container( + // width: double.infinity, + // height: 60, + // color: accentColor.withOpacity(0.3), + // ), + // ), + // 12.width, + // Expanded( + // child: Container( + // width: double.infinity, + // height: 60, + // color: accentColor.withOpacity(0.3), + // ), + // ), + // 12.width, + // Expanded( + // child: Container( + // width: double.infinity, + // height: 60, + // color: accentColor.withOpacity(0.3), + // ), + // ), + // 12.width, + // Expanded( + // child: Container( + // width: double.infinity, + // height: 60, + // color: accentColor.withOpacity(0.3), + // ), + // ), + // ], + // ), + 40.height, + ShowFillButton( + title: "Check Code", + width: double.infinity, + onPressed: () { + onClick(code); + }, + ) + ], ), ); } diff --git a/lib/widgets/txt_field.dart b/lib/widgets/txt_field.dart index 712bf20..37e6bbe 100644 --- a/lib/widgets/txt_field.dart +++ b/lib/widgets/txt_field.dart @@ -16,7 +16,7 @@ class TxtField extends StatelessWidget { bool isNeedClickAll; bool isButtonEnable; double? elevation; - Function? onTap; + VoidCallback? onTap; String? buttonTitle; int? maxLines; bool isSidePaddingZero; @@ -47,6 +47,7 @@ class TxtField extends StatelessWidget { @override Widget build(BuildContext context) { controller.text = value ?? ""; + controller.selection = TextSelection.fromPosition(TextPosition(offset: controller.text.length)); return InkWell( onTap: isNeedClickAll == false ? null @@ -130,7 +131,7 @@ class TxtField extends StatelessWidget { if (isButtonEnable) Material( child: InkWell( - onTap: () {}, + onTap: onTap, customBorder: inkWellCorner(), child: Container( height: 55,