diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 52fe383..6a60234 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,8 @@ + { if (resp.status == ResponseStatus.SUCCESS) { Get.back(); Get.toNamed(RouteName.kyc); - // SharedPreferences prefs = await SharedPreferences.getInstance(); - // await prefs.setString('accessToken', resp.data["data"]["access-token"]); - // await prefs.setString('productType', - // resp.data["data"]["nature_of_business_id"].toString()); - // naturebusiness = - // resp.data["data"]["nature_of_business_id"].toString(); - - // ProfileApi().GetProfileApi().then( - // (value) { - - // Get.toNamed(RouteName.mainscreen); - // }, - // ); - - // Get.to(() => CustomBottomBar(pageIndex: 0)); } else if (resp.status == ResponseStatus.PRIVATE) { Get.back(); String? message = resp.data['message']; diff --git a/lib/view/login/Kyc.dart b/lib/view/login/Kyc.dart index 6257951..0679021 100644 --- a/lib/view/login/Kyc.dart +++ b/lib/view/login/Kyc.dart @@ -1,21 +1,27 @@ import 'dart:io'; import 'dart:ui'; +import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:get/get.dart'; +import 'package:get/get.dart' hide MultipartFile, FormData; import 'package:glassmorphism/glassmorphism.dart'; import 'package:traderscircuit/Utils/Common/CommonAppbar.dart'; import 'package:traderscircuit/Utils/Common/CustomTextFormField.dart'; import 'package:traderscircuit/Utils/Common/commonBotton.dart'; +import 'package:traderscircuit/Utils/base_manager.dart'; import 'package:traderscircuit/Utils/text.dart'; +import 'package:traderscircuit/Utils/utils.dart'; import 'package:traderscircuit/resources/routes/route_name.dart'; import 'package:traderscircuit/view/onBoarding/splashScreen1.dart'; +import 'package:traderscircuit/view_model/Login/add_kyc_api.dart'; import '../../controller/kyc_controller.dart'; import '../../view_model/RiskProfileApi/risk_profile_api.dart'; +import 'package:path/path.dart' as path; + class Kyc extends StatefulWidget { const Kyc({super.key}); @@ -24,52 +30,67 @@ class Kyc extends StatefulWidget { } class _KycState extends State { - TextEditingController pincode = TextEditingController(); - TextEditingController dobcontroller = TextEditingController(); + final GlobalKey _addkycform = GlobalKey(); + TextEditingController pannumber = TextEditingController(); + TextEditingController aadhaarnumber = TextEditingController(); Color primaryColor = Colors.transparent.withOpacity(0.2); Color secondaryColor = Colors.grey.shade800; KYCController kycController = Get.put(KYCController()); - TextEditingController panController = TextEditingController(); - TextEditingController addharController = TextEditingController(); - // DateTime timebackPressed = DateTime.now(); + var panFMulti; + var panBMulti; + var aadFMulti; + var aadBMulti; - // Future _selectDate(BuildContext context) async { - // final DateTime? picked = await showDatePicker( - // context: context, - // initialDate: DateTime.now(), - // firstDate: DateTime(1900), - // lastDate: DateTime.now(), - // builder: (context, child) { - // return Theme( - // data: Theme.of(context).copyWith( - // colorScheme: const ColorScheme.light( - // surface: Colors.black, - // onSurface: Colors.white, - // primary: Color(0xff9A0000), - // onPrimary: Colors.white, - // ), - // textButtonTheme: TextButtonThemeData( - // style: TextButton.styleFrom( - // foregroundColor: Colors.white, - // ), - // ), - // ), - // child: child!); - // }); + _addKyc() async { + panFMulti = await MultipartFile.fromFile( + kycController.panFrontImage.value, + filename: path.basename(kycController.panFrontImage.value), + ); + panBMulti = await MultipartFile.fromFile( + kycController.panBackImage.value, + filename: path.basename(kycController.panBackImage.value), + ); + aadBMulti = await MultipartFile.fromFile( + kycController.aadharBackImage.value, + filename: path.basename(kycController.aadharBackImage.value), + ); + aadFMulti = await MultipartFile.fromFile( + kycController.aadharFrontImage.value, + filename: path.basename(kycController.aadharFrontImage.value), + ); + final isValid = _addkycform.currentState?.validate(); + if (isValid!) { + Utils.loader(); + FormData formdata = FormData.fromMap({ + "pan_front_image": panFMulti, + "pan_back_image": panBMulti, + "adhar_number": aadhaarnumber.text, + "pan_number": pannumber.text, + "adhar_front_image": aadFMulti, + "adhar_back_image": aadBMulti, + }); - // if (picked != null && picked != DateTime.now()) { - // setState(() { - // dobcontroller.text = "${picked.toLocal()}".split(' ')[0]; - // final birthDate = DateTime( - // picked.year, - // picked.month, - // picked.day, - // ); - // }); - // } - // } + final resp = await AddKycAPI(formdata).addkycApi(); + if (resp.status == ResponseStatus.SUCCESS) { + Get.back(); + Get.toNamed(RouteName.updateriskprofile); + } else if (resp.status == ResponseStatus.PRIVATE) { + Get.back(); + String? message = resp.data['message']; + Utils.showToast("$message"); + } else if (resp.status == ResponseStatus.ERROR) { + Get.back(); + String? message = resp.data['message']; + Utils.showToast("$message"); + } else { + Get.back(); + String? message = resp.data['message']; + Utils.showToast("$message"); + } + } + } @override Widget build(BuildContext context) { @@ -90,503 +111,442 @@ class _KycState extends State { Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16), - child: ListView( - physics: const BouncingScrollPhysics(), - // mainAxisAlignment: MainAxisAlignment.start, - // crossAxisAlignment: CrossAxisAlignment.start, - - children: [ - // CommonDropdownBtn(hint: "hint", items: ["hi", "hii"]), - // Row( - // children: [ - // text18W400("Full Name"), - // ], - // ), - // SizedBox( - // height: 15.h, - // ), - // CustomTextFormField(), - // SizedBox( - // height: 30.h, - // ), - // Row( - // children: [ - // text18W400("Email Address"), - // ], - // ), - // SizedBox( - // height: 15.h, - // ), - // CustomTextFormField(), - // SizedBox( - // height: 30.h, - // ), - // Row( - // children: [ - // text18W400("Phone Number"), - // ], - // ), - // SizedBox( - // height: 15.h, - // ), - // CustomTextFormField(), - // SizedBox( - // height: 30.h, - // ), - // Row( - // children: [ - // text18W400("Date Of Birth"), - // ], - // ), - // SizedBox( - // height: 15.h, - // ), - // CustomTextFormField( - // suffixIcon: Icon( - // Icons.calendar_month_outlined, - // color: Colors.white, - // ), - // readonly: true, - // onTap: () { - // _selectDate(context); - // }, - // ), - // SizedBox( - // height: 30.h, - // ), - // Row( - // children: [ - // text18W400("City"), - // ], - // ), - // SizedBox( - // height: 15.h, - // ), - // CustomTextFormField(), - Row( - children: [ - text18W500("Step 1 : Personal Information"), - ], - ), - SizedBox( - height: 30.h, - ), - Row( - children: [ - text18W400("Upload pan card image"), - ], - ), - SizedBox( - height: 15.h, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - InkWell( - onTap: () { - if (kycController.panFrontImage.isEmpty) { - Get.toNamed(RouteName.kycImage, arguments: { - "type": "pan front", - }); - } - }, - child: GlassmorphicContainer( - width: 170.w, - height: 105.h, - borderRadius: 8, - linearGradient: LinearGradient( + child: Form( + key: _addkycform, + child: ListView( + physics: const BouncingScrollPhysics(), + children: [ + Row( + children: [ + text18W500("Step 1 : Personal Information"), + ], + ), + SizedBox( + height: 30.h, + ), + Row( + children: [ + text18W400("Upload pan card image"), + ], + ), + SizedBox( + height: 15.h, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( + onTap: () { + if (kycController.panFrontImage.isEmpty) { + Get.toNamed(RouteName.kycImage, arguments: { + "type": "pan front", + }); + } + }, + child: GlassmorphicContainer( + width: 170.w, + height: 105.h, + borderRadius: 8, + linearGradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + const Color(0xFFffffff).withOpacity(0.1), + const Color(0xFFFFFFFF).withOpacity(0.05), + ], + stops: const [ + 0.1, + 1, + ]), + border: 0.8, + blur: 10, + borderGradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ - const Color(0xFFffffff).withOpacity(0.1), - const Color(0xFFFFFFFF).withOpacity(0.05), + const Color(0xff9A0000).withOpacity(0.5), + const Color(0xFFffffff).withOpacity(0.5), ], - stops: const [ - 0.1, - 1, - ]), - border: 0.8, - blur: 10, - borderGradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - const Color(0xff9A0000).withOpacity(0.5), - const Color(0xFFffffff).withOpacity(0.5), - ], - ), - child: (kycController.panFrontImage.isNotEmpty) - ? Stack( - children: [ - Padding( - padding: const EdgeInsets.symmetric( - vertical: 20, horizontal: 40), - child: Image( - image: FileImage( - File( + ), + child: (kycController.panFrontImage.isNotEmpty) + ? Stack( + children: [ + Padding( + padding: const EdgeInsets.symmetric( + vertical: 20, horizontal: 40), + child: Image( + image: FileImage( + File( + kycController + .panFrontImage.value, + ), + ), + fit: BoxFit.cover, + width: Get.width, + height: 50.h, + ), + ), + Positioned( + top: 6, + right: 10, + child: InkWell( + onTap: () { kycController - .panFrontImage.value, + .panFrontImage.value = ""; + }, + child: SvgPicture.asset( + "assets/images/svg/cancel.svg", + width: 18, + height: 18, ), ), - fit: BoxFit.cover, - width: Get.width, - height: 50.h, - ), - ), - Positioned( - top: 6, - right: 10, - child: InkWell( - onTap: () { - kycController - .panFrontImage.value = ""; - }, - child: SvgPicture.asset( - "assets/images/svg/cancel.svg", - width: 18, - height: 18, - ), - ), - ) - ], - ) - : Center( - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - const Icon( - Icons.file_upload_outlined, - size: 42, - color: Colors.white, - ), - SizedBox( - height: 10.h, - ), - text14W400("Front Side") + ) ], + ) + : Center( + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + const Icon( + Icons.file_upload_outlined, + size: 42, + color: Colors.white, + ), + SizedBox( + height: 10.h, + ), + text14W400("Front Side") + ], + ), ), - ), + ), ), - ), - InkWell( - onTap: () { - if (kycController.panBackImage.isEmpty) { - Get.toNamed(RouteName.kycImage, arguments: { - "type": "pan back", - }); - } - }, - child: GlassmorphicContainer( - width: 170.w, - height: 105.h, - borderRadius: 8, - linearGradient: LinearGradient( + InkWell( + onTap: () { + if (kycController.panBackImage.isEmpty) { + Get.toNamed(RouteName.kycImage, arguments: { + "type": "pan back", + }); + } + }, + child: GlassmorphicContainer( + width: 170.w, + height: 105.h, + borderRadius: 8, + linearGradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + const Color(0xFFffffff).withOpacity(0.1), + const Color(0xFFFFFFFF).withOpacity(0.05), + ], + stops: const [ + 0.1, + 1, + ]), + border: 0.8, + blur: 10, + borderGradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ - const Color(0xFFffffff).withOpacity(0.1), - const Color(0xFFFFFFFF).withOpacity(0.05), + const Color(0xff9A0000).withOpacity(0.5), + const Color(0xFFffffff).withOpacity(0.5), ], - stops: const [ - 0.1, - 1, - ]), - border: 0.8, - blur: 10, - borderGradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - const Color(0xff9A0000).withOpacity(0.5), - const Color(0xFFffffff).withOpacity(0.5), - ], - ), - child: (kycController.panBackImage.isNotEmpty) - ? Stack( - children: [ - Padding( - padding: const EdgeInsets.symmetric( - vertical: 20, horizontal: 40), - child: Image( - image: FileImage( - File( + ), + child: (kycController.panBackImage.isNotEmpty) + ? Stack( + children: [ + Padding( + padding: const EdgeInsets.symmetric( + vertical: 20, horizontal: 40), + child: Image( + image: FileImage( + File( + kycController + .panBackImage.value, + ), + ), + fit: BoxFit.cover, + width: Get.width, + height: 50.h, + ), + ), + Positioned( + top: 6, + right: 10, + child: InkWell( + onTap: () { kycController - .panBackImage.value, + .panBackImage.value = ""; + }, + child: SvgPicture.asset( + "assets/images/svg/cancel.svg", + width: 18, + height: 18, ), ), - fit: BoxFit.cover, - width: Get.width, - height: 50.h, - ), - ), - Positioned( - top: 6, - right: 10, - child: InkWell( - onTap: () { - kycController.panBackImage.value = - ""; - }, - child: SvgPicture.asset( - "assets/images/svg/cancel.svg", - width: 18, - height: 18, - ), - ), - ) - ], - ) - : Center( - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - const Icon( - Icons.file_upload_outlined, - size: 42, - color: Colors.white, - ), - SizedBox( - height: 10.h, - ), - text14W400("Back Side") + ) ], + ) + : Center( + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + const Icon( + Icons.file_upload_outlined, + size: 42, + color: Colors.white, + ), + SizedBox( + height: 10.h, + ), + text14W400("Back Side") + ], + ), ), - ), - ), - ) - ], - ), - SizedBox( - height: 30.h, - ), - Row( - children: [ - text18W400("Pan Card"), - ], - ), - SizedBox( - height: 15.h, - ), - const CustomTextFormField(), - SizedBox( - height: 15.h, - ), - Row( - children: [ - text18W400("Aadhar Number"), - ], - ), - SizedBox( - height: 15.h, - ), - const CustomTextFormField( - texttype: TextInputType.phone, - ), - SizedBox( - height: 30.h, - ), - Row( - children: [ - text18W400("Upload Aadhar card image"), - ], - ), - SizedBox( - height: 15.h, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - InkWell( - onTap: () { - if (kycController.aadharFrontImage.isEmpty) { - Get.toNamed(RouteName.kycImage, arguments: { - "type": "aadhar front", - }); - } - }, - child: GlassmorphicContainer( - width: 170.w, - height: 105.h, - borderRadius: 8, - linearGradient: LinearGradient( + ), + ) + ], + ), + SizedBox( + height: 30.h, + ), + Row( + children: [ + text18W400("Pan Card"), + ], + ), + SizedBox( + height: 15.h, + ), + CustomTextFormField( + textEditingController: pannumber, + ), + SizedBox( + height: 15.h, + ), + Row( + children: [ + text18W400("Aadhar Number"), + ], + ), + SizedBox( + height: 15.h, + ), + CustomTextFormField( + textEditingController: aadhaarnumber, + texttype: TextInputType.phone, + ), + SizedBox( + height: 30.h, + ), + Row( + children: [ + text18W400("Upload Aadhar card image"), + ], + ), + SizedBox( + height: 15.h, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( + onTap: () { + if (kycController.aadharFrontImage.isEmpty) { + Get.toNamed(RouteName.kycImage, arguments: { + "type": "aadhar front", + }); + } + }, + child: GlassmorphicContainer( + width: 170.w, + height: 105.h, + borderRadius: 8, + linearGradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + const Color(0xFFffffff).withOpacity(0.1), + const Color(0xFFFFFFFF).withOpacity(0.05), + ], + stops: const [ + 0.1, + 1, + ]), + border: 0.8, + blur: 10, + borderGradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ - const Color(0xFFffffff).withOpacity(0.1), - const Color(0xFFFFFFFF).withOpacity(0.05), + const Color(0xff9A0000).withOpacity(0.5), + const Color(0xFFffffff).withOpacity(0.5), ], - stops: const [ - 0.1, - 1, - ]), - border: 0.8, - blur: 10, - borderGradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - const Color(0xff9A0000).withOpacity(0.5), - const Color(0xFFffffff).withOpacity(0.5), - ], - ), - child: (kycController.aadharFrontImage.isNotEmpty) - ? Stack( - children: [ - Padding( - padding: const EdgeInsets.symmetric( - vertical: 20, horizontal: 40), - child: Image( - image: FileImage( - File( - kycController - .aadharFrontImage.value, + ), + child: (kycController + .aadharFrontImage.isNotEmpty) + ? Stack( + children: [ + Padding( + padding: const EdgeInsets.symmetric( + vertical: 20, horizontal: 40), + child: Image( + image: FileImage( + File( + kycController + .aadharFrontImage.value, + ), + ), + fit: BoxFit.cover, + width: Get.width, + height: 50.h, + ), + ), + Positioned( + top: 6, + right: 10, + child: InkWell( + onTap: () { + kycController.aadharFrontImage + .value = ""; + }, + child: SvgPicture.asset( + "assets/images/svg/cancel.svg", + width: 18, + height: 18, ), ), - fit: BoxFit.cover, - width: Get.width, - height: 50.h, - ), - ), - Positioned( - top: 6, - right: 10, - child: InkWell( - onTap: () { - kycController - .aadharFrontImage.value = ""; - }, - child: SvgPicture.asset( - "assets/images/svg/cancel.svg", - width: 18, - height: 18, - ), - ), - ) - ], - ) - : Center( - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - const Icon( - Icons.file_upload_outlined, - size: 42, - color: Colors.white, - ), - SizedBox( - height: 10.h, - ), - text14W400("Front Side") + ) ], + ) + : Center( + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + const Icon( + Icons.file_upload_outlined, + size: 42, + color: Colors.white, + ), + SizedBox( + height: 10.h, + ), + text14W400("Front Side") + ], + ), ), - ), + ), ), - ), - InkWell( - onTap: () { - if (kycController.aadharBackImage.isEmpty) { - Get.toNamed(RouteName.kycImage, arguments: { - "type": "aadhar back", - }); - } - }, - child: GlassmorphicContainer( - width: 170.w, - height: 105.h, - borderRadius: 8, - linearGradient: LinearGradient( + InkWell( + onTap: () { + if (kycController.aadharBackImage.isEmpty) { + Get.toNamed(RouteName.kycImage, arguments: { + "type": "aadhar back", + }); + } + }, + child: GlassmorphicContainer( + width: 170.w, + height: 105.h, + borderRadius: 8, + linearGradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + const Color(0xFFffffff).withOpacity(0.1), + const Color(0xFFFFFFFF).withOpacity(0.05), + ], + stops: const [ + 0.1, + 1, + ]), + border: 0.8, + blur: 10, + borderGradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ - const Color(0xFFffffff).withOpacity(0.1), - const Color(0xFFFFFFFF).withOpacity(0.05), + const Color(0xff9A0000).withOpacity(0.5), + const Color(0xFFffffff).withOpacity(0.5), ], - stops: const [ - 0.1, - 1, - ]), - border: 0.8, - blur: 10, - borderGradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - const Color(0xff9A0000).withOpacity(0.5), - const Color(0xFFffffff).withOpacity(0.5), - ], - ), - child: (kycController.aadharBackImage.isNotEmpty) - ? Stack( - children: [ - Padding( - padding: const EdgeInsets.symmetric( - vertical: 20, horizontal: 40), - child: Image( - image: FileImage( - File( + ), + child: (kycController + .aadharBackImage.isNotEmpty) + ? Stack( + children: [ + Padding( + padding: const EdgeInsets.symmetric( + vertical: 20, horizontal: 40), + child: Image( + image: FileImage( + File( + kycController + .aadharBackImage.value, + ), + ), + fit: BoxFit.cover, + width: Get.width, + height: 50.h, + ), + ), + Positioned( + top: 6, + right: 10, + child: InkWell( + onTap: () { kycController - .aadharBackImage.value, + .aadharBackImage.value = ""; + }, + child: SvgPicture.asset( + "assets/images/svg/cancel.svg", + width: 18, + height: 18, ), ), - fit: BoxFit.cover, - width: Get.width, - height: 50.h, - ), - ), - Positioned( - top: 6, - right: 10, - child: InkWell( - onTap: () { - kycController - .aadharBackImage.value = ""; - }, - child: SvgPicture.asset( - "assets/images/svg/cancel.svg", - width: 18, - height: 18, - ), - ), - ) - ], - ) - : Center( - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - const Icon( - Icons.file_upload_outlined, - size: 42, - color: Colors.white, - ), - SizedBox( - height: 10.h, - ), - text14W400("Back Side") + ) ], + ) + : Center( + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + const Icon( + Icons.file_upload_outlined, + size: 42, + color: Colors.white, + ), + SizedBox( + height: 10.h, + ), + text14W400("Back Side") + ], + ), ), - ), - ), - ) - ], - ), - SizedBox( - height: 70.h, - ), - CommonBtn( - text: "Next", - onTap: () { - Get.toNamed(RouteName.updateriskprofile); - }, - ), - SizedBox( - height: 10.h, - ), - ], + ), + ) + ], + ), + SizedBox( + height: 70.h, + ), + CommonBtn( + text: "Next", + onTap: () { + _addKyc(); + // Get.toNamed(RouteName.updateriskprofile); + }, + ), + SizedBox( + height: 10.h, + ), + ], + ), ), ), ], diff --git a/lib/view/login/VerifyOtp.dart b/lib/view/login/VerifyOtp.dart index a07e3ba..6e4475f 100644 --- a/lib/view/login/VerifyOtp.dart +++ b/lib/view/login/VerifyOtp.dart @@ -68,13 +68,16 @@ class _VerifyOTPState extends State { // ProfileApi().GetProfileApi().then( // (value) { - isProfileUpdated == 0 - ? Get.toNamed(RouteName.adddetails) - : isKycUpdated == 0 - ? Get.toNamed(RouteName.kyc) - : isriskProfileUpdated == 0 - ? Get.toNamed(RouteName.updateriskprofile) - : Get.toNamed(RouteName.mainscreen); + Get.toNamed(RouteName.secureaccess); + + // // isProfileUpdated == 0 + // // ? Get.toNamed(RouteName.adddetails) + // // : isKycUpdated == 0 + // // ? Get.toNamed(RouteName.kyc) + // // : isriskProfileUpdated == 0 + // // ? Get.toNamed(RouteName.updateriskprofile) + // // : Get.toNamed(RouteName.mainscreen); + // Get.toNamed(RouteName.mainscreen); // }, // ); diff --git a/lib/view/secureAccess.dart/Faceid.dart b/lib/view/secureAccess.dart/Faceid.dart index eaa12d3..4fecc98 100644 --- a/lib/view/secureAccess.dart/Faceid.dart +++ b/lib/view/secureAccess.dart/Faceid.dart @@ -4,8 +4,10 @@ import 'package:get/get.dart'; import 'package:traderscircuit/Utils/Common/CommonAppbar.dart'; import 'package:traderscircuit/Utils/Common/commonBotton.dart'; import 'package:traderscircuit/Utils/text.dart'; +import 'package:traderscircuit/Utils/utils.dart'; import 'package:traderscircuit/resources/routes/route_name.dart'; import 'package:traderscircuit/view/onBoarding/splashScreen1.dart'; +import 'package:traderscircuit/view/secureAccess.dart/faceIdScreen.dart'; class Faceid extends StatefulWidget { const Faceid({super.key}); @@ -55,8 +57,14 @@ class _FaceidState extends State { ), CommonBtn( text: "Setup", - onTap: () { - Get.toNamed(RouteName.adddetails); + onTap: () async { + bool result = await LocalAuth.authenticate(); + // Get.toNamed(RouteName.adddetails); + if (result) { + Get.toNamed(RouteName.adddetails); + } else { + Utils.showToast("msg"); + } }, ) ], diff --git a/lib/view/secureAccess.dart/Fingerprint.dart b/lib/view/secureAccess.dart/Fingerprint.dart index b7c750b..c2bd698 100644 --- a/lib/view/secureAccess.dart/Fingerprint.dart +++ b/lib/view/secureAccess.dart/Fingerprint.dart @@ -6,6 +6,7 @@ import 'package:traderscircuit/Utils/Common/commonBotton.dart'; import 'package:traderscircuit/Utils/text.dart'; import 'package:traderscircuit/resources/routes/route_name.dart'; import 'package:traderscircuit/view/onBoarding/splashScreen1.dart'; +import 'package:local_auth/local_auth.dart'; class Fingerprint extends StatefulWidget { const Fingerprint({super.key}); @@ -17,6 +18,40 @@ class Fingerprint extends StatefulWidget { class _FingerprintState extends State { Color primaryColor = Colors.transparent.withOpacity(0.2); Color secondaryColor = Colors.grey.shade800; + + bool? _hasBioSensor; + LocalAuthentication authentication = LocalAuthentication(); + + Future _checkBio() async { + try { + _hasBioSensor = await authentication.canCheckBiometrics; + // print(_hasBioSensor); + if (_hasBioSensor!) { + _getAuth(); + } + // ignore: empty_catches + } catch (e) {} + } + + Future _getAuth() async { + bool isAuth = false; + try { + isAuth = await authentication.authenticate( + localizedReason: 'localizedReason', + options: const AuthenticationOptions( + // biometricOnly: true, + useErrorDialogs: true, + stickyAuth: true, + ), + ); + if (isAuth) { + Get.toNamed(RouteName.adddetails); + } + print(isAuth); + // ignore: empty_catches + } catch (e) {} + } + @override Widget build(BuildContext context) { return Scaffold( @@ -53,7 +88,8 @@ class _FingerprintState extends State { CommonBtn( text: "Setup", onTap: () { - Get.toNamed(RouteName.adddetails); + _checkBio(); + // Get.toNamed(RouteName.adddetails); }, ) ], diff --git a/lib/view/secureAccess.dart/SecureAccess.dart b/lib/view/secureAccess.dart/SecureAccess.dart index 49bb891..7d839ef 100644 --- a/lib/view/secureAccess.dart/SecureAccess.dart +++ b/lib/view/secureAccess.dart/SecureAccess.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; @@ -7,6 +9,7 @@ import 'package:traderscircuit/Utils/Common/commonBotton.dart'; import 'package:traderscircuit/Utils/text.dart'; import 'package:traderscircuit/resources/routes/route_name.dart'; import 'package:traderscircuit/view/onBoarding/splashScreen1.dart'; +import 'package:traderscircuit/view/secureAccess.dart/faceIdScreen.dart'; class SecureAccess extends StatefulWidget { const SecureAccess({super.key}); @@ -42,212 +45,220 @@ class _SecureAccessState extends State { SizedBox( height: 30.h, ), - InkWell( - onTap: () { - Get.toNamed(RouteName.faceid); - }, - child: GlassmorphicContainer( - width: double.infinity, - height: 80.h, - borderRadius: 8, - linearGradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - Colors.white.withOpacity(0.1), - Color(0xFFFFFFFF).withOpacity(0.05), - ], - stops: [ - 0.1, - 1, - ]), - border: 0, - blur: 10, - borderGradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - Color(0xff9A0000).withOpacity(0.5), - Color(0xFFffffff).withOpacity(0.5), - ], - ), - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - SizedBox( - width: 10.w, - ), - Image.asset( - "assets/images/png/face-id.png", - height: 40.h, - width: 40.w, - ), - SizedBox( - width: 20.w, - ), - text20W400( - "Face ID", - ), + Platform.isIOS + ? InkWell( + onTap: () { + // Get.to(LocalAuth()); + Get.toNamed(RouteName.faceid); + }, + child: GlassmorphicContainer( + width: double.infinity, + height: 80.h, + borderRadius: 8, + linearGradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + Colors.white.withOpacity(0.1), + Color(0xFFFFFFFF).withOpacity(0.05), + ], + stops: [ + 0.1, + 1, + ]), + border: 0, + blur: 10, + borderGradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + Color(0xff9A0000).withOpacity(0.5), + Color(0xFFffffff).withOpacity(0.5), ], ), - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Icon( - Icons.arrow_forward_ios, - color: Colors.white, - ), - SizedBox( - width: 20.w, - ), - ], - ) - ], - ), - ), - ), - ), + child: Center( + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + SizedBox( + width: 10.w, + ), + Image.asset( + "assets/images/png/face-id.png", + height: 40.h, + width: 40.w, + ), + SizedBox( + width: 20.w, + ), + text20W400( + "Face ID", + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Icon( + Icons.arrow_forward_ios, + color: Colors.white, + ), + SizedBox( + width: 20.w, + ), + ], + ) + ], + ), + ), + ), + ) + : SizedBox(), SizedBox( height: 20.h, ), - InkWell( - onTap: () { - Get.toNamed(RouteName.fingerprint); - }, - child: GlassmorphicContainer( - width: double.infinity, - height: 80.h, - borderRadius: 8, - linearGradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - Colors.white.withOpacity(0.1), - Color(0xFFFFFFFF).withOpacity(0.05), - ], - stops: [ - 0.1, - 1, - ]), - border: 0, - blur: 10, - borderGradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - Color(0xff9A0000).withOpacity(0.5), - Color(0xFFffffff).withOpacity(0.5), - ], - ), - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - SizedBox( - width: 10.w, - ), - Image.asset( - "assets/images/png/fingerprint.png", - height: 40.h, - width: 40.w, - ), - SizedBox( - width: 20.w, - ), - text20W400("Fingerprint"), + Platform.isAndroid + ? InkWell( + onTap: () { + Get.toNamed(RouteName.fingerprint); + }, + child: GlassmorphicContainer( + width: double.infinity, + height: 80.h, + borderRadius: 8, + linearGradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + Colors.white.withOpacity(0.1), + Color(0xFFFFFFFF).withOpacity(0.05), + ], + stops: [ + 0.1, + 1, + ]), + border: 0, + blur: 10, + borderGradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + Color(0xff9A0000).withOpacity(0.5), + Color(0xFFffffff).withOpacity(0.5), ], ), - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Icon( - Icons.arrow_forward_ios, - color: Colors.white, - ), - SizedBox( - width: 20.w, - ) - ], - ) - ], - ), - ), - ), - ), + child: Center( + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + SizedBox( + width: 10.w, + ), + Image.asset( + "assets/images/png/fingerprint.png", + height: 40.h, + width: 40.w, + ), + SizedBox( + width: 20.w, + ), + text20W400("Fingerprint"), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Icon( + Icons.arrow_forward_ios, + color: Colors.white, + ), + SizedBox( + width: 20.w, + ) + ], + ) + ], + ), + ), + ), + ) + : SizedBox(), SizedBox( height: 20.h, ), - InkWell( - onTap: () { - Get.toNamed(RouteName.pin); - }, - child: GlassmorphicContainer( - width: double.infinity, - height: 80.h, - borderRadius: 8, - linearGradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - Colors.white.withOpacity(0.1), - Color(0xFFFFFFFF).withOpacity(0.05), - ], - stops: [ - 0.1, - 1, - ]), - border: 0, - blur: 10, - borderGradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - Color(0xff9A0000).withOpacity(0.5), - Color(0xFFffffff).withOpacity(0.5), - ], - ), - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - SizedBox( - width: 10.w, - ), - Image.asset( - "assets/images/png/pin.png", - height: 40.h, - width: 40.w, - ), - SizedBox( - width: 20.w, - ), - text20W400("4 Digit Pin"), - ], - ), - Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Icon( - Icons.arrow_forward_ios, - color: Colors.white, - ), - SizedBox( - width: 20.w, - ) - ], - ), - ], - ), - ), - ), - ), + // InkWell( + // onTap: () { + // Get.toNamed(RouteName.pin); + // }, + // child: GlassmorphicContainer( + // width: double.infinity, + // height: 80.h, + // borderRadius: 8, + // linearGradient: LinearGradient( + // begin: Alignment.topLeft, + // end: Alignment.bottomRight, + // colors: [ + // Colors.white.withOpacity(0.1), + // Color(0xFFFFFFFF).withOpacity(0.05), + // ], + // stops: [ + // 0.1, + // 1, + // ]), + // border: 0, + // blur: 10, + // borderGradient: LinearGradient( + // begin: Alignment.topLeft, + // end: Alignment.bottomRight, + // colors: [ + // Color(0xff9A0000).withOpacity(0.5), + // Color(0xFFffffff).withOpacity(0.5), + // ], + // ), + // child: Center( + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Row( + // children: [ + // SizedBox( + // width: 10.w, + // ), + // Image.asset( + // "assets/images/png/pin.png", + // height: 40.h, + // width: 40.w, + // ), + // SizedBox( + // width: 20.w, + // ), + // text20W400("4 Digit Pin"), + // ], + // ), + // Row( + // mainAxisAlignment: MainAxisAlignment.end, + // children: [ + // Icon( + // Icons.arrow_forward_ios, + // color: Colors.white, + // ), + // SizedBox( + // width: 20.w, + // ) + // ], + // ), + // ], + // ), + // ), + // ), + // ), + SizedBox( height: 250.h, ), diff --git a/lib/view/secureAccess.dart/faceIdScreen.dart b/lib/view/secureAccess.dart/faceIdScreen.dart new file mode 100644 index 0000000..79fad40 --- /dev/null +++ b/lib/view/secureAccess.dart/faceIdScreen.dart @@ -0,0 +1,47 @@ +import 'package:flutter/material.dart'; +import 'package:local_auth/local_auth.dart'; + +class LocalAuth { + static final _auth = LocalAuthentication(); + + static Future _canAthenticate() async => + await _auth.canCheckBiometrics || await _auth.isDeviceSupported(); + + static Future authenticate() async { + try { + if (!await _canAthenticate()) return false; + return await _auth.authenticate( + localizedReason: 'Use Fingerprint or Face Id to authenticate', + options: const AuthenticationOptions( + biometricOnly: true, + useErrorDialogs: true, + stickyAuth: true, + ), + // authMessages: [ + // AndroidAuthMessages( + // signInTitle: 'Oops! Biometric authentication required!', + // cancelButton: 'No thanks', + // ), + // IOSAuthMessages( + // cancelButton: 'No thanks', + // ), + // ], + + ); + // final bool didAuthenticate = await _auth.authenticate( + // localizedReason: 'Please authenticate to show account balance', + // authMessages: const [ + // AndroidAuthMessages( + // signInTitle: 'Oops! Biometric authentication required!', + // cancelButton: 'No thanks', + // ), + // IOSAuthMessages( + // cancelButton: 'No thanks', + // ), + // ]); + } catch (e) { + debugPrint('error $e'); + return false; + } + } +} diff --git a/lib/view_model/Login/add_kyc_api.dart b/lib/view_model/Login/add_kyc_api.dart new file mode 100644 index 0000000..7d766d3 --- /dev/null +++ b/lib/view_model/Login/add_kyc_api.dart @@ -0,0 +1,27 @@ +import 'package:traderscircuit/Utils/api_urls.dart'; +import 'package:traderscircuit/Utils/base_manager.dart'; +import 'package:traderscircuit/data/network/network_api_services.dart'; + +class AddKycAPI { + AddKycAPI(this.data); + var data; + Future> addkycApi() async { + final response = await NetworkApiServices().postApi( + // optionalpar: true, + data, + ApiUrls.AddKyc, + ); + + if (response.status == ResponseStatus.SUCCESS) { + Map responseData = + Map.from(response.data); + if (responseData['status'] == "success") { + print("token is $response"); + } else { + return ResponseData( + responseData['message'], ResponseStatus.FAILED); + } + } + return response; + } +} diff --git a/pubspec.lock b/pubspec.lock index 389bb18..0c4175d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -512,6 +512,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.4" + intl: + dependency: transitive + description: + name: intl + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf + url: "https://pub.dev" + source: hosted + version: "0.19.0" js: dependency: transitive description: @@ -528,6 +536,46 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + local_auth: + dependency: "direct main" + description: + name: local_auth + sha256: "280421b416b32de31405b0a25c3bd42dfcef2538dfbb20c03019e02a5ed55ed0" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + local_auth_android: + dependency: transitive + description: + name: local_auth_android + sha256: "3bcd732dda7c75fcb7ddaef12e131230f53dcc8c00790d0d6efb3aa0fbbeda57" + url: "https://pub.dev" + source: hosted + version: "1.0.37" + local_auth_darwin: + dependency: transitive + description: + name: local_auth_darwin + sha256: "33381a15b0de2279523eca694089393bb146baebdce72a404555d03174ebc1e9" + url: "https://pub.dev" + source: hosted + version: "1.2.2" + local_auth_platform_interface: + dependency: transitive + description: + name: local_auth_platform_interface + sha256: "1b842ff177a7068442eae093b64abe3592f816afd2a533c0ebcdbe40f9d2075a" + url: "https://pub.dev" + source: hosted + version: "1.0.10" + local_auth_windows: + dependency: transitive + description: + name: local_auth_windows + sha256: "505ba3367ca781efb1c50d3132e44a2446bccc4163427bc203b9b4d8994d97ea" + url: "https://pub.dev" + source: hosted + version: "1.0.10" lottie: dependency: "direct main" description: @@ -1095,5 +1143,7 @@ packages: source: hosted version: "6.3.0" sdks: - dart: ">=3.1.0 <4.0.0" - flutter: ">=3.13.0" + + dart: ">=3.2.3 <4.0.0" + flutter: ">=3.16.6" + diff --git a/pubspec.yaml b/pubspec.yaml index 1f9325b..6edff00 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -39,9 +39,13 @@ dependencies: firebase_core: dio: ^5.1.2 expansion_tile_group: ^1.2.4 + + local_auth: ^2.2.0 + scgateway_flutter_plugin: ^2.3.1 async: ^2.4.1 + dev_dependencies: flutter_test: sdk: flutter