From 95f04af2eb49d24ae935070e19e9286ed6a3bf09 Mon Sep 17 00:00:00 2001 From: Sujal Bandhara Date: Fri, 18 May 2018 09:59:09 +0530 Subject: [PATCH 1/3] Wallofcoin Buying Wizard Added Wall of Coin Buying Wizard --- PivxWallet.xcodeproj/project.pbxproj | 326 ++ PivxWallet/BRReceiveViewController.m | 28 + PivxWallet/BRRootViewController.m | 71 +- PivxWallet/BRTxHistoryViewController.m | 21 +- PivxWallet/Base.lproj/Main.storyboard | 89 +- PivxWallet/MBProgressHUD.m | 4 +- .../PivxControllers/MenuController.swift | 27 +- PivxWallet/PivxNibs/Controllers/Menu.xib | 71 +- PivxWallet/PivxWallet-Prefix.pch | 2 +- .../Wallofcoins/APIManager/APIManager.h | 44 + .../Wallofcoins/APIManager/APIManager.m | 821 ++++ .../Wallofcoins/CustomCell/WOCOfferCell.h | 24 + .../Wallofcoins/CustomCell/WOCOfferCell.m | 46 + .../Wallofcoins/CustomCell/WOCSignOutCell.h | 17 + .../Wallofcoins/CustomCell/WOCSignOutCell.m | 37 + .../Wallofcoins/CustomCell/WOCSummaryCell.h | 28 + .../Wallofcoins/CustomCell/WOCSummaryCell.m | 37 + .../Wallofcoins/Resources/countries.json | 172 + .../Wallofcoins/StoryBoard/buyDash.storyboard | 2581 ++++++++++ .../Wallofcoins/StoryBoard/wocSell.storyboard | 4175 +++++++++++++++++ .../Wallofcoins/WOCBaseViewController.h | 28 + .../Wallofcoins/WOCBaseViewController.m | 402 ++ .../WOCBuyingInstructionsViewController.h | 49 + .../WOCBuyingInstructionsViewController.m | 639 +++ .../WOCBuyingSummaryViewController.h | 25 + .../WOCBuyingSummaryViewController.m | 431 ++ .../WOCBuyingWizardHomeViewController.h | 30 + .../WOCBuyingWizardHomeViewController.m | 238 + ...WOCBuyingWizardInputAmountViewController.h | 28 + ...WOCBuyingWizardInputAmountViewController.m | 178 + .../WOCBuyingWizardInputEmailViewController.h | 24 + .../WOCBuyingWizardInputEmailViewController.m | 66 + ...yingWizardInputPhoneNumberViewController.h | 25 + ...yingWizardInputPhoneNumberViewController.m | 546 +++ ...izardInputVarificationCodeViewController.h | 27 + ...izardInputVarificationCodeViewController.m | 68 + .../WOCBuyingWizardOfferListViewController.h | 25 + .../WOCBuyingWizardOfferListViewController.m | 491 ++ ...CBuyingWizardPaymentCenterViewController.h | 21 + ...CBuyingWizardPaymentCenterViewController.m | 99 + .../WOCBuyingWizardZipCodeViewController.h | 22 + .../WOCBuyingWizardZipCodeViewController.m | 104 + PivxWallet/Wallofcoins/WOCConstants.h | 117 + .../WOCDefaultBaseViewController.h | 44 + .../WOCDefaultBaseViewController.m | 255 + .../AsyncImageView/WOCAsyncImageView.h | 277 ++ .../AsyncImageView/WOCAsyncImageView.m | 636 +++ .../WOCHelpers/WOCAlertController.h | 18 + .../WOCHelpers/WOCAlertController.m | 62 + .../WOCHelpers/WOCLocationManager.h | 23 + .../WOCHelpers/WOCLocationManager.m | 135 + .../Wallofcoins/WOCHoldIssueViewController.h | 16 + .../Wallofcoins/WOCHoldIssueViewController.m | 42 + .../WOCMedia.xcassets/Contents.json | 6 + .../barcode.imageset/Contents.json | 21 + .../barcode.imageset/download.png | Bin 0 -> 373 bytes .../dropdown_icon.imageset/Contents.json | 21 + .../dropdown_icon.imageset/dropdown_icon.png | Bin 0 -> 1187 bytes .../Contents.json | 23 + .../ic_account_balance_black.png | Bin 0 -> 1500 bytes .../ic_account_balance_black@2x.png | Bin 0 -> 1745 bytes .../ic_account_balance_black@3x.png | Bin 0 -> 3765 bytes .../Contents.json | 23 + .../ic_arrow_back_white_24dp.png | Bin 0 -> 1305 bytes .../ic_arrow_back_white_24dp@2x.png | Bin 0 -> 1571 bytes .../ic_arrow_back_white_24dp@3x.png | Bin 0 -> 3765 bytes .../navigation_back.imageset/Contents.json | 24 + .../navigation_back.png | Bin 0 -> 3726 bytes .../woc-icon.imageset/Contents.json | 21 + .../woc-icon.imageset/Main Logo (Color).pdf | Bin 0 -> 14264 bytes .../x.imageset/Contents.json | 21 + .../WOCMedia.xcassets/x.imageset/x.png | Bin 0 -> 293 bytes .../Wallofcoins/WOCPasswordViewController.h | 28 + .../Wallofcoins/WOCPasswordViewController.m | 219 + .../WOCSellingAddNewBankViewController.h | 23 + .../WOCSellingAddNewBankViewController.m | 127 + .../WOCSellingAdsInstructionsViewController.h | 30 + .../WOCSellingAdsInstructionsViewController.m | 133 + ...dvancedOptionsInstructionsViewController.h | 21 + ...dvancedOptionsInstructionsViewController.m | 83 + .../WOCSellingCreatePasswordViewController.h | 27 + .../WOCSellingCreatePasswordViewController.m | 82 + .../WOCSellingInstructionsViewController.h | 47 + .../WOCSellingInstructionsViewController.m | 633 +++ .../WOCSellingPasswordViewController.h | 28 + .../WOCSellingPasswordViewController.m | 218 + .../WOCSellingSignInViewController.h | 26 + .../WOCSellingSignInViewController.m | 260 + .../WOCSellingSingUpViewController.h | 28 + .../WOCSellingSingUpViewController.m | 741 +++ .../WOCSellingSummaryViewController.h | 25 + .../WOCSellingSummaryViewController.m | 476 ++ .../WOCSellingVerifyDetailViewController.h | 30 + .../WOCSellingVerifyDetailViewController.m | 790 ++++ ...OCSellingWizardConfirmCodeViewController.h | 30 + ...OCSellingWizardConfirmCodeViewController.m | 116 + .../WOCSellingWizardHomeViewController.h | 29 + .../WOCSellingWizardHomeViewController.m | 136 + ...OCSellingWizardInputAmountViewController.h | 30 + ...OCSellingWizardInputAmountViewController.m | 186 + ...WOCSellingWizardInputEmailViewController.h | 24 + ...WOCSellingWizardInputEmailViewController.m | 70 + ...ingWizardInputPhoineNumberViewController.h | 26 + ...ingWizardInputPhoineNumberViewController.m | 490 ++ .../WOCSellingWizardOfferListViewController.h | 25 + .../WOCSellingWizardOfferListViewController.m | 496 ++ ...SellingWizardPaymentCenterViewController.h | 22 + ...SellingWizardPaymentCenterViewController.m | 104 + .../WOCSellingWizardZipCodeViewController.h | 23 + .../WOCSellingWizardZipCodeViewController.m | 102 + .../Wallofcoins/WOCSignInViewController.h | 26 + .../Wallofcoins/WOCSignInViewController.m | 258 + WallofCoins-README.md | 704 +++ 113 files changed, 20873 insertions(+), 71 deletions(-) create mode 100644 PivxWallet/Wallofcoins/APIManager/APIManager.h create mode 100644 PivxWallet/Wallofcoins/APIManager/APIManager.m create mode 100644 PivxWallet/Wallofcoins/CustomCell/WOCOfferCell.h create mode 100644 PivxWallet/Wallofcoins/CustomCell/WOCOfferCell.m create mode 100644 PivxWallet/Wallofcoins/CustomCell/WOCSignOutCell.h create mode 100644 PivxWallet/Wallofcoins/CustomCell/WOCSignOutCell.m create mode 100644 PivxWallet/Wallofcoins/CustomCell/WOCSummaryCell.h create mode 100644 PivxWallet/Wallofcoins/CustomCell/WOCSummaryCell.m create mode 100644 PivxWallet/Wallofcoins/Resources/countries.json create mode 100644 PivxWallet/Wallofcoins/StoryBoard/buyDash.storyboard create mode 100644 PivxWallet/Wallofcoins/StoryBoard/wocSell.storyboard create mode 100644 PivxWallet/Wallofcoins/WOCBaseViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCBaseViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCBuyingInstructionsViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCBuyingInstructionsViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCBuyingSummaryViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCBuyingSummaryViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCBuyingWizardHomeViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCBuyingWizardHomeViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCBuyingWizardInputAmountViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCBuyingWizardInputAmountViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCBuyingWizardInputEmailViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCBuyingWizardInputEmailViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCBuyingWizardInputPhoneNumberViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCBuyingWizardInputPhoneNumberViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCBuyingWizardInputVarificationCodeViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCBuyingWizardInputVarificationCodeViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCBuyingWizardOfferListViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCBuyingWizardOfferListViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCBuyingWizardPaymentCenterViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCBuyingWizardPaymentCenterViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCBuyingWizardZipCodeViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCBuyingWizardZipCodeViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCConstants.h create mode 100644 PivxWallet/Wallofcoins/WOCDefaultBaseViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCDefaultBaseViewController.m create mode 100755 PivxWallet/Wallofcoins/WOCHelpers/AsyncImageView/WOCAsyncImageView.h create mode 100755 PivxWallet/Wallofcoins/WOCHelpers/AsyncImageView/WOCAsyncImageView.m create mode 100644 PivxWallet/Wallofcoins/WOCHelpers/WOCAlertController.h create mode 100644 PivxWallet/Wallofcoins/WOCHelpers/WOCAlertController.m create mode 100644 PivxWallet/Wallofcoins/WOCHelpers/WOCLocationManager.h create mode 100644 PivxWallet/Wallofcoins/WOCHelpers/WOCLocationManager.m create mode 100644 PivxWallet/Wallofcoins/WOCHoldIssueViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCHoldIssueViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCMedia.xcassets/Contents.json create mode 100644 PivxWallet/Wallofcoins/WOCMedia.xcassets/barcode.imageset/Contents.json create mode 100644 PivxWallet/Wallofcoins/WOCMedia.xcassets/barcode.imageset/download.png create mode 100644 PivxWallet/Wallofcoins/WOCMedia.xcassets/dropdown_icon.imageset/Contents.json create mode 100644 PivxWallet/Wallofcoins/WOCMedia.xcassets/dropdown_icon.imageset/dropdown_icon.png create mode 100644 PivxWallet/Wallofcoins/WOCMedia.xcassets/ic_account_balance_black.imageset/Contents.json create mode 100644 PivxWallet/Wallofcoins/WOCMedia.xcassets/ic_account_balance_black.imageset/ic_account_balance_black.png create mode 100644 PivxWallet/Wallofcoins/WOCMedia.xcassets/ic_account_balance_black.imageset/ic_account_balance_black@2x.png create mode 100644 PivxWallet/Wallofcoins/WOCMedia.xcassets/ic_account_balance_black.imageset/ic_account_balance_black@3x.png create mode 100644 PivxWallet/Wallofcoins/WOCMedia.xcassets/ic_arrow_back_white.imageset/Contents.json create mode 100644 PivxWallet/Wallofcoins/WOCMedia.xcassets/ic_arrow_back_white.imageset/ic_arrow_back_white_24dp.png create mode 100644 PivxWallet/Wallofcoins/WOCMedia.xcassets/ic_arrow_back_white.imageset/ic_arrow_back_white_24dp@2x.png create mode 100644 PivxWallet/Wallofcoins/WOCMedia.xcassets/ic_arrow_back_white.imageset/ic_arrow_back_white_24dp@3x.png create mode 100644 PivxWallet/Wallofcoins/WOCMedia.xcassets/navigation_back.imageset/Contents.json create mode 100644 PivxWallet/Wallofcoins/WOCMedia.xcassets/navigation_back.imageset/navigation_back.png create mode 100644 PivxWallet/Wallofcoins/WOCMedia.xcassets/woc-icon.imageset/Contents.json create mode 100644 PivxWallet/Wallofcoins/WOCMedia.xcassets/woc-icon.imageset/Main Logo (Color).pdf create mode 100644 PivxWallet/Wallofcoins/WOCMedia.xcassets/x.imageset/Contents.json create mode 100644 PivxWallet/Wallofcoins/WOCMedia.xcassets/x.imageset/x.png create mode 100644 PivxWallet/Wallofcoins/WOCPasswordViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCPasswordViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingAddNewBankViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingAddNewBankViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdsInstructionsViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdsInstructionsViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdvancedOptionsInstructionsViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdvancedOptionsInstructionsViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingCreatePasswordViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingCreatePasswordViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingInstructionsViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingInstructionsViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingPasswordViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingPasswordViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingSignInViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingSignInViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingSingUpViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingSingUpViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingSummaryViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingSummaryViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingVerifyDetailViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingVerifyDetailViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardConfirmCodeViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardConfirmCodeViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardHomeViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardHomeViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputAmountViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputAmountViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputEmailViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputEmailViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputPhoineNumberViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputPhoineNumberViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardOfferListViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardOfferListViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardPaymentCenterViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardPaymentCenterViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardZipCodeViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardZipCodeViewController.m create mode 100644 PivxWallet/Wallofcoins/WOCSignInViewController.h create mode 100644 PivxWallet/Wallofcoins/WOCSignInViewController.m create mode 100644 WallofCoins-README.md diff --git a/PivxWallet.xcodeproj/project.pbxproj b/PivxWallet.xcodeproj/project.pbxproj index f2970721..31cf2dad 100644 --- a/PivxWallet.xcodeproj/project.pbxproj +++ b/PivxWallet.xcodeproj/project.pbxproj @@ -7,6 +7,51 @@ objects = { /* Begin PBXBuildFile section */ + 04533BC720998E4E00022EE3 /* ActivityLogs.md in Resources */ = {isa = PBXBuildFile; fileRef = 04533B6A20998E4D00022EE3 /* ActivityLogs.md */; }; + 04533BC820998E4E00022EE3 /* APIManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B6D20998E4D00022EE3 /* APIManager.m */; }; + 04533BC920998E4E00022EE3 /* WOCOfferCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B7020998E4D00022EE3 /* WOCOfferCell.m */; }; + 04533BCA20998E4E00022EE3 /* WOCSignOutCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B7220998E4D00022EE3 /* WOCSignOutCell.m */; }; + 04533BCB20998E4E00022EE3 /* WOCSummaryCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B7420998E4D00022EE3 /* WOCSummaryCell.m */; }; + 04533BCC20998E4E00022EE3 /* countries.json in Resources */ = {isa = PBXBuildFile; fileRef = 04533B7620998E4D00022EE3 /* countries.json */; }; + 04533BCD20998E4E00022EE3 /* buyDash.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 04533B7820998E4D00022EE3 /* buyDash.storyboard */; }; + 04533BCE20998E4E00022EE3 /* wocSell.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 04533B7920998E4D00022EE3 /* wocSell.storyboard */; }; + 04533BCF20998E4E00022EE3 /* WOCBaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B7B20998E4D00022EE3 /* WOCBaseViewController.m */; }; + 04533BD020998E4E00022EE3 /* WOCBuyingInstructionsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B7D20998E4D00022EE3 /* WOCBuyingInstructionsViewController.m */; }; + 04533BD120998E4E00022EE3 /* WOCBuyingSummaryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B7F20998E4D00022EE3 /* WOCBuyingSummaryViewController.m */; }; + 04533BD220998E4E00022EE3 /* WOCBuyingWizardHomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B8120998E4D00022EE3 /* WOCBuyingWizardHomeViewController.m */; }; + 04533BD320998E4E00022EE3 /* WOCBuyingWizardInputAmountViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B8320998E4D00022EE3 /* WOCBuyingWizardInputAmountViewController.m */; }; + 04533BD420998E4E00022EE3 /* WOCBuyingWizardInputEmailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B8520998E4D00022EE3 /* WOCBuyingWizardInputEmailViewController.m */; }; + 04533BD520998E4E00022EE3 /* WOCBuyingWizardInputPhoneNumberViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B8720998E4D00022EE3 /* WOCBuyingWizardInputPhoneNumberViewController.m */; }; + 04533BD620998E4E00022EE3 /* WOCBuyingWizardInputVarificationCodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B8920998E4E00022EE3 /* WOCBuyingWizardInputVarificationCodeViewController.m */; }; + 04533BD720998E4E00022EE3 /* WOCBuyingWizardOfferListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B8B20998E4E00022EE3 /* WOCBuyingWizardOfferListViewController.m */; }; + 04533BD820998E4E00022EE3 /* WOCBuyingWizardPaymentCenterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B8D20998E4E00022EE3 /* WOCBuyingWizardPaymentCenterViewController.m */; }; + 04533BD920998E4E00022EE3 /* WOCBuyingWizardZipCodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B8F20998E4E00022EE3 /* WOCBuyingWizardZipCodeViewController.m */; }; + 04533BDA20998E4E00022EE3 /* WOCDefaultBaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B9220998E4E00022EE3 /* WOCDefaultBaseViewController.m */; }; + 04533BDB20998E4E00022EE3 /* WOCAsyncImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B9620998E4E00022EE3 /* WOCAsyncImageView.m */; }; + 04533BDC20998E4E00022EE3 /* WOCAlertController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B9820998E4E00022EE3 /* WOCAlertController.m */; }; + 04533BDD20998E4E00022EE3 /* WOCLocationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B9A20998E4E00022EE3 /* WOCLocationManager.m */; }; + 04533BDE20998E4E00022EE3 /* WOCHoldIssueViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B9C20998E4E00022EE3 /* WOCHoldIssueViewController.m */; }; + 04533BDF20998E4E00022EE3 /* WOCMedia.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 04533B9D20998E4E00022EE3 /* WOCMedia.xcassets */; }; + 04533BE020998E4E00022EE3 /* WOCPasswordViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B9F20998E4E00022EE3 /* WOCPasswordViewController.m */; }; + 04533BE120998E4E00022EE3 /* WOCSellingAddNewBankViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BA220998E4E00022EE3 /* WOCSellingAddNewBankViewController.m */; }; + 04533BE220998E4E00022EE3 /* WOCSellingAdsInstructionsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BA420998E4E00022EE3 /* WOCSellingAdsInstructionsViewController.m */; }; + 04533BE320998E4E00022EE3 /* WOCSellingAdvancedOptionsInstructionsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BA620998E4E00022EE3 /* WOCSellingAdvancedOptionsInstructionsViewController.m */; }; + 04533BE420998E4E00022EE3 /* WOCSellingCreatePasswordViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BA820998E4E00022EE3 /* WOCSellingCreatePasswordViewController.m */; }; + 04533BE520998E4E00022EE3 /* WOCSellingInstructionsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BAA20998E4E00022EE3 /* WOCSellingInstructionsViewController.m */; }; + 04533BE620998E4E00022EE3 /* WOCSellingPasswordViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BAC20998E4E00022EE3 /* WOCSellingPasswordViewController.m */; }; + 04533BE720998E4E00022EE3 /* WOCSellingSignInViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BAE20998E4E00022EE3 /* WOCSellingSignInViewController.m */; }; + 04533BE820998E4E00022EE3 /* WOCSellingSingUpViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BB020998E4E00022EE3 /* WOCSellingSingUpViewController.m */; }; + 04533BE920998E4E00022EE3 /* WOCSellingSummaryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BB220998E4E00022EE3 /* WOCSellingSummaryViewController.m */; }; + 04533BEA20998E4E00022EE3 /* WOCSellingVerifyDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BB420998E4E00022EE3 /* WOCSellingVerifyDetailViewController.m */; }; + 04533BEB20998E4E00022EE3 /* WOCSellingWizardConfirmCodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BB620998E4E00022EE3 /* WOCSellingWizardConfirmCodeViewController.m */; }; + 04533BEC20998E4E00022EE3 /* WOCSellingWizardHomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BB820998E4E00022EE3 /* WOCSellingWizardHomeViewController.m */; }; + 04533BED20998E4F00022EE3 /* WOCSellingWizardInputAmountViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BBA20998E4E00022EE3 /* WOCSellingWizardInputAmountViewController.m */; }; + 04533BEE20998E4F00022EE3 /* WOCSellingWizardInputEmailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BBC20998E4E00022EE3 /* WOCSellingWizardInputEmailViewController.m */; }; + 04533BEF20998E4F00022EE3 /* WOCSellingWizardInputPhoineNumberViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BBE20998E4E00022EE3 /* WOCSellingWizardInputPhoineNumberViewController.m */; }; + 04533BF020998E4F00022EE3 /* WOCSellingWizardOfferListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BC020998E4E00022EE3 /* WOCSellingWizardOfferListViewController.m */; }; + 04533BF120998E4F00022EE3 /* WOCSellingWizardPaymentCenterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BC220998E4E00022EE3 /* WOCSellingWizardPaymentCenterViewController.m */; }; + 04533BF220998E4F00022EE3 /* WOCSellingWizardZipCodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BC420998E4E00022EE3 /* WOCSellingWizardZipCodeViewController.m */; }; + 04533BF320998E4F00022EE3 /* WOCSignInViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BC620998E4E00022EE3 /* WOCSignInViewController.m */; }; 220128D31C753C670001CAC1 /* BRSocketHelpers.c in Sources */ = {isa = PBXBuildFile; fileRef = 220128D11C753C670001CAC1 /* BRSocketHelpers.c */; }; 2204604E1B9F61E600D07B61 /* BREventManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 2204604D1B9F61E600D07B61 /* BREventManager.m */; }; 2204604F1B9F61E600D07B61 /* BREventManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 2204604D1B9F61E600D07B61 /* BREventManager.m */; }; @@ -222,6 +267,92 @@ /* Begin PBXFileReference section */ 017F1FD33D08A0ADF224456B /* Pods-pivxwallet.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-pivxwallet.debug.xcconfig"; path = "Pods/Target Support Files/Pods-pivxwallet/Pods-pivxwallet.debug.xcconfig"; sourceTree = ""; }; + 04533B6A20998E4D00022EE3 /* ActivityLogs.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = ActivityLogs.md; sourceTree = ""; }; + 04533B6C20998E4D00022EE3 /* APIManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIManager.h; sourceTree = ""; }; + 04533B6D20998E4D00022EE3 /* APIManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APIManager.m; sourceTree = ""; }; + 04533B6F20998E4D00022EE3 /* WOCOfferCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCOfferCell.h; sourceTree = ""; }; + 04533B7020998E4D00022EE3 /* WOCOfferCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCOfferCell.m; sourceTree = ""; }; + 04533B7120998E4D00022EE3 /* WOCSignOutCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSignOutCell.h; sourceTree = ""; }; + 04533B7220998E4D00022EE3 /* WOCSignOutCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSignOutCell.m; sourceTree = ""; }; + 04533B7320998E4D00022EE3 /* WOCSummaryCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSummaryCell.h; sourceTree = ""; }; + 04533B7420998E4D00022EE3 /* WOCSummaryCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSummaryCell.m; sourceTree = ""; }; + 04533B7620998E4D00022EE3 /* countries.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = countries.json; sourceTree = ""; }; + 04533B7820998E4D00022EE3 /* buyDash.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = buyDash.storyboard; sourceTree = ""; }; + 04533B7920998E4D00022EE3 /* wocSell.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = wocSell.storyboard; sourceTree = ""; }; + 04533B7A20998E4D00022EE3 /* WOCBaseViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCBaseViewController.h; sourceTree = ""; }; + 04533B7B20998E4D00022EE3 /* WOCBaseViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCBaseViewController.m; sourceTree = ""; }; + 04533B7C20998E4D00022EE3 /* WOCBuyingInstructionsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCBuyingInstructionsViewController.h; sourceTree = ""; }; + 04533B7D20998E4D00022EE3 /* WOCBuyingInstructionsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCBuyingInstructionsViewController.m; sourceTree = ""; }; + 04533B7E20998E4D00022EE3 /* WOCBuyingSummaryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCBuyingSummaryViewController.h; sourceTree = ""; }; + 04533B7F20998E4D00022EE3 /* WOCBuyingSummaryViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCBuyingSummaryViewController.m; sourceTree = ""; }; + 04533B8020998E4D00022EE3 /* WOCBuyingWizardHomeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCBuyingWizardHomeViewController.h; sourceTree = ""; }; + 04533B8120998E4D00022EE3 /* WOCBuyingWizardHomeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCBuyingWizardHomeViewController.m; sourceTree = ""; }; + 04533B8220998E4D00022EE3 /* WOCBuyingWizardInputAmountViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCBuyingWizardInputAmountViewController.h; sourceTree = ""; }; + 04533B8320998E4D00022EE3 /* WOCBuyingWizardInputAmountViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCBuyingWizardInputAmountViewController.m; sourceTree = ""; }; + 04533B8420998E4D00022EE3 /* WOCBuyingWizardInputEmailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCBuyingWizardInputEmailViewController.h; sourceTree = ""; }; + 04533B8520998E4D00022EE3 /* WOCBuyingWizardInputEmailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCBuyingWizardInputEmailViewController.m; sourceTree = ""; }; + 04533B8620998E4D00022EE3 /* WOCBuyingWizardInputPhoneNumberViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCBuyingWizardInputPhoneNumberViewController.h; sourceTree = ""; }; + 04533B8720998E4D00022EE3 /* WOCBuyingWizardInputPhoneNumberViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCBuyingWizardInputPhoneNumberViewController.m; sourceTree = ""; }; + 04533B8820998E4D00022EE3 /* WOCBuyingWizardInputVarificationCodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCBuyingWizardInputVarificationCodeViewController.h; sourceTree = ""; }; + 04533B8920998E4E00022EE3 /* WOCBuyingWizardInputVarificationCodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCBuyingWizardInputVarificationCodeViewController.m; sourceTree = ""; }; + 04533B8A20998E4E00022EE3 /* WOCBuyingWizardOfferListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCBuyingWizardOfferListViewController.h; sourceTree = ""; }; + 04533B8B20998E4E00022EE3 /* WOCBuyingWizardOfferListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCBuyingWizardOfferListViewController.m; sourceTree = ""; }; + 04533B8C20998E4E00022EE3 /* WOCBuyingWizardPaymentCenterViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCBuyingWizardPaymentCenterViewController.h; sourceTree = ""; }; + 04533B8D20998E4E00022EE3 /* WOCBuyingWizardPaymentCenterViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCBuyingWizardPaymentCenterViewController.m; sourceTree = ""; }; + 04533B8E20998E4E00022EE3 /* WOCBuyingWizardZipCodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCBuyingWizardZipCodeViewController.h; sourceTree = ""; }; + 04533B8F20998E4E00022EE3 /* WOCBuyingWizardZipCodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCBuyingWizardZipCodeViewController.m; sourceTree = ""; }; + 04533B9020998E4E00022EE3 /* WOCConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCConstants.h; sourceTree = ""; }; + 04533B9120998E4E00022EE3 /* WOCDefaultBaseViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCDefaultBaseViewController.h; sourceTree = ""; }; + 04533B9220998E4E00022EE3 /* WOCDefaultBaseViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCDefaultBaseViewController.m; sourceTree = ""; }; + 04533B9520998E4E00022EE3 /* WOCAsyncImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCAsyncImageView.h; sourceTree = ""; }; + 04533B9620998E4E00022EE3 /* WOCAsyncImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCAsyncImageView.m; sourceTree = ""; }; + 04533B9720998E4E00022EE3 /* WOCAlertController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCAlertController.h; sourceTree = ""; }; + 04533B9820998E4E00022EE3 /* WOCAlertController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCAlertController.m; sourceTree = ""; }; + 04533B9920998E4E00022EE3 /* WOCLocationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCLocationManager.h; sourceTree = ""; }; + 04533B9A20998E4E00022EE3 /* WOCLocationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCLocationManager.m; sourceTree = ""; }; + 04533B9B20998E4E00022EE3 /* WOCHoldIssueViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCHoldIssueViewController.h; sourceTree = ""; }; + 04533B9C20998E4E00022EE3 /* WOCHoldIssueViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCHoldIssueViewController.m; sourceTree = ""; }; + 04533B9D20998E4E00022EE3 /* WOCMedia.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = WOCMedia.xcassets; sourceTree = ""; }; + 04533B9E20998E4E00022EE3 /* WOCPasswordViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCPasswordViewController.h; sourceTree = ""; }; + 04533B9F20998E4E00022EE3 /* WOCPasswordViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCPasswordViewController.m; sourceTree = ""; }; + 04533BA120998E4E00022EE3 /* WOCSellingAddNewBankViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingAddNewBankViewController.h; sourceTree = ""; }; + 04533BA220998E4E00022EE3 /* WOCSellingAddNewBankViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingAddNewBankViewController.m; sourceTree = ""; }; + 04533BA320998E4E00022EE3 /* WOCSellingAdsInstructionsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingAdsInstructionsViewController.h; sourceTree = ""; }; + 04533BA420998E4E00022EE3 /* WOCSellingAdsInstructionsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingAdsInstructionsViewController.m; sourceTree = ""; }; + 04533BA520998E4E00022EE3 /* WOCSellingAdvancedOptionsInstructionsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingAdvancedOptionsInstructionsViewController.h; sourceTree = ""; }; + 04533BA620998E4E00022EE3 /* WOCSellingAdvancedOptionsInstructionsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingAdvancedOptionsInstructionsViewController.m; sourceTree = ""; }; + 04533BA720998E4E00022EE3 /* WOCSellingCreatePasswordViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingCreatePasswordViewController.h; sourceTree = ""; }; + 04533BA820998E4E00022EE3 /* WOCSellingCreatePasswordViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingCreatePasswordViewController.m; sourceTree = ""; }; + 04533BA920998E4E00022EE3 /* WOCSellingInstructionsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingInstructionsViewController.h; sourceTree = ""; }; + 04533BAA20998E4E00022EE3 /* WOCSellingInstructionsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingInstructionsViewController.m; sourceTree = ""; }; + 04533BAB20998E4E00022EE3 /* WOCSellingPasswordViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingPasswordViewController.h; sourceTree = ""; }; + 04533BAC20998E4E00022EE3 /* WOCSellingPasswordViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingPasswordViewController.m; sourceTree = ""; }; + 04533BAD20998E4E00022EE3 /* WOCSellingSignInViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingSignInViewController.h; sourceTree = ""; }; + 04533BAE20998E4E00022EE3 /* WOCSellingSignInViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingSignInViewController.m; sourceTree = ""; }; + 04533BAF20998E4E00022EE3 /* WOCSellingSingUpViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingSingUpViewController.h; sourceTree = ""; }; + 04533BB020998E4E00022EE3 /* WOCSellingSingUpViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingSingUpViewController.m; sourceTree = ""; }; + 04533BB120998E4E00022EE3 /* WOCSellingSummaryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingSummaryViewController.h; sourceTree = ""; }; + 04533BB220998E4E00022EE3 /* WOCSellingSummaryViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingSummaryViewController.m; sourceTree = ""; }; + 04533BB320998E4E00022EE3 /* WOCSellingVerifyDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingVerifyDetailViewController.h; sourceTree = ""; }; + 04533BB420998E4E00022EE3 /* WOCSellingVerifyDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingVerifyDetailViewController.m; sourceTree = ""; }; + 04533BB520998E4E00022EE3 /* WOCSellingWizardConfirmCodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingWizardConfirmCodeViewController.h; sourceTree = ""; }; + 04533BB620998E4E00022EE3 /* WOCSellingWizardConfirmCodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingWizardConfirmCodeViewController.m; sourceTree = ""; }; + 04533BB720998E4E00022EE3 /* WOCSellingWizardHomeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingWizardHomeViewController.h; sourceTree = ""; }; + 04533BB820998E4E00022EE3 /* WOCSellingWizardHomeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingWizardHomeViewController.m; sourceTree = ""; }; + 04533BB920998E4E00022EE3 /* WOCSellingWizardInputAmountViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingWizardInputAmountViewController.h; sourceTree = ""; }; + 04533BBA20998E4E00022EE3 /* WOCSellingWizardInputAmountViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingWizardInputAmountViewController.m; sourceTree = ""; }; + 04533BBB20998E4E00022EE3 /* WOCSellingWizardInputEmailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingWizardInputEmailViewController.h; sourceTree = ""; }; + 04533BBC20998E4E00022EE3 /* WOCSellingWizardInputEmailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingWizardInputEmailViewController.m; sourceTree = ""; }; + 04533BBD20998E4E00022EE3 /* WOCSellingWizardInputPhoineNumberViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingWizardInputPhoineNumberViewController.h; sourceTree = ""; }; + 04533BBE20998E4E00022EE3 /* WOCSellingWizardInputPhoineNumberViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingWizardInputPhoineNumberViewController.m; sourceTree = ""; }; + 04533BBF20998E4E00022EE3 /* WOCSellingWizardOfferListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingWizardOfferListViewController.h; sourceTree = ""; }; + 04533BC020998E4E00022EE3 /* WOCSellingWizardOfferListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingWizardOfferListViewController.m; sourceTree = ""; }; + 04533BC120998E4E00022EE3 /* WOCSellingWizardPaymentCenterViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingWizardPaymentCenterViewController.h; sourceTree = ""; }; + 04533BC220998E4E00022EE3 /* WOCSellingWizardPaymentCenterViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingWizardPaymentCenterViewController.m; sourceTree = ""; }; + 04533BC320998E4E00022EE3 /* WOCSellingWizardZipCodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingWizardZipCodeViewController.h; sourceTree = ""; }; + 04533BC420998E4E00022EE3 /* WOCSellingWizardZipCodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingWizardZipCodeViewController.m; sourceTree = ""; }; + 04533BC520998E4E00022EE3 /* WOCSignInViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSignInViewController.h; sourceTree = ""; }; + 04533BC620998E4E00022EE3 /* WOCSignInViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSignInViewController.m; sourceTree = ""; }; 220128D11C753C670001CAC1 /* BRSocketHelpers.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = BRSocketHelpers.c; sourceTree = ""; }; 220128D21C753C670001CAC1 /* BRSocketHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BRSocketHelpers.h; sourceTree = ""; }; 2204604C1B9F61E600D07B61 /* BREventManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BREventManager.h; sourceTree = ""; }; @@ -566,6 +697,155 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 04533B6920998E4D00022EE3 /* Wallofcoins */ = { + isa = PBXGroup; + children = ( + 04533B6A20998E4D00022EE3 /* ActivityLogs.md */, + 04533B6B20998E4D00022EE3 /* APIManager */, + 04533B6E20998E4D00022EE3 /* CustomCell */, + 04533B7520998E4D00022EE3 /* Resources */, + 04533B7720998E4D00022EE3 /* StoryBoard */, + 04533B7A20998E4D00022EE3 /* WOCBaseViewController.h */, + 04533B7B20998E4D00022EE3 /* WOCBaseViewController.m */, + 04533B7C20998E4D00022EE3 /* WOCBuyingInstructionsViewController.h */, + 04533B7D20998E4D00022EE3 /* WOCBuyingInstructionsViewController.m */, + 04533B7E20998E4D00022EE3 /* WOCBuyingSummaryViewController.h */, + 04533B7F20998E4D00022EE3 /* WOCBuyingSummaryViewController.m */, + 04533B8020998E4D00022EE3 /* WOCBuyingWizardHomeViewController.h */, + 04533B8120998E4D00022EE3 /* WOCBuyingWizardHomeViewController.m */, + 04533B8220998E4D00022EE3 /* WOCBuyingWizardInputAmountViewController.h */, + 04533B8320998E4D00022EE3 /* WOCBuyingWizardInputAmountViewController.m */, + 04533B8420998E4D00022EE3 /* WOCBuyingWizardInputEmailViewController.h */, + 04533B8520998E4D00022EE3 /* WOCBuyingWizardInputEmailViewController.m */, + 04533B8620998E4D00022EE3 /* WOCBuyingWizardInputPhoneNumberViewController.h */, + 04533B8720998E4D00022EE3 /* WOCBuyingWizardInputPhoneNumberViewController.m */, + 04533B8820998E4D00022EE3 /* WOCBuyingWizardInputVarificationCodeViewController.h */, + 04533B8920998E4E00022EE3 /* WOCBuyingWizardInputVarificationCodeViewController.m */, + 04533B8A20998E4E00022EE3 /* WOCBuyingWizardOfferListViewController.h */, + 04533B8B20998E4E00022EE3 /* WOCBuyingWizardOfferListViewController.m */, + 04533B8C20998E4E00022EE3 /* WOCBuyingWizardPaymentCenterViewController.h */, + 04533B8D20998E4E00022EE3 /* WOCBuyingWizardPaymentCenterViewController.m */, + 04533B8E20998E4E00022EE3 /* WOCBuyingWizardZipCodeViewController.h */, + 04533B8F20998E4E00022EE3 /* WOCBuyingWizardZipCodeViewController.m */, + 04533B9020998E4E00022EE3 /* WOCConstants.h */, + 04533B9120998E4E00022EE3 /* WOCDefaultBaseViewController.h */, + 04533B9220998E4E00022EE3 /* WOCDefaultBaseViewController.m */, + 04533B9320998E4E00022EE3 /* WOCHelpers */, + 04533B9B20998E4E00022EE3 /* WOCHoldIssueViewController.h */, + 04533B9C20998E4E00022EE3 /* WOCHoldIssueViewController.m */, + 04533B9D20998E4E00022EE3 /* WOCMedia.xcassets */, + 04533B9E20998E4E00022EE3 /* WOCPasswordViewController.h */, + 04533B9F20998E4E00022EE3 /* WOCPasswordViewController.m */, + 04533BA020998E4E00022EE3 /* WOCSellng */, + 04533BC520998E4E00022EE3 /* WOCSignInViewController.h */, + 04533BC620998E4E00022EE3 /* WOCSignInViewController.m */, + ); + path = Wallofcoins; + sourceTree = ""; + }; + 04533B6B20998E4D00022EE3 /* APIManager */ = { + isa = PBXGroup; + children = ( + 04533B6C20998E4D00022EE3 /* APIManager.h */, + 04533B6D20998E4D00022EE3 /* APIManager.m */, + ); + path = APIManager; + sourceTree = ""; + }; + 04533B6E20998E4D00022EE3 /* CustomCell */ = { + isa = PBXGroup; + children = ( + 04533B6F20998E4D00022EE3 /* WOCOfferCell.h */, + 04533B7020998E4D00022EE3 /* WOCOfferCell.m */, + 04533B7120998E4D00022EE3 /* WOCSignOutCell.h */, + 04533B7220998E4D00022EE3 /* WOCSignOutCell.m */, + 04533B7320998E4D00022EE3 /* WOCSummaryCell.h */, + 04533B7420998E4D00022EE3 /* WOCSummaryCell.m */, + ); + path = CustomCell; + sourceTree = ""; + }; + 04533B7520998E4D00022EE3 /* Resources */ = { + isa = PBXGroup; + children = ( + 04533B7620998E4D00022EE3 /* countries.json */, + ); + path = Resources; + sourceTree = ""; + }; + 04533B7720998E4D00022EE3 /* StoryBoard */ = { + isa = PBXGroup; + children = ( + 04533B7820998E4D00022EE3 /* buyDash.storyboard */, + 04533B7920998E4D00022EE3 /* wocSell.storyboard */, + ); + path = StoryBoard; + sourceTree = ""; + }; + 04533B9320998E4E00022EE3 /* WOCHelpers */ = { + isa = PBXGroup; + children = ( + 04533B9420998E4E00022EE3 /* AsyncImageView */, + 04533B9720998E4E00022EE3 /* WOCAlertController.h */, + 04533B9820998E4E00022EE3 /* WOCAlertController.m */, + 04533B9920998E4E00022EE3 /* WOCLocationManager.h */, + 04533B9A20998E4E00022EE3 /* WOCLocationManager.m */, + ); + path = WOCHelpers; + sourceTree = ""; + }; + 04533B9420998E4E00022EE3 /* AsyncImageView */ = { + isa = PBXGroup; + children = ( + 04533B9520998E4E00022EE3 /* WOCAsyncImageView.h */, + 04533B9620998E4E00022EE3 /* WOCAsyncImageView.m */, + ); + path = AsyncImageView; + sourceTree = ""; + }; + 04533BA020998E4E00022EE3 /* WOCSellng */ = { + isa = PBXGroup; + children = ( + 04533BA120998E4E00022EE3 /* WOCSellingAddNewBankViewController.h */, + 04533BA220998E4E00022EE3 /* WOCSellingAddNewBankViewController.m */, + 04533BA320998E4E00022EE3 /* WOCSellingAdsInstructionsViewController.h */, + 04533BA420998E4E00022EE3 /* WOCSellingAdsInstructionsViewController.m */, + 04533BA520998E4E00022EE3 /* WOCSellingAdvancedOptionsInstructionsViewController.h */, + 04533BA620998E4E00022EE3 /* WOCSellingAdvancedOptionsInstructionsViewController.m */, + 04533BA720998E4E00022EE3 /* WOCSellingCreatePasswordViewController.h */, + 04533BA820998E4E00022EE3 /* WOCSellingCreatePasswordViewController.m */, + 04533BA920998E4E00022EE3 /* WOCSellingInstructionsViewController.h */, + 04533BAA20998E4E00022EE3 /* WOCSellingInstructionsViewController.m */, + 04533BAB20998E4E00022EE3 /* WOCSellingPasswordViewController.h */, + 04533BAC20998E4E00022EE3 /* WOCSellingPasswordViewController.m */, + 04533BAD20998E4E00022EE3 /* WOCSellingSignInViewController.h */, + 04533BAE20998E4E00022EE3 /* WOCSellingSignInViewController.m */, + 04533BAF20998E4E00022EE3 /* WOCSellingSingUpViewController.h */, + 04533BB020998E4E00022EE3 /* WOCSellingSingUpViewController.m */, + 04533BB120998E4E00022EE3 /* WOCSellingSummaryViewController.h */, + 04533BB220998E4E00022EE3 /* WOCSellingSummaryViewController.m */, + 04533BB320998E4E00022EE3 /* WOCSellingVerifyDetailViewController.h */, + 04533BB420998E4E00022EE3 /* WOCSellingVerifyDetailViewController.m */, + 04533BB520998E4E00022EE3 /* WOCSellingWizardConfirmCodeViewController.h */, + 04533BB620998E4E00022EE3 /* WOCSellingWizardConfirmCodeViewController.m */, + 04533BB720998E4E00022EE3 /* WOCSellingWizardHomeViewController.h */, + 04533BB820998E4E00022EE3 /* WOCSellingWizardHomeViewController.m */, + 04533BB920998E4E00022EE3 /* WOCSellingWizardInputAmountViewController.h */, + 04533BBA20998E4E00022EE3 /* WOCSellingWizardInputAmountViewController.m */, + 04533BBB20998E4E00022EE3 /* WOCSellingWizardInputEmailViewController.h */, + 04533BBC20998E4E00022EE3 /* WOCSellingWizardInputEmailViewController.m */, + 04533BBD20998E4E00022EE3 /* WOCSellingWizardInputPhoineNumberViewController.h */, + 04533BBE20998E4E00022EE3 /* WOCSellingWizardInputPhoineNumberViewController.m */, + 04533BBF20998E4E00022EE3 /* WOCSellingWizardOfferListViewController.h */, + 04533BC020998E4E00022EE3 /* WOCSellingWizardOfferListViewController.m */, + 04533BC120998E4E00022EE3 /* WOCSellingWizardPaymentCenterViewController.h */, + 04533BC220998E4E00022EE3 /* WOCSellingWizardPaymentCenterViewController.m */, + 04533BC320998E4E00022EE3 /* WOCSellingWizardZipCodeViewController.h */, + 04533BC420998E4E00022EE3 /* WOCSellingWizardZipCodeViewController.m */, + ); + path = WOCSellng; + sourceTree = ""; + }; 2B5735681FE04BEB00110745 /* PivxUtils */ = { isa = PBXGroup; children = ( @@ -794,6 +1074,7 @@ 7579F7FE19231D4600CA56F4 /* ThirdParty */ = { isa = PBXGroup; children = ( + 04533B6920998E4D00022EE3 /* Wallofcoins */, FB021E581E4DEFD300D17638 /* MBProgressHUD */, FB021E501E47E17200D17638 /* FBShimmering */, 752E28EF19234E8100DB5A3C /* Reachability.h */, @@ -1373,14 +1654,19 @@ 2BFA523A1FE0AC4D00A3C808 /* Menu.xib in Resources */, 757E09991ADB8EEB006FD352 /* Localizable.strings in Resources */, 2B5735811FE0882B00110745 /* Step1View.xib in Resources */, + 04533BDF20998E4E00022EE3 /* WOCMedia.xcassets in Resources */, 75F2E0D31BE9803900EAE861 /* Launch Screen.storyboard in Resources */, 2B57357A1FE087D800110745 /* Setup.xib in Resources */, + 04533BCD20998E4E00022EE3 /* buyDash.storyboard in Resources */, 2B5735831FE0882B00110745 /* Step4View.xib in Resources */, 2B5735671FE04BC400110745 /* PivxAssets.xcassets in Resources */, + 04533BCC20998E4E00022EE3 /* countries.json in Resources */, + 04533BCE20998E4E00022EE3 /* wocSell.storyboard in Resources */, 2BBE61991FE482AB00D06CD7 /* NewAddress.xib in Resources */, 2B5735821FE0882B00110745 /* Step3View.xib in Resources */, 2B4838CB1FE21655001C8D09 /* Donation.xib in Resources */, 2BBE61AE1FE48BC000D06CD7 /* EmptyCell.xib in Resources */, + 04533BC720998E4E00022EE3 /* ActivityLogs.md in Resources */, 2B5735801FE0882B00110745 /* Step2View.xib in Resources */, 75C0E3BF1B1BA294007BC531 /* BIP39Words.plist in Resources */, 2BBE61AF1FE48BC000D06CD7 /* AddressContactCell.xib in Resources */, @@ -1529,50 +1815,79 @@ 6BD745B41FE56EE500B94848 /* BRPivxUtils.m in Sources */, 752E28AA19234AE300DB5A3C /* BRAddressEntity.m in Sources */, 2BFA52371FE08A8300A3C808 /* BaseController.swift in Sources */, + 04533BF320998E4F00022EE3 /* WOCSignInViewController.m in Sources */, 75AA5F55194143D5003F23BD /* BRBouncyBurgerButton.m in Sources */, 752E28AB19234AE300DB5A3C /* BRMerkleBlockEntity.m in Sources */, + 04533BC920998E4E00022EE3 /* WOCOfferCell.m in Sources */, + 04533BDE20998E4E00022EE3 /* WOCHoldIssueViewController.m in Sources */, + 04533BF120998E4F00022EE3 /* WOCSellingWizardPaymentCenterViewController.m in Sources */, + 04533BD820998E4E00022EE3 /* WOCBuyingWizardPaymentCenterViewController.m in Sources */, + 04533BEE20998E4F00022EE3 /* WOCSellingWizardInputEmailViewController.m in Sources */, 2B8A1C9D1FEB594800C7427C /* EmptyTableCell.swift in Sources */, BA7B53501BDA9A2800355E8D /* BRAppleWatchData.m in Sources */, + 04533BDC20998E4E00022EE3 /* WOCAlertController.m in Sources */, 2B57356E1FE04C4200110745 /* Utils.swift in Sources */, + 04533BEA20998E4E00022EE3 /* WOCSellingVerifyDetailViewController.m in Sources */, + 04533BCB20998E4E00022EE3 /* WOCSummaryCell.m in Sources */, + 04533BE920998E4E00022EE3 /* WOCSellingSummaryViewController.m in Sources */, 752E28AC19234AE300DB5A3C /* BRPeerEntity.m in Sources */, FBF2680E1E419318001A1C8B /* DSShapeshiftEntity+CoreDataClass.m in Sources */, 2BBE61AB1FE48AF900D06CD7 /* EmptyCell.swift in Sources */, + 04533BE420998E4E00022EE3 /* WOCSellingCreatePasswordViewController.m in Sources */, 2BBE61A31FE4853B00D06CD7 /* AddressContactController.swift in Sources */, FBF268041E414B93001A1C8B /* NSData+Dash.m in Sources */, + 04533BD620998E4E00022EE3 /* WOCBuyingWizardInputVarificationCodeViewController.m in Sources */, 752E28AD19234AE300DB5A3C /* BRTransactionEntity.m in Sources */, 752E28AE19234AE300DB5A3C /* BRTxInputEntity.m in Sources */, 752E28AF19234AE300DB5A3C /* BRTxOutputEntity.m in Sources */, 2B5735701FE04C4200110745 /* UIView+Anchors.swift in Sources */, 22DE8CF11D02407F007F07F3 /* BRWalletConstants.m in Sources */, + 04533BDB20998E4E00022EE3 /* WOCAsyncImageView.m in Sources */, FBF2680F1E419318001A1C8B /* DSShapeshiftEntity+CoreDataProperties.m in Sources */, 2B5735761FE086F500110745 /* SetupController.swift in Sources */, BAA4843C1B3EFFAF0075C749 /* UIImage+Utils.m in Sources */, BA7B535C1BDBC36700355E8D /* BRTransaction+Utils.m in Sources */, + 04533BD320998E4E00022EE3 /* WOCBuyingWizardInputAmountViewController.m in Sources */, 758DBD0E1980634900389E2A /* BRTxDetailViewController.m in Sources */, FB021E4F1E42EB5F00D17638 /* NSAttributedString+Attachments.m in Sources */, + 04533BD020998E4E00022EE3 /* WOCBuyingInstructionsViewController.m in Sources */, 7548CF3719556FD700EF827F /* BRCopyLabel.m in Sources */, 752E28D119234C3600DB5A3C /* BRKey.m in Sources */, + 04533BE220998E4E00022EE3 /* WOCSellingAdsInstructionsViewController.m in Sources */, + 04533BDA20998E4E00022EE3 /* WOCDefaultBaseViewController.m in Sources */, + 04533BED20998E4F00022EE3 /* WOCSellingWizardInputAmountViewController.m in Sources */, 84F68C8A1975E9E2002FC300 /* BRScanViewController.m in Sources */, + 04533BEC20998E4E00022EE3 /* WOCSellingWizardHomeViewController.m in Sources */, 2204604E1B9F61E600D07B61 /* BREventManager.m in Sources */, FBF267FD1E414AA2001A1C8B /* DSShapeshiftManager.m in Sources */, 752E28D219234C3600DB5A3C /* BRKey+BIP38.m in Sources */, + 04533BCF20998E4E00022EE3 /* WOCBaseViewController.m in Sources */, 220460551BA0BEEE00D07B61 /* BREventConfirmView.m in Sources */, + 04533BD420998E4E00022EE3 /* WOCBuyingWizardInputEmailViewController.m in Sources */, 752E28D919234C3600DB5A3C /* BRTransaction.m in Sources */, 752E28CE19234C3600DB5A3C /* BRBIP32Sequence.m in Sources */, BAC7B6BE1BD9C29900165B84 /* BRPhoneWCSessionManager.m in Sources */, 2B57356F1FE04C4200110745 /* PivxExtensions.swift in Sources */, 752E28CF19234C3600DB5A3C /* BRBIP39Mnemonic.m in Sources */, + 04533BD120998E4E00022EE3 /* WOCBuyingSummaryViewController.m in Sources */, 752E28DA19234C3600DB5A3C /* BRWallet.m in Sources */, FB021E561E47E17200D17638 /* FBShimmeringLayer.m in Sources */, + 04533BE320998E4E00022EE3 /* WOCSellingAdvancedOptionsInstructionsViewController.m in Sources */, 752E28DB19234C3600DB5A3C /* BRWalletManager.m in Sources */, 752E28D319234C3600DB5A3C /* BRMerkleBlock.m in Sources */, + 04533BD220998E4E00022EE3 /* WOCBuyingWizardHomeViewController.m in Sources */, 2B5735711FE04C4200110745 /* Constants.swift in Sources */, + 04533BCA20998E4E00022EE3 /* WOCSignOutCell.m in Sources */, 752E28D019234C3600DB5A3C /* BRBloomFilter.m in Sources */, 2BBE61B51FE48E6500D06CD7 /* ContactAddress.swift in Sources */, 752E28D619234C3600DB5A3C /* BRPeer.m in Sources */, 752E28D819234C3600DB5A3C /* BRPeerManager.m in Sources */, 752E28D419234C3600DB5A3C /* BRPaymentProtocol.m in Sources */, + 04533BD920998E4E00022EE3 /* WOCBuyingWizardZipCodeViewController.m in Sources */, + 04533BEF20998E4F00022EE3 /* WOCSellingWizardInputPhoineNumberViewController.m in Sources */, + 04533BE620998E4E00022EE3 /* WOCSellingPasswordViewController.m in Sources */, 752E28D519234C3600DB5A3C /* BRPaymentRequest.m in Sources */, + 04533BD720998E4E00022EE3 /* WOCBuyingWizardOfferListViewController.m in Sources */, 7525B619192453840041C0F2 /* BRNavigationBar.m in Sources */, 75F2E0D61BEAA6A400EAE861 /* BRTxMetadataEntity.m in Sources */, 2BBE619E1FE4833500D06CD7 /* NewAddressController.swift in Sources */, @@ -1588,22 +1903,33 @@ FB9CC2711F8E27B80079309F /* DWGenerateViewController.m in Sources */, 220128D31C753C670001CAC1 /* BRSocketHelpers.c in Sources */, 752E28E919234DA200DB5A3C /* NSManagedObject+Sugar.m in Sources */, + 04533BD520998E4E00022EE3 /* WOCBuyingWizardInputPhoneNumberViewController.m in Sources */, + 04533BE520998E4E00022EE3 /* WOCSellingInstructionsViewController.m in Sources */, BA7B53541BDAA0A800355E8D /* BRAppleWatchTransactionData.m in Sources */, FB021E571E47E17200D17638 /* FBShimmeringView.m in Sources */, + 04533BDD20998E4E00022EE3 /* WOCLocationManager.m in Sources */, + 04533BC820998E4E00022EE3 /* APIManager.m in Sources */, FBF267A11E414877001A1C8B /* NSString+Dash.m in Sources */, FB021E5B1E4DEFE800D17638 /* MBProgressHUD.m in Sources */, + 04533BF220998E4F00022EE3 /* WOCSellingWizardZipCodeViewController.m in Sources */, 751B2B5C1B68911700EA87FB /* BRTxHistoryViewController.m in Sources */, 752E28EA19234DA200DB5A3C /* NSMutableData+Bitcoin.m in Sources */, 752E28EB19234DA200DB5A3C /* NSString+Bitcoin.m in Sources */, 757C89521A2FCE420076B373 /* BRSettingsViewController.m in Sources */, 75D5F3D2191EC270004AB296 /* BRAppDelegate.m in Sources */, + 04533BE120998E4E00022EE3 /* WOCSellingAddNewBankViewController.m in Sources */, 759FBB36193290F600AB4465 /* BRRootViewController.m in Sources */, 752E289A192349CE00DB5A3C /* DashWallet.xcdatamodeld in Sources */, + 04533BEB20998E4E00022EE3 /* WOCSellingWizardConfirmCodeViewController.m in Sources */, + 04533BE820998E4E00022EE3 /* WOCSellingSingUpViewController.m in Sources */, 2BFA523C1FE0AC5C00A3C808 /* MenuController.swift in Sources */, + 04533BF020998E4F00022EE3 /* WOCSellingWizardOfferListViewController.m in Sources */, + 04533BE020998E4E00022EE3 /* WOCPasswordViewController.m in Sources */, 6BA7F2911FDF048100C1027B /* quark.c in Sources */, 759FBB37193290F600AB4465 /* BRSendViewController.m in Sources */, 752E28F119234E8100DB5A3C /* Reachability.m in Sources */, 2BBE61A91FE48AEC00D06CD7 /* AddressContactCell.swift in Sources */, + 04533BE720998E4E00022EE3 /* WOCSellingSignInViewController.m in Sources */, 75D5F3CE191EC270004AB296 /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/PivxWallet/BRReceiveViewController.m b/PivxWallet/BRReceiveViewController.m index ff6bf2d5..dc9b3eeb 100644 --- a/PivxWallet/BRReceiveViewController.m +++ b/PivxWallet/BRReceiveViewController.m @@ -44,6 +44,11 @@ //#define QR_IMAGE_FILE [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).lastObject\ // stringByAppendingPathComponent:@"qr.png"] + +//WallOfCoins +#import "WOCConstants.h" +#import "BRAppDelegate.h" + @interface BRReceiveViewController () @property (nonatomic, strong) UIImage *qrImage; @@ -505,4 +510,27 @@ - (void)animateTransition:(id)transitionCo return self; } +// MARK: - Wall of Coin Module +// Added New Button to Buy Dash with cash +- (IBAction)buyPIVXWithCashAction:(id)sender { + [sender setEnabled:NO]; + + [self dismissViewControllerAnimated:NO completion:^{ + [self loadWOCModule]; + [sender setEnabled:YES]; + }]; +} + +-(void)loadWOCModule +{ + dispatch_async(dispatch_get_main_queue(), ^{ + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:WOCBuyingStoryboard bundle:nil]; + UINavigationController *navController = (UINavigationController*) [storyboard instantiateViewControllerWithIdentifier:@"wocNavigationController"]; + [navController.navigationBar setTintColor:[UIColor whiteColor]]; + BRAppDelegate *appDelegate = (BRAppDelegate*)[[UIApplication sharedApplication] delegate]; + appDelegate.window.rootViewController = navController; + }); +} + + @end diff --git a/PivxWallet/BRRootViewController.m b/PivxWallet/BRRootViewController.m index 08d00ebf..d7686289 100644 --- a/PivxWallet/BRRootViewController.m +++ b/PivxWallet/BRRootViewController.m @@ -89,11 +89,13 @@ -(BOOL)prefersStatusBarHidden { } - (void)addErrorView{ - if (!self.errorBar.superview) { - [self.navigationController.navigationBar addSubview:self.errorBar]; - [self.navigationController.navigationBar addConstraint:[NSLayoutConstraint constraintWithItem:self.errorBar attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.navigationController.navigationBar attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0]]; - [self.navigationController.navigationBar addConstraint:[NSLayoutConstraint constraintWithItem:self.errorBar attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.navigationController.navigationBar attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.0]]; - [self.navigationController.navigationBar addConstraint:[NSLayoutConstraint constraintWithItem:self.errorBar attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.navigationController.navigationBar attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-48.0]]; + if (self.errorBar != nil && self.errorBar.hidden == FALSE) { + if (!self.errorBar.superview) { + [self.navigationController.navigationBar addSubview:self.errorBar]; + [self.navigationController.navigationBar addConstraint:[NSLayoutConstraint constraintWithItem:self.errorBar attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.navigationController.navigationBar attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0]]; + [self.navigationController.navigationBar addConstraint:[NSLayoutConstraint constraintWithItem:self.errorBar attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.navigationController.navigationBar attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.0]]; + [self.navigationController.navigationBar addConstraint:[NSLayoutConstraint constraintWithItem:self.errorBar attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.navigationController.navigationBar attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-48.0]]; + } } } @@ -177,36 +179,37 @@ - (void)viewDidLoad if (self.urlObserver == nil ) { self.urlObserver = [[NSNotificationCenter defaultCenter] addObserverForName:BRURLNotification object:nil queue:nil - usingBlock:^(NSNotification *note) { - if (! manager.noWallet) { - if (self.navigationController.topViewController != self) { - [self.navigationController popToRootViewControllerAnimated:YES]; - } - - if (self.navigationController.presentedViewController) { - [self.navigationController dismissViewControllerAnimated:YES completion:nil]; + usingBlock:^(NSNotification *note) { + if (! manager.noWallet) { + if (self.navigationController.topViewController != self) { + [self.navigationController popToRootViewControllerAnimated:YES]; + } + + if (self.navigationController.presentedViewController) { + [self.navigationController dismissViewControllerAnimated:YES completion:nil]; + } + + NSURL * url = note.userInfo[@"url"]; + + + + + BRSendViewController *c = self.sendViewController; + + [self.pageViewController setViewControllers:(c ? @[c] : @[]) + direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:^(BOOL finished) { + _url = note.userInfo[@"url"]; + + if (self.didAppear && [UIApplication sharedApplication].protectedDataAvailable) { + _url = nil; + [c performSelector:@selector(handleURL:) withObject:note.userInfo[@"url"] afterDelay:0.0]; + } + }]; + } - - NSURL * url = note.userInfo[@"url"]; - - - - - BRSendViewController *c = self.sendViewController; - - [self.pageViewController setViewControllers:(c ? @[c] : @[]) - direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:^(BOOL finished) { - _url = note.userInfo[@"url"]; - - if (self.didAppear && [UIApplication sharedApplication].protectedDataAvailable) { - _url = nil; - [c performSelector:@selector(handleURL:) withObject:note.userInfo[@"url"] afterDelay:0.0]; - } - }]; - - } - }]; + }]; } + if (self.fileObserver == nil) { self.fileObserver = [[NSNotificationCenter defaultCenter] addObserverForName:BRFileNotification object:nil queue:nil @@ -234,6 +237,7 @@ - (void)viewDidLoad } }]; } + if (self.foregroundObserver == nil) { self.foregroundObserver = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillEnterForegroundNotification object:nil @@ -838,7 +842,6 @@ - (void)protectedViewDidAppear } } - - (void)viewWillDisappear:(BOOL)animated { if (self.navBarTap) [self.navigationController.navigationBar removeGestureRecognizer:self.navBarTap]; diff --git a/PivxWallet/BRTxHistoryViewController.m b/PivxWallet/BRTxHistoryViewController.m index fd614921..04e7f49c 100644 --- a/PivxWallet/BRTxHistoryViewController.m +++ b/PivxWallet/BRTxHistoryViewController.m @@ -41,6 +41,10 @@ #import #import "pivxwallet-Swift.h" +//WallOfCoins +#import "WOCConstants.h" +#import "BRAppDelegate.h" + #define TRANSACTION_CELL_HEIGHT 75 static NSString *dateFormat(NSString *template) @@ -637,7 +641,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } else { EmptyTableCell *tran = [tableView dequeueReusableCellWithIdentifier:self.emptyIdentifier forIndexPath:indexPath]; - [tran configureWithTitle:@"NO TRANSACTIONS" image:@"imgTransactionEmpty"]; + [tran configureWithTitle:@"Load up your Wallet ->" image:@"woc-icon"]; return tran; //cell = [tableView dequeueReusableCellWithIdentifier:noTxIdent]; } @@ -750,7 +754,9 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath [self performSelector:@selector(more:) withObject:tableView afterDelay:0.0]; } else if (self.transactions.count > 0) [self showTx:self.transactions[indexPath.row]]; // transaction details - + NSLog(@"Open WOC module Here"); + [self loadWOCModule]; + [tableView deselectRowAtIndexPath:indexPath animated:YES]; break; @@ -782,6 +788,17 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath } } +// MARK: - Wall of Coin Module +-(void)loadWOCModule +{ + dispatch_async(dispatch_get_main_queue(), ^{ + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:WOCBuyingStoryboard bundle:nil]; + UINavigationController *navController = (UINavigationController*) [storyboard instantiateViewControllerWithIdentifier:@"wocNavigationController"]; + [navController.navigationBar setTintColor:[UIColor whiteColor]]; + BRAppDelegate *appDelegate = (BRAppDelegate*)[[UIApplication sharedApplication] delegate]; + appDelegate.window.rootViewController = navController; + }); +} // MARK: - UIViewControllerAnimatedTransitioning // This is used for percent driven interactive transitions, as well as for container controllers that have companion diff --git a/PivxWallet/Base.lproj/Main.storyboard b/PivxWallet/Base.lproj/Main.storyboard index afbfc7a8..f42cb129 100644 --- a/PivxWallet/Base.lproj/Main.storyboard +++ b/PivxWallet/Base.lproj/Main.storyboard @@ -1,12 +1,14 @@ - + - + + + @@ -744,17 +746,18 @@ - + - + - + - + @@ -778,16 +781,15 @@ - + - - + + @@ -819,14 +848,19 @@ + + + + + @@ -864,6 +898,31 @@ + @@ -904,7 +963,7 @@ diff --git a/PivxWallet/PivxWallet-Prefix.pch b/PivxWallet/PivxWallet-Prefix.pch index 283048d8..ee042abc 100644 --- a/PivxWallet/PivxWallet-Prefix.pch +++ b/PivxWallet/PivxWallet-Prefix.pch @@ -18,7 +18,7 @@ #endif #ifndef DASH_TESTNET -#define DASH_TESTNET 1 +#define DASH_TESTNET 0 #endif //#define SNAPSHOT 1 #define PEER_LOGGING 1 diff --git a/PivxWallet/Wallofcoins/APIManager/APIManager.h b/PivxWallet/Wallofcoins/APIManager/APIManager.h new file mode 100644 index 00000000..a5da9163 --- /dev/null +++ b/PivxWallet/Wallofcoins/APIManager/APIManager.h @@ -0,0 +1,44 @@ +// +// APIManager.h +// Wallofcoins +// +// Created by Genitrust on 01/12/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCConstants.h" + +@interface APIManager : NSObject + +@property (nonatomic, strong) NSDate *lastMarketInfoCheck; + ++ (instancetype)sharedInstance; + +- (void)testAPI; +- (void)getAvailablePaymentCenters:(void (^)(id responseDict, NSError *error))completionBlock ; +- (void)makeAPIRequestWithURL:(NSString*)apiURL methord:(NSString*)httpMethord parameter:(id)parameter header:(NSDictionary*)header andCompletionBlock:(void (^)(id responseDict, NSError *error))completionBlock; +- (void)discoverInfo:(NSDictionary*)params response:(void (^)(id responseDict, NSError *error))completionBlock; +- (void)discoveryInputs:(NSString*)dicoverId response:(void (^)(id responseDict, NSError *error))completionBlock; +- (void)createHold:(NSDictionary*)params response:(void (^)(id responseDict, NSError *error))completionBlock; +- (void)captureHold:(NSDictionary*)params holdId:(NSString *)holdId response:(void (^)(id responseDict, NSError *error))completionBlock; +- (void)confirmDeposit:(NSString *)orderId response:(void (^)(id responseDict, NSError *error))completionBlock; +- (void)cancelOrder:(NSString *)orderId response:(void (^)(id responseDict, NSError *error))completionBlock; +- (void)getOrders:(NSDictionary*)params response:(void (^)(id responseDict, NSError *error))completionBlock; +- (void)authorizeDevice:(NSDictionary*)params phone:(NSString*)phoneNo response:(void (^)(id responseDict, NSError *error))completionBlock; +- (void)login:(NSDictionary*)params phone:(NSString*)phoneNo response:(void (^)(id responseDict, NSError *error))completionBlock; +- (void)signOut:(NSDictionary*)params phone:(NSString*)phoneNo response:(void (^)(id responseDict, NSError *error))completionBlock; +- (void)getDevice:(void (^)(id responseDict, NSError *error))completionBlock; +- (void)registerDevice:(NSDictionary*)params response:(void (^)(id responseDict, NSError *error))completionBlock; +- (void)deleteHold:(NSString*)holdId response:(void (^)(id responseDict, NSError *error))completionBlock; +- (void)getHold:(void (^)(id responseDict, NSError *error))completionBlock; + +- (void)getIncomingOrders:(NSDictionary*)params response:(void (^)(id responseDict, NSError *error))completionBlock; +- (void)confirmDepositForIncomingOrdersId:(NSString*)orderId response:(void (^)(id responseDict, NSError *error))completionBlock; +- (void)invalidateDepositForIncomingOrdersId:(NSString*)orderId response:(void (^)(id responseDict, NSError *error))completionBlock; +- (void)registerUser:(NSDictionary*)params response:(void (^)(id responseDict, NSError *error))completionBlock; +- (void)resetPassword:(NSDictionary*)params phone:(NSString*)phoneNo response:(void (^)(id responseDict, NSError *error))completionBlock; +- (void)createAd:(NSDictionary*)params response:(void (^)(id responseDict, NSError *error))completionBlock; + +- (void)getAllAds:(NSDictionary*)params response:(void (^)(id responseDict, NSError *error))completionBlock; +- (void)getDetailFromADId:(NSString*)AdvertiseId response:(void (^)(id responseDict, NSError *error))completionBlock; +@end diff --git a/PivxWallet/Wallofcoins/APIManager/APIManager.m b/PivxWallet/Wallofcoins/APIManager/APIManager.m new file mode 100644 index 00000000..84462927 --- /dev/null +++ b/PivxWallet/Wallofcoins/APIManager/APIManager.m @@ -0,0 +1,821 @@ +// +// APIManager.m +// Wallofcoins +// +// Created by Genitrust on 01/12/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "APIManager.h" +#import + +#define API_ERROR_TITLE @"Wallofcoins" +#define BASE_URL (isProduction)?BASE_URL_PRODUCTION:BASE_URL_DEVELOPMENT +#define TIMEOUT_INTERVAL 30.0 +#define JSONParameter @"JSONPara" + +@interface APIManager() + +@end + +@implementation APIManager + +- (id)init { + self = [super init]; + if (self) { + [self initAPIManager]; + } + return self; +} + +// API Manager Singleton Instance ++ (instancetype)sharedInstance { + static id singleton = nil; + static dispatch_once_t onceToken = 0; + + dispatch_once(&onceToken, ^{ + singleton = [self new]; + }); + + return singleton; +} + +- (void)initAPIManager { + APILog(@"Init APIManager"); +} + +#pragma mark - Wallofcoins API calls + +- (void)testAPI { + APILog(@"Test API Called"); + [self getAvailablePaymentCenters:^(id responseDict, NSError *error) { + + APILog(@"getAvailablePaymentCenters Called"); + + if ([responseDict isKindOfClass:[NSArray class]]) { + NSArray *responseArray = (NSArray*)responseDict; + + if (responseArray.count > 0) { + NSDictionary *responseDictionary = responseArray[0]; + APILog(@"First responseDictionary %@",responseDictionary); + + APILog(@"1First logo %@",Str(responseDictionary[@"logo"])); + if (responseDictionary[@"logo"] != [NSNull null]) { + APILog(@"First logo %@",responseDictionary[@"logo"]); + } + } + } + }]; +} + +//////////////////////////////////////////////////////////////////// +/* + Name: GET AVAILABLE PAYMENT CENTERS (OPTIONAL) + Detail : API for get payment center list using GET method... + API Funcation Name: getAvailablePaymentCenters + Url: https://woc.reference.genitrust.com/api/v1/banks/ + Method: GET + + Success Output: + [ + { + "id": 14, + "name": "Genitrust", + "url": "https://genitrust.com/", + "logo": null, + "logoHq": null, + "icon": null, + "iconHq": null, + "country": "us", + "payFields": false + }, + ... + ] + */ +//////////////////////////////////////////////////////////////////// + +- (void)getAvailablePaymentCenters:(void (^)(id responseDict, NSError *error))completionBlock { + NSString *version = @"v1"; + NSString *constant = @"banks"; + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/%@/",BASE_URL,API_FOLDER,API_VERSION,constant]; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderContentType: @"application/json" + }; + + [self makeAPIRequestWithURL:apiURL methord:@"GET" parameter: nil header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; +} + +/* + #### SEARCH & DISCOVERY + + An API for discover available option, which will return Discovery ID along with list of information. + + ```http + POST https://woc.reference.genitrust.com/api/v1/discoveryInputs/ + ``` + + ##### Request : + + ```json + { + "publisherId": "", + "cryptoAddress": "", + "usdAmount": "500", + "crypto": "DASH", + "bank": "", + "zipCode": "34236" + } + ``` + + > Publisher Id: an Unique ID generated for commit transections. + > cryptoAddress: Cryptographic Address for user, it's optional parameter. + > usdAmount: Amount in USD (Need to apply conversation from DASH to USD) + > crypto: crypto type either DASH or BTC for bitcoin. + > bank: Selected bank ID from bank list. pass empty if selected none. + > zipCode: zip code of user, need to take input from user. + + ##### Response : + + ```json + { + "id": "935c882fe79e39e1acd98a801d8ce420", + "usdAmount": "500", + "cryptoAmount": "0", + "crypto": "DASH", + "fiat": "USD", + "zipCode": "34236", + "bank": 5, + "state": null, + "cryptoAddress": "", + "createdIp": "182.76.224.130", + "location": { + "latitude": 27.3331293, + "longitude": -82.5456374 + }, + "browserLocation": null, + "publisher": null + } + ``` + */ +- (void)discoverInfo:(NSDictionary*)params response:(void (^)(id responseDict, NSError *error))completionBlock { + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/discoveryInputs/",BASE_URL,API_FOLDER,API_VERSION]; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderContentType: @"application/json" + }; + + [self makeAPIRequestWithURL:apiURL methord:@"POST" parameter: params header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; +} + +/*#### GET OFFERS + + An API for fetch all offers for received Discovery ID. + + ```http + GET https://woc.reference.genitrust.com/api/v1/discoveryInputs//offers/ + ```*/ + +- (void)discoveryInputs:(NSString*)dicoverId response:(void (^)(id responseDict, NSError *error))completionBlock { + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/discoveryInputs/%@/offers/",BASE_URL,API_FOLDER,API_VERSION,dicoverId]; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderContentType: @"application/json" + }; + + [self makeAPIRequestWithURL:apiURL methord:@"GET" parameter: nil header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; +} + +/*#### CREATE HOLD + + From offer list on offer click we have to create an hold on offer for generate initial request. + + ```http + HEADER X-Coins-Api-Token: + + POST https://woc.reference.genitrust.com/api/v1/holds/ + ``` + + It need X-Coins-Api-Token as a header parameter which is five time mobile number without space and country code. + + ##### Request : + + ```json + { + "publisherId": "", + "offer": "eyJ1c2QiOiAiNTA...", + "phone": "+19411101467", + "deviceName": "Ref Client", + "password": "94111014679411101467941110146794111014679411101467" + } + ```*/ + +- (void)createHold:(NSDictionary*)params response:(void (^)(id responseDict, NSError *error))completionBlock { + + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/holds/",BASE_URL,API_FOLDER,API_VERSION]; + NSString *phNo = [NSString stringWithFormat:@"%@",[params valueForKey:WOCUserDefaultsLocalDeviceCode]]; + NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderContentType:@"application/json" + }; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderToken: token, + WOCApiHeaderContentType: @"application/json" + }; + } + + [self makeAPIRequestWithURL:apiURL methord:@"POST" parameter: params header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; +} + +/*#### CAPTURE HOLD + + We have to match user input code with `__PURCHASE_CODE` and if verify, we have to proceed further. + + ```http + HEADER X-Coins-Api-Token: ZGV2aWNlOjQ0NT... + + POST https://woc.reference.genitrust.com/api/v1/holds//capture/ + ``` + + #####Request : + + ``` + { + "verificationCode": "CK99K" + } + ```*/ + +- (void)captureHold:(NSDictionary*)params holdId:(NSString *)holdId response:(void (^)(id responseDict, NSError *error))completionBlock { + + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/holds/%@/capture/",BASE_URL,API_FOLDER,API_VERSION,holdId]; + NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderContentType:@"application/json" + }; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderToken: token, + WOCApiHeaderContentType: @"application/json" + }; + } + + [self makeAPIRequestWithURL:apiURL methord:@"POST" parameter: params header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; +} + +/*#### CONFIRM DEPOSIT + + ```http + HEADER X-Coins-Api-Token: + + POST https://woc.reference.genitrust.com/api/v1/orders//confirmDeposit/ + ```*/ + +- (void)confirmDeposit:(NSString *)orderId response:(void (^)(id responseDict, NSError *error))completionBlock { + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/orders/%@/confirmDeposit/",BASE_URL,API_FOLDER,API_VERSION,orderId]; + NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderContentType:@"application/json" + }; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderToken: token, + WOCApiHeaderContentType: @"application/json" + }; + } + + [self makeAPIRequestWithURL:apiURL methord:@"POST" parameter: nil header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; +} + +- (void)cancelOrder:(NSString *)orderId response:(void (^)(id responseDict, NSError *error))completionBlock { + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/orders/%@/",BASE_URL,API_FOLDER,API_VERSION,orderId]; + NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId + }; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderToken: token + }; + } + + [self makeAPIRequestWithURL:apiURL methord:@"DELETE" parameter: nil header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; +} + +- (void)getOrders:(NSDictionary*)params response:(void (^)(id responseDict, NSError *error))completionBlock { + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/orders/",BASE_URL,API_FOLDER,API_VERSION]; + NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId + }; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderToken: token + }; + [self makeAPIRequestWithURL:apiURL methord:@"GET" parameter: params header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; + } + else { + NSError * returnError = [NSError errorWithDomain:API_ERROR_TITLE code:403 userInfo:nil]; + completionBlock(nil,returnError); + } +} + +- (void)authorizeDevice:(NSDictionary*)params phone:(NSString*)phoneNo response:(void (^)(id responseDict, NSError *error))completionBlock { + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/auth/%@/",BASE_URL,API_FOLDER,API_VERSION,phoneNo]; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId + }; + + [self makeAPIRequestWithURL:apiURL methord:@"GET" parameter: params header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; +} + +- (void)login:(NSDictionary*)params phone:(NSString*)phoneNo response:(void (^)(id responseDict, NSError *error))completionBlock { + + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/auth/%@/authorize/",BASE_URL,API_FOLDER,API_VERSION,phoneNo]; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderContentType: @"application/json" + }; + + [self makeAPIRequestWithURL:apiURL methord:@"POST" parameter: params header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; +} + +- (void)signOut:(NSDictionary*)params phone:(NSString*)phoneNo response:(void (^)(id responseDict, NSError *error))completionBlock { + + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/auth/%@/",BASE_URL,API_FOLDER,API_VERSION,phoneNo]; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId + }; + + [self makeAPIRequestWithURL:apiURL methord:@"DELETE" parameter: params header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; +} + +- (void)getDevice:(void (^)(id responseDict, NSError *error))completionBlock { + + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/devices/",BASE_URL,API_FOLDER,API_VERSION]; + NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId + }; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderToken: token + }; + } + + [self makeAPIRequestWithURL:apiURL methord:@"GET" parameter:nil header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; +} + +- (void)registerDevice:(NSDictionary*)params response:(void (^)(id responseDict, NSError *error))completionBlock { + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/devices/",BASE_URL,API_FOLDER,API_VERSION]; + NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderContentType:@"application/json" + }; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderToken: token, + WOCApiHeaderContentType: @"application/json" + }; + } + + [self makeAPIRequestWithURL:apiURL methord:@"POST" parameter: params header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; +} + +- (void)deleteHold:(NSString*)holdId response:(void (^)(id responseDict, NSError *error))completionBlock { + + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/holds/%@/",BASE_URL,API_FOLDER,API_VERSION,holdId]; + NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId + }; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderToken: token + }; + } + + [self makeAPIRequestWithURL:apiURL methord:@"DELETE" parameter: nil header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; +} + +- (void)getHold:(void (^)(id responseDict, NSError *error))completionBlock { + + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/holds/",BASE_URL,API_FOLDER,API_VERSION]; + NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId + }; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderToken: token + }; + + [self makeAPIRequestWithURL:apiURL methord:@"GET" parameter: nil header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; + } + else { + + NSError *returnError = [NSError errorWithDomain:API_ERROR_TITLE code:403 userInfo:@{@"response":@"error",@"detail":@"Error in featching active hold"}]; + completionBlock(nil,returnError); + } +} +// MARK: - SELLING WIZARD +- (void)registerUser:(NSDictionary*)params response:(void (^)(id responseDict, NSError *error))completionBlock { + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/auth/",BASE_URL,API_FOLDER,API_VERSION]; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderContentType: @"application/json" + }; + + [self makeAPIRequestWithURL:apiURL methord:@"POST" parameter: params header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; +} + +//password1=sujal123456&password2=sujal123456 +- (void)resetPassword:(NSDictionary*)params phone:(NSString*)phoneNo response:(void (^)(id responseDict, NSError *error))completionBlock { + + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/auth/%@/resetPassword/",BASE_URL,API_FOLDER,API_VERSION,phoneNo]; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderContentType: @"application/json" + }; + + [self makeAPIRequestWithURL:apiURL methord:@"POST" parameter: params header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; +} + +- (void)getIncomingOrders:(NSDictionary*)params response:(void (^)(id responseDict, NSError *error))completionBlock { + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/incomingOrders/",BASE_URL,API_FOLDER,API_VERSION]; + NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId + }; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderToken: token + }; + [self makeAPIRequestWithURL:apiURL methord:@"GET" parameter: params header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; + } + else { + NSError * returnError = [NSError errorWithDomain:API_ERROR_TITLE code:403 userInfo:nil]; + completionBlock(nil,returnError); + } +} + +- (void)confirmDepositForIncomingOrdersId:(NSString*)orderId response:(void (^)(id responseDict, NSError *error))completionBlock { + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/incomingOrders/%@/confirmDeposit/",BASE_URL,API_FOLDER,API_VERSION,orderId]; + NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderContentType:@"application/json" + }; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderToken: token, + WOCApiHeaderContentType: @"application/json" + }; + } + + [self makeAPIRequestWithURL:apiURL methord:@"POST" parameter: nil header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; + +} + +- (void)invalidateDepositForIncomingOrdersId:(NSString*)orderId response:(void (^)(id responseDict, NSError *error))completionBlock { + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/incomingOrders/%@/invalidateDeposit/",BASE_URL,API_FOLDER,API_VERSION,orderId]; + NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderContentType:@"application/json" + }; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderToken: token, + WOCApiHeaderContentType: @"application/json" + }; + } + + [self makeAPIRequestWithURL:apiURL methord:@"POST" parameter: nil header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; +} + +/* + POST http://woc.reference.genitrust.com/api/adcreate/ + + { + "phone": "2397772604", + "email": "sujal.bandhara@bypt.in", + "phoneCode": "1", + "bankBusiness": "19", + "sellCrypto": "DASH", + "userEnabled": true, + "dynamicPrice": false, + "currentPrice": "1.2", + "name": "Test Axis", + "number": "6758493020", + "number2": "6758493020" + } +*/ +- (void)createAd:(NSDictionary*)params response:(void (^)(id responseDict, NSError *error))completionBlock { + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/ad/",BASE_URL,API_FOLDER,API_VERSION]; + NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderContentType:@"application/json" + }; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderToken: token, + WOCApiHeaderContentType: @"application/json" + }; + } + + [self makeAPIRequestWithURL:apiURL methord:@"POST" parameter: params header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; +} + +- (void)getAllAds:(NSDictionary*)params response:(void (^)(id responseDict, NSError *error))completionBlock { + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/ad/",BASE_URL,API_FOLDER,API_VERSION]; + NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId + }; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderToken: token + }; + [self makeAPIRequestWithURL:apiURL methord:@"GET" parameter: nil header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; + } + else { + NSError * returnError = [NSError errorWithDomain:API_ERROR_TITLE code:403 userInfo:nil]; + completionBlock(nil,returnError); + } +} + +- (void)getDetailFromADId:(NSString*)AdvertiseId response:(void (^)(id responseDict, NSError *error))completionBlock { + +// [self getAllAds:nil response:^(id responseDict, NSError *error) { +// APILog(@"responseDict %@",responseDict); +// }]; + + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/ad/%@/",BASE_URL,API_FOLDER,API_VERSION,AdvertiseId]; + NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *parameter = @{ + + }; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId + }; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderToken: token + }; + [self makeAPIRequestWithURL:apiURL methord:@"GET" parameter: parameter header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; + } + else { + NSError * returnError = [NSError errorWithDomain:API_ERROR_TITLE code:403 userInfo:nil]; + completionBlock(nil,returnError); + } +} + +- (void)getPendingBalanceFromADId:(NSString*)AdvertiseId response:(void (^)(id responseDict, NSError *error))completionBlock { + + // [self getAllAds:nil response:^(id responseDict, NSError *error) { + // APILog(@"responseDict %@",responseDict); + // }]; + + NSString *apiURL = [NSString stringWithFormat:@"%@/%@/%@/ad/%@/pendingBalance/",BASE_URL,API_FOLDER,API_VERSION,AdvertiseId]; + NSString *token = [[NSUserDefaults standardUserDefaults] valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *parameter = @{ + + }; + + NSDictionary *header = @{ + WOCApiHeaderPublisherId: WOCPublisherId + }; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + header = @{ + WOCApiHeaderPublisherId: WOCPublisherId, + WOCApiHeaderToken: token + }; + [self makeAPIRequestWithURL:apiURL methord:@"GET" parameter: parameter header: header andCompletionBlock:^(id responseDict, NSError *error) { + completionBlock(responseDict,error); + }]; + } + else { + NSError * returnError = [NSError errorWithDomain:API_ERROR_TITLE code:403 userInfo:nil]; + completionBlock(nil,returnError); + } +} + +// MARK: - API calls +- (void)makeAPIRequestWithURL:(NSString*)apiURL methord:(NSString*)httpMethord parameter:(id)parameter header:(NSDictionary*)header andCompletionBlock:(void (^)(id responseDict, NSError *error))completionBlock +{ + APILog(@"**>API REQUEST URL: %@\n%@",httpMethord,apiURL); + + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:apiURL] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:TIMEOUT_INTERVAL]; + + if (![httpMethord isEqualToString:@"GET"]) { + [request setHTTPMethod:httpMethord]; + + if ([parameter isKindOfClass:[NSDictionary class]]) { + APILog(@"**>API REQUEST Parameter: \n%@",parameter); + NSDictionary *para = (NSDictionary*)parameter; + + if ([[para allKeys] containsObject:JSONParameter]) { + NSData *postData = [NSJSONSerialization dataWithJSONObject:parameter options:0 error:nil]; + [request setHTTPBody:postData]; + } + else { + [request setHTTPBody:[self httpBodyForParamsDictionary:parameter]]; + } + } + } + + if (header != nil) { + APILog(@"**>API REQUEST Header: \n%@",header); + [request setAllHTTPHeaderFields:header]; + } + + NSURLSession *session = [NSURLSession sharedSession]; + [[session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable connectionError) { + + NSError *error = nil; + APILog(@"==>API Response statusCode [%ld]",((NSHTTPURLResponse*)response).statusCode); + + if (data != nil) { + id dictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error]; + APILog(@"==>API RESPONSE : \n%@",dictionary); + + if (connectionError != nil) { + APILog(@"XX>API RESPONSE ERROR: [%ld]\n%@ ",((NSHTTPURLResponse*)response).statusCode,connectionError.localizedDescription); + } + + if (((((NSHTTPURLResponse*)response).statusCode /100) != 2) || connectionError) { + + NSError * returnError = connectionError; + if (!returnError) { + if (dictionary[@"detail"] != nil) { + returnError = [NSError errorWithDomain:API_ERROR_TITLE code:((NSHTTPURLResponse*)response).statusCode userInfo:dictionary]; + } + else { + returnError = [NSError errorWithDomain:API_ERROR_TITLE code:((NSHTTPURLResponse*)response).statusCode userInfo:nil]; + } + } + dispatch_async(dispatch_get_main_queue(), ^{ + completionBlock(nil,returnError); + }); + return; + } + else if (((NSHTTPURLResponse*)response).statusCode == 204) { + NSDictionary *responseDict = @{@"content" : @"NO"} ; + completionBlock(responseDict,nil); + return; + } + + if (error) { + dispatch_async(dispatch_get_main_queue(), ^{ + APILog(@"XX>API RESPONSE ERROR: \n%@",error.localizedDescription); + completionBlock(nil,error); + }); + return; + } + dispatch_async(dispatch_get_main_queue(), ^{ + if (dictionary != nil) { + completionBlock(dictionary,nil); + } + else { + APILog(@"==>API RESPONSE : \n%@",@{@"response" : @"error"}); + completionBlock(@{@"response":@"error"},nil); + } + }); + } + else { + APILog(@"==>API RESPONSE : \n%@",@{@"response":@"error"}); + completionBlock(@{@"response":@"error"},nil); + } + }] resume]; +} + +- (NSData *)httpBodyForParamsDictionary:(NSDictionary *)paramDictionary { + NSMutableArray *parameterArray = [NSMutableArray array]; + + [paramDictionary enumerateKeysAndObjectsUsingBlock:^(NSString *key, id obj, BOOL *stop) { + + if ([obj isKindOfClass:[NSString class]]) { + NSString *param = [NSString stringWithFormat:@"%@=%@", key, [obj stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]]; + [parameterArray addObject:param]; + } + else { + + NSString *param = [NSString stringWithFormat:@"%@=%@", key, obj]; + [parameterArray addObject:param]; + } + }]; + + NSString *string = [parameterArray componentsJoinedByString:@"&"]; + APILog(@"##>API REQUEST PARAMETERS: \n%@",string); + return [string dataUsingEncoding:NSUTF8StringEncoding]; +} +@end + diff --git a/PivxWallet/Wallofcoins/CustomCell/WOCOfferCell.h b/PivxWallet/Wallofcoins/CustomCell/WOCOfferCell.h new file mode 100644 index 00000000..aeb5ac21 --- /dev/null +++ b/PivxWallet/Wallofcoins/CustomCell/WOCOfferCell.h @@ -0,0 +1,24 @@ +// +// WOCOfferCell.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import + +@interface WOCOfferCell : UITableViewCell + +@property (weak, nonatomic) IBOutlet UIView *mainView; +@property (weak, nonatomic) IBOutlet UIImageView *bankImageView; +@property (weak, nonatomic) IBOutlet UIImageView *otherBankImageView; +@property (weak, nonatomic) IBOutlet UILabel *dashTitleLabel; +@property (weak, nonatomic) IBOutlet UILabel *dashSubTitleLabel; +@property (weak, nonatomic) IBOutlet UILabel *bankNameLabel; +@property (weak, nonatomic) IBOutlet UILabel *locationLabel; +@property (weak, nonatomic) IBOutlet UIButton *orderButton; +@property (weak, nonatomic) IBOutlet UIButton *locationButton; +@property (weak, nonatomic) IBOutlet UILabel *dollarLabel; + +@end diff --git a/PivxWallet/Wallofcoins/CustomCell/WOCOfferCell.m b/PivxWallet/Wallofcoins/CustomCell/WOCOfferCell.m new file mode 100644 index 00000000..e61a1883 --- /dev/null +++ b/PivxWallet/Wallofcoins/CustomCell/WOCOfferCell.m @@ -0,0 +1,46 @@ +// +// WOCOfferCell.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCOfferCell.h" + +@implementation WOCOfferCell + +- (void)awakeFromNib { + + [super awakeFromNib]; + // Initialization code + + self.orderButton.layer.cornerRadius = 3.0; + self.orderButton.layer.masksToBounds = YES; + + self.locationButton.layer.cornerRadius = 3.0; + self.locationButton.layer.masksToBounds = YES; + + [self setShadowOnMainView:self.mainView]; +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated { + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +#pragma mark - Function + +- (void)setShadowOnMainView:(UIView *)view { + view.layer.cornerRadius = 3.0; + view.layer.masksToBounds = YES; + + view.layer.shadowColor = [UIColor lightGrayColor].CGColor; + view.layer.shadowOffset = CGSizeMake(0, 0); + view.layer.shadowRadius = 1; + view.layer.shadowOpacity = 1; + view.layer.masksToBounds = NO; +} + +@end diff --git a/PivxWallet/Wallofcoins/CustomCell/WOCSignOutCell.h b/PivxWallet/Wallofcoins/CustomCell/WOCSignOutCell.h new file mode 100644 index 00000000..1c419223 --- /dev/null +++ b/PivxWallet/Wallofcoins/CustomCell/WOCSignOutCell.h @@ -0,0 +1,17 @@ +// +// WOCSignOutCell.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import + +@interface WOCSignOutCell : UITableViewCell + +@property (weak, nonatomic) IBOutlet UIView *mainView; +@property (weak, nonatomic) IBOutlet UILabel *descriptionLabel; +@property (weak, nonatomic) IBOutlet UIButton *signOutButton; + +@end diff --git a/PivxWallet/Wallofcoins/CustomCell/WOCSignOutCell.m b/PivxWallet/Wallofcoins/CustomCell/WOCSignOutCell.m new file mode 100644 index 00000000..a8947e33 --- /dev/null +++ b/PivxWallet/Wallofcoins/CustomCell/WOCSignOutCell.m @@ -0,0 +1,37 @@ +// +// WOCSignOutCell.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCSignOutCell.h" + +@implementation WOCSignOutCell + +- (void)awakeFromNib { + [super awakeFromNib]; + // Initialization code + + [self setShadowOnMainView:self.mainView]; +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated { + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +- (void)setShadowOnMainView:(UIView *)view { + view.layer.cornerRadius = 3.0; + view.layer.masksToBounds = YES; + + view.layer.shadowColor = [UIColor lightGrayColor].CGColor; + view.layer.shadowOffset = CGSizeMake(0, 0); + view.layer.shadowRadius = 1; + view.layer.shadowOpacity = 1; + view.layer.masksToBounds = NO; +} + +@end diff --git a/PivxWallet/Wallofcoins/CustomCell/WOCSummaryCell.h b/PivxWallet/Wallofcoins/CustomCell/WOCSummaryCell.h new file mode 100644 index 00000000..716d4c8f --- /dev/null +++ b/PivxWallet/Wallofcoins/CustomCell/WOCSummaryCell.h @@ -0,0 +1,28 @@ +// +// WOCSummaryCell.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import + +@interface WOCSummaryCell : UITableViewCell + +@property (weak, nonatomic) IBOutlet UIView *mainView; +@property (weak, nonatomic) IBOutlet UIImageView *bankImageView; +@property (weak, nonatomic) IBOutlet UILabel *nameLabel; +@property (weak, nonatomic) IBOutlet UILabel *phoneLabel; +@property (weak, nonatomic) IBOutlet UILabel *firstNameLabel; +@property (weak, nonatomic) IBOutlet UILabel *lastNameLabel; +@property (weak, nonatomic) IBOutlet UILabel *birthCountryLabel; +@property (weak, nonatomic) IBOutlet UILabel *pickupStateLabel; +@property (weak, nonatomic) IBOutlet UILabel *cashDepositLabel; +@property (weak, nonatomic) IBOutlet UIView *statusView; +@property (weak, nonatomic) IBOutlet UILabel *statusLabel; +@property (weak, nonatomic) IBOutlet UILabel *totalDashLabel; + + + +@end diff --git a/PivxWallet/Wallofcoins/CustomCell/WOCSummaryCell.m b/PivxWallet/Wallofcoins/CustomCell/WOCSummaryCell.m new file mode 100644 index 00000000..441f7c71 --- /dev/null +++ b/PivxWallet/Wallofcoins/CustomCell/WOCSummaryCell.m @@ -0,0 +1,37 @@ +// +// WOCSummaryCell.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCSummaryCell.h" + +@implementation WOCSummaryCell + +- (void)awakeFromNib { + [super awakeFromNib]; + // Initialization code + + self.mainView.layer.cornerRadius = 10.0; + self.mainView.layer.masksToBounds = YES; + + [self setShadowOnMainView:self.mainView]; +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated { + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +- (void)setShadowOnMainView:(UIView *)view { + view.layer.shadowColor = [UIColor lightGrayColor].CGColor; + view.layer.shadowOffset = CGSizeMake(0, 1); + view.layer.shadowRadius = 1; + view.layer.shadowOpacity = 1; + view.layer.masksToBounds = NO; +} + +@end diff --git a/PivxWallet/Wallofcoins/Resources/countries.json b/PivxWallet/Wallofcoins/Resources/countries.json new file mode 100644 index 00000000..8016172f --- /dev/null +++ b/PivxWallet/Wallofcoins/Resources/countries.json @@ -0,0 +1,172 @@ +{ + "countries": [ + { + "name": "United States", + "code": "+1", + "currency": "USD", + "short": "us", + "top": 210, + "left": 210 + }, + { + "name": "United Kingdom", + "code": "+44", + "currency": "USD", + "short": "uk", + "top": 268, + "left": 132 + }, + { + "name": "Argentina", + "code": "+54", + "currency": "USD", + "short": "ar", + "top": 100, + "left": 194 + }, + { + "name": "Australia", + "code": "+61", + "currency": "USD", + "short": "au", + "top": 247, + "left": 33 + }, + { + "name": "Brazil", + "code": "+55", + "currency": "USD", + "short": "br", + "top": 63, + "left": 47 + }, + { + "name": "Canada", + "code": "+1", + "currency": "USD", + "short": "ca", + "top": 268, + "left": 55 + }, + { + "name": "China", + "code": "+86", + "currency": "USD", + "short": "cn", + "top": 105, + "left": 55 + }, + { + "name": "Germany", + "code": "+49", + "currency": "USD", + "short": "de", + "top": 42, + "left": 210 + }, + { + "name": "Ghana", + "code": "+233", + "currency": "USD", + "short": "gh", + "top": 105, + "left": 121 + }, + { + "name": "Hong Kong", + "code": "+852", + "currency": "USD", + "short": "hk", + "top": 147, + "left": 116 + }, + { + "name": "Latvia", + "code": "+371", + "currency": "USD", + "short": "lv", + "top": 147, + "left": 176 + }, + { + "name": "Malaysia", + "code": "+60", + "currency": "USD", + "short": "my", + "top": 268, + "left": 22 + }, + { + "name": "Mexico", + "code": "+52", + "currency": "USD", + "short": "mx", + "top": 268, + "left": 210 + }, + { + "name": "Nigeria", + "code": "+234", + "currency": "USD", + "short": "ng", + "top": 268, + "left": 110 + }, + { + "name": "Philippines", + "code": "+63", + "currency": "USD", + "short": "ph", + "top": 42, + "left": 234 + }, + { + "name": "Poland", + "code": "+48", + "currency": "USD", + "short": "pl", + "top": 142, + "left": 194 + }, + { + "name": "Portugal", + "code": "+351", + "currency": "USD", + "short": "pt", + "top": 147, + "left": 179 + }, + { + "name": "Romania", + "code": "+40", + "currency": "USD", + "short": "ro", + "top": 84, + "left": 179 + }, + { + "name": "Russia", + "code": "+7", + "currency": "USD", + "short": "ru", + "top": 189, + "left": 116 + }, + { + "name": "Singapore", + "code": "+65", + "currency": "USD", + "short": "sg", + "top": 168, + "left": 116 + }, + { + "name": "Spain", + "code": "+34", + "currency": "USD", + "short": "es", + "top": 123, + "left": 29 + } + ] +} \ No newline at end of file diff --git a/PivxWallet/Wallofcoins/StoryBoard/buyDash.storyboard b/PivxWallet/Wallofcoins/StoryBoard/buyDash.storyboard new file mode 100644 index 00000000..a0c16138 --- /dev/null +++ b/PivxWallet/Wallofcoins/StoryBoard/buyDash.storyboard @@ -0,0 +1,2581 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + If you have any questions, there is a live chat window at wallofcoins.com or you may call the phone number that sent you a text message. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Wall of Coins will verify your payment. This usually takes up to 10 minutes. To expedite your order, take a picture of your receipt and click here to email your receipt to Wall of Coins. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PivxWallet/Wallofcoins/StoryBoard/wocSell.storyboard b/PivxWallet/Wallofcoins/StoryBoard/wocSell.storyboard new file mode 100644 index 00000000..d2773969 --- /dev/null +++ b/PivxWallet/Wallofcoins/StoryBoard/wocSell.storyboard @@ -0,0 +1,4175 @@ + + + + + + + + + + + + + + + + Helvetica + Helvetica-Bold + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + If you have any questions, there is a live chat window at wallofcoins.com or you may call the phone number that sent you a text message. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Wall of Coins will verify your payment. This usually takes up to 10 minutes. To expedite your order, take a picture of your receipt and click here to email your receipt to Wall of Coins. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PivxWallet/Wallofcoins/WOCBaseViewController.h b/PivxWallet/Wallofcoins/WOCBaseViewController.h new file mode 100644 index 00000000..e0ea94f4 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCBaseViewController.h @@ -0,0 +1,28 @@ +// +// WOCBaseViewController.h +// Wallofcoins +// +// Created by Genitrust on 27/02/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCDefaultBaseViewController.h" + +@interface WOCBaseViewController : WOCDefaultBaseViewController + +- (IBAction)onSignOutButtonClick:(id)sender; + +- (void)loginWOC; +- (void)signOutWOC; +- (void)refereshToken; +- (void)pushToWOCRoot; +- (void)getOrderList; +- (void)backToMainView; +- (void)setWocDeviceCode; +- (void)clearLocalStorage; +- (void)storeDeviceInfoLocally; + +- (NSString *)wocDeviceCode; +- (NSString*)getDeviceIDFromPhoneNumber:(NSString*)phoneNo; +@end diff --git a/PivxWallet/Wallofcoins/WOCBaseViewController.m b/PivxWallet/Wallofcoins/WOCBaseViewController.m new file mode 100644 index 00000000..dde83264 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCBaseViewController.m @@ -0,0 +1,402 @@ +// +// WOCBaseViewController.m +// Wallofcoins +// +// Created by Genitrust on 27/02/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCBaseViewController.h" +#import "WOCBuyingInstructionsViewController.h" +#import "WOCBuyingSummaryViewController.h" +#import "WOCBuyingWizardHomeViewController.h" + +#import "WOCSellingWizardHomeViewController.h" +#import "WOCSellingInstructionsViewController.h" +#import "WOCSellingSummaryViewController.h" + +@interface WOCBaseViewController () + +@end + +@implementation WOCBaseViewController + ++ (instancetype) sharedInstance { + static dispatch_once_t pred = 0; + static id _sharedObject = nil; + dispatch_once(&pred, ^{ + _sharedObject = [[self alloc] init]; + }); + return _sharedObject; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + [self setWocDeviceCode]; +} + +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + + NSString * storyboardName = [self.storyboard valueForKey:@"name"]; + + if ([storyboardName isEqualToString:WOCBuyingStoryboard]) { + self.title = [NSString stringWithFormat:@"buy %@ with cash",WOCCurrency]; + } + else { + self.title = [NSString stringWithFormat:@"sell %@ for cash",WOCCurrency]; + } +} + +- (void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; + self.title = @""; +} + +- (IBAction)onSignOutButtonClick:(id)sender { + [self signOutWOC]; +} + +- (void)setWocDeviceCode { + //store deviceCode in userDefault + int launched = [self.defaults integerForKey:WOCUserDefaultsLaunchStatus]; + if (launched == 0) { + NSString *uuid = [[NSUUID UUID] UUIDString]; + [self.defaults setValue:uuid forKey:WOCUserDefaultsLocalDeviceCode]; + [self.defaults setInteger:1 forKey:WOCUserDefaultsLaunchStatus]; + [self.defaults synchronize]; + } +} + +- (NSString *)wocDeviceCode { + NSString *deviceCode = @""; + + if ([self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode] != nil) { + deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + } + return deviceCode; +} + +- (void)storeDeviceInfoLocally { + + if ([self.defaults objectForKey:WOCUserDefaultsLocalPhoneNumber] != nil) { + if ([self.defaults objectForKey:WOCUserDefaultsLocalDeviceId] != nil) { + NSString * phoneNumber = [self.defaults objectForKey:WOCUserDefaultsLocalPhoneNumber]; + NSString * deviceID = [self.defaults objectForKey:WOCUserDefaultsLocalDeviceId]; + + NSMutableDictionary *localDeiveDict = [NSMutableDictionary dictionaryWithCapacity:0]; + if ([self.defaults objectForKey:WOCUserDefaultsLocalDeviceInfo] != nil) { + localDeiveDict = [NSMutableDictionary dictionaryWithDictionary:[self.defaults objectForKey:WOCUserDefaultsLocalDeviceInfo]]; + } + + localDeiveDict[phoneNumber] = [NSString stringWithFormat:@"%@",deviceID]; + if (localDeiveDict != nil) { + [self.defaults setObject:localDeiveDict forKey:WOCUserDefaultsLocalDeviceInfo]; + [self.defaults synchronize]; + } + } + } + + APILog(@"Device info %@",[self.defaults objectForKey:WOCUserDefaultsLocalDeviceInfo]); +} + +- (void)clearLocalStorage +{ + [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; +} + +- (NSString*)getDeviceIDFromPhoneNumber:(NSString*)phoneNo { + + if ([self.defaults objectForKey:WOCUserDefaultsLocalDeviceInfo] != nil) { + if ([[self.defaults objectForKey:WOCUserDefaultsLocalDeviceInfo] isKindOfClass:[NSDictionary class]]) { + NSMutableDictionary *deviceInfoDict = [NSMutableDictionary dictionaryWithDictionary:[self.defaults objectForKey:WOCUserDefaultsLocalDeviceInfo]]; + if (deviceInfoDict[phoneNo] != nil) { + NSString *deviceId = deviceInfoDict[phoneNo]; + if (deviceId != nil) { + if (deviceId.length > 0) { + if (![deviceId isEqualToString:@"(null)"]) { + return deviceId; + } + } + } + } + } + } + return nil; +} + +- (void)refereshToken { + + if ([self.defaults objectForKey:WOCUserDefaultsLocalDeviceInfo] != nil) { + if ([[self.defaults objectForKey:WOCUserDefaultsLocalDeviceInfo] isKindOfClass:[NSDictionary class]]) { + NSMutableDictionary *deviceInfoDict = [NSMutableDictionary dictionaryWithDictionary:[self.defaults objectForKey:WOCUserDefaultsLocalDeviceInfo]]; + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + if (phoneNo != nil) { + if (deviceInfoDict[phoneNo] != nil) { + NSString *deviceId = deviceInfoDict[phoneNo]; + if (deviceId != nil) { + if (deviceId.length > 0 && (![deviceId isEqualToString:@"(null)"])) { + [self.defaults setObject:deviceId forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self.defaults setObject:deviceInfoDict forKey:WOCUserDefaultsLocalDeviceInfo]; + [self.defaults synchronize]; + [self loginWOC]; + return; + } + else { + [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; + + [deviceInfoDict removeObjectForKey:phoneNo]; + [self.defaults setObject:deviceInfoDict forKey:WOCUserDefaultsLocalDeviceInfo]; + [self.defaults synchronize]; + + dispatch_async(dispatch_get_main_queue(), ^{ + UIAlertController *alert = [UIAlertController alertControllerWithTitle:ALERT_TITLE message:@"Error while login with phone number. please try to login again." preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + [self loginWOC]; + }]; + + [alert addAction:okAction]; + + [self presentViewController:alert animated:YES completion:nil]; + }); + } + } + } + } + } + } +} + +- (void)backToMainView { + + [super backToMainView]; + [self storeDeviceInfoLocally]; +} +// MARK: - API +// Will call SignOut API then Store phone number with Device ID in Local storage and Backto Main View + +- (void)loginWOC { + + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + NSString *deviceId = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceId]; + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *params = @{ + WOCApiBodyDeviceCode: deviceCode + }; + + if (deviceId != nil && (![deviceId isEqualToString:@"(null)"])) { + + params = @{ + WOCApiBodyDeviceCode: deviceCode, + WOCApiBodyDeviceId: deviceId, + WOCApiBodyJsonParameter: @"YES" + }; + + [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDict, NSError *error) { + + if (error == nil) { + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self storeDeviceInfoLocally]; + } + else { + [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; + //[self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + + NSString *title = ALERT_TITLE; + dispatch_async(dispatch_get_main_queue(), ^{ + UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:@"SIGN IN for the device is hidden" preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + [self backToMainView]; + }]; + + [alert addAction:okAction]; + + [self presentViewController:alert animated:YES completion:nil]; + }); + } + }]; + } +} + +- (void)signOutWOC { + + NSString * phoneNumber = [self.defaults objectForKey:WOCUserDefaultsLocalPhoneNumber]; + + if (phoneNumber != nil) { + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + NSDictionary *params = @{ + }; + + [[APIManager sharedInstance] signOut:nil phone:phoneNumber response:^(id responseDict, NSError *error) { + + dispatch_async(dispatch_get_main_queue(), ^{ + [hud hideAnimated:YES]; + }); + + if (error != nil) { + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + + [self backToMainView]; + [self clearLocalStorage]; + + }]; + } + else { + [self backToMainView]; + [self clearLocalStorage]; + } +} + +- (void)pushToWOCRoot { + + dispatch_async(dispatch_get_main_queue(), ^{ + + NSString * storyboardName = [self.storyboard valueForKey:@"name"]; + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil]; + UINavigationController *navController = (UINavigationController*) [storyboard instantiateViewControllerWithIdentifier:@"wocNavigationController"]; + + if ([storyboardName isEqualToString:WOCBuyingStoryboard]) { + WOCBuyingWizardHomeViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"WOCBuyingWizardHomeViewController"];// Or any VC with Id + vc.isFromSend = YES; + [navController.navigationBar setTintColor:[UIColor whiteColor]]; + BRAppDelegate *appDelegate = (BRAppDelegate*)[[UIApplication sharedApplication] delegate]; + appDelegate.window.rootViewController = navController; + } + else { + WOCSellingWizardHomeViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"WOCSellingWizardHomeViewController"];// Or any VC with Id + vc.isFromSend = YES; + [navController.navigationBar setTintColor:[UIColor whiteColor]]; + BRAppDelegate *appDelegate = (BRAppDelegate*)[[UIApplication sharedApplication] delegate]; + appDelegate.window.rootViewController = navController; + } + }); +} + +// MARK: - WallofCoins API + +- (void)getOrderList { + + NSString * storyboardName = [self.storyboard valueForKey:@"name"]; + + if ([storyboardName isEqualToString:WOCBuyingStoryboard]) { + [[APIManager sharedInstance] getOrders:nil response:^(id responseDict, NSError *error) { + [self loadOrdersWithResponse:responseDict withError:error]; + }]; + } + else { + [self getIncomingList]; + } +} + +- (void)getIncomingList { + + [[APIManager sharedInstance] getIncomingOrders:nil response:^(id responseDict, NSError *error) { + + [self loadOrdersWithResponse:responseDict withError:error]; + }]; +} + +- (void)loadOrdersWithResponse:(id)responseDict withError: (NSError *)error +{ + NSString * storyboardName = [self.storyboard valueForKey:@"name"]; + + dispatch_async(dispatch_get_main_queue(), ^{ + if (error == nil) { + if ([responseDict isKindOfClass:[NSArray class]]) { + NSString *phoneNo = [[NSUserDefaults standardUserDefaults] valueForKey:WOCUserDefaultsLocalPhoneNumber]; + + NSArray *orders = [[NSArray alloc] initWithArray:(NSArray*)responseDict]; + if (orders.count > 0) { + NSPredicate *wdvPredicate = [NSPredicate predicateWithFormat:@"status == 'WD'"]; + NSArray *wdArray = [orders filteredArrayUsingPredicate:wdvPredicate]; + if (wdArray.count > 0) { + NSDictionary *orderDict = (NSDictionary*)[wdArray objectAtIndex:0]; + NSString *status = [NSString stringWithFormat:@"%@",[orderDict valueForKey:@"status"]]; + if ([status isEqualToString:@"WD"]) { + if ([storyboardName isEqualToString:WOCBuyingStoryboard]) { + WOCBuyingInstructionsViewController *buyingInstructionsViewController = [self getViewController:@"WOCBuyingInstructionsViewController"]; + buyingInstructionsViewController.phoneNo = phoneNo; + buyingInstructionsViewController.isFromSend = YES; + buyingInstructionsViewController.isFromOffer = NO; + buyingInstructionsViewController.orderDict = orderDict; + [self pushViewController:buyingInstructionsViewController animated:YES]; + } + else { + WOCSellingInstructionsViewController *sellingInstructionsViewController = [self getViewController:@"WOCSellingInstructionsViewController"]; + sellingInstructionsViewController.phoneNo = phoneNo; + sellingInstructionsViewController.isFromSend = YES; + sellingInstructionsViewController.isFromOffer = NO; + sellingInstructionsViewController.orderDict = orderDict; + [self pushViewController:sellingInstructionsViewController animated:YES]; + } + } + } + else { + + if ([storyboardName isEqualToString:WOCBuyingStoryboard]) { + WOCBuyingSummaryViewController *buyingInstructionsViewController = [self getViewController:@"WOCBuyingSummaryViewController"]; + buyingInstructionsViewController.phoneNo = phoneNo; + buyingInstructionsViewController.orders = orders; + buyingInstructionsViewController.isFromSend = YES; + [self pushViewController:buyingInstructionsViewController animated:YES]; + } + else { + WOCSellingSummaryViewController *sellingSummaryViewController = [self getViewController:@"WOCSellingSummaryViewController"]; + sellingSummaryViewController.phoneNo = phoneNo; + sellingSummaryViewController.orders = orders; + sellingSummaryViewController.isFromSend = YES; + [self pushViewController:sellingSummaryViewController animated:YES]; + } + } + } + else { + if ([storyboardName isEqualToString:WOCBuyingStoryboard]) { + WOCBuyingSummaryViewController *buyingSummaryViewController = [self getViewController:@"WOCBuyingSummaryViewController"]; + buyingSummaryViewController.phoneNo = phoneNo; + buyingSummaryViewController.orders = orders; + buyingSummaryViewController.isFromSend = YES; + buyingSummaryViewController.isHideSuccessAlert = YES; + [self pushViewController:buyingSummaryViewController animated:YES]; + } + else { + WOCSellingSummaryViewController *sellingSummaryViewController = [self getViewController:@"WOCSellingSummaryViewController"]; + sellingSummaryViewController.phoneNo = phoneNo; + sellingSummaryViewController.orders = orders; + sellingSummaryViewController.isFromSend = YES; + sellingSummaryViewController.isHideSuccessAlert = YES; + [self pushViewController:sellingSummaryViewController animated:YES]; + } + } + } + else { + [self backToMainView]; + } + } + else { + [self refereshToken]; + } + }); +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +@end diff --git a/PivxWallet/Wallofcoins/WOCBuyingInstructionsViewController.h b/PivxWallet/Wallofcoins/WOCBuyingInstructionsViewController.h new file mode 100644 index 00000000..1e974321 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCBuyingInstructionsViewController.h @@ -0,0 +1,49 @@ +// +// WOCBuyingInstructionsViewController.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" +@interface WOCBuyingInstructionsViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *purchaseCode; +@property (strong, nonatomic) NSString *holdId; +@property (strong, nonatomic) NSString *offerId; +@property (strong, nonatomic) NSString *phoneNo; +@property (strong, nonatomic) NSDictionary *orderDict; +@property (assign, nonatomic) BOOL isFromSend; +@property (assign, nonatomic) BOOL isFromOffer; + +@property (weak, nonatomic) IBOutlet UIImageView *bankImageView; +@property (weak, nonatomic) IBOutlet UILabel *bankNameLabel; +@property (weak, nonatomic) IBOutlet UILabel *phoneLabel; +@property (weak, nonatomic) IBOutlet UIButton *checkLocationButton; + +@property (weak, nonatomic) IBOutlet UILabel *accountNameLabel; +@property (weak, nonatomic) IBOutlet UILabel *accountNumberLabel; +@property (weak, nonatomic) IBOutlet UILabel *cashDepositLabel; +@property (weak, nonatomic) IBOutlet UILabel *depositDueLabel; +@property (weak, nonatomic) IBOutlet UIButton *depositFinishedButton; +@property (weak, nonatomic) IBOutlet UIButton *cancelOrderButton; + +@property (weak, nonatomic) IBOutlet UILabel *instructionsLabel; +@property (weak, nonatomic) IBOutlet UITextView *instructionTextField; +@property (weak, nonatomic) IBOutlet UIButton *wallOfCoinsButton; +@property (weak, nonatomic) IBOutlet UILabel *loginPhoneLabel; +@property (weak, nonatomic) IBOutlet UIButton *signOutButton; +@property (weak, nonatomic) IBOutlet UIButton *showOnMapNearbyButton; +@property (weak, nonatomic) IBOutlet UILabel *orderDetailFirstLable; + +- (IBAction)onShowMapButtonClicked:(id)sender; +- (IBAction)onDepositFinishedButtonClicked:(id)sender; +- (IBAction)onCancelOrderButtonClicked:(id)sender; +- (IBAction)onWallOfCoinsButtonClicked:(id)sender; +- (IBAction)onSignOutButtonClicked:(id)sender; +- (void)captureHold:(NSString*)purchaseCode holdId:(NSString*)holdId ; +- (void)deleteHold:(NSString*)holdId count:(NSUInteger)count; + +@end diff --git a/PivxWallet/Wallofcoins/WOCBuyingInstructionsViewController.m b/PivxWallet/Wallofcoins/WOCBuyingInstructionsViewController.m new file mode 100644 index 00000000..64009f4a --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCBuyingInstructionsViewController.m @@ -0,0 +1,639 @@ +// +// WOCBuyingInstructionsViewController.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCBuyingInstructionsViewController.h" +#import "WOCBuyingSummaryViewController.h" +#import "WOCBuyingWizardHomeViewController.h" +#import "APIManager.h" +#import "WOCConstants.h" +#import "BRRootViewController.h" +#import "BRAppDelegate.h" +#import "WOCAlertController.h" +#import "WOCLocationManager.h" +#import "MBProgressHUD.h" + +@interface WOCBuyingInstructionsViewController () + +@property (strong, nonatomic) NSString *orderId; +@property (strong, nonatomic) NSString *dueTime; +@property (assign, nonatomic) int minutes; +@property (strong, nonatomic) NSTimer *timer; +@property (strong, nonatomic) NSString *locationUrl; +@end + +@implementation WOCBuyingInstructionsViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + [self setShadowOnButton:self.depositFinishedButton]; + [self setShadowOnButton:self.cancelOrderButton]; + [self setShadowOnButton:self.wallOfCoinsButton]; + [self setShadowOnButton:self.signOutButton]; + + [self.signOutButton setTitleColor:WOCTHEMECOLOR forState:UIControlStateNormal]; + [self.showOnMapNearbyButton setTitleColor:WOCTHEMECOLOR forState:UIControlStateNormal]; + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + NSString *loginPhone = [NSString stringWithFormat:@"Your wallet is signed into Wall of Coins using your mobile number %@",phoneNo]; + self.loginPhoneLabel.text = loginPhone; + + if (self.orderDict.count > 0) { + [self updateData:self.orderDict]; + } + + self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"navigation_back"] style:UIBarButtonItemStylePlain target:self action:@selector(back:)]; + + if (!self.isFromSend && !self.isFromOffer) { + if ([self.purchaseCode length] > 0 && [self.holdId length] > 0) { + [self captureHold:self.purchaseCode holdId:self.holdId]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Please enter purchase code." viewController:self.navigationController.visibleViewController]; + } + } + else if (self.isFromOffer) { + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + if (self.offerId != nil && [self.offerId length] > 0) { + [self createHold:self.offerId phoneNo:phoneNo]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Please select offer." viewController:self.navigationController.visibleViewController]; + [self.navigationController popViewControllerAnimated:YES]; + } + } + + NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"If you have any questions, there is a live chat window at wallofcoins.com or you may call the phone number that sent you a text message." attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15.5]}]; + + [attributedString addAttribute:NSLinkAttributeName + value:@"https://wallofcoins.com" + range:[[attributedString string] rangeOfString:@"wallofcoins.com"]]; + + + NSDictionary *linkAttributes = @{ + NSForegroundColorAttributeName: [UIColor blackColor], + NSUnderlineColorAttributeName: [UIColor blackColor], + NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle) + }; + + // assume that textView is a UITextView previously created (either by code or Interface Builder) + self.instructionTextField.linkTextAttributes = linkAttributes; // customizes the appearance of links + self.instructionTextField.attributedText = attributedString; + self.instructionTextField.delegate = self; + + self.orderDetailFirstLable.text = [NSString stringWithFormat:@"You must deposit cash at the above Payment Center. Additional fees may apply. Paying in another method other than cash may delay your order.\n\nDo not throw away or misplace your receipt. A receipt is required before you will receive %@!\nFor your convenience, we are texting you these payment instructions.\nWhen you are finished making the payment, you must press Deposit Finished to receive your %@.",WOCCurrency,WOCCurrency]; +} + +- (void)pushToHome +{ + dispatch_async(dispatch_get_main_queue(), ^{ + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:WOCBuyingStoryboard bundle:nil]; + WOCBuyingWizardHomeViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"WOCBuyingWizardHomeViewController"]; + vc.isFromSend = YES; + UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:vc]; + [navigationController.navigationBar setTintColor:[UIColor whiteColor]]; + BRAppDelegate *appDelegate = (BRAppDelegate*)[[UIApplication sharedApplication] delegate]; + appDelegate.window.rootViewController = navigationController; + }); + return; + + BOOL viewFound = NO; + + for (UIViewController *controller in self.navigationController.viewControllers) { + if ([controller isKindOfClass:[WOCBuyingWizardHomeViewController class]]) { + [self.navigationController popToViewController:controller animated:NO]; + viewFound = YES; + break; + } + } + + if (viewFound == NO) { + dispatch_async(dispatch_get_main_queue(), ^{ + WOCBuyingWizardHomeViewController *homeViewController = [self getViewController:@"WOCBuyingWizardHomeViewController"]; + [self pushViewController:homeViewController animated:YES]; + }); + } +} + +- (void)back:(id)sender { + [self pushToBuyingSummary]; +} + +- (void)pushToBuyingSummary { + dispatch_async(dispatch_get_main_queue(), ^{ + WOCBuyingSummaryViewController *summaryViewController = [self getViewController:@"WOCBuyingSummaryViewController"]; + summaryViewController.phoneNo = self.phoneNo; + summaryViewController.isHideSuccessAlert = YES; + [self pushViewController:summaryViewController animated:YES]; + }); +} + +- (void)pushToStep1 { + [self backToMainView]; +} + +- (void)openSite:(NSURL*)url { + if ([[UIApplication sharedApplication] canOpenURL:url]) { + [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) { + APILog(@"URL opened..."); + }]; + } +} + +- (void)stopTimer { + dispatch_async(dispatch_get_main_queue(), ^{ + [self.timer invalidate]; + }); +} + +- (void)showDepositAlert { + UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Confirmation!" message:@"Are you sure you finished making the payment?" preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + [self confirmDeposit]; + }]; + + UIAlertAction *noAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + }]; + + [alert addAction:yesAction]; + [alert addAction:noAction]; + [self presentViewController:alert animated:YES completion:nil]; +} + +- (void)showCancelOrderAlert { + + UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Confirmation!" message:@"Are you sure you want to cancel order?" preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + [self cancelOrder]; + }]; + + UIAlertAction *noAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + }]; + + [alert addAction:yesAction]; + [alert addAction:noAction]; + [self presentViewController:alert animated:YES completion:nil]; +} + +- (void)updateData:(NSDictionary*)dictionary { + + NSString *bankLogo = REMOVE_NULL_VALUE([dictionary valueForKey:@"bankLogo"]); + NSString *bankName = REMOVE_NULL_VALUE([dictionary valueForKey:@"bankName"]); + NSString *phoneNo = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([[dictionary valueForKey:@"nearestBranch"] valueForKey:@"phone"])]; + NSString *accountName = REMOVE_NULL_VALUE([dictionary valueForKey:@"nameOnAccount"]); + NSString *accountNo = REMOVE_NULL_VALUE([dictionary valueForKey:@"account"]); + float depositAmount = [[dictionary valueForKey:@"payment"] floatValue]; + NSString *depositDue = REMOVE_NULL_VALUE([dictionary valueForKey:@"paymentDue"]); + NSString *totalDash = REMOVE_NULL_VALUE([dictionary valueForKey:@"total"]); + self.orderId = REMOVE_NULL_VALUE([dictionary valueForKey:@"id"]); + + //bankLogo + if (![[dictionary valueForKey:@"bankLogo"] isEqual:[NSNull null]] && [bankLogo length] > 0) { + self.bankImageView.image = [UIImage imageNamed:@"ic_account_balance_black"]; + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), + ^{ + NSURL *imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",bankLogo]]; + NSData *imageData = [NSData dataWithContentsOfURL:imageURL]; + + //This is your completion handler + dispatch_sync(dispatch_get_main_queue(), ^{ + //If self.image is atomic (not declared with nonatomic) + // you could have set it directly above + if (imageData != nil) { + self.bankImageView.image = [UIImage imageWithData:imageData]; + } + else { + self.bankImageView.image = [UIImage imageNamed:@"ic_account_balance_black"]; + } + }); + }); + } + else { + self.bankImageView.image = [UIImage imageNamed:@"ic_account_balance_black"]; + } + + //bankLocationUrl + if ([dictionary valueForKey:@"bankUrl"] != [NSNull null]) { + [self.checkLocationButton setTitle:@"Check locations" forState:UIControlStateNormal]; + self.locationUrl = [dictionary valueForKey:@"bankUrl"]; + if ([[dictionary valueForKey:@"nearestBranch"] class] != [NSNull class]) { + if([dictionary valueForKey:@"nearestBranch"][@"address"] != nil) { + if ([[[dictionary valueForKey:@"nearestBranch"] valueForKey:@"address"] length] > 0) { + [self.checkLocationButton setHidden:YES]; + }} + } + } + + self.bankNameLabel.text = bankName; + self.phoneLabel.text = [NSString stringWithFormat:@"Location's phone #: %@",phoneNo]; + self.accountNameLabel.text = [NSString stringWithFormat:@"Name on Account: %@",accountName]; + self.accountNumberLabel.text = [NSString stringWithFormat:@"Account #: %@",accountNo]; + self.cashDepositLabel.text = [NSString stringWithFormat:@"Cash to Deposit: $%.02f",depositAmount]; + + NSNumber *num = [NSNumber numberWithDouble:([totalDash doubleValue] * 1000000)]; + self.instructionsLabel.text = [NSString stringWithFormat:@"You are ordering: %@ %@ (%@ %@)",totalDash,WOCCurrencySpecial, [self getCryptoPrice:num],WOCCurrencySymbolMinor]; + + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; + formatter.dateFormat = API_DATE_FORMAT; + NSDate *local = [formatter dateFromString:depositDue]; + APILog(@"local: %@",local); + + formatter.dateFormat = LOCAL_DATE_FORMAT; + NSString *localTime = [formatter stringFromDate:local]; + APILog(@"localTime: %@",localTime); + self.dueTime = localTime; + + NSString *currentTime = [formatter stringFromDate:[NSDate date]]; + APILog(@"currentTime UTC : %@",currentTime); + + NSMutableAttributedString *timeString = [self dateDiffrenceBetweenTwoDates:currentTime endDate:localTime]; + NSMutableAttributedString *dueString = [[NSMutableAttributedString alloc] initWithString:@"Deposit Due: "]; + [dueString appendAttributedString:timeString]; + + self.depositDueLabel.attributedText = dueString; + + self.timer = [[NSTimer alloc] init]; + self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(checkTime) userInfo:nil repeats:YES]; + + if ([[dictionary valueForKey:@"account"] length] > 16) { + NSArray *accountArr = [NSJSONSerialization JSONObjectWithData:[[dictionary valueForKey:@"account"] dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:nil]; + NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"displaySort" ascending:YES comparator:^NSComparisonResult(id obj1, id obj2) { + float aObj1 = [(NSString *)obj1 floatValue]; + float aObj2 = [(NSString *)obj2 floatValue]; + return aObj1 > aObj2; + }]; + + NSArray *accountArray = [accountArr sortedArrayUsingDescriptors:@[sort]]; + if (accountArray.count > 2) { + self.phoneLabel.text = [NSString stringWithFormat:@"Name: %@ %@",REMOVE_NULL_VALUE([[accountArray objectAtIndex:0] valueForKey:@"value"]), REMOVE_NULL_VALUE([[accountArray objectAtIndex:2] valueForKey:@"value"])]; + } + + if (accountArray.count > 3) { + self.accountNameLabel.text = [NSString stringWithFormat:@"Country of Birth: %@",REMOVE_NULL_VALUE([[accountArray objectAtIndex:3] valueForKey:@"value"])]; + } + + if (accountArray.count > 1) { + self.accountNumberLabel.text = [NSString stringWithFormat:@"Pick-up State: %@",REMOVE_NULL_VALUE([[accountArray objectAtIndex:1] valueForKey:@"value"])]; + } + } +} + +- (void)checkTime { + + if (self.minutes > 0) { + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; + formatter.dateFormat = LOCAL_DATE_FORMAT; + NSString *currentTime = [formatter stringFromDate:[NSDate date]]; + NSMutableAttributedString *timeString = [self dateDiffrenceBetweenTwoDates:currentTime endDate:self.dueTime]; + NSMutableAttributedString *dueString = [[NSMutableAttributedString alloc] initWithString:@"Deposit Due: "]; + [dueString appendAttributedString:timeString]; + self.depositDueLabel.attributedText = dueString; + } + else { + self.depositDueLabel.text = @"Deposit Due: time expired"; + [self stopTimer]; + } +} + +- (NSMutableAttributedString*)dateDiffrenceBetweenTwoDates:(NSString*)startDate endDate:(NSString*)endDate { + NSMutableAttributedString *timeLeft = [[NSMutableAttributedString alloc] init]; + + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; + formatter.dateFormat = LOCAL_DATE_FORMAT; + + NSDate *startDateT = [formatter dateFromString:startDate]; + NSDate *endDateT = [formatter dateFromString:endDate]; + + NSDateComponents *components; + + NSInteger days; + NSInteger hours; + NSInteger minutes = 0; + NSInteger seconds = 0; + + components = [[NSCalendar currentCalendar] components:NSCalendarUnitDay fromDate:startDateT toDate:endDateT options:0]; + days = [components day]; + components = [[NSCalendar currentCalendar] components:NSCalendarUnitHour fromDate:startDateT toDate:endDateT options:0]; + hours = [components hour]; + components = [[NSCalendar currentCalendar] components:NSCalendarUnitMinute fromDate:startDateT toDate:endDateT options:0]; + minutes = [components minute]; + components = [[NSCalendar currentCalendar] components:NSCalendarUnitSecond fromDate:startDateT toDate:endDateT options:0]; + seconds = [components second]; + NSString *secondsInString = [NSString stringWithFormat:@"%ld ", (long)minutes]; + + self.minutes = [secondsInString intValue]; + + NSInteger daysN = (int) (floor(seconds / (3600 * 24))); + if(daysN) seconds -= daysN * 3600 * 24; + + NSInteger hoursN = (int) (floor(seconds / 3600)); + if(hoursN) seconds -= hoursN * 3600; + + NSInteger minutesN = (int) (floor(seconds / 60)); + if(minutesN) seconds -= minutesN * 60; + + if(daysN) { + [timeLeft appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%ld Days ", (long)daysN*1]]]; + } + + if(hoursN) { + [timeLeft appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat: @"%ld Hour ", (long)hoursN*1]]]; + } + + if(minutesN) { + [timeLeft appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat: @"%ld Minutes ",(long)minutesN*1]]]; + } + + return timeLeft; +} + +// MARK: - API + +- (void)createHold:(NSString*)offerId phoneNo:(NSString*)phone { + + dispatch_async(dispatch_get_main_queue(), ^{ + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + NSDictionary *params ; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + params = @{ + WOCApiBodyOffer: [NSString stringWithFormat:@"%@==",offerId], + WOCApiBodyJsonParameter:@"YES" + }; + } + else { + params = @{ + WOCApiBodyOffer: [NSString stringWithFormat:@"%@==",offerId], + WOCApiBodyPhoneNumber: phone, + WOCApiBodyDeviceName: WOCApiBodyDeviceName_IOS, + WOCApiBodyDeviceCode: deviceCode, + WOCApiBodyJsonParameter:@"YES" + }; + } + + [[APIManager sharedInstance] createHold:params response:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^{ + [hud hideAnimated:YES]; + }); + + if (error == nil) { + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + if ([responseDictionary valueForKey:WOCApiResponseToken] != nil && (![[responseDictionary valueForKey:WOCApiResponseToken] isEqualToString:@"(null)"])) { + + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiResponseToken]] forKey:WOCUserDefaultsAuthToken]; + [self.defaults setValue:phone forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + } + + NSString *holdId = [NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiResponseId]]; + self.holdId = holdId; + + NSString *purchaseCode = [NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiResponsePurchaseCde]]; + self.purchaseCode = purchaseCode; + + [self captureHold:purchaseCode holdId:holdId]; + } + else if (error.code == 403 ) { + [self getHold]; + } + else if (error.code == 500 ) { + [self pushToBuyingSummary]; + } + }]; + }); +} + +- (void)getHold { + + [[APIManager sharedInstance] getHold:^(id responseDict, NSError *error) { + if (error == nil) { + APILog(@"Hold with Hold Id: %@.",responseDict); + + if ([responseDict isKindOfClass:[NSArray class]]) { + NSArray *holdArray = (NSArray*)responseDict; + if (holdArray.count > 0) { + NSUInteger count = holdArray.count; + NSUInteger activeHodCount = 0; + + for (int i = 0; i < holdArray.count; i++) { + count -= count; + + NSDictionary *holdDict = [holdArray objectAtIndex:i]; + NSString *holdId = [holdDict valueForKey:WOCApiResponseId]; + NSString *holdStatus = [holdDict valueForKey:WOCApiResponseHoldsStatus]; + if (holdStatus != nil) { + if ([holdStatus isEqualToString:@"AC"]) { + if (holdId) { + activeHodCount = activeHodCount + 1; + [self deleteHold:holdId count:count]; + } + } + } + else { + if (holdId) { + activeHodCount = activeHodCount + 1; + [self deleteHold:holdId count:count]; + } + } + } + + if (activeHodCount == 0 ) { + [self getOrderList]; + } + } + else { + [self getOrderList]; + } + } + else { + [self getOrderList]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + }]; +} + +- (void)deleteHold:(NSString*)holdId count:(NSUInteger)count { + + NSDictionary *params = @{ + }; + + [[APIManager sharedInstance] deleteHold:holdId response:^(id responseDict, NSError *error) { + + if (error == nil) { + APILog(@"Hold deleted."); + + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + [self createHold:self.offerId phoneNo:phoneNo]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + }]; +} + +- (void)captureHold:(NSString*)purchaseCode holdId:(NSString*)holdId { + + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + NSDictionary *params = @{ + WOCApiBodyVerificationCode: purchaseCode, + WOCApiBodyJsonParameter: @"YES" + }; + + [[APIManager sharedInstance] captureHold:params holdId:self.holdId response:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^{ + [hud hideAnimated:YES]; + }); + + if (error == nil) { + if ([responseDict isKindOfClass:[NSArray class]]) + { + NSArray *response = [[NSArray alloc] initWithArray:(NSArray*)responseDict]; + if (response.count > 0) { + if ([[response objectAtIndex:0] isKindOfClass:[NSDictionary class]]) { + [self updateData:[response objectAtIndex:0]]; + } + } + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + [self.navigationController popViewControllerAnimated:YES]; + } + }]; +} + +- (void)confirmDeposit { + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + if (self.orderId != nil) { + + [[APIManager sharedInstance] confirmDeposit:self.orderId response:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^{ + [hud hideAnimated:YES]; + }); + + if (error == nil) { + [self stopTimer]; + [self pushToBuyingSummary]; + } + else { + + dispatch_async(dispatch_get_main_queue(), ^{ + if (error.userInfo != nil) { + if (error.userInfo[@"detail"] != nil) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self.navigationController.visibleViewController]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + }); + } + }]; + } +} + +- (void)cancelOrder { + + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + if (self.orderId != nil) { + + [[APIManager sharedInstance] cancelOrder:self.orderId response:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^{ + [hud hideAnimated:YES]; + }); + + if (error == nil) { + [self stopTimer]; + [self backToMainView]; + } + else { + dispatch_async(dispatch_get_main_queue(), ^{ + if (error.userInfo != nil) { + if (error.userInfo[@"detail"] != nil) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self.navigationController.visibleViewController]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + }); + } + }]; + } +} + +// MARK: - button actions + +- (IBAction)onShowMapButtonClicked:(id)sender { + if (self.locationUrl != nil) { + if (![self.locationUrl hasPrefix:@"http"]) { + self.locationUrl = [NSString stringWithFormat:@"https://%@",self.locationUrl]; + } + + if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:self.locationUrl]]) { + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.locationUrl] options:@{} completionHandler:^(BOOL success) { + APILog(@"URL opened."); + }]; + } + } + else { + // Your location from latitude and longitude + double latitude = [[self.defaults valueForKey:WOCUserDefaultsLocalLocationLatitude] doubleValue]; + double longitude = [[self.defaults valueForKey:WOCUserDefaultsLocalLocationLongitude] doubleValue]; + + NSString* directionsURL = [NSString stringWithFormat:@"http://maps.apple.com/?saddr=%f,%f&daddr=%f,%f", latitude, longitude, latitude, longitude]; + if ([[UIApplication sharedApplication] respondsToSelector:@selector(openURL:options:completionHandler:)]) { + [[UIApplication sharedApplication] openURL:[NSURL URLWithString: directionsURL] options:@{} completionHandler:^(BOOL success) {}]; + } + } +} + +- (IBAction)onDepositFinishedButtonClicked:(id)sender { + [self showDepositAlert]; +} + +- (IBAction)onCancelOrderButtonClicked:(id)sender { + [self showCancelOrderAlert]; +} + +- (IBAction)onWallOfCoinsButtonClicked:(id)sender { + [self openSite:[NSURL URLWithString:@"https://wallofcoins.com"]]; +} + +- (IBAction)onSignOutButtonClicked:(id)sender { + [self signOutWOC]; +} + +// MARK: - UITextView Delegate + +- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange { + if ([[URL scheme] isEqualToString:@"https"]) { + [self openSite:URL]; + return NO; + } + return YES; +} + +@end diff --git a/PivxWallet/Wallofcoins/WOCBuyingSummaryViewController.h b/PivxWallet/Wallofcoins/WOCBuyingSummaryViewController.h new file mode 100644 index 00000000..bd8cbbf0 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCBuyingSummaryViewController.h @@ -0,0 +1,25 @@ +// +// WOCBuyingSummaryViewController.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" +@interface WOCBuyingSummaryViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *phoneNo; +@property (strong, nonatomic) NSArray *orders; +@property (assign, nonatomic) BOOL isFromSend; +@property (assign, nonatomic) BOOL isHideSuccessAlert; +@property (weak, nonatomic) IBOutlet UITextView *instructionTextField; +@property (weak, nonatomic) IBOutlet UILabel *instructionLabel; +@property (weak, nonatomic) IBOutlet UITableView *buyingSummaryTableView; +@property (weak, nonatomic) IBOutlet UIButton *buyMoreDashButton; + +- (IBAction)onBuyMoreDashButtonClick:(id)sender; +- (void)displayAlert; + +@end diff --git a/PivxWallet/Wallofcoins/WOCBuyingSummaryViewController.m b/PivxWallet/Wallofcoins/WOCBuyingSummaryViewController.m new file mode 100644 index 00000000..df5841b1 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCBuyingSummaryViewController.m @@ -0,0 +1,431 @@ +// +// WOCBuyingSummaryViewController.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#define WD @"WD" +#define WDV @"WDV" +#define RERR @"RERR" +#define DERR @"DERR" +#define RSD @"RSD" +#define RMIT @"RMIT" +#define UCRV @"UCRV" +#define PAYP @"PAYP" +#define SENT @"SENT" + +#define STATUS_WD @"Waiting Deposit" +#define STATUS_WDV @"Waiting Deposit Verification" +#define STATUS_RERR @"Issue with Receipt" +#define STATUS_DERR @"Issue with Deposit" +#define STATUS_RSD @"Reserved for Deposit" +#define STATUS_RMIT @"Remit Address Missing" +#define STATUS_UCRV @"Under Review" +#define STATUS_PAYP @"Done - Pending Delivery" +#define STATUS_SENT @"Done - Units Delivered" + +#import "WOCBuyingSummaryViewController.h" +#import "WOCSummaryCell.h" +#import "WOCSignOutCell.h" +#import "WOCBuyingWizardHomeViewController.h" +#import "WOCBuyingWizardInputAmountViewController.h" +#import "APIManager.h" +#import "BRRootViewController.h" +#import "BRAppDelegate.h" +#import +#import "WOCAlertController.h" +#import "MBProgressHUD.h" +#import "WOCAsyncImageView.h" + +@interface WOCBuyingSummaryViewController () + +@property (strong, nonatomic) NSArray *wdOrders; +@property (strong, nonatomic) NSArray *otherOrders; + +@end + +@implementation WOCBuyingSummaryViewController + +- (void)viewDidLoad { + + [super viewDidLoad]; + + self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"navigation_back"] style:UIBarButtonItemStylePlain target:self action:@selector(back:)]; + + [self setShadowOnButton:self.buyMoreDashButton]; + [self setAttributedString]; + + if (self.orders.count == 0) { + [self reloadOrderTable]; + [self getOrders]; + if (!self.isHideSuccessAlert) { + [self displayAlert]; + } + } + else { + + NSPredicate *wdvPredicate = [NSPredicate predicateWithFormat:@"status == 'WD'"]; + NSArray *wdvArray = [self.orders filteredArrayUsingPredicate:wdvPredicate]; + self.wdOrders = [[NSArray alloc] initWithArray:wdvArray]; + + NSPredicate *otherPredicate = [NSPredicate predicateWithFormat:@"status == 'WDV' || status == 'RERR' || status == 'DERR' || status == 'RSD' || status == 'RMIT' || status == 'UCRV' || status == 'PAYP' || status == 'SENT' || status == 'ACAN'"]; + NSArray *otherArray = [self.orders filteredArrayUsingPredicate:otherPredicate]; + self.otherOrders = [[NSArray alloc] initWithArray:otherArray]; + + APILog(@"wdvArray count: %lu, otherArray count: %lu",(unsigned long)wdvArray.count,(unsigned long)otherArray.count); + + [self reloadOrderTable]; + } + + [self.buyMoreDashButton setTitleColor:WOCTHEMECOLOR forState:UIControlStateNormal]; +} + +- (void)setAttributedString { + + NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"Wall of Coins will verify your payment. This usually takes up to 10 minutes. To expedite your order, take a picture of your receipt and click here to email your receipt to Wall of Coins." attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]}]; + + [attributedString addAttribute:NSLinkAttributeName + value:@"support@wallofcoins.com" + range:[[attributedString string] rangeOfString:@"click here"]]; + + + NSDictionary *linkAttributes = @{NSForegroundColorAttributeName: [UIColor blackColor], + NSUnderlineColorAttributeName: [UIColor blackColor], + NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle)}; + + self.instructionTextField.linkTextAttributes = linkAttributes; + self.instructionTextField.attributedText = attributedString; + self.instructionTextField.delegate = self; +} + +- (void)back:(id)sender { + + [self backToMainView]; +} + +- (NSString*)checkStatus:(NSString*)status { + + NSString *string = @""; + + if ([status isEqualToString:WD]) { + string = [NSString stringWithFormat:@"Status: %@",STATUS_WD]; + } + else if ([status isEqualToString:WDV]) { + string = [NSString stringWithFormat:@"Status: %@",STATUS_WDV]; + } + else if ([status isEqualToString:RERR]) { + string = [NSString stringWithFormat:@"Status: %@",STATUS_RERR]; + } + else if ([status isEqualToString:DERR]) { + string = [NSString stringWithFormat:@"Status: %@",STATUS_DERR]; + } + else if ([status isEqualToString:RMIT]) { + string = [NSString stringWithFormat:@"Status: %@",STATUS_RMIT]; + } + else if ([status isEqualToString:UCRV]) { + string = [NSString stringWithFormat:@"Status: %@",STATUS_UCRV]; + } + else if ([status isEqualToString:PAYP]) { + string = [NSString stringWithFormat:@"Status: %@",STATUS_PAYP]; + } + else if ([status isEqualToString:SENT]) { + string = [NSString stringWithFormat:@"Status: %@",STATUS_SENT]; + } + + return string; +} + +- (void)displayAlert { + + [[WOCAlertController sharedInstance] alertshowWithTitle:@"" message:[NSString stringWithFormat:@"Thank you for making the payment!\nOnce we verify your payment, we will send the %@ to your wallet!",WOCCurrency] viewController:self]; +} + +// MARK: - IBAction + +- (IBAction)onBuyMoreDashButtonClick:(id)sender { + [self backToMainView]; +} + +- (IBAction)onSignOutButtonClick:(id)sender { + [self signOutWOC]; +} + +- (IBAction)wallOfCoinsClicked:(id)sender { + + NSURL *url = [NSURL URLWithString:@"https://wallofcoins.com"]; + if ([[UIApplication sharedApplication] canOpenURL:url]) { + [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) { + APILog(@"URL opened..."); + }]; + } +} + +// MARK: - API +- (void)getOrders { + + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + NSDictionary *params = @{ + }; + + [[APIManager sharedInstance] getOrders:nil response:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^{ + [hud hideAnimated:YES]; + }); + + if (error == nil) { + if ([responseDict isKindOfClass:[NSArray class]]) { + NSArray *response = [[NSArray alloc] initWithArray:(NSArray*)responseDict]; + self.orders = response; + + NSPredicate *wdvPredicate = [NSPredicate predicateWithFormat:@"status == 'WD'"]; + NSArray *wdvArray = [self.orders filteredArrayUsingPredicate:wdvPredicate]; + self.wdOrders = [[NSArray alloc] initWithArray:wdvArray]; + + NSPredicate *otherPredicate = [NSPredicate predicateWithFormat:@"status == 'WDV' || status == 'RERR' || status == 'DERR' || status == 'RSD' || status == 'RMIT' || status == 'UCRV' || status == 'PAYP' || status == 'SENT' || status == 'ACAN'"]; + NSArray *otherArray = [self.orders filteredArrayUsingPredicate:otherPredicate]; + self.otherOrders = [[NSArray alloc] initWithArray:otherArray]; + + APILog(@"wdvArray count: %lu, otherArray count: %lu",(unsigned long)wdvArray.count,(unsigned long)otherArray.count); + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + + [self reloadOrderTable]; + + }]; +} + +- (void)reloadOrderTable{ + if (self.orders.count > 0) { + self.instructionTextField.text = @"Wall of Coins will verify your payment. This usually takes up to 10 minutes. To expedite your order, take a picture of your receipt and click here to email your receipt to Wall of Coins."; + } + else { + self.instructionTextField.text = [NSString stringWithFormat:@"You have no order history with %@ for iOS. To see your full order history across all devices, visit %@",WOCCryptoCurrency,BASE_URL_PRODUCTION]; + } + self.instructionLabel.hidden = YES; + self.instructionTextField.hidden = NO; + [self.buyingSummaryTableView reloadData]; +} +#pragma mark - UITableView DataSource + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 4; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + + if (section == 0) { + return self.wdOrders.count; + } + else if (section == 1) { + return 1; + } + else if (section == 2){ + return 1; + } + else { + return self.otherOrders.count; + } +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + + if (indexPath.section == 1) { + WOCSignOutCell *cell = [tableView dequeueReusableCellWithIdentifier:@"linkCell"]; + [cell.signOutButton addTarget:self action:@selector(wallOfCoinsClicked:) forControlEvents:UIControlEventTouchUpInside]; + return cell; + } + else if (indexPath.section == 2) { + WOCSignOutCell *cell = [tableView dequeueReusableCellWithIdentifier:@"signOutCell"]; + cell.descriptionLabel.text = [NSString stringWithFormat:@"Your wallet is signed into Wall of Coins using your mobile number %@",self.phoneNo]; + [cell.signOutButton addTarget:self action:@selector(onSignOutButtonClick:) forControlEvents:UIControlEventTouchUpInside]; + return cell; + } + else { + static const NSInteger IMAGE_VIEW_TAG = 98; + NSString *cellIdentifier = @"offerCell"; + + WOCSummaryCell *cell = [tableView dequeueReusableCellWithIdentifier:@"summaryCell"]; + + NSDictionary *orderDict = [[NSDictionary alloc] init]; + + if (indexPath.section == 0) { + orderDict = self.wdOrders[indexPath.row]; + + if (![[orderDict valueForKey:@"account"] isEqual:[NSNull null]]) { + if ([[orderDict valueForKey:@"account"] length] > 16) { + cell = [tableView dequeueReusableCellWithIdentifier:@"summaryCell1"]; + NSArray *accountArr = [NSJSONSerialization JSONObjectWithData:[[orderDict valueForKey:@"account"] dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:nil]; + NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"displaySort" ascending:YES comparator:^NSComparisonResult(id obj1, id obj2) { + float aObj1 = [(NSString *)obj1 floatValue]; + float aObj2 = [(NSString *)obj2 floatValue]; + return aObj1 > aObj2; + }]; + NSArray *accountArray = [accountArr sortedArrayUsingDescriptors:@[sort]]; + cell.phoneLabel.hidden = YES; + if (accountArray.count > 0) { + cell.firstNameLabel.text = [NSString stringWithFormat:@"First Name: %@",REMOVE_NULL_VALUE([[accountArray objectAtIndex:0] valueForKey:@"value"])]; + } + if (accountArray.count > 2) { + cell.lastNameLabel.text = [NSString stringWithFormat:@"Last Name: %@",REMOVE_NULL_VALUE([[accountArray objectAtIndex:2] valueForKey:@"value"])]; + } + if (accountArray.count > 3) { + cell.birthCountryLabel.text = [NSString stringWithFormat:@"Country of Birth: %@",REMOVE_NULL_VALUE([[accountArray objectAtIndex:3] valueForKey:@"value"])]; + } + if (accountArray.count > 1) { + cell.pickupStateLabel.text = [NSString stringWithFormat:@"Pick-up State: %@",REMOVE_NULL_VALUE([[accountArray objectAtIndex:1] valueForKey:@"value"])]; + } + } + } + } + else { + orderDict = self.otherOrders[indexPath.row]; + } + + NSString *bankLogo = REMOVE_NULL_VALUE([orderDict valueForKey:@"bankLogo"]); + NSString *bankIcon = REMOVE_NULL_VALUE([orderDict valueForKey:@"bankIcon"]); + NSString *bankName = REMOVE_NULL_VALUE([orderDict valueForKey:@"bankName"]); + NSString *phoneNo = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([[orderDict valueForKey:@"nearestBranch"] valueForKey:@"phone"])]; + float depositAmount = [[orderDict valueForKey:@"payment"] floatValue]; + NSString *totalDash = REMOVE_NULL_VALUE([orderDict valueForKey:@"total"]); + NSString *status = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([orderDict valueForKey:@"status"])]; + + UIView *cellView = cell.bankImageView.superview; + + WOCAsyncImageView *imageView = (WOCAsyncImageView *)[cellView viewWithTag:IMAGE_VIEW_TAG]; + + if (imageView == nil) { + imageView = [[WOCAsyncImageView alloc] initWithFrame:cell.bankImageView.frame]; + imageView.contentMode = UIViewContentModeScaleAspectFill; + imageView.clipsToBounds = YES; + imageView.image = [UIImage imageNamed:@"ic_account_balance_black"]; + imageView.tag = IMAGE_VIEW_TAG; + [cellView addSubview:imageView]; + } + + cell.bankImageView.hidden = YES; + imageView.hidden = NO; + + //get image view + //cancel loading previous image for cell + [[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:imageView]; + //bankLogo + if ([bankLogo length] > 0) { + imageView.imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",bankLogo]]; + } + else if ([bankIcon length] > 0) { + imageView.imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",bankIcon]]; + //cell.imgView.image = [UIImage imageNamed:@"ic_account_balance_black"]; + } + + cell.nameLabel.text = bankName; + cell.phoneLabel.text = [NSString stringWithFormat:@"Location's phone #: %@",phoneNo]; + if ([[[orderDict valueForKey:@"nearestBranch"] valueForKey:@"phone"] isEqual:[NSNull null]]) { + [cell.phoneLabel setHidden:YES]; + } + cell.cashDepositLabel.text = [NSString stringWithFormat:@"Cash to Deposit: $%.02f",depositAmount]; + + NSNumber *num = [NSNumber numberWithDouble:([totalDash doubleValue] * 1000000)]; + NSNumberFormatter *numFormatter = [[NSNumberFormatter alloc] init]; + [numFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4]; + [numFormatter setNumberStyle:NSNumberFormatterDecimalStyle]; + //[numFormatter setAllowsFloats:YES]; + [numFormatter setAlwaysShowsDecimalSeparator:YES]; + //[numFormatter setDecimalSeparator:@"."]; + [numFormatter setUsesGroupingSeparator:YES]; + [numFormatter setGroupingSeparator:@","]; + [numFormatter setGroupingSize:3]; + NSString *stringNum = [numFormatter stringFromNumber:num]; + cell.totalDashLabel.text = [NSString stringWithFormat:@"Total %@: %@ (%@ %@)",WOCCurrencySpecial,totalDash,stringNum,WOCCurrencySymbolMinor]; + cell.statusLabel.text = [self checkStatus:status]; + + return cell; + } +} + +// MARK: - UITableView Delegate + +- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { + + if (section == 3) { + UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.buyingSummaryTableView.frame.size.width, 50)]; + headerView.backgroundColor = [UIColor colorWithRed:250.0/255.0 green:250.0/255.0 blue:250.0/255.0 alpha:1.0]; + UILabel *lblTitle = [[UILabel alloc] initWithFrame:CGRectMake(15, 5, headerView.frame.size.width - 30, headerView.frame.size.height - 15)]; + lblTitle.text = @"Order History"; + lblTitle.font = [UIFont systemFontOfSize:14.0 weight:UIFontWeightMedium]; + lblTitle.textAlignment = NSTextAlignmentCenter; + lblTitle.backgroundColor = [UIColor whiteColor]; + lblTitle.layer.cornerRadius = 10.0; + lblTitle.layer.masksToBounds = YES; + + [self setShadowOnView:lblTitle]; + [headerView addSubview:lblTitle]; + return headerView; + } + return nil; +} + +- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { + + if (section == 3) { + if (self.otherOrders.count > 0) { + return 50; + } + } + return 0; +} + +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { + + if (indexPath.section == 1 || indexPath.section == 2) { + return 110.0; + } + else { + NSDictionary *orderDict = [[NSDictionary alloc] init]; + if (indexPath.section == 0) { + orderDict = self.wdOrders[indexPath.row]; + if (![[orderDict valueForKey:@"account"] isEqual:[NSNull null]]) { + if ([[orderDict valueForKey:@"account"] length] > 16) { + return 250.0; + } + } + } + else { + orderDict = self.otherOrders[indexPath.row]; + } + return 185.0; + } +} + +#pragma mark - UITextView Delegate +- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange { + + if ([[URL absoluteString] hasPrefix:@"support"]) { + if([MFMailComposeViewController canSendMail]) { + MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init]; + mailController.mailComposeDelegate = self; + + NSDictionary *orderDict = [self.orders objectAtIndex:0]; + [mailController setSubject:[NSString stringWithFormat:@"Order #{%@} - {%@}",[orderDict valueForKey:@"id"],self.phoneNo]]; + [mailController setToRecipients:[NSArray arrayWithObject:@"support@wallofcoins.com"]]; + [mailController setMessageBody:@"" isHTML:NO]; + [self presentViewController:mailController animated:YES completion:nil]; + } + return NO; + } + return YES; +} + +#pragma mark - MFMailComposer Delegate +- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { + + [self dismissViewControllerAnimated:YES completion:nil]; +} + +@end + diff --git a/PivxWallet/Wallofcoins/WOCBuyingWizardHomeViewController.h b/PivxWallet/Wallofcoins/WOCBuyingWizardHomeViewController.h new file mode 100644 index 00000000..03223805 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCBuyingWizardHomeViewController.h @@ -0,0 +1,30 @@ +// +// WOCBuyingWizardHomeViewController.h +// Wallofcoins +// +// Created by Genitrust on 23/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" +//WOCBuyingWizardHomeViewController +// Find My Location Screen +@interface WOCBuyingWizardHomeViewController : WOCBaseViewController + +@property (weak, nonatomic) IBOutlet UIButton *locationButton; +@property (weak, nonatomic) IBOutlet UIButton *noThanksButton; +@property (weak, nonatomic) IBOutlet UILabel *descriptionLabel; +@property (weak, nonatomic) IBOutlet UIButton *signoutButton; +@property (weak, nonatomic) IBOutlet UIView *signoutView; +@property (weak, nonatomic) IBOutlet UIButton *orderListButton; +@property (assign, nonatomic) BOOL isFromSend; +@property (weak, nonatomic) IBOutlet UILabel *informationLable; + +- (void)setLogoutButton; +- (IBAction)onBackButtonClick:(id)sender; +- (IBAction)onFindLocationButtonClick:(id)sender; +- (IBAction)noThanksButtonClick:(id)sender; +- (IBAction)onSignOutButtonClick:(id)sender; + +@end diff --git a/PivxWallet/Wallofcoins/WOCBuyingWizardHomeViewController.m b/PivxWallet/Wallofcoins/WOCBuyingWizardHomeViewController.m new file mode 100644 index 00000000..970befb7 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCBuyingWizardHomeViewController.m @@ -0,0 +1,238 @@ +// +// WOCBuyingWizardHomeViewController.m +// Wallofcoins +// +// Created by Genitrust on 23/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCBuyingWizardHomeViewController.h" +#import "WOCLocationManager.h" +#import "WOCBuyingWizardZipCodeViewController.h" +#import "WOCBuyingWizardPaymentCenterViewController.h" +#import "WOCBuyingWizardInputAmountViewController.h" +#import "WOCConstants.h" +#import "BRAppDelegate.h" +#import "BRRootViewController.h" +#import "MBProgressHUD.h" +#import "APIManager.h" +#import "WOCAlertController.h" + +@interface WOCBuyingWizardHomeViewController () + +@property (strong, nonatomic) NSString *zipCode; + +@end + +@implementation WOCBuyingWizardHomeViewController + +- (void)viewDidLoad { + + self.isBackButtonRequire = YES; + + [super viewDidLoad]; + + [self.defaults removeObjectForKey:WOCUserDefaultsLocalLocationLatitude]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalLocationLongitude]; + + [[NSNotificationCenter defaultCenter] removeObserver:WOCNotificationObserverNameBuyDashStep1]; + [[NSNotificationCenter defaultCenter] removeObserver:WOCNotificationObserverNameBuyDashStep2]; + [[NSNotificationCenter defaultCenter] removeObserver:WOCNotificationObserverNameBuyDashStep4]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setLogoutButton) name:WOCNotificationObserverNameBuyDashStep1 object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(openBuyDashStep2) name:WOCNotificationObserverNameBuyDashStep2 object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(findZipCode) name:WOCNotificationObserverNameBuyDashStep4 object:nil]; + + [self setShadowOnButton:self.locationButton]; + [self setShadowOnButton:self.noThanksButton]; + [self setButtonColor:self.locationButton]; + self.informationLable.textColor = WOCTHEMECOLOR; + [self.orderListButton setTitleColor:WOCTHEMECOLOR forState:UIControlStateNormal]; + [self.orderListButton setTitleColor:WOCTHEMECOLOR forState:UIControlStateSelected]; +} + +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + [self setLogoutButton]; +} + +- (void) viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; + [self.locationButton setUserInteractionEnabled:YES]; +} + +- (void) setLogoutButton { + + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + NSString *loginPhone = [NSString stringWithFormat:@"Your wallet is signed into Wall of Coins using your mobile number %@",phoneNo]; + self.descriptionLabel.text = loginPhone; + [self.signoutButton setTitle:@"SIGN OUT" forState:UIControlStateNormal]; + [self.signoutView setHidden:NO]; + [self.orderListButton setHidden:NO]; + } + else { + NSString *loginPhone = [NSString stringWithFormat:@"Do you already have an order?"]; + self.descriptionLabel.text = loginPhone; + [self.signoutButton setTitle:@"SIGN IN HERE" forState:UIControlStateNormal]; + [self.orderListButton setHidden:YES]; + [self.signoutView setHidden:NO]; + } + + [self setShadowOnButton:self.signoutButton]; + [self setShadowOnButton:self.orderListButton]; +} + +- (void) openBuyDashStep2 { + [self push:@"WOCBuyingWizardZipCodeViewController"]; +} + +- (void) openBuyDashStep3 { + [self push:@"WOCBuyingWizardPaymentCenterViewController"]; +} + +- (void) openBuyDashStep4 { + WOCBuyingWizardInputAmountViewController *inputAmountViewController = (WOCBuyingWizardInputAmountViewController*)[self getViewController:@"WOCBuyingWizardInputAmountViewController"]; + inputAmountViewController.zipCode = self.zipCode; + [self pushViewController:inputAmountViewController animated:YES]; +} + +- (void)back:(id)sender { + [self backToRoot]; +} + +- (void)showAlert { + + UIAlertController *alert = [UIAlertController alertControllerWithTitle:ALERT_TITLE message:@"Are you in the USA?" preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + [self refereshToken]; + [self openBuyDashStep2]; + }]; + + UIAlertAction *noAction = [UIAlertAction actionWithTitle:@"No" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + [self refereshToken]; + [self openBuyDashStep3]; + + }]; + + [alert addAction:yesAction]; + [alert addAction:noAction]; + + [self presentViewController:alert animated:YES completion:nil]; +} + +- (void)findZipCode { + + [self.locationButton setUserInteractionEnabled:YES]; + + // Your location from latitude and longitude + NSString *latitude = [self.defaults valueForKey:WOCUserDefaultsLocalLocationLatitude]; + NSString *longitude = [self.defaults valueForKey:WOCUserDefaultsLocalLocationLongitude]; + + if (latitude != nil && longitude != nil) { + CLLocation *location = [[CLLocation alloc] initWithLatitude:[latitude doubleValue] longitude:[longitude doubleValue]]; + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + // Call the method to find the address + [self getAddressFromLocation:location completionHandler:^(NSMutableDictionary *placeDetail) { + dispatch_async(dispatch_get_main_queue(), ^{ + [hud hideAnimated:YES]; + }); + + APILog(@"address informations : %@", placeDetail); + APILog(@"ZIP code : %@", [placeDetail valueForKey:@"ZIP"]); + + [self.defaults setObject:[placeDetail valueForKey:WOCApiBodyCountryCode] forKey:WOCApiBodyCountryCode]; + [self.defaults synchronize]; + self.zipCode = [placeDetail valueForKey:@"ZIP"]; + [self openBuyDashStep4]; + } + failureHandler:^(NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^{ + [hud hideAnimated:YES]; + }); + [self.defaults removeObjectForKey:WOCApiBodyCountryCode]; + APILog(@"Error : %@", error); + }]; + } + else { + + [self.defaults removeObjectForKey:WOCApiBodyCountryCode]; + [[WOCLocationManager sharedInstance] startLocationService]; + } +} + +- (void)getAddressFromLocation:(CLLocation *)location completionHandler:(void (^)(NSMutableDictionary *placemark))completionHandler failureHandler:(void (^)(NSError *error))failureHandler { + + NSMutableDictionary *d = [NSMutableDictionary new]; + CLGeocoder *geocoder = [CLGeocoder new]; + [geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) { + if (failureHandler && (error || placemarks.count == 0)) { + failureHandler(error); + } + else { + CLPlacemark *placemark = [placemarks objectAtIndex:0]; + if(completionHandler) { + + completionHandler([NSMutableDictionary dictionaryWithDictionary:placemark.addressDictionary]); + } + } + }]; +} + +// MARK: - API +- (void)signOut:(NSString*)phone { + + [self signOutWOC]; +} +- (IBAction)onOrderListClick:(id)sender { + + [self getOrderList]; +} + +// MARK: - IBAction +- (IBAction)onBackButtonClick:(id)sender { + dispatch_async(dispatch_get_main_queue(), ^{ + [self.navigationController popViewControllerAnimated:YES]; + [self.navigationController.navigationBar setHidden:NO]; + }); +} + +- (IBAction)onFindLocationButtonClick:(id)sender { + + [self refereshToken]; + [self.defaults removeObjectForKey:WOCApiBodyCountryCode]; + [self.defaults synchronize]; + if ([[WOCLocationManager sharedInstance] locationServiceEnabled]) { + [self findZipCode]; + [self.locationButton setUserInteractionEnabled:NO]; + } + else { + // Enable Location services + [[WOCLocationManager sharedInstance] startLocationService]; + [self.locationButton setUserInteractionEnabled:NO]; + } +} + +- (IBAction)noThanksButtonClick:(id)sender { + [self.defaults removeObjectForKey:WOCApiBodyCountryCode]; + [self.defaults synchronize]; + [self showAlert]; +} + +- (IBAction)onSignOutButtonClick:(id)sender { + + UIButton * btn = (UIButton*) sender; + if (btn != nil) { + if ([btn.titleLabel.text isEqualToString:@"SIGN IN HERE"]) { + [self push:@"WOCSignInViewController"]; + } + else { + [self signOutWOC]; + } + } + [self performSelector:@selector(setLogoutButton) withObject:nil afterDelay:1.0]; +} +@end diff --git a/PivxWallet/Wallofcoins/WOCBuyingWizardInputAmountViewController.h b/PivxWallet/Wallofcoins/WOCBuyingWizardInputAmountViewController.h new file mode 100644 index 00000000..ae8b856a --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCBuyingWizardInputAmountViewController.h @@ -0,0 +1,28 @@ +// +// WOCBuyingWizardInputAmountViewController.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" +//WOCBuyingWizardInputAmountViewController +// Get Offer with Amount +@interface WOCBuyingWizardInputAmountViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *bankId; +@property (strong, nonatomic) NSString *zipCode; + +@property (weak, nonatomic) IBOutlet UITextField *dashTextField; +@property (weak, nonatomic) IBOutlet UITextField *dollarTextField; +@property (weak, nonatomic) IBOutlet UIView *line1View; +@property (weak, nonatomic) IBOutlet UIView *line2View; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *line1HeightConstant; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *line2HeightConstant; +@property (weak, nonatomic) IBOutlet UIButton *offerButton; + +- (IBAction)onGetOffersButtonClick:(id)sender; + +@end diff --git a/PivxWallet/Wallofcoins/WOCBuyingWizardInputAmountViewController.m b/PivxWallet/Wallofcoins/WOCBuyingWizardInputAmountViewController.m new file mode 100644 index 00000000..4b697c33 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCBuyingWizardInputAmountViewController.m @@ -0,0 +1,178 @@ +// +// WOCBuyingWizardInputAmountViewController.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCBuyingWizardInputAmountViewController.h" +#import "WOCBuyingWizardOfferListViewController.h" +#import "WOCConstants.h" +#import "APIManager.h" +#import "WOCLocationManager.h" +#import +#import "BRWalletManager.h" +#import "WOCAlertController.h" +#import "BRAppDelegate.h" + + +static const int dashTextFieldTag = 101; +static const int dollarTextFieldTag = 102; + +@interface WOCBuyingWizardInputAmountViewController () + +@end + +@implementation WOCBuyingWizardInputAmountViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + [self setShadowOnButton:self.offerButton]; + self.dashTextField.text = [NSString stringWithFormat:@"to acquire %@ (%@) (1,000,000 %@ = 1 %@)",WOCCurrency,WOCCurrencySymbol,WOCCurrencyMinorSpecial,WOCCurrencySpecial]; + self.dashTextField.delegate = self; + self.dollarTextField.delegate = self; + [self.dashTextField setUserInteractionEnabled:NO]; + self.line1HeightConstant.constant = 1; + self.line2HeightConstant.constant = 2; + [self.dollarTextField becomeFirstResponder]; +} + +// MARK: - IBAction + +- (IBAction)onGetOffersButtonClick:(id)sender { + + NSString *dollarString = [self.dollarTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + + if ([dollarString length] > 0 && [dollarString intValue] != 0) { + if ([dollarString intValue] >= 5) { + if ([dollarString intValue] <10000000) { + if ((self.zipCode != nil && [self.zipCode length] > 0) || (self.bankId != nil && [self.bankId length] > 0)) { + if ([self.bankId length] > 0) { + [self sendUserData:dollarString zipCode:@"" bankId:self.bankId]; + } + else if ([self.zipCode length] > 0) { + [self sendUserData:dollarString zipCode:self.zipCode bankId:@""]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"zipCode or bankId is empty." viewController:self.navigationController.visibleViewController]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Amount must be less than $100000." viewController:self.navigationController.visibleViewController]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Amount must be more than $5." viewController:self.navigationController.visibleViewController]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Enter amount." viewController:self.navigationController.visibleViewController]; + } +} + +// MARK: - API +- (void)sendUserData:(NSString*)amount zipCode:(NSString*)zipCode bankId:(NSString*)bankId { + + if (self.dashTextField != nil) { + [self.dashTextField resignFirstResponder]; + } + if (self.dollarTextField != nil) { + [self.dollarTextField resignFirstResponder]; + } + + BRWalletManager *manager = [BRWalletManager sharedInstance]; + NSString *cryptoAddress = manager.wallet.receiveAddress; + APILog(@"cryptoAddress = %@",cryptoAddress); + + NSDictionary *params = @{ + WOCApiBodyCryptoAmount: @"0", + WOCApiBodyUsdAmount: amount, + WOCApiBodyCrypto: WOCCryptoCurrency, + WOCApiBodyCryptoAddress:cryptoAddress, + WOCApiBodyJsonParameter: @"YES" + }; + + //Receive Crypto Currency Address... + NSString *latitude = [self.defaults valueForKey:WOCUserDefaultsLocalLocationLatitude]; + NSString *longitude = [self.defaults valueForKey:WOCUserDefaultsLocalLocationLongitude]; + + if (latitude == nil && longitude == nil) { + latitude = @""; + longitude = @""; + } + + if (latitude.length > 0 && longitude.length > 0) { + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:params]; + [dict setObject:@{WOCApiBodyLatitude:latitude , + WOCApiBodyLongitude:longitude } forKey:WOCApiBodyBrowserLocation]; + params = (NSDictionary*)dict; + } + + if (zipCode != nil && zipCode.length > 0) { + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:params]; + [dict setObject:zipCode forKey:WOCApiBodyZipCode]; + params = (NSDictionary*)dict; + } + + if (bankId != nil && bankId.length > 0) { + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:params]; + [dict setObject:bankId forKey:WOCApiBodyBank]; + params = (NSDictionary*)dict; + } + + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:params]; + + if (bankId == nil || bankId.length == 0) { + NSString *countryCodeFromLatLong = [self.defaults objectForKey:WOCApiBodyCountryCode]; + + if (countryCodeFromLatLong == nil) { + NSString *countryCode = [[NSLocale currentLocale] objectForKey: NSLocaleCountryCode]; + [dict setObject:countryCode.lowercaseString forKey:WOCApiBodyCountry]; + } + else { + [dict setObject:countryCodeFromLatLong.lowercaseString forKey:WOCApiBodyCountry]; + } + } + //[dict setObject:@"us" forKey:WOCApiBodyCountry]; + + params = (NSDictionary*)dict; + + [[APIManager sharedInstance] discoverInfo:params response:^(id responseDict, NSError *error) { + if (error == nil) { + NSDictionary *dictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + + if ([dictionary valueForKey:@"id"] != nil) { + WOCBuyingWizardOfferListViewController *offerListViewController = (WOCBuyingWizardOfferListViewController*)[self getViewController:@"WOCBuyingWizardOfferListViewController"];; + offerListViewController.discoveryId = [NSString stringWithFormat:@"%@",[dictionary valueForKey:@"id"]]; + offerListViewController.amount = self.dollarTextField.text; + [self pushViewController:offerListViewController animated:YES]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Error in getting offers. Please try after some time." viewController:self.navigationController.visibleViewController]; + } + } + else { + + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + }]; +} + +// MARK: - UITextField Delegates + +- (void)textFieldDidBeginEditing:(UITextField *)textField { + + if (textField.tag == dashTextFieldTag) { + self.line1HeightConstant.constant = 2; + self.line2HeightConstant.constant = 1; + } + else { + self.line1HeightConstant.constant = 1; + self.line2HeightConstant.constant = 2; + } +} + +@end + diff --git a/PivxWallet/Wallofcoins/WOCBuyingWizardInputEmailViewController.h b/PivxWallet/Wallofcoins/WOCBuyingWizardInputEmailViewController.h new file mode 100644 index 00000000..2421116b --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCBuyingWizardInputEmailViewController.h @@ -0,0 +1,24 @@ +// +// WOCBuyingWizardInputEmailViewController.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" +//WOCBuyingWizardInputEmailViewController +// Enter Email Address Screen +@interface WOCBuyingWizardInputEmailViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *offerId; + +@property (weak, nonatomic) IBOutlet UIButton *nextButton; +@property (weak, nonatomic) IBOutlet UITextField *emailTextField; + +- (IBAction)onDoNotSendMeEmailButtonClicked:(id)sender; +- (IBAction)onNextButtonClicked:(id)sender; +@property (weak, nonatomic) IBOutlet UIButton *doNotSendEmailButton; + +@end diff --git a/PivxWallet/Wallofcoins/WOCBuyingWizardInputEmailViewController.m b/PivxWallet/Wallofcoins/WOCBuyingWizardInputEmailViewController.m new file mode 100644 index 00000000..dddf3629 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCBuyingWizardInputEmailViewController.m @@ -0,0 +1,66 @@ +// +// WOCBuyingWizardInputEmailViewController.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCBuyingWizardInputEmailViewController.h" +#import "WOCBuyingWizardInputPhoneNumberViewController.h" +#import "WOCAlertController.h" +#import "WOCConstants.h" + +@interface WOCBuyingWizardInputEmailViewController () + +@end + +@implementation WOCBuyingWizardInputEmailViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + [self setShadowOnButton:self.nextButton]; + [self.doNotSendEmailButton setTitleColor:WOCTHEMECOLOR forState:UIControlStateNormal]; +} + +- (BOOL)validateEmailWithString:(NSString*)checkString { + + BOOL stricterFilter = NO; // Discussion http://blog.logichigh.com/2010/09/02/validating-an-e-mail-address/ + NSString *stricterFilterString = @"[A-Z0-9a-z\\._%+-]+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2,4}"; + NSString *laxString = @".+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2}[A-Za-z]*"; + NSString *emailRegex = stricterFilter ? stricterFilterString : laxString; + NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex]; + return [emailTest evaluateWithObject:checkString]; +} + +// MARK: - IBAction + +- (IBAction)onDoNotSendMeEmailButtonClicked:(id)sender { + WOCBuyingWizardInputPhoneNumberViewController *inputPhoneNumberViewController = [self getViewController:@"WOCBuyingWizardInputPhoneNumberViewController"]; + inputPhoneNumberViewController.offerId = self.offerId; + inputPhoneNumberViewController.emailId = @""; + [self pushViewController:inputPhoneNumberViewController animated:YES]; +} + +- (IBAction)onNextButtonClicked:(id)sender { + + NSString *emailStr = [self.emailTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + + if ([emailStr length] == 0) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter email." viewController:self.navigationController.visibleViewController]; + } + else if (![self validateEmailWithString:emailStr]) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter valid email." viewController:self.navigationController.visibleViewController]; + } + else { + + WOCBuyingWizardInputPhoneNumberViewController *inputPhoneNumberViewController = [self getViewController:@"WOCBuyingWizardInputPhoneNumberViewController"]; + inputPhoneNumberViewController.offerId = self.offerId; + inputPhoneNumberViewController.emailId = emailStr; + [self pushViewController:inputPhoneNumberViewController animated:YES]; + } +} + +@end + diff --git a/PivxWallet/Wallofcoins/WOCBuyingWizardInputPhoneNumberViewController.h b/PivxWallet/Wallofcoins/WOCBuyingWizardInputPhoneNumberViewController.h new file mode 100644 index 00000000..aae21e82 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCBuyingWizardInputPhoneNumberViewController.h @@ -0,0 +1,25 @@ +// +// WOCBuyingWizardInputPhoneNumberViewController.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" +//WOCBuyingWizardInputPhoneNumberViewController +// Enter Phone Number Screen +@interface WOCBuyingWizardInputPhoneNumberViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *offerId; +@property (strong, nonatomic) NSString *emailId; +@property (assign, nonatomic) BOOL isActiveHoldChecked; +@property (assign, nonatomic) BOOL isForLoginOny; +@property (weak, nonatomic) IBOutlet UIButton *nextButton; +@property (weak, nonatomic) IBOutlet UITextField *countryCodeTextField; +@property (weak, nonatomic) IBOutlet UITextField *phoneNumberTextField; + +- (IBAction)onNextButtonClicked:(id)sender; + +@end diff --git a/PivxWallet/Wallofcoins/WOCBuyingWizardInputPhoneNumberViewController.m b/PivxWallet/Wallofcoins/WOCBuyingWizardInputPhoneNumberViewController.m new file mode 100644 index 00000000..74d33599 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCBuyingWizardInputPhoneNumberViewController.m @@ -0,0 +1,546 @@ +// +// WOCBuyingWizardInputPhoneNumberViewController.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCBuyingWizardInputPhoneNumberViewController.h" +#import "WOCBuyingWizardInputVarificationCodeViewController.h" +#import "WOCBuyingInstructionsViewController.h" +#import "WOCBuyingSummaryViewController.h" +#import "WOCPasswordViewController.h" +#import "BRRootViewController.h" +#import "BRAppDelegate.h" +#import "APIManager.h" +#import "WOCConstants.h" +#import "WOCAlertController.h" +#import "MBProgressHUD.h" +#import "WOCHoldIssueViewController.h" +#import "WOCBuyingWizardHomeViewController.h" + +@interface WOCBuyingWizardInputPhoneNumberViewController () + +@property (strong, nonatomic) NSArray *countries; +@property (strong, nonatomic) UIPickerView *pickerView; +@property (strong, nonatomic) NSString *countryCode; +@property (strong, nonatomic) NSString *purchaseCode; +@property (strong, nonatomic) NSString *holdId; + +@end + +@implementation WOCBuyingWizardInputPhoneNumberViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + [self setShadowOnButton:self.nextButton]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(openBuyDashStep8:) name:WOCNotificationObserverNameBuyDashStep8 object:nil]; + + self.pickerView = [[UIPickerView alloc] init]; + self.pickerView.delegate = self; + self.pickerView.dataSource = self; + self.countryCodeTextField.inputView = self.pickerView; + + [self loadJSON]; +} + +- (void)loadJSON { + // Retrieve local JSON file called example.json + NSString *filePath = [[NSBundle mainBundle] pathForResource:@"countries" ofType:@"json"]; + + // Load the file into an NSData object called JSONData + NSError *error = nil; + NSData *JSONData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:&error]; + + // Create an Objective-C object from JSON Data + NSDictionary *countriesDict = [NSJSONSerialization JSONObjectWithData:JSONData options:NSJSONReadingMutableContainers error:nil]; + NSArray *countries = [countriesDict valueForKey:@"countries"]; + + self.countries = countries; + if (self.countries.count > 0) { + self.countryCodeTextField.text = [NSString stringWithFormat:@"%@ (%@)",self.countries[0][@"name"],self.countries[0][@"code"]]; + self.countryCode = [NSString stringWithFormat:@"%@",self.countries[0][@"code"]]; + } + + [self.pickerView reloadAllComponents]; +} + +- (void)openBuyDashStep8:(NSNotification*)notification { + + NSString *phoneNo = [NSString stringWithFormat:@"%@",notification.object]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + + [self createHoldAfterAuthorize:phoneNo]; +} + +// MARK: - API + +- (void)checkPhone:(NSString*)phone code:(NSString*)countryCode { + + NSDictionary *params = @{ + }; + + NSString *phoneNo = [NSString stringWithFormat:@"%@%@",countryCode,phone]; + + [[APIManager sharedInstance] authorizeDevice:nil phone:phoneNo response:^(id responseDict, NSError *error) { + + if (error == nil) { + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + + if ([[responseDictionary valueForKey:@"availableAuthSources"] isKindOfClass:[NSArray class]]) { + NSArray *availableAuthSource = (NSArray*)[responseDictionary valueForKey:@"availableAuthSources"]; + if (availableAuthSource.count > 0) { + if ([[availableAuthSource objectAtIndex:0] isEqualToString:@"password"]) { + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:WOCBuyingStoryboard bundle:nil]; + WOCPasswordViewController *passwordViewController = [storyboard instantiateViewControllerWithIdentifier:@"WOCPasswordViewController"]; + passwordViewController.phoneNo = phoneNo; + passwordViewController.modalTransitionStyle = UIModalPresentationOverCurrentContext; + [self.navigationController presentViewController:passwordViewController animated:YES completion:nil]; + } + else if ([[availableAuthSource objectAtIndex:0] isEqualToString:@"device"]) { + [self createHoldAfterAuthorize:phoneNo]; + } + } + } + } + else { + + if ([error code] == 404) { + //new number + [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + + [self createHold:phoneNo]; + } + else { + dispatch_async(dispatch_get_main_queue(), ^{ + if (error.userInfo != nil) { + if (error.userInfo[@"detail"] != nil) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self.navigationController.visibleViewController]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + }); + } + } + }]; +} + +- (void)login:(NSString*)phoneNo { + + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + NSString *deviceId = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceId]; + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *params = @{ + WOCApiBodyDeviceCode: deviceCode + }; + + if (deviceId != nil) { + + params = @{ + WOCApiBodyDeviceCode: deviceCode, + WOCApiBodyDeviceId: deviceId, + WOCApiBodyJsonParameter: @"YES" + }; + + [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDict, NSError *error) { + + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + if (error == nil) { + if (responseDictionary != nil) { + [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self storeDeviceInfoLocally]; + [self createHoldAfterAuthorize:phoneNo]; + } + } + else { + [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + + BOOL isNewPhone = YES; + if (error.code == 400) { + if (error.userInfo != nil) { + NSString *errorDetail = error.userInfo[@"detail"]; + if (errorDetail != nil) { + if ([errorDetail isEqualToString:@"Unable to authorize your phone number. Password may be incorrect."]) { + isNewPhone = NO; + } + } + } + } + if (isNewPhone) { + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + [self createHoldAfterAuthorize:phoneNo]; + } + else { + [self openHoldIssueVC]; + } + } + }]; + } +} + +- (void)createHold:(NSString*)phoneNo { + + __block MBProgressHUD *hud; + if (!self.isForLoginOny) { + dispatch_async(dispatch_get_main_queue(), ^(void) { + hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + }); + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *params; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + params = @{ + WOCApiBodyOffer: [NSString stringWithFormat:@"%@==",self.offerId], + WOCApiBodyJsonParameter:@"YES" + }; + } + else { + params = @{ + WOCApiBodyOffer: [NSString stringWithFormat:@"%@==",self.offerId], + WOCApiBodyPhoneNumber: phoneNo, + WOCApiBodyDeviceName: WOCApiBodyDeviceName_IOS, + WOCApiBodyDeviceCode: deviceCode, + WOCApiBodyJsonParameter:@"YES" + }; + + if (self.emailId != nil && self.emailId.length > 0) { + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:params]; + [dict setObject:self.emailId forKey:WOCApiBodyEmail]; + params = (NSDictionary*)dict; + } + } + + [[APIManager sharedInstance] createHold:params response:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^(void) { + [hud hideAnimated:YES]; + }); + + if (error == nil) { + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + if ([responseDictionary valueForKey:WOCApiResponseToken] != nil && (![[responseDictionary valueForKey:WOCApiResponseToken] isEqualToString:@"(null)"])) { + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiResponseToken]] forKey:WOCUserDefaultsAuthToken]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self storeDeviceInfoLocally]; + } + + NSString *holdId = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([responseDictionary valueForKey:WOCApiResponseId])]; + self.holdId = holdId; + + NSString *purchaseCode = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([responseDictionary valueForKey:WOCApiResponsePurchaseCde])]; + if (![purchaseCode isKindOfClass:[NSNull class]]) { + self.purchaseCode = purchaseCode; + } + else { + self.purchaseCode = @""; + } + + WOCBuyingWizardInputVarificationCodeViewController *inputVarificationCodeViewController = [self getViewController:@"WOCBuyingWizardInputVarificationCodeViewController"]; + inputVarificationCodeViewController.phoneNo = phoneNo; + inputVarificationCodeViewController.offerId = self.offerId; + inputVarificationCodeViewController.purchaseCode = self.purchaseCode; + inputVarificationCodeViewController.deviceCode = deviceCode; + inputVarificationCodeViewController.emailId = self.emailId; + inputVarificationCodeViewController.holdId = self.holdId; + [self pushViewController:inputVarificationCodeViewController animated:YES]; + } + else if (error.code == 403 ) { + [self resolveActiveHoldIssue:phoneNo]; + } + else if (error.code == 401 ) { + [self registerDevice:phoneNo]; + } + }]; + } + else { + + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + if (token != nil && (![token isEqualToString:@"(null)"])) { + [self getOrderList]; + } + else { + + UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Error" message:@"Please select an offer and then try to register/login with app." preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + [self backToMainView]; + }]; + + [alert addAction:okAction]; + [self presentViewController:alert animated:YES completion:nil]; + + } + } +} + +- (void)resolveActiveHoldIssue:(NSString*)phoneNo { + + if (!self.isActiveHoldChecked) { + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + if (token != nil && (![token isEqualToString:@"(null)"])) { + /*you receive Status 403 from POST /api/v1/holds/ + IF YOU HAVE a token or the deviceId/deviceCode, login with that device -- you will use the token to get a list of holds so that you can cancel the holds. IF THERE ARE NO HOLDS, then you will bring the user to the Buy Summary, where they will see their latest WD orders. + */ + self.isActiveHoldChecked = YES; + [self getHold]; + } + else { + NSString *deviceID = [self getDeviceIDFromPhoneNumber:phoneNo]; + if (deviceID.length > 0 && (![deviceID isEqualToString:@"(null)"])) { + [self.defaults setObject:deviceID forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self login:phoneNo]; + } + else { + [self openHoldIssueVC]; + } + } + } +} + +- (void)openHoldIssueVC { + /* + IF YOU DO NOT HAVE the token or deviceId/deviceCode in local storage, then you will need to show a new view that says, "You already have an open hold or a pending order with Wall of Coins. Before you can create a new order, you must finish these orders." and then show a yellow button w/ blue text (just like the "BUY MORE {Crypto Currency} WITH CASH" button), and when they press that button, you will bring them to this website link: + https://wallofcoins.com/signin/1-2397776832/ + https://wallofcoins.com/signin/{phone_country_code}-{local_phone_number}/ + */ + NSString *txtPhone = [self.phoneNumberTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + NSString *txtcountryCode = [self.countryCode stringByReplacingOccurrencesOfString:@"+" withString:@""]; + WOCHoldIssueViewController *aViewController = [self getViewController:@"WOCHoldIssueViewController"]; + aViewController.phoneNo = [NSString stringWithFormat:@"%@-%@",txtcountryCode,txtPhone]; + [self pushViewController:aViewController animated:YES]; +} + +- (void)resolvePandingOrderIssue { + + [self getOrderList]; +} + +- (void)getHold { + + [[APIManager sharedInstance] getHold:^(id responseDict, NSError *error) { + if (error == nil) { + APILog(@"Hold with Hold Id: %@.",responseDict); + if ([responseDict isKindOfClass:[NSArray class]]) { + NSArray *holdArray = (NSArray*)responseDict; + if (holdArray.count > 0) { + NSUInteger count = holdArray.count; + NSUInteger activeHodCount = 0; + + for (int i = 0; i < holdArray.count; i++) { + count -= count; + + NSDictionary *holdDict = [holdArray objectAtIndex:i]; + NSString *holdId = [holdDict valueForKey:WOCApiResponseId]; + NSString *holdStatus = [holdDict valueForKey:WOCApiResponseHoldsStatus]; + + if (holdStatus != nil) { + if ([holdStatus isEqualToString:@"AC"]) { + if (holdId) { + activeHodCount = activeHodCount + 1; + [self deleteHold:holdId count:count]; + } + } + } + else { + if (holdId) { + activeHodCount = activeHodCount + 1; + [self deleteHold:holdId count:count]; + } + } + } + + if (activeHodCount == 0 ) { + [self resolvePandingOrderIssue]; + } + } + else { + [self resolvePandingOrderIssue]; + } + } + else { + [self resolvePandingOrderIssue]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + }]; +} + +- (void)deleteHold:(NSString*)holdId count:(NSUInteger)count { + + NSDictionary *params = @{ + }; + + [[APIManager sharedInstance] deleteHold:holdId response:^(id responseDict, NSError *error) { + if (error == nil) { + APILog(@"Hold deleted."); + + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + [self createHoldAfterAuthorize:phoneNo]; + } + }]; +} + +- (void)registerDevice:(NSString*)phoneNo { + + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *params = @{ + WOCApiBodyName: WOCApiBodyDeviceName_IOS, + WOCApiBodyCode: deviceCode, + WOCApiBodyJsonParameter:@"YES" + }; + + [[APIManager sharedInstance] registerDevice:params response:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^(void) { + [hud hideAnimated:YES]; + }); + + if (error == nil) { + NSDictionary *response = (NSDictionary*)responseDict; + if (response.count > 0) { + NSString *deviceId = [NSString stringWithFormat:@"%@",[response valueForKey:WOCApiResponseId]]; + [self authorize:phoneNo deviceId:deviceId]; + } + } + else { + + [self pushToStep1]; + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + }]; +} + +- (void)authorize:(NSString*)phoneNo deviceId:(NSString*)deviceId { + + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *params = @{ + WOCApiBodyDeviceCode: deviceCode, + WOCApiBodyJsonParameter: @"YES" + }; + + if (deviceId != nil && (![deviceId isEqualToString:@"(null)"])) { + params = @{ + WOCApiBodyDeviceCode: deviceCode, + WOCApiBodyDeviceId: deviceId, + WOCApiBodyJsonParameter: @"YES" + }; + } + + [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDict, NSError *error) { + if (error == nil) { + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self storeDeviceInfoLocally]; + [self createHoldAfterAuthorize:phoneNo]; + } + else { + [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + }]; +} + +- (void)createHoldAfterAuthorize:(NSString*)phoneNo { + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + + [self createHold:phoneNo]; + } + else { + NSString *deviceID = [self getDeviceIDFromPhoneNumber:phoneNo]; + if (deviceID != nil) { + [self.defaults setObject:deviceID forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self login:phoneNo]; + } + else { + [self createHold:phoneNo]; + } + } +} + +// MARK: - IBAction +- (IBAction)onNextButtonClicked:(id)sender { + + NSString *txtPhone = [self.phoneNumberTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + + if ([self.countryCode length] == 0) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Select country code." viewController:self.navigationController.visibleViewController]; + } + else if ([txtPhone length] == 0) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter phone number." viewController:self.navigationController.visibleViewController]; + } + else if ([txtPhone length] == 10) { + self.isActiveHoldChecked = NO; + [self checkPhone:txtPhone code:self.countryCode]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter valid phone number." viewController:self.navigationController.visibleViewController]; + } +} + +// MARK: - UIPickerView Delegates + +- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView { + return 1; +} + +- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component { + return self.countries.count; +} + +- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { + return [NSString stringWithFormat:@"%@ (%@)",self.countries[row][@"name"],self.countries[row][@"code"]]; +} + +- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { + self.countryCodeTextField.text = [NSString stringWithFormat:@"%@ (%@)",self.countries[row][@"name"],self.countries[row][@"code"]]; + self.countryCode = [NSString stringWithFormat:@"%@",self.countries[row][@"code"]]; +} + +- (void)pushToStep1 { + [self storeDeviceInfoLocally]; + [self backToMainView]; +} + +@end + diff --git a/PivxWallet/Wallofcoins/WOCBuyingWizardInputVarificationCodeViewController.h b/PivxWallet/Wallofcoins/WOCBuyingWizardInputVarificationCodeViewController.h new file mode 100644 index 00000000..cdb7cf70 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCBuyingWizardInputVarificationCodeViewController.h @@ -0,0 +1,27 @@ +// +// WOCBuyingWizardInputVarificationCodeViewController.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" +//WOCBuyingWizardInputVarificationCodeViewController + +@interface WOCBuyingWizardInputVarificationCodeViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *purchaseCode; +@property (strong, nonatomic) NSString *offerId; +@property (strong, nonatomic) NSString *holdId; +@property (strong, nonatomic) NSString *phoneNo; +@property (strong, nonatomic) NSString *emailId; +@property (strong, nonatomic) NSString *deviceCode; + +@property (weak, nonatomic) IBOutlet UITextField *purchaseCodeTextField; +@property (weak, nonatomic) IBOutlet UIButton *purchaseCodeButton; + +- (IBAction)onConfirmPurchaseCodeButtonClick:(id)sender; + +@end diff --git a/PivxWallet/Wallofcoins/WOCBuyingWizardInputVarificationCodeViewController.m b/PivxWallet/Wallofcoins/WOCBuyingWizardInputVarificationCodeViewController.m new file mode 100644 index 00000000..c4ed6c59 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCBuyingWizardInputVarificationCodeViewController.m @@ -0,0 +1,68 @@ +// +// WOCBuyingWizardInputVarificationCodeViewController.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCBuyingWizardInputVarificationCodeViewController.h" +#import "WOCBuyingInstructionsViewController.h" +#import "WOCBuyingSummaryViewController.h" +#import "APIManager.h" +#import "WOCConstants.h" +#import "WOCAlertController.h" +#import "BRRootViewController.h" +#import "BRAppDelegate.h" +#import "MBProgressHUD.h" + +@interface WOCBuyingWizardInputVarificationCodeViewController () + +@end + +@implementation WOCBuyingWizardInputVarificationCodeViewController + +- (void)viewDidLoad { + + [super viewDidLoad]; + + [self setShadowOnButton:self.purchaseCodeButton]; + + if (self.purchaseCode != nil) { + self.purchaseCodeTextField.text = REMOVE_NULL_VALUE(self.purchaseCode); + } + else { + self.purchaseCodeTextField.text = @""; + } + self.purchaseCodeTextField.delegate = self; +} + +- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { + + if(textField.text.length == 4 && string.length == 1) { + [self performSelector:@selector(onConfirmPurchaseCodeButtonClick:) withObject:self afterDelay:1.0]; + } + return YES; +} + +// MARK: - IBAction + +- (IBAction)onConfirmPurchaseCodeButtonClick:(id)sender { + + NSString *txtCode = [self.purchaseCodeTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + if ([txtCode length] == 5) { + WOCBuyingInstructionsViewController *buyingInstructionsViewController = [self getViewController:@"WOCBuyingInstructionsViewController"]; + buyingInstructionsViewController.purchaseCode = txtCode; + buyingInstructionsViewController.holdId = self.holdId; + buyingInstructionsViewController.phoneNo = self.phoneNo; + [self pushViewController:buyingInstructionsViewController animated:YES]; + } + else if ([txtCode length] == 0) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:@"Enter Purchase Code" viewController:self.navigationController.visibleViewController]; + } + else if ([txtCode length] != 5) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:@"Enter Valid Purchase Code" viewController:self.navigationController.visibleViewController]; + } +} +@end + diff --git a/PivxWallet/Wallofcoins/WOCBuyingWizardOfferListViewController.h b/PivxWallet/Wallofcoins/WOCBuyingWizardOfferListViewController.h new file mode 100644 index 00000000..7ee104d3 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCBuyingWizardOfferListViewController.h @@ -0,0 +1,25 @@ +// +// WOCBuyingWizardOfferListViewController.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" +//WOCBuyingWizardOfferListViewController +// Offer List ViewController +@interface WOCBuyingWizardOfferListViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *discoveryId; +@property (strong, nonatomic) NSString *amount; + +@property (weak, nonatomic) IBOutlet UILabel *instructionLabel; +@property (weak, nonatomic) IBOutlet UITableView *offerListTableView; +@property (weak, nonatomic) IBOutlet UILabel *informationLable; + +- (IBAction)onOrderButtonClicked:(id)sender; +- (NSIndexPath*)getIndexPathfromTag:(NSInteger)tag; + +@end diff --git a/PivxWallet/Wallofcoins/WOCBuyingWizardOfferListViewController.m b/PivxWallet/Wallofcoins/WOCBuyingWizardOfferListViewController.m new file mode 100644 index 00000000..ad3b95b6 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCBuyingWizardOfferListViewController.m @@ -0,0 +1,491 @@ +// +// WOCBuyingWizardOfferListViewController.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCBuyingWizardOfferListViewController.h" +#import "WOCBuyingWizardInputEmailViewController.h" +#import "WOCBuyingInstructionsViewController.h" +#import "WOCBuyingSummaryViewController.h" +#import "BRRootViewController.h" +#import "BRAppDelegate.h" +#import "WOCOfferCell.h" +#import "APIManager.h" +#import "BRWalletManager.h" +#import "WOCAlertController.h" +#import "MBProgressHUD.h" +#import "WOCBuyingWizardHomeViewController.h" +#import "WOCAsyncImageView.h" + +@interface WOCBuyingWizardOfferListViewController () + +@property (strong, nonatomic) NSArray *offers; +@property (strong, nonatomic) NSMutableDictionary *offersDict; + +@property (assign, nonatomic) BOOL incremented; +@property (assign, nonatomic) BOOL isExtendedSearch; +@end + +@implementation WOCBuyingWizardOfferListViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.instructionLabel.text = [NSString stringWithFormat:@"Below are offers for at least $%@. You must click the ORDER button before you receive instructions to pay at the Cash Payment center.",self.amount]; + [self getOffers]; + self.informationLable.textColor = WOCTHEMECOLOR; +} + +- (void)pushToStep6:(NSInteger)sender { + + NSIndexPath *indexPath = [self getIndexPathfromTag:sender]; + NSString *key = self.offersDict.allKeys[indexPath.section]; + NSArray *offerArray = self.offersDict[key]; + NSDictionary *offerDict = offerArray[indexPath.row]; + WOCBuyingWizardInputEmailViewController *inputEmailViewController = (WOCBuyingWizardInputEmailViewController*)[self getViewController:@"WOCBuyingWizardInputEmailViewController"]; + inputEmailViewController.offerId = [NSString stringWithFormat:@"%@",[offerDict valueForKey:@"id"]]; + [self pushViewController:inputEmailViewController animated:YES]; +} + +// MARK: - API + +- (void)getOffers { + + self.offersDict = [NSMutableDictionary dictionaryWithCapacity:0]; + if (self.discoveryId != nil && [self.discoveryId length] > 0) { + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + [[APIManager sharedInstance] discoveryInputs:self.discoveryId response:^(id responseDict, NSError *error) { + + dispatch_async(dispatch_get_main_queue(), ^{ + [hud hideAnimated:YES]; + }); + + if (error == nil) { + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + if ([[responseDictionary valueForKey:@"isExtendedSearch"] boolValue]) { + self.isExtendedSearch = YES; + + self.instructionLabel.text = [NSString stringWithFormat:@"Most Convenient Options While $%@ is not available, we gathered the closest options.You must click the ORDER button before you receive instructions to pay at the Cash Payment center.",self.amount]; + } + else { + self.isExtendedSearch = NO; + + if ([[responseDictionary valueForKey:@"incremented"] boolValue]) { + self.incremented = YES; + self.instructionLabel.text = [NSString stringWithFormat:@"Below are offers for at least $%@. You must click the ORDER button before you receive instructions to pay at the Cash Payment center.",self.amount]; + } + else { + self.incremented = NO; + self.instructionLabel.text = [NSString stringWithFormat:@"Below are offers for $%@. You must click the ORDER button before you receive instructions to pay at the Cash Payment center.",self.amount]; + } + } + + if ([responseDictionary valueForKey:@"singleDeposit"] != nil) { + if ([[responseDictionary valueForKey:@"singleDeposit"] isKindOfClass:[NSArray class]]) { + + NSArray *offersArray = [[NSArray alloc] initWithArray:(NSArray*)[responseDictionary valueForKey:@"singleDeposit"]]; + self.offers = [[NSArray alloc] initWithArray:offersArray]; + if (offersArray.count > 0) { + self.offersDict[@""] = offersArray; + } + } + } + + if ([responseDictionary valueForKey:@"doubleDeposit"] != nil) { + if ([[responseDictionary valueForKey:@"doubleDeposit"] isKindOfClass:[NSArray class]]) { + NSArray *offersArray = [[NSArray alloc] initWithArray:(NSArray*)[responseDictionary valueForKey:@"doubleDeposit"]]; + NSArray *doubleOffer = [self getOffersFromDoubleDeposit:offersArray]; + if (doubleOffer.count > 0) { + if (self.isExtendedSearch) { + NSString *key = [NSString stringWithFormat:@"Best Value options: more %@ for under $%@ cash.",WOCCurrency,self.amount]; + self.offersDict[key] = doubleOffer; + } + else { + NSString *key = [NSString stringWithFormat:@"Best Value options: more %@ for $%@ cash.",WOCCurrency,self.amount]; + self.offersDict[key] = doubleOffer; + } + } + } + } + + if ([responseDictionary valueForKey:@"multipleBanks"] != nil) { + if ([[responseDictionary valueForKey:@"multipleBanks"] isKindOfClass:[NSArray class]]) { + NSArray *offersArray = [[NSArray alloc] initWithArray:(NSArray*)[responseDictionary valueForKey:@"multipleBanks"]]; + NSArray *multipleBankOffer = [self getOffersFromDoubleDeposit:offersArray]; NSArray *doubleOffer = [self getOffersFromDoubleDeposit:offersArray]; + if (multipleBankOffer.count > 0) { + if (self.isExtendedSearch) { + NSString *key = [NSString stringWithFormat:@"Best Value options: more %@ for under $%@ cash from multiple banks.",WOCCurrency,self.amount]; + self.offersDict[key] = multipleBankOffer; + } + else { + NSString *key = [NSString stringWithFormat:@"Best Value options: more %@ for $%@ cash from multiple banks.",WOCCurrency,self.amount]; + self.offersDict[key] = multipleBankOffer; + } + } + } + } + + dispatch_async(dispatch_get_main_queue(), ^{ + [self.offerListTableView reloadData]; + }); + + } + else { + dispatch_async(dispatch_get_main_queue(), ^{ + if (error.userInfo != nil) { + if (error.userInfo[@"detail"] != nil) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self.navigationController.visibleViewController]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + }); + } + }]; + } +} + +- (NSArray*)getOffersFromDoubleDeposit:(NSArray*)doubleDepositOffers +{ + NSMutableArray *signleDepositOfferArray = [NSMutableArray arrayWithCapacity:0]; + for (NSDictionary *offerDictionary in doubleDepositOffers) + { + NSMutableDictionary *reviceOfferDict = [[NSMutableDictionary alloc] initWithCapacity:0]; + reviceOfferDict[@"deposit"] = @{ + @"currency": REMOVE_NULL_VALUE(offerDictionary[@"totalDeposit"][@"currency"]), + @"amount": REMOVE_NULL_VALUE(offerDictionary[@"totalDeposit"][@"amount"]) + }; + reviceOfferDict[@"id"] = offerDictionary[@"id"]; + + if (offerDictionary[@"firstOffer"] != nil) { + NSDictionary *firstOfferDict = offerDictionary[@"firstOffer"]; + + reviceOfferDict[@"crypto"] = firstOfferDict[@"crypto"]; + reviceOfferDict[@"amount"] = @{ + @"DASH" : REMOVE_NULL_VALUE(firstOfferDict[@"amount"][@"DASH"]), + @"dots" : REMOVE_NULL_VALUE(firstOfferDict[@"amount"][@"dots"]), + @"bits" : REMOVE_NULL_VALUE(firstOfferDict[@"amount"][@"bits"]), + @"BTC" : REMOVE_NULL_VALUE(firstOfferDict[@"amount"][@"BTC"]) + }; + reviceOfferDict[@"discoveryId"] = REMOVE_NULL_VALUE(firstOfferDict[@"discoveryId"]); + reviceOfferDict[@"distance"] = REMOVE_NULL_VALUE(firstOfferDict[@"distance"]); + reviceOfferDict[@"address"] = REMOVE_NULL_VALUE(firstOfferDict[@"address"] ); + reviceOfferDict[@"state"] = REMOVE_NULL_VALUE(firstOfferDict[@"state"]) ; + reviceOfferDict[@"bankName"] = REMOVE_NULL_VALUE(firstOfferDict[@"bankName"]) ; + reviceOfferDict[@"bankLogo"] = REMOVE_NULL_VALUE(firstOfferDict[@"bankLogo"]) ; + reviceOfferDict[@"bankIcon"] = REMOVE_NULL_VALUE(firstOfferDict[@"bankIcon"]) ; + reviceOfferDict[@"bankLocationUrl"] = REMOVE_NULL_VALUE(firstOfferDict[@"bankLocationUrl"]); + reviceOfferDict[@"city"] = REMOVE_NULL_VALUE(firstOfferDict[@"city"]); + + + if (offerDictionary[@"secondOffer"] != nil) { + NSDictionary *secondOffer = offerDictionary[@"secondOffer"]; + if (![REMOVE_NULL_VALUE(firstOfferDict[@"bankName"]) isEqualToString:REMOVE_NULL_VALUE(secondOffer[@"bankName"])]) { + reviceOfferDict[@"isMultipleBank"] = @YES; + reviceOfferDict[@"otherBankName"] = REMOVE_NULL_VALUE(secondOffer[@"bankName"]); + reviceOfferDict[@"otherBankLogo"] = REMOVE_NULL_VALUE(secondOffer[@"bankLogo"]); + } + + NSDictionary *amountDict = firstOfferDict[@"amount"]; + NSDictionary *secondAmountDict = offerDictionary[@"secondOffer"]; + + NSNumber *firstOfferMinorNumber = [NSNumber numberWithFloat:[NSString stringWithFormat:@"%@",[REMOVE_NULL_VALUE(firstOfferDict[@"amount"][WOCCryptoCurrencySmall]) stringByReplacingOccurrencesOfString:@"," withString:@""]].floatValue]; + + NSNumber *secondOfferMinorNumber = [NSNumber numberWithFloat:[NSString stringWithFormat:@"%@",[REMOVE_NULL_VALUE(secondOffer[@"amount"][WOCCryptoCurrencySmall]) stringByReplacingOccurrencesOfString:@"," withString:@""]].floatValue]; + + NSNumber *totoalMinorNumber = [NSNumber numberWithFloat:(firstOfferMinorNumber.longLongValue + secondOfferMinorNumber.floatValue)] ; + + NSString *totalMinorStr = [self getCryptoPrice:totoalMinorNumber]; + APILog(@"totalMinorStr = %@",totalMinorStr); + + NSNumber *firstOfferMajorNumber = [NSNumber numberWithFloat:[NSString stringWithFormat:@"%@",[REMOVE_NULL_VALUE(firstOfferDict[@"amount"][WOCCryptoCurrency]) stringByReplacingOccurrencesOfString:@"," withString:@""]].floatValue]; + + NSNumber *secondOfferMajorNumber = [NSNumber numberWithFloat:[NSString stringWithFormat:@"%@",[REMOVE_NULL_VALUE(secondOffer[@"amount"][WOCCryptoCurrency]) stringByReplacingOccurrencesOfString:@"," withString:@""]].floatValue]; + + NSNumber *totoalMajorNumber = [NSNumber numberWithFloat:(firstOfferMajorNumber.longLongValue + secondOfferMajorNumber.floatValue)] ; + + NSString *totalMajorStr = [self getCryptoPrice:totoalMajorNumber]; + APILog(@"totalMajorStr = %@",totalMajorStr); + + reviceOfferDict[@"amount"] = @{ + WOCCryptoCurrency : totalMajorStr, + WOCCryptoCurrencySmall : totalMinorStr, + @"bits" : [NSNumber numberWithFloat:([amountDict[@"bits"] floatValue] + [secondAmountDict[@"bits"] floatValue])], + @"BTC" : [NSNumber numberWithFloat:([amountDict[@"BTC"] floatValue] + [secondAmountDict[@"BTC"] floatValue])] + }; + } + + [signleDepositOfferArray addObject:reviceOfferDict]; + } + } + return (NSArray*)signleDepositOfferArray; +} + +- (void)getOrders:(NSInteger)sender { + + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + NSDictionary *params = @{ + }; + + [[APIManager sharedInstance] getOrders:nil response:^(id responseDict, NSError *error) { + + dispatch_async(dispatch_get_main_queue(), ^(void){ + [hud hideAnimated:YES]; + }); + + NSString *phoneNo = [[NSUserDefaults standardUserDefaults] valueForKey:WOCUserDefaultsLocalPhoneNumber]; + + if (error == nil) { + if ([responseDict isKindOfClass:[NSArray class]]) { + NSArray *orders = [[NSArray alloc] initWithArray:(NSArray*)responseDict]; + if (orders.count > 0) { + NSPredicate *wdvPredicate = [NSPredicate predicateWithFormat:@"status == 'WD'"]; + NSArray *wdArray = [orders filteredArrayUsingPredicate:wdvPredicate]; + + if (wdArray.count > 0) { + NSDictionary *orderDict = (NSDictionary*)[wdArray objectAtIndex:0]; + NSString *status = [NSString stringWithFormat:@"%@",[orderDict valueForKey:@"status"]]; + if ([status isEqualToString:@"WD"]) { + WOCBuyingInstructionsViewController *instructionsViewController = [self getViewController:@"WOCBuyingInstructionsViewController"]; + instructionsViewController.phoneNo = phoneNo; + instructionsViewController.isFromSend = YES; + instructionsViewController.isFromOffer = NO; + instructionsViewController.orderDict = orderDict; + [self pushViewController:instructionsViewController animated:YES]; + return ; + } + } + } + } + + WOCBuyingInstructionsViewController *buyingInstructionsViewController = [self getViewController:@"WOCBuyingInstructionsViewController"]; + buyingInstructionsViewController.phoneNo = phoneNo; + buyingInstructionsViewController.isFromSend = NO; + buyingInstructionsViewController.isFromOffer = YES; + + NSIndexPath *indexPath = [self getIndexPathfromTag:sender]; + NSString *key = self.offersDict.allKeys[indexPath.section]; + NSArray *offerArray = self.offersDict[key]; + NSDictionary *offerDict = offerArray[indexPath.row]; + + buyingInstructionsViewController.offerId = [NSString stringWithFormat:@"%@",[offerDict valueForKey:WOCApiResponseId]]; + [self pushViewController:buyingInstructionsViewController animated:YES]; + } + else { + + [self refereshToken]; + } + }]; +} + +// MARK: - IBAction + +- (IBAction)onOrderButtonClicked:(id)sender { + + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + if (token != nil && (![token isEqualToString:@"(null)"])) { + [self getOrders:[sender tag]]; + } + else { + [self pushToStep6:[sender tag]]; + } +} + +- (IBAction)checkLocationClicked:(id)sender { + + NSIndexPath *indexPath = [self getIndexPathfromTag:[sender tag]]; + NSString *key = self.offersDict.allKeys[indexPath.section]; + NSArray *offerArray = self.offersDict[key]; + NSDictionary *offerDict = offerArray[indexPath.row]; + + if (![[offerDict valueForKey:@"bankLocationUrl"] isEqual:[NSNull null]]) { + NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",[offerDict valueForKey:@"bankLocationUrl"]]]; + if ([[UIApplication sharedApplication] canOpenURL:url]) { + [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) { + APILog(@"URL opened!"); + }]; + } + } +} + +// MARK: - UITableView DataSource +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + + return self.offersDict.allKeys.count; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + + NSString *key = self.offersDict.allKeys[section]; + NSArray *offerArray = self.offersDict[key]; + return offerArray.count; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + + static const NSInteger IMAGE_VIEW_TAG = 98; + static const NSInteger OTHER_IMAGE_VIEW_TAG = 99; + NSString *cellIdentifier = @"offerCell"; + WOCOfferCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; + UIView *cellView = cell.bankImageView.superview; + + WOCAsyncImageView *imageView = (WOCAsyncImageView *)[cellView viewWithTag:IMAGE_VIEW_TAG]; + WOCAsyncImageView *otherImageView = (WOCAsyncImageView *)[cellView viewWithTag:OTHER_IMAGE_VIEW_TAG]; + + if (imageView == nil) { + imageView = [[WOCAsyncImageView alloc] initWithFrame:cell.bankImageView.frame]; + imageView.contentMode = UIViewContentModeScaleAspectFill; + imageView.clipsToBounds = YES; + imageView.image = [UIImage imageNamed:@"ic_account_balance_black"]; + imageView.tag = IMAGE_VIEW_TAG; + [cellView addSubview:imageView]; + } + + if (otherImageView == nil) { + + otherImageView = [[WOCAsyncImageView alloc] initWithFrame:cell.otherBankImageView.frame]; + otherImageView.contentMode = UIViewContentModeScaleAspectFill; + otherImageView.clipsToBounds = YES; + otherImageView.image = [UIImage imageNamed:@"ic_account_balance_black"]; + otherImageView.tag = OTHER_IMAGE_VIEW_TAG; + [cellView addSubview:otherImageView]; + otherImageView.hidden = YES; + } + + cell.bankImageView.hidden = YES; + cell.otherBankImageView.hidden = YES; + otherImageView.hidden = YES; + imageView.hidden = NO; + + //get image view + //cancel loading previous image for cell + [[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:imageView]; + [[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:otherImageView]; + + NSString *key = self.offersDict.allKeys[indexPath.section]; + NSArray *offerArray = self.offersDict[key]; + + NSDictionary *offerDict = offerArray[indexPath.row]; + if (self.incremented || self.isExtendedSearch) { + [cell.dollarLabel setHidden:NO]; + } + else { + [cell.dollarLabel setHidden:NO]; + } + + NSString *dashAmount = [NSString stringWithFormat:@"%@ %@",WOCCurrencySymbol,REMOVE_NULL_VALUE([[offerDict valueForKey:@"amount"] valueForKey:WOCCryptoCurrency])]; + NSString *bits = [NSString stringWithFormat:@"(%@ %@)",WOCCurrencySymbolMinor,REMOVE_NULL_VALUE([[offerDict valueForKey:@"amount"] valueForKey:WOCCryptoCurrencySmall])]; + NSString *dollarAmount = [NSString stringWithFormat:@"Pay $%@",REMOVE_NULL_VALUE([[offerDict valueForKey:@"deposit"] valueForKey:@"amount"])]; + NSString *bankName = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([offerDict valueForKey:@"bankName"])]; + NSString *bankAddress = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([offerDict valueForKey:@"address"])]; + NSString *bankLocationUrl = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([offerDict valueForKey:@"bankLocationUrl"])]; + NSString *bankLogo = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([offerDict valueForKey:@"bankLogo"])]; + NSString *bankIcon = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([offerDict valueForKey:@"bankIcon"])]; + NSString *otherbankLogo = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([offerDict valueForKey:@"otherBankLogo"])]; + + cell.locationLabel.font = [UIFont systemFontOfSize:12]; + cell.dashTitleLabel.text = dashAmount; + cell.dashSubTitleLabel.text = bits; + cell.dollarLabel.text = dollarAmount; + cell.bankNameLabel.text = bankName; + cell.locationLabel.text = bankAddress; + + if (bankLocationUrl.length > 0) { + [cell.locationButton setHidden:NO]; + cell.locationButton.tag = indexPath.section * 100000 + indexPath.row; + [cell.locationButton addTarget:self action:@selector(checkLocationClicked:) forControlEvents:UIControlEventTouchUpInside]; + } + + if (offerDict[@"isMultipleBank"] != nil) { + + BOOL isMultipleBank = [offerDict valueForKey:@"isMultipleBank"]; + + if (isMultipleBank) { + bankAddress = [offerDict valueForKey:@"otherBankName"]; + cell.locationLabel.font = cell.bankNameLabel.font; + } + + + if ([otherbankLogo length] > 0) { + otherImageView.hidden = NO; + //load the image + otherImageView.imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",otherbankLogo]]; + } + } + + + //bankLogo + if ([bankLogo length] > 0) { + + imageView.imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",bankLogo]]; + } + else if ([bankIcon length] > 0) { + + imageView.imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",bankIcon]]; + + cell.bankImageView.image = [UIImage imageNamed:@"ic_account_balance_black"]; + } + + cell.orderButton.tag = indexPath.section * 100000 + indexPath.row; + [cell.orderButton addTarget:self action:@selector(onOrderButtonClicked:) forControlEvents:UIControlEventTouchUpInside]; + + return cell; +} + +// MARK: - UITableView Delegate + +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { + + NSString *key = self.offersDict.allKeys[indexPath.section]; + NSArray *offerArray = self.offersDict[key]; + NSDictionary *offerDict = offerArray[indexPath.row]; + if (offerDict[@"isMultipleBank"] != nil) { + BOOL isMultipleBank = [offerDict valueForKey:@"isMultipleBank"]; + if (isMultipleBank) { + return 150.0; + } + } + return 125.0; +} + +- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { + float height = 20.0; + if (section > 0) { + height = 50.0; + } + NSString *key = self.offersDict.allKeys[section]; + UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, tableView.frame.size.width, height)]; + UILabel *lblHeader = [[UILabel alloc] initWithFrame:CGRectMake(10.0, 0.0, headerView.frame.size.width-20.0, height)]; + lblHeader.text = key; + lblHeader.numberOfLines = 2.0; + lblHeader.backgroundColor = [UIColor colorWithRed:250.0/255.0 green:250.0/255.0 blue:250.0/255.0 alpha:1.0]; + lblHeader.textAlignment = NSTextAlignmentCenter; + [headerView addSubview:lblHeader]; + return headerView; +} + +- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { + if (section > 0){ + return 50.0; + } + return 20.0; +} + +- (NSIndexPath*)getIndexPathfromTag:(NSInteger)tag { + + int row = tag % 100000; + int section = tag / 100000; + NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section]; + return indexPath; +} +@end + diff --git a/PivxWallet/Wallofcoins/WOCBuyingWizardPaymentCenterViewController.h b/PivxWallet/Wallofcoins/WOCBuyingWizardPaymentCenterViewController.h new file mode 100644 index 00000000..8090fce1 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCBuyingWizardPaymentCenterViewController.h @@ -0,0 +1,21 @@ +// +// WOCBuyingWizardPaymentCenterViewController.h +// Wallofcoins +// +// Created by Genitrust on 23/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" +//WOCBuyingWizardPaymentCenterViewController + +@interface WOCBuyingWizardPaymentCenterViewController : WOCBaseViewController + +@property (weak, nonatomic) IBOutlet UITextField *paymentCenterTextField; +@property (weak, nonatomic) IBOutlet UIButton *nextButton; +@property (weak, nonatomic) IBOutlet UILabel *informationLable; + +- (IBAction)onNextButtonClick:(id)sender; + +@end diff --git a/PivxWallet/Wallofcoins/WOCBuyingWizardPaymentCenterViewController.m b/PivxWallet/Wallofcoins/WOCBuyingWizardPaymentCenterViewController.m new file mode 100644 index 00000000..8dc29608 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCBuyingWizardPaymentCenterViewController.m @@ -0,0 +1,99 @@ +// +// WOCBuyingWizardPaymentCenterViewController.m +// Wallofcoins +// +// Created by Genitrust on 23/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCBuyingWizardPaymentCenterViewController.h" +#import "WOCBuyingWizardInputAmountViewController.h" +#import "APIManager.h" +#import "WOCAlertController.h" + +@interface WOCBuyingWizardPaymentCenterViewController () + +@property (strong, nonatomic) NSArray *paymentCenters; +@property (strong, nonatomic) UIPickerView *pickerView; +@property (strong, nonatomic) NSString *bankId; + +@end + +@implementation WOCBuyingWizardPaymentCenterViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + [self setShadowOnButton:self.nextButton]; + [self setButtonColor:self.nextButton]; + + self.pickerView = [[UIPickerView alloc] init]; + self.pickerView.delegate = self; + self.pickerView.dataSource = self; + self.paymentCenterTextField.inputView = self.pickerView; + [self getPaymentCenters]; + self.informationLable.textColor = WOCTHEMECOLOR; +} + +// MARK: - API + +- (void)getPaymentCenters { + + [[APIManager sharedInstance] getAvailablePaymentCenters:^(id responseDict, NSError *error) { + if (error == nil) { + if ([responseDict isKindOfClass:[NSArray class]]) { + NSArray *responseArray = [[NSArray alloc] initWithArray:(NSArray *)responseDict]; + NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]; + self.paymentCenters = [responseArray sortedArrayUsingDescriptors:@[sort]]; + [self.pickerView reloadAllComponents]; + } + } + }]; +} + +// MARK: - IBAction + +- (IBAction)onNextButtonClick:(id)sender { + + if ([self.bankId length] > 0) { + WOCBuyingWizardInputAmountViewController *inputAmountViewController = (WOCBuyingWizardInputAmountViewController*)[self getViewController:@"WOCBuyingWizardInputAmountViewController"];; + inputAmountViewController.bankId = self.bankId; + NSString *bankInfo = [NSString stringWithFormat:@"%@ (-%@)",self.paymentCenterTextField.text,self.bankId]; + [self.defaults setObject:bankInfo forKey:WOCUserDefaultsLocalBankInfo]; + [self.defaults synchronize]; + + [self.defaults setObject:self.paymentCenterTextField.text forKey:WOCUserDefaultsLocalBankName]; + [self.defaults synchronize]; + + [self.defaults setObject:self.bankId forKey:WOCUserDefaultsLocalBankAccount]; + [self.defaults synchronize]; + + [self pushViewController:inputAmountViewController animated:YES]; + return; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Select payment center." viewController:self.navigationController.visibleViewController]; + } +} + +// MARK: UIPickerView Delegates + +- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView { + return 1; +} + +- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component { + return self.paymentCenters.count; +} + +- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { + return self.paymentCenters[row][@"name"]; +} + +- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { + self.paymentCenterTextField.text = self.paymentCenters[row][@"name"]; + self.bankId = [NSString stringWithFormat:@"%@",self.paymentCenters[row][@"id"]]; +} + +@end + diff --git a/PivxWallet/Wallofcoins/WOCBuyingWizardZipCodeViewController.h b/PivxWallet/Wallofcoins/WOCBuyingWizardZipCodeViewController.h new file mode 100644 index 00000000..a2819a41 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCBuyingWizardZipCodeViewController.h @@ -0,0 +1,22 @@ +// +// WOCBuyingWizardZipCodeViewController.h +// Wallofcoins +// +// Created by Genitrust on 23/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" +//WOCBuyingWizardZipCodeViewController +// Enter ZipCode +@interface WOCBuyingWizardZipCodeViewController : WOCBaseViewController + +@property (weak, nonatomic) IBOutlet UITextField *zipCodeTextField; +@property (weak, nonatomic) IBOutlet UIButton *nextButton; +@property (assign, nonatomic) BOOL isZipCodeBlank; +@property (weak, nonatomic) IBOutlet UILabel *informationLable; + +- (IBAction)onNextButtonClick:(id)sender; + +@end diff --git a/PivxWallet/Wallofcoins/WOCBuyingWizardZipCodeViewController.m b/PivxWallet/Wallofcoins/WOCBuyingWizardZipCodeViewController.m new file mode 100644 index 00000000..deae6027 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCBuyingWizardZipCodeViewController.m @@ -0,0 +1,104 @@ +// +// WOCBuyingWizardZipCodeViewController.m +// Wallofcoins +// +// Created by Genitrust on 23/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCBuyingWizardZipCodeViewController.h" +#import "WOCBuyingWizardPaymentCenterViewController.h" +#import "WOCBuyingWizardInputAmountViewController.h" +#import "APIManager.h" +#import "WOCLocationManager.h" +#import +#import +#import +@interface WOCBuyingWizardZipCodeViewController () + +@end + +@implementation WOCBuyingWizardZipCodeViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + [self.navigationItem.backBarButtonItem setTitle:@""]; + [self setShadowOnButton:self.nextButton]; + [self setButtonColor:self.nextButton]; + self.informationLable.textColor = WOCTHEMECOLOR; +} + +// MARK: - IBAction + +- (IBAction)onNextButtonClick:(id)sender { + + [self.defaults removeObjectForKey:WOCApiBodyCountryCode]; + + [self.defaults synchronize]; + + NSString *zipCode = [self.zipCodeTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + + if ([zipCode length] == 0) { + [self push:@"WOCBuyingWizardPaymentCenterViewController"]; + } + else if ([zipCode length] < 5 || [zipCode length] > 6 ) { + [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Enter valid zipcode" viewController:self.navigationController.visibleViewController]; + } + else { + + [self setCountryWithZipCode:zipCode]; + + WOCBuyingWizardInputAmountViewController *viewController = (WOCBuyingWizardInputAmountViewController*)[self getViewController:@"WOCBuyingWizardInputAmountViewController"];; + viewController.zipCode = zipCode; + [self pushViewController:viewController animated:YES]; + } +} + +- (void)setCountryWithZipCode:(NSString *)zipCode { + + CLGeocoder* geoCoder = [[CLGeocoder alloc] init]; + CNMutablePostalAddress *postalAddress = [[CNMutablePostalAddress alloc] init]; + postalAddress.postalCode = zipCode; + postalAddress.country = @"us"; + postalAddress.state = @""; + if (@available(iOS 11.0, *)) { + [geoCoder geocodePostalAddress:postalAddress completionHandler:^(NSArray *placemarks, NSError *error) { + if ([placemarks count] > 0) { + CLPlacemark* placemark = [placemarks objectAtIndex:0]; + [self.defaults setObject:[placemark ISOcountryCode].lowercaseString forKey:WOCApiBodyCountryCode]; + [self.defaults synchronize]; + APILog(@"%@",[placemark description]); + APILog(@"======> country code is %@",[placemark ISOcountryCode]); + } + else { + APILog(@"Error in featching Country ="); + } + }]; + } + else { + // Fallback on earlier versions + [geoCoder geocodeAddressDictionary:@{(NSString *)kABPersonAddressZIPKey : zipCode,(NSString*)kABPersonAddressCountryCodeKey : @"us"} + completionHandler:^(NSArray *placemarks, NSError *error) { + if ([placemarks count] > 0) { + CLPlacemark* placemark = [placemarks objectAtIndex:0]; + + NSString* city = placemark.addressDictionary[(NSString*)kABPersonAddressCityKey]; + NSString* state = placemark.addressDictionary[(NSString*)kABPersonAddressStateKey]; + NSString* country = placemark.addressDictionary[(NSString*)kABPersonAddressCountryCodeKey]; + + [self.defaults setObject:country.lowercaseString forKey:WOCApiBodyCountryCode]; + [self.defaults synchronize]; + APILog(@"%@",[placemark description]); + APILog(@"======> country code is city [%@] state [%@] country [%@]",city,state,country); + + } else { + // Lookup Failed + APILog(@"Error in featching Country ="); + } + }]; + } +} + +@end + diff --git a/PivxWallet/Wallofcoins/WOCConstants.h b/PivxWallet/Wallofcoins/WOCConstants.h new file mode 100644 index 00000000..bf2202a2 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCConstants.h @@ -0,0 +1,117 @@ +// +// WOCConstants.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#ifndef WOCConstants_h +#define WOCConstants_h + +#define SHOW_LOGS NO + +#ifdef SHOW_LOGS +#define APILog(x, ...) //NSLog(@"\n\n%s %d: \n" x, __FUNCTION__, __LINE__, ##__VA_ARGS__) +#else +#define APILog(x, ...) +#endif +#define Str(str) (str != [NSNull null])?str:@"" +#define ALERT_TITLE [NSString stringWithFormat:@"%@ Wallet",WOCCurrency] + +#define REMOVE_NULL_VALUE(value) (value == nil)?@"":(![value isEqual:[NSNull null]])?value:@"" + +//static const BOOL isProduction = NO; // IF TESTNET SET DASH_TESTNET = 1 +static const BOOL isProduction = YES; // IF MAINNET SET DASH_TESTNET = 0 + +#define BASE_URL_PRODUCTION @"https://wallofcoins.com" +#define BASE_URL_DEVELOPMENT @"https://wallofcoins.com" +#define API_FOLDER @"api" +#define API_VERSION @"v1" + +#define API_DATE_FORMAT @"yyyy-MM-dd'T'HH:mm:ss.SSSZZZZ" +#define LOCAL_DATE_FORMAT @"yyyy-MM-dd HH:mm:ss" + +#define WOCApiBodyDeviceName_IOS [NSString stringWithFormat:@"%@ Wallet (iOS)",WOCCurrency] + +#pragma mark - USER DEFAULT KEYS + +static NSString * const WOCUserDefaultsAuthToken = @"WOCUserDefaultsAuthToken"; +static NSString * const WOCUserDefaultsLocalLocationLatitude = @"WOCUserDefaultLocalLocationLatitude"; +static NSString * const WOCUserDefaultsLocalLocationLongitude = @"WOCUserDefaultLocalLocationLongitude"; +static NSString * const WOCUserDefaultsLocalDeviceCode = @"WOCUserDefaultsLocalDeviceCode"; +static NSString * const WOCUserDefaultsLocalDeviceId = @"WOCUserDefaultsLocalDeviceId"; +static NSString * const WOCUserDefaultsLocalCountryCode = @"WOCUserDefaultLocalCountryCode"; +static NSString * const WOCUserDefaultsLaunchStatus = @"WOCUserDefaultsLaunchStatus"; +static NSString * const WOCUserDefaultsLocalDeviceInfo = @"WOCUserDefaultsLocalDeviceInfo"; +static NSString * const WOCUserDefaultsLocalPhoneNumber = @"WOCUserDefaultsLocalPhoneNumber"; +static NSString * const WOCUserDefaultsLocalEmail = @"WOCUserDefaultsLocalEmail"; +static NSString * const WOCUserDefaultsLocalBankInfo = @"WOCUserDefaultsLocalBankInfo"; +static NSString * const WOCUserDefaultsLocalBankName = @"WOCUserDefaultsLocalBankName"; +static NSString * const WOCUserDefaultsLocalBankAccount = @"WOCUserDefaultsLocalBankAccount"; +static NSString * const WOCUserDefaultsLocalBankAccountNumber = @"WOCUserDefaultsLocalBankAccountNumber"; +static NSString * const WOCUserDefaultsLocalPrice = @"WOCUserDefaultsLocalPrice"; +static NSString * const WOCUserDefaultsLocalMinDeposit = @"WOCUserDefaultsLocalMinDeposit"; +static NSString * const WOCUserDefaultsLocalMaxDeposit = @"WOCUserDefaultsLocalMaxDeposit"; + +#pragma mark - NOTIFICATION OBSERVER NAME + +static NSString * const WOCNotificationObserverNameBuyDashStep1 = @"WOCNotificationObserverNameBuyDashStep1"; +static NSString * const WOCNotificationObserverNameBuyDashStep2 = @"WOCNotificationObserverNameBuyDashStep2"; +static NSString * const WOCNotificationObserverNameBuyDashStep4 = @"WOCNotificationObserverNameBuyDashStep4"; +static NSString * const WOCNotificationObserverNameBuyDashStep8 = @"WOCNotificationObserverNameBuyDashStep8"; + +#pragma mark - API PARAMETERS KEYS + +static NSString * const WOCApiHeaderContentType = @"Content-Type"; +static NSString * const WOCApiHeaderPublisherId = @"X-Coins-Publisher"; +static NSString * const WOCApiHeaderToken = @"X-Coins-Api-Token"; +static NSString * const WOCApiBodyCryptoAmount = @"cryptoAmount"; +static NSString * const WOCApiBodyUsdAmount = @"usdAmount"; +static NSString * const WOCApiBodyCrypto = @"crypto"; +static NSString * const WOCApiBodyCryptoAddress = @"cryptoAddress"; +static NSString * const WOCApiBodyBank = @"bank"; +static NSString * const WOCApiBodyZipCode = @"zipCode"; +static NSString * const WOCApiBodyOffer = @"offer"; +static NSString * const WOCApiBodyDeviceName = @"deviceName"; +static NSString * const WOCApiBodyDeviceCode = @"deviceCode"; +static NSString * const WOCApiBodyDeviceId = @"deviceId"; +static NSString * const WOCApiBodyCode = @"code"; +static NSString * const WOCApiBodyName = @"name"; +static NSString * const WOCApiBodyPhoneNumber = @"phone"; +static NSString * const WOCApiBodyEmail = @"email"; +static NSString * const WOCApiBodyJsonParameter = @"JSONPara"; +static NSString * const WOCApiBodyVerificationCode = @"verificationCode"; +static NSString * const WOCApiBodyPassword = @"password"; +static NSString * const WOCApiBodyLatitude = @"latitude"; +static NSString * const WOCApiBodyLongitude = @"longitude"; +static NSString * const WOCApiBodyBrowserLocation = @"browserLocation"; +static NSString * const WOCApiBodyCountry = @"country"; +static NSString * const WOCApiBodyCountryCode = @"CountryCode"; + +#pragma mark - API PARAMETERS KEYS + +static NSString * const WOCApiResponseToken = @"token"; +static NSString * const WOCApiResponseId = @"id"; +static NSString * const WOCApiResponseDeviceId = @"deviceId"; +static NSString * const WOCApiResponsePurchaseCde = @"__PURCHASE_CODE"; +static NSString * const WOCApiResponseHolds = @"holds"; +static NSString * const WOCApiResponseHoldsStatus = @"status"; + +#pragma mark - OTHER +static NSString * const WOCBuyingStoryboard = @"buyDash"; +static NSString * const WOCsellingStoryboard = @"wocSell"; + +///* + static NSString * const WOCPublisherId = @"46"; + static NSString * const WOCCurrency = @"PIV"; + static NSString * const WOCCurrencySpecial = @"ⱣIV"; + static NSString * const WOCCurrencyMinorSpecial = @"µⱣiv"; + static NSString * const WOCCurrencySymbol = @"Ᵽ"; + static NSString * const WOCCurrencySymbolMinor = @"µⱣiv"; + static NSString * const WOCCryptoCurrencySmall = @"uPiv"; + static NSString * const WOCCryptoCurrency = @"PIVX"; + #define WOCTHEMECOLOR [UIColor colorWithRed:85.0/255.0 green:71.0/255.0 blue:108.0/255.0 alpha:1.0] +//*/ + +#endif diff --git a/PivxWallet/Wallofcoins/WOCDefaultBaseViewController.h b/PivxWallet/Wallofcoins/WOCDefaultBaseViewController.h new file mode 100644 index 00000000..f1c8f4c1 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCDefaultBaseViewController.h @@ -0,0 +1,44 @@ +// +// WOCBaseViewController.h +// Wallofcoins +// +// Created by Genitrust on 27/02/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCConstants.h" +#import "BRAppDelegate.h" +#import "BRRootViewController.h" +#import "MBProgressHUD.h" +#import "APIManager.h" +#import "WOCAlertController.h" + +@interface WOCDefaultBaseViewController : UIViewController + +@property (strong, nonatomic) NSUserDefaults *defaults; +@property (assign, nonatomic) BOOL isBackButtonRequire; + ++ (instancetype) sharedInstance; + +- (void)back; +- (void)backToRoot; +- (void)backToMainView; +- (void)push:(NSString*)viewControllerStr ; +- (void)clearLocalStorage; + +- (id)getViewController:(NSString*)viewControllerStr; +- (void)pushViewControllerStr:(NSString*)viewControllerStr; +- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated; + +- (NSString*)getCryptoPrice:(NSNumber*)number; + +- (IBAction)onBackButtonClick:(id)sender; +- (IBAction)onSignOutButtonClick:(id)sender; +- (IBAction)onBackToMainViewButtonClick:(id)sender; +- (BOOL)isValidEmail:(NSString *)checkString; +- (void)setShadowOnView:(UIView *)view; +- (void)setShadowOnButton:(UIButton *)button; +- (void)setButtonColor: (UIButton *)button; + +@end diff --git a/PivxWallet/Wallofcoins/WOCDefaultBaseViewController.m b/PivxWallet/Wallofcoins/WOCDefaultBaseViewController.m new file mode 100644 index 00000000..40f1a9b0 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCDefaultBaseViewController.m @@ -0,0 +1,255 @@ +// +// WOCBaseViewController.m +// Wallofcoins +// +// Created by Genitrust on 27/02/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCDefaultBaseViewController.h" + +#define MAIN_VIEWCONTROLLER @"WOCBuyingWizardHomeViewController" +#define MAIN_VIEWCONTROLLER_SELL @"WOCSellingWizardHomeViewController" + +@interface WOCDefaultBaseViewController () + +@end + +@implementation WOCDefaultBaseViewController + ++ (instancetype) sharedInstance { + static dispatch_once_t pred = 0; + static id _sharedObject = nil; + dispatch_once(&pred, ^{ + _sharedObject = [[self alloc] init]; + }); + return _sharedObject; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.defaults = [NSUserDefaults standardUserDefaults]; + + APILog(@"------------> You are In %@",[super class]); + + if (self.isBackButtonRequire) { + + if ([self.navigationController.visibleViewController isKindOfClass:NSClassFromString(MAIN_VIEWCONTROLLER)] || [self.navigationController.visibleViewController isKindOfClass:NSClassFromString(MAIN_VIEWCONTROLLER_SELL)]) { + self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"navigation_back"] style:UIBarButtonItemStylePlain target:self action:@selector(backToRoot)]; + } + else { + self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"navigation_back"] style:UIBarButtonItemStylePlain target:self action:@selector(backToMainView)]; + } + } +} + +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + NSString *loginPhone = [NSString stringWithFormat:@"Your wallet is signed into Wall of Coins using your mobile number %@",phoneNo]; + } +} + +- (void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; + +} + +- (void)setShadowOnView:(UIView *)view { + + view.layer.cornerRadius = 3.0; + view.layer.masksToBounds = YES; + view.layer.shadowColor = [UIColor lightGrayColor].CGColor; + view.layer.shadowOffset = CGSizeMake(0, 1); + view.layer.shadowRadius = 1; + view.layer.shadowOpacity = 1; + view.layer.masksToBounds = NO; +} + + +- (void)setShadowOnButton:(UIButton *)button { + + button.layer.cornerRadius = 3.0; + button.layer.masksToBounds = YES; + button.layer.shadowColor = [UIColor lightGrayColor].CGColor; + button.layer.shadowOffset = CGSizeMake(0, 1); + button.layer.shadowRadius = 1; + button.layer.shadowOpacity = 1; + button.layer.masksToBounds = NO; +} +- (void)setButtonColor:(UIButton *)button { + button.backgroundColor = WOCTHEMECOLOR; +} +- (BOOL) isValidEmail:(NSString *)checkString +{ + BOOL stricterFilter = NO; // Discussion http://blog.logichigh.com/2010/09/02/validating-an-e-mail-address/ + NSString *stricterFilterString = @"^[A-Z0-9a-z\\._%+-]+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2,4}$"; + NSString *laxString = @"^.+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2}[A-Za-z]*$"; + NSString *emailRegex = stricterFilter ? stricterFilterString : laxString; + NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex]; + return [emailTest evaluateWithObject:checkString]; +} + +- (void)showAlertWithText:(NSString*)alertText { + + UIAlertController *alert = [UIAlertController alertControllerWithTitle:ALERT_TITLE message:alertText preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *okayAction = [UIAlertAction actionWithTitle:@"Okay" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + }]; + + [alert addAction:okayAction]; + + [self presentViewController:alert animated:YES completion:nil]; +} + +- (NSString*)getCryptoPrice:(NSNumber*)number +{ + NSNumberFormatter *numFormatter = [[NSNumberFormatter alloc] init]; + [numFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4]; + [numFormatter setNumberStyle:NSNumberFormatterDecimalStyle]; + [numFormatter setAlwaysShowsDecimalSeparator:YES]; + [numFormatter setUsesGroupingSeparator:YES]; + [numFormatter setMinimumFractionDigits:2]; + [numFormatter setMaximumFractionDigits:2]; + [numFormatter setGroupingSeparator:@","]; + [numFormatter setGroupingSize:3]; + NSString *numberStr = [numFormatter stringFromNumber:number]; + return numberStr; +} + +- (void)pushViewControllerStr:(NSString*)viewControllerStr { + + NSString * storyboardName = [self.storyboard valueForKey:@"name"]; + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil]; + id pushViewController = [storyboard instantiateViewControllerWithIdentifier:viewControllerStr]; + if (pushViewController != nil) { + if ([pushViewController isKindOfClass:NSClassFromString(viewControllerStr)]) { + dispatch_async(dispatch_get_main_queue(), ^{ + if (![self.navigationController.visibleViewController isKindOfClass:NSClassFromString(viewControllerStr)]) { + [self.navigationController pushViewController:pushViewController animated:YES]; + } + }); + } + } +} +// MARK: - BACK Funcations +- (void)backToRoot { + + dispatch_async(dispatch_get_main_queue(), ^{ + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; + BRRootViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"RootViewController"]; + + UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; + [nav.navigationBar setTintColor:[UIColor whiteColor]]; + + UIPageControl.appearance.pageIndicatorTintColor = [UIColor lightGrayColor]; + UIPageControl.appearance.currentPageIndicatorTintColor = [UIColor blueColor]; + + BRAppDelegate *appDelegate = (BRAppDelegate*)[[UIApplication sharedApplication] delegate]; + appDelegate.window.rootViewController = nav; + }); +} + +- (void)backToMainView { + + NSString * storyboardName = [self.storyboard valueForKey:@"name"]; + if ([storyboardName isEqualToString:WOCBuyingStoryboard]) { + [self push:MAIN_VIEWCONTROLLER]; + } + else { + [self push:MAIN_VIEWCONTROLLER_SELL]; + } +} + +- (id)getViewController:(NSString*)viewControllerStr { + + NSString * storyboardName = [self.storyboard valueForKey:@"name"]; + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil]; + return [storyboard instantiateViewControllerWithIdentifier:viewControllerStr]; +} + +- (void)push:(NSString*)viewControllerStr { + + dispatch_async(dispatch_get_main_queue(), ^{ + + if (![self.navigationController.visibleViewController isKindOfClass:NSClassFromString(viewControllerStr)]) { + BOOL mainViewFound = NO; + for (UIViewController *vc in self.navigationController.viewControllers) { + if ([vc isKindOfClass:NSClassFromString(viewControllerStr)]) { + mainViewFound = YES; + [self.navigationController popToViewController:vc animated:YES]; + } + } + + if (!mainViewFound) { + [self pushViewControllerStr:viewControllerStr]; + } + } + else { + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:WOCNotificationObserverNameBuyDashStep1 object:nil]; + }); + } + }); +} + +- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated { + + dispatch_async(dispatch_get_main_queue(), ^{ + + if (![self.navigationController.visibleViewController isKindOfClass:[viewController class]]) { + BOOL mainViewFound = NO; + for (UIViewController *vc in self.navigationController.viewControllers) { + + if ([vc isKindOfClass:[viewController class]]) { + mainViewFound = YES; + [self.navigationController popToViewController:vc animated:animated]; + } + } + + if (!mainViewFound) { + dispatch_async(dispatch_get_main_queue(), ^{ + if (![self.navigationController.visibleViewController isKindOfClass:[viewController class]]) { + [self.navigationController pushViewController:viewController animated:animated]; + } + }); + } + } + else { + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:WOCNotificationObserverNameBuyDashStep1 object:nil]; + }); + } + }); +} + +- (void)back { + + dispatch_async(dispatch_get_main_queue(), ^{ + [self.navigationController popViewControllerAnimated:YES]; + [self.navigationController.navigationBar setHidden:NO]; + }); +} + +// MARK: - IBAction + +- (IBAction)onBackButtonClick:(id)sender { + [self back]; +} + +- (IBAction)onBackToMainViewButtonClick:(id)sender { + [self backToMainView]; +} + +- (IBAction)onSignOutButtonClick:(id)sender { +} +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} +@end + diff --git a/PivxWallet/Wallofcoins/WOCHelpers/AsyncImageView/WOCAsyncImageView.h b/PivxWallet/Wallofcoins/WOCHelpers/AsyncImageView/WOCAsyncImageView.h new file mode 100755 index 00000000..2660ef69 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCHelpers/AsyncImageView/WOCAsyncImageView.h @@ -0,0 +1,277 @@ +// +// AsyncImageView.h +// +// Version 1.6 +// +// Created by Nick Lockwood on 03/04/2011. +// Copyright (c) 2011 Charcoal Design +// +// Distributed under the permissive zlib License +// Get the latest version from here: +// +// https://github.com/nicklockwood/AsyncImageView +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the +// use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software in a +// product, an acknowledgment in the product documentation would be appreciated +// but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// + + +#import +#import +#import + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wobjc-missing-property-synthesis" + +NS_ASSUME_NONNULL_BEGIN + +/** + * Error domain string for AsyncImageLoader errors. + */ +extern NSString *const AsyncImageLoaderErrorDomain; + +/** + * This fires when an image has been loaded. The notification object contains + * the target object that loaded the image file (e.g. the UIImageView) and the + * userInfo dictionary contains the following keys: + * - AsyncImageImageKey + * - AsyncImageURLKey + * - AsyncImageCacheKey + */ +extern NSString *const AsyncImageLoadDidFinish; + +/** + * This fires when an image did not load due to an error. The notification object + * contains the target object that attempted to load the image file (e.g. the + * UIImageView) and the userInfo dictionary contains the following keys: + * - AsyncImageErrorKey + * - AsyncImageURLKey + */ +extern NSString *const AsyncImageLoadDidFail; + +/** + * The UIImage that was loaded. + */ +extern NSString *const AsyncImageImageKey; + +/** + * The NSURL that the image was loaded from (or failed to load from). + */ +extern NSString *const AsyncImageURLKey; + +/** + * The NSCache that the image was stored in. + */ +extern NSString *const AsyncImageCacheKey; + +/** + * The NSError generated by the underlying NSURLSession + */ +extern NSString *const AsyncImageErrorKey; + + +/** + * AsyncImageLoader manages the loading/downloading and queueing of image + * requests. Set properties of the shared loader instance to control loading + * behaviour, or call its loading methods directly to preload images off-screen. + */ +@interface AsyncImageLoader : NSObject + +/** + * The default loader instance used for image requests. + */ ++ (AsyncImageLoader *)sharedLoader; + +/** + * The default cache instance used by image loaders. + */ ++ (NSCache *)defaultCache; + +/** + * The cache to be used for image load requests. You can change this value at + * any time and it will affect all subsequent load requests until it is changed + * again. By default this is set to `[AsyncImageLoader sharedCache]`. Set this + * to nil to disable caching completely, or you can set it to a new NSCache + * instance or subclass for fine-grained cache control. + */ +@property (nonatomic, strong, nullable) NSCache *cache; + +/** + * The number of images to load concurrently. Images are loaded on background + * threads but loading too many concurrently can choke the CPU. + * The default value is 4. + */ +@property (nonatomic, assign) NSUInteger concurrentLoads; + +/** + * The loading timeout, in seconds. This defaults to 60, which should be more + * than enough for loading over WiFi, but may be too short for downloading large + * images over a slow 2G/3G connection. + */ +@property (nonatomic, assign) NSTimeInterval loadingTimeout; + +/** + * This queues an image for download. If the queue is empty and the image is + * already in cache, this will trigger the success action immediately. + * + * The target is retained by the AsyncImageLoader, however the loader will + * monitor to see if the target is being retained by any other objects, and will + * release it and terminate the file load if it is not. The target can be nil, + * in which case the load will still happen as normal and can completion can be + * detected using the `AsyncImageLoadDidFinish` and `AsyncImageLoadDidFail` + * notifications. + */ +- (void)loadImageWithURL:(nullable NSURL *)URL + target:(nullable id)target + success:(nullable SEL)success + failure:(nullable SEL)failure; + +/** + * Works the same as above, except the action will only be called if the loading + * is successful. Failure can still be detected using the `AsyncImageLoadDidFail` + * notification. + */ +- (void)loadImageWithURL:(nullable NSURL *)URL + target:(nullable id)target + action:(nullable SEL)action; + +/** + * Works the same as above, but no target or actions are specified. Use + * `AsyncImageLoadDidFinish` and `AsyncImageLoadDidFail` to detect when the + * loading is complete. + */ +- (void)loadImageWithURL:(nullable NSURL *)URL; + +/** + * This cancels loading the image with the specified URL for the specified + * target and action. + */ +- (void)cancelLoadingURL:(nullable NSURL *)URL + target:(nullable id)target + action:(nullable SEL)action; + +/** + * This cancels loading the image with the specified URL for any actions on the + * specified target; + */ +- (void)cancelLoadingURL:(nullable NSURL *)URL + target:(nullable id)target; + +/** + * This cancels loading the image with the specified URL. + */ +- (void)cancelLoadingURL:(nullable NSURL *)URL; + +/** + * This cancels loading all queued image URLs with the specified action on the + * specified target; + */ +- (void)cancelLoadingImagesForTarget:(nullable id)target + action:(nullable SEL)action; + +/** + * This cancels loading all queued image URLs for the specified target; + */ +- (void)cancelLoadingImagesForTarget:(nullable id)target; + +/** + * Returns the most recent image URL assigned to the target for the given action. + * This is not necessarily the next image that will be assigned if several image + * URLs have been queued on that target. + */ +- (NSURL *)URLForTarget:(nullable id)target + action:(nullable SEL)action; + +/** + * Returns the most recent image URL assigned to the target. + * This is not necessarily the next image that will be assigned if several image + * URLs have been queued on that target. + */ +- (NSURL *)URLForTarget:(nullable id)target; + +@end + + +/** + * a category on UIImageView. This implements provides an `imageURL` property + * that can be used to trigger an asynchronous load of a new image. + */ +@interface UIImageView(AsyncImageView) + +/** + * Upon setting this property, AsyncImageView will begin loading/downloading the + * specified image on a background thread. Once the image file has loaded, the + * UIImageView's image property will be set to the resultant image. If you set + * this property again while the previous image is still loading then the images + * will be queued for loading in the order in which they were set. + * + * This means that you can, for example, set a UIImageView to load a small + * thumbnail image and then immediately set it to load a larger image and the + * thumbnail image will still be loaded and set before the larger image loads. + * + * If you access this property it will return the most recent image URL set for + * the UIImageView, which may not be the next one to be loaded if several image + * URLs have been queued on that image view. If you wish to cancel the + * previously loading image, use the `-cancelLoadingURL:target:` method on the + * AsyncImageLoader class, passing the UIImageView instance as the target. + */ +@property (nonatomic, strong, nullable) NSURL *imageURL; + +@end + + +/** + * a subclass of UIImageView. This implements some useful features on top of the + * UIImageView category, including the automatic display of a loading spinner, + * and a nice crossfade effect when the image loads. + */ +@interface WOCAsyncImageView : UIImageView + +/** + * If YES, the AsyncImageView will display a loading spinner when the imageURL + * is set. This will automatically hide once the image has loaded. Note that + * this value should bet set *before* setting the imageURL. Setting this value + * when loading is already in progress will have no effect. Defaults to YES. + */ +@property (assign, nonatomic) BOOL showActivityIndicator; + +/** + * The style that will be used for the UIActivityIndicator (if enabled). Note + * that this value should bet set *before* setting the imageURL. Setting this + * value when loading is already in progress will cause the spinner to disappear. + */ +@property (nonatomic, assign) UIActivityIndicatorViewStyle activityIndicatorStyle; + +/** + * The color for the UIActivityIndicator. Defaults to light grey. + */ +@property (nonatomic, strong, nullable) UIColor *activityIndicatorColor; + +/** + * The crossfade animation duration, in seconds. If value is greater than 0, the + * image will crossfade in once it loads instead of appearing suddenly. Defaults + * to 0.4. + */ +@property (nonatomic, assign) NSTimeInterval crossfadeDuration; + +@end + +NS_ASSUME_NONNULL_END + +#pragma clang diagnostic pop + diff --git a/PivxWallet/Wallofcoins/WOCHelpers/AsyncImageView/WOCAsyncImageView.m b/PivxWallet/Wallofcoins/WOCHelpers/AsyncImageView/WOCAsyncImageView.m new file mode 100755 index 00000000..a5b25d52 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCHelpers/AsyncImageView/WOCAsyncImageView.m @@ -0,0 +1,636 @@ +// +// WOCAsyncImageView.m +// +// Version 1.6 +// +// Created by Nick Lockwood on 03/04/2011. +// Copyright (c) 2011 Charcoal Design +// +// Distributed under the permissive zlib License +// Get the latest version from here: +// +// https://github.com/nicklockwood/AsyncImageView +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the +// use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it +// freely, subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; you must not +// claim that you wrote the original software. If you use this software in a +// product, an acknowledgment in the product documentation would be appreciated +// but is not required. +// +// 2. Altered source versions must be plainly marked as such, and must not be +// misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// + + +#import "WOCAsyncImageView.h" +#import + +#pragma clang diagnostic ignored "-Wgnu" + + +#import +#if !__has_feature(objc_arc) +#error This class requires automatic reference counting +#endif + + +NSString *const AsyncImageLoaderErrorDomain = @"AsyncImageLoader"; + +NSString *const AsyncImageLoadDidFinish = @"AsyncImageLoadDidFinish"; +NSString *const AsyncImageLoadDidFail = @"AsyncImageLoadDidFail"; + +NSString *const AsyncImageImageKey = @"image"; +NSString *const AsyncImageURLKey = @"URL"; +NSString *const AsyncImageCacheKey = @"cache"; +NSString *const AsyncImageErrorKey = @"error"; + + +@interface AsyncImageConnection : NSObject + +@property (nonatomic, strong, readonly) NSURL *URL; +@property (nonatomic, strong, readonly) NSCache *cache; +@property (nonatomic, strong, readonly) id target; +@property (nonatomic, assign, readonly) SEL success; +@property (nonatomic, assign, readonly) SEL failure; +@property (nonatomic, readonly) UIImage *cachedImage; + +@property (nonatomic, copy) dispatch_block_t cancellationToken; +@property (nonatomic, getter = isLoading) BOOL loading; +@property (atomic, getter = isCancelled) BOOL cancelled; + +- (AsyncImageConnection *)initWithURL:(NSURL *)URL + cache:(NSCache *)cache + target:(id)target + success:(SEL)success + failure:(SEL)failure; + +- (void)start; +- (void)cancel; + +@end + + +@implementation AsyncImageConnection + +- (AsyncImageConnection *)initWithURL:(NSURL *)URL + cache:(NSCache *)cache + target:(id)target + success:(SEL)success + failure:(SEL)failure +{ + if ((self = [self init])) { + _URL = URL; + _cache = cache; + _target = target; + _success = success; + _failure = failure; + } + return self; +} + +- (UIImage *)cachedImage +{ + UIImage *image = [self.cache objectForKey:self.URL]; + if (!image && self.URL.fileURL) { + NSString *path = self.URL.absoluteURL.path; + NSString *resourcePath = [NSBundle mainBundle].resourcePath; + if ([path hasPrefix:resourcePath]) { + path = [path substringFromIndex:resourcePath.length]; + if ([path hasPrefix:@"/"]) { + path = [path substringFromIndex:1]; + } + image = [UIImage imageNamed:path]; + if (image) { + [self.cache setObject:image forKey:self.URL]; + } + } + } + return image; +} + +- (void)loadFailedWithError:(NSError *)error +{ + self.loading = NO; + self.cancelled = NO; + [[NSNotificationCenter defaultCenter] postNotificationName:AsyncImageLoadDidFail + object:self.target + userInfo:@{AsyncImageURLKey: self.URL, + AsyncImageErrorKey: error}]; +} + +- (void)postImage:(UIImage *)image +{ + if (!self.cancelled) { + NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithObjectsAndKeys: + image, AsyncImageImageKey, + self.URL, AsyncImageURLKey, + nil]; + if (self.cache) { + userInfo[AsyncImageCacheKey] = self.cache; + } + + self.loading = NO; + [[NSNotificationCenter defaultCenter] postNotificationName:AsyncImageLoadDidFinish + object:self.target + userInfo:[userInfo copy]]; + } + else { + self.loading = NO; + self.cancelled = NO; + } +} + +- (void)processDataInBackground:(NSData *)data +{ + if (!self.cancelled) { + UIImage *image; + @synchronized ([self class]) { + CGImageSourceRef imageSourceRef = CGImageSourceCreateWithData((CFDataRef)data, NULL); + if (imageSourceRef) { + CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSourceRef, 0, NULL); + if (imageProperties) { + NSNumber *width = CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelWidth); + NSNumber *height = CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelHeight); + CFRelease(imageProperties); + + double maxSize = MAX(width.doubleValue, height.doubleValue); + NSDictionary *options = @{(__bridge id)kCGImageSourceShouldAllowFloat: @YES, + (__bridge id)kCGImageSourceCreateThumbnailWithTransform: @YES, + (__bridge id)kCGImageSourceCreateThumbnailFromImageAlways: @YES, + (__bridge id)kCGImageSourceThumbnailMaxPixelSize: @(maxSize)}; + CGImageRef imageRef = CGImageSourceCreateThumbnailAtIndex(imageSourceRef, 0, + (__bridge CFDictionaryRef)options); + if (imageRef) { + //infer scale from filename + CGFloat scale = 1.0; + NSString *path = self.URL.lastPathComponent.stringByDeletingPathExtension; + if ([path hasSuffix:@"@2x"]) { + scale = 2.0; + } + else if ([path hasSuffix:@"@3x"]) { + scale = 3.0; + } + image = [UIImage imageWithCGImage:imageRef scale:scale orientation:UIImageOrientationUp]; + CGImageRelease(imageRef); + + //add to cache (may be cached already but it doesn't matter) + if (image && self.URL) { + [self.cache setObject:image forKey:self.URL]; + } + + // post image + [self performSelectorOnMainThread:@selector(postImage:) + withObject:image + waitUntilDone:NO]; + } + } + CFRelease(imageSourceRef); + } + } + if (!image) { + @autoreleasepool + { + NSError *error = [NSError errorWithDomain:AsyncImageLoaderErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey: @"Invalid image data"}]; + [self performSelectorOnMainThread:@selector(loadFailedWithError:) withObject:error waitUntilDone:NO]; + } + } + } + else { + //clean up + [self performSelectorOnMainThread:@selector(postImage:) + withObject:nil + waitUntilDone:NO]; + } +} + +- (void)loadDataInBackground +{ + if (!self.cancelled) { + NSError *error; + NSData *data = [NSData dataWithContentsOfURL:self.URL options:NSDataReadingMappedIfSafe error:&error]; + if (data) { + [self processDataInBackground:data]; + } + else { + [self performSelectorOnMainThread:@selector(loadFailedWithError:) withObject:error waitUntilDone:NO]; + } + } +} + +- (void)start +{ + if (self.loading && !self.cancelled) { + return; + } + + //begin loading + self.loading = YES; + self.cancelled = NO; + + //check for nil URL + if (self.URL == nil) { + [self postImage:nil]; + return; + } + + //check for cached image + UIImage *image = self.cachedImage; + if (image) { + //post image + [self performSelectorOnMainThread:@selector(postImage:) withObject:image waitUntilDone:NO]; + return; + } + + //check if local image + if (self.URL.fileURL) { + [self performSelectorInBackground:@selector(loadDataInBackground) withObject:nil]; + return; + } + + //begin load + NSURLRequest *request = [NSURLRequest requestWithURL:self.URL + cachePolicy:NSURLRequestReloadIgnoringLocalCacheData + timeoutInterval:[AsyncImageLoader sharedLoader].loadingTimeout]; + + __weak AsyncImageConnection *weakSelf = self; + NSURLSessionTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, __unused NSURLResponse * _Nullable response, NSError * _Nullable error) { + + AsyncImageConnection *strongSelf = weakSelf; + if (!strongSelf || strongSelf.cancelled) { + return; + } + if (error) { + [strongSelf performSelectorOnMainThread:@selector(loadFailedWithError:) withObject:error waitUntilDone:NO]; + } + else { + [strongSelf performSelectorInBackground:@selector(processDataInBackground:) withObject:data]; + } + }]; + + [task resume]; + + self.cancellationToken = ^{ [task cancel]; }; +} + +- (void)cancel +{ + self.cancelled = YES; + if (self.cancellationToken) + { + self.cancellationToken(); + } + self.cancellationToken = nil; +} + +@end + + +@interface AsyncImageLoader () + +@property (nonatomic, strong) NSMutableArray *connections; + +@end + + +@implementation AsyncImageLoader + ++ (AsyncImageLoader *)sharedLoader +{ + static AsyncImageLoader *sharedInstance = nil; + if (sharedInstance == nil) { + sharedInstance = [[self alloc] init]; + } + return sharedInstance; +} + ++ (NSCache *)defaultCache +{ + static NSCache *sharedCache = nil; + if (sharedCache == nil) { + sharedCache = [[NSCache alloc] init]; + [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidReceiveMemoryWarningNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(__unused NSNotification *note) { + + [sharedCache removeAllObjects]; + }]; + } + return sharedCache; +} + +- (instancetype)init +{ + if ((self = [super init])) { + self.cache = [[self class] defaultCache]; + _concurrentLoads = 4; + _loadingTimeout = 60.0; + _connections = [[NSMutableArray alloc] init]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(imageLoaded:) + name:AsyncImageLoadDidFinish + object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(imageFailed:) + name:AsyncImageLoadDidFail + object:nil]; + } + return self; +} + +- (void)updateQueue +{ + //start connections + NSUInteger count = 0; + for (AsyncImageConnection *connection in self.connections) + { + if (!connection.loading) { + if (connection.cachedImage) { + [connection start]; + } + else if (count < self.concurrentLoads) { + count ++; + [connection start]; + } + } + } +} + +- (void)imageLoaded:(NSNotification *)notification +{ + //complete connections for URL + NSURL *URL = (notification.userInfo)[AsyncImageURLKey]; + for (NSInteger i = (NSInteger)self.connections.count - 1; i >= 0; i--) + { + AsyncImageConnection *connection = self.connections[(NSUInteger)i]; + if (connection.URL == URL || [connection.URL isEqual:URL]) { + //cancel earlier connections for same target/action + for (NSInteger j = i - 1; j >= 0; j--) + { + AsyncImageConnection *earlier = self.connections[(NSUInteger)j]; + if (earlier.target == connection.target && + earlier.success == connection.success) { + [earlier cancel]; + [self.connections removeObjectAtIndex:(NSUInteger)j]; + i--; + } + } + + //cancel connection (in case it's a duplicate) + [connection cancel]; + + //perform action + UIImage *image = (notification.userInfo)[AsyncImageImageKey]; + ((void (*)(id, SEL, id, id))objc_msgSend)(connection.target, connection.success, image, connection.URL); + + //remove from queue + [self.connections removeObjectAtIndex:(NSUInteger)i]; + } + } + + //update the queue + [self updateQueue]; +} + +- (void)imageFailed:(NSNotification *)notification +{ + //remove connections for URL + NSURL *URL = (notification.userInfo)[AsyncImageURLKey]; + for (NSInteger i = (NSInteger)self.connections.count - 1; i >= 0; i--) + { + AsyncImageConnection *connection = self.connections[(NSUInteger)i]; + if ([connection.URL isEqual:URL]) { + //cancel connection (in case it's a duplicate) + [connection cancel]; + + //perform failure action + if (connection.failure) { + NSError *error = (notification.userInfo)[AsyncImageErrorKey]; + ((void (*)(id, SEL, id, id))objc_msgSend)(connection.target, connection.failure, error, URL); + } + + //remove from queue + [self.connections removeObjectAtIndex:(NSUInteger)i]; + } + } + + //update the queue + [self updateQueue]; +} + +- (void)loadImageWithURL:(NSURL *)URL target:(id)target success:(SEL)success failure:(SEL)failure +{ + //check cache + UIImage *image = [self.cache objectForKey:URL]; + if (image) { + [self cancelLoadingImagesForTarget:self action:success]; + if (success) { + dispatch_async(dispatch_get_main_queue(), ^(void) { + ((void (*)(id, SEL, id, id))objc_msgSend)(target, success, image, URL); + }); + } + return; + } + + //cancel loading previous URL if new URL is nil or is a local file and last URL wasn't + if (!URL || (URL.fileURL && ![self URLForTarget:URL action:success].fileURL)) { + [self cancelLoadingImagesForTarget:self action:success]; + } + + //create new connection + AsyncImageConnection *connection = [[AsyncImageConnection alloc] initWithURL:URL + cache:self.cache + target:target + success:success + failure:failure]; + BOOL added = NO; + for (NSUInteger i = 0, count = self.connections.count; i < count; i++) + { + AsyncImageConnection *existingConnection = self.connections[i]; + if (!existingConnection.loading) { + [self.connections insertObject:connection atIndex:i]; + added = YES; + break; + } + } + if (!added) { + [self.connections addObject:connection]; + } + [self updateQueue]; +} + +- (void)loadImageWithURL:(NSURL *)URL target:(id)target action:(SEL)action +{ + [self loadImageWithURL:URL target:target success:action failure:nil]; +} + +- (void)loadImageWithURL:(NSURL *)URL +{ + [self loadImageWithURL:URL target:nil success:nil failure:nil]; +} + +- (void)cancelLoadingURL:(NSURL *)URL target:(id)target action:(SEL)action +{ + for (NSInteger i = (NSInteger)self.connections.count - 1; i >= 0; i--) + { + AsyncImageConnection *connection = self.connections[(NSUInteger)i]; + if ((!URL || [connection.URL isEqual:URL]) && + (!target || connection.target == target) && + (!action || connection.success == action)) { + [connection cancel]; + [self.connections removeObjectAtIndex:(NSUInteger)i]; + } + } +} + +- (void)cancelLoadingURL:(NSURL *)URL target:(id)target +{ + [self cancelLoadingURL:URL target:target action:NULL]; +} + +- (void)cancelLoadingURL:(NSURL *)URL +{ + [self cancelLoadingURL:URL target:nil]; +} + +- (void)cancelLoadingImagesForTarget:(id)target action:(SEL)action +{ + [self cancelLoadingURL:nil target:target action:action]; +} + +- (void)cancelLoadingImagesForTarget:(id)target +{ + [self cancelLoadingURL:nil target:target action:NULL]; +} + +- (NSURL *)URLForTarget:(id)target action:(SEL)action +{ + for (NSInteger i = (NSInteger)self.connections.count - 1; i >= 0; i--) + { + AsyncImageConnection *connection = self.connections[(NSUInteger)i]; + if (connection.target == target && (!action || connection.success == action)) { + return connection.URL; + } + } + return nil; +} + +- (NSURL *)URLForTarget:(id)target +{ + return [self URLForTarget:target action:NULL]; +} + +- (void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + +@end + + +@implementation UIImageView(WOCAsyncImageView) + +- (void)setImageURL:(NSURL *)imageURL +{ + [[AsyncImageLoader sharedLoader] loadImageWithURL:imageURL target:self action:@selector(setImage:)]; +} + +- (NSURL *)imageURL +{ + return [[AsyncImageLoader sharedLoader] URLForTarget:self action:@selector(setImage:)]; +} + +@end + + +@interface WOCAsyncImageView () + +@property (nonatomic, strong) UIActivityIndicatorView *activityView; + +@end + + +@implementation WOCAsyncImageView + +- (void)setUp +{ + self.showActivityIndicator = (self.image == nil); + self.activityIndicatorStyle = UIActivityIndicatorViewStyleWhite; + self.activityIndicatorColor = [UIColor lightGrayColor]; + self.crossfadeDuration = 0.4; +} + +- (instancetype)initWithFrame:(CGRect)frame +{ + if ((self = [super initWithFrame:frame])) { + [self setUp]; + } + return self; +} + +- (instancetype)initWithCoder:(NSCoder *)aDecoder +{ + if ((self = [super initWithCoder:aDecoder])) { + [self setUp]; + } + return self; +} + +- (void)setImageURL:(NSURL *)imageURL +{ + UIImage *image = [[AsyncImageLoader sharedLoader].cache objectForKey:imageURL]; + if (image) { + self.image = image; + return; + } + super.imageURL = imageURL; + if (self.showActivityIndicator && !self.image && imageURL) { + if (self.activityView == nil) { + self.activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:self.activityIndicatorStyle]; + self.activityView.color = self.activityIndicatorColor; + self.activityView.hidesWhenStopped = YES; + self.activityView.center = CGPointMake(self.bounds.size.width / 2.0, self.bounds.size.height / 2.0); + self.activityView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin; + [self addSubview:self.activityView]; + } + [self.activityView startAnimating]; + } +} + +- (void)setActivityIndicatorStyle:(UIActivityIndicatorViewStyle)style +{ + _activityIndicatorStyle = style; + [self.activityView removeFromSuperview]; + self.activityView = nil; +} + +- (void)setActivityIndicatorColor:(UIColor *)activityIndicatorColor +{ + _activityIndicatorColor = activityIndicatorColor; + self.activityView.color = activityIndicatorColor; +} + +- (void)setImage:(UIImage *)image +{ + if (image != self.image && self.crossfadeDuration > 0) { + CATransition *animation = [CATransition animation]; + animation.type = kCATransitionFade; + animation.duration = self.crossfadeDuration; + [self.layer addAnimation:animation forKey:nil]; + } + super.image = image; + [self.activityView stopAnimating]; +} + +- (void)dealloc +{ + [[AsyncImageLoader sharedLoader] cancelLoadingURL:self.imageURL target:self]; +} + +@end diff --git a/PivxWallet/Wallofcoins/WOCHelpers/WOCAlertController.h b/PivxWallet/Wallofcoins/WOCHelpers/WOCAlertController.h new file mode 100644 index 00000000..df28d69f --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCHelpers/WOCAlertController.h @@ -0,0 +1,18 @@ +// +// WOCAlertController.h +// Wallofcoins +// +// Created by Genitrust on 02/02/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import + +@interface WOCAlertController : NSObject + ++ (WOCAlertController *)sharedInstance; + +- (void)alertshowWithTitle:(NSString*)title message:(NSString*)message viewController:(UIViewController*)viewController; +- (void)alertshowWithError:(NSError*)error viewController:(UIViewController*)viewController; + +@end diff --git a/PivxWallet/Wallofcoins/WOCHelpers/WOCAlertController.m b/PivxWallet/Wallofcoins/WOCHelpers/WOCAlertController.m new file mode 100644 index 00000000..4ac98781 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCHelpers/WOCAlertController.m @@ -0,0 +1,62 @@ +// +// WOCAlertController.m +// Wallofcoins +// +// Created by Genitrust on 02/02/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCAlertController.h" + +@implementation WOCAlertController + +static WOCAlertController *alert = NULL; + ++ (WOCAlertController *)sharedInstance { + if (!alert) { + alert = [[WOCAlertController alloc] init]; + } + return alert; +} + +- (void)alertshowWithTitle:(NSString*)title message:(NSString*)message viewController:(UIViewController*)viewController { + UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + }]; + + [alert addAction:okAction]; + + if (viewController != nil) { + [viewController presentViewController:alert animated:YES completion:nil]; + } +} + +- (void)alertshowWithError:(NSError*)error viewController:(UIViewController*)viewController { + NSString *title = @"Error"; + dispatch_async(dispatch_get_main_queue(), ^{ + UIAlertController *alert; + if (error.userInfo != nil) { + if (error.userInfo[@"detail"] != nil) { + alert = [UIAlertController alertControllerWithTitle:title message:error.userInfo[@"detail"] preferredStyle:UIAlertControllerStyleAlert]; + } + else { + alert = [UIAlertController alertControllerWithTitle:title message:error.localizedDescription preferredStyle:UIAlertControllerStyleAlert]; + } + } + else { + alert = [UIAlertController alertControllerWithTitle:title message:error.localizedDescription preferredStyle:UIAlertControllerStyleAlert]; + } + + UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + }]; + + [alert addAction:okAction]; + + if (viewController != nil) { + [viewController presentViewController:alert animated:YES completion:nil]; + } + }); +} + +@end diff --git a/PivxWallet/Wallofcoins/WOCHelpers/WOCLocationManager.h b/PivxWallet/Wallofcoins/WOCHelpers/WOCLocationManager.h new file mode 100644 index 00000000..6e1b424f --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCHelpers/WOCLocationManager.h @@ -0,0 +1,23 @@ +// +// WOCLocationManager.h +// Wallofcoins +// +// Created by Genitrust on 23/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import + +@interface WOCLocationManager : NSObject + +@property (strong, nonatomic) CLLocationManager *manager; +@property (strong, nonatomic) CLLocation *lastLocation; + ++ (WOCLocationManager *)sharedInstance; + +- (void)startLocationService; +- (BOOL)locationServiceEnabled; +- (CLLocationCoordinate2D) getLocationFromAddressString:(NSString*) addressStr; + +@end diff --git a/PivxWallet/Wallofcoins/WOCHelpers/WOCLocationManager.m b/PivxWallet/Wallofcoins/WOCHelpers/WOCLocationManager.m new file mode 100644 index 00000000..6d486b30 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCHelpers/WOCLocationManager.m @@ -0,0 +1,135 @@ +// +// WOCLocationManager.m +// Wallofcoins +// +// Created by Genitrust on 23/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCLocationManager.h" +#import "WOCConstants.h" + +@implementation WOCLocationManager + ++ (WOCLocationManager *)sharedInstance { + static dispatch_once_t onceToken; + static WOCLocationManager *locationManager; + + dispatch_once(&onceToken, ^{ + locationManager = [[WOCLocationManager alloc] init]; + }); + + return locationManager; +} + +- (void)startLocationService { + self.manager = [[CLLocationManager alloc] init]; + self.manager.desiredAccuracy = kCLLocationAccuracyBest; + self.manager.delegate = self; + + if ([self.manager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { + [self.manager requestWhenInUseAuthorization]; + } + [self.manager startUpdatingLocation]; +} + +- (BOOL)locationServiceEnabled { + if ([CLLocationManager locationServicesEnabled]) { + switch ([CLLocationManager authorizationStatus]) { + case kCLAuthorizationStatusAuthorizedWhenInUse : + return YES; + break; + default: + return NO; + break; + } + } + else { + return NO; + } +} + +- (CLLocationCoordinate2D) getLocationFromAddressString:(NSString*) addressStr { + double latitude = 0, longitude = 0; + NSString *esc_addr = [addressStr stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]]; + NSString *req = [NSString stringWithFormat:@"http://maps.google.com/maps/api/geocode/json?sensor=false&address=%@", esc_addr]; + NSString *result = [NSString stringWithContentsOfURL:[NSURL URLWithString:req] encoding:NSUTF8StringEncoding error:NULL]; + if (result) { + NSScanner *scanner = [NSScanner scannerWithString:result]; + if ([scanner scanUpToString:@"\"lat\" :" intoString:nil] && [scanner scanString:@"\"lat\" :" intoString:nil]) { + [scanner scanDouble:&latitude]; + if ([scanner scanUpToString:@"\"lng\" :" intoString:nil] && [scanner scanString:@"\"lng\" :" intoString:nil]) { + [scanner scanDouble:&longitude]; + } + } + } + CLLocationCoordinate2D center; + center.latitude = latitude; + center.longitude = longitude; + return center; +} + +- (void)openStep4 { + if (self.lastLocation != nil) { + [[NSNotificationCenter defaultCenter] postNotificationName:WOCNotificationObserverNameBuyDashStep4 object:nil]; + } +} + +- (void)showLocationAlertPopup { + + UIAlertController *alert = [UIAlertController + alertControllerWithTitle:[NSString stringWithFormat:@"Allow \"%@\" to Access Your Location While You Use the App?",WOCCurrency] message:@"Your current location will be used to show you birds nearby."preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *yesButton = [UIAlertAction + actionWithTitle:@"Don't Allow" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) + { + }]; + + UIAlertAction *noButton = [UIAlertAction + actionWithTitle:@"Allow" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) + { + NSURL *settingsURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; + + if ([[UIApplication sharedApplication] canOpenURL:settingsURL]) { + [[UIApplication sharedApplication] openURL:settingsURL options:@{} completionHandler:nil]; + } + }]; + + [alert addAction:yesButton]; + [alert addAction:noButton]; + + [[[[UIApplication sharedApplication] keyWindow] rootViewController] presentViewController:alert animated:YES completion:nil]; +} + +// MARK: - CLLocationManager Delegate +- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { + + if ([locations count]) { + self.lastLocation = [locations lastObject]; + + if ([NSString stringWithFormat:@"%f",self.lastLocation.coordinate.latitude] != nil) { + [[NSUserDefaults standardUserDefaults] setValue:[NSString stringWithFormat:@"%f",self.lastLocation.coordinate.latitude] forKey:WOCUserDefaultsLocalLocationLatitude]; + [[NSUserDefaults standardUserDefaults] setValue:[NSString stringWithFormat:@"%f",self.lastLocation.coordinate.longitude] forKey:WOCUserDefaultsLocalLocationLongitude]; + [[NSUserDefaults standardUserDefaults] synchronize]; + } + } +} + +- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status { + + if (status == kCLAuthorizationStatusDenied) { + + [[NSNotificationCenter defaultCenter] postNotificationName:WOCNotificationObserverNameBuyDashStep2 object:nil]; + + } else if (status == kCLAuthorizationStatusAuthorizedWhenInUse) { + + [self performSelector:@selector(openStep4) withObject:nil afterDelay:2.0]; + } +} + +@end + diff --git a/PivxWallet/Wallofcoins/WOCHoldIssueViewController.h b/PivxWallet/Wallofcoins/WOCHoldIssueViewController.h new file mode 100644 index 00000000..176cb2d0 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCHoldIssueViewController.h @@ -0,0 +1,16 @@ +// +// WOCHoldIssueViewController.h +// Wallofcoins +// +// Created by Genitrust on 21/02/18. +// Copyright © 2018 Aaron Voisine. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" +@interface WOCHoldIssueViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *phoneNo; +- (IBAction)onSignInButtonClick:(id)sender; + +@end diff --git a/PivxWallet/Wallofcoins/WOCHoldIssueViewController.m b/PivxWallet/Wallofcoins/WOCHoldIssueViewController.m new file mode 100644 index 00000000..29b604ae --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCHoldIssueViewController.m @@ -0,0 +1,42 @@ +// +// WOCHoldIssueViewController.m +// Wallofcoins +// +// Created by Genitrust on 21/02/18. +// Copyright © 2018 Aaron Voisine. All rights reserved. +// + +#import "WOCHoldIssueViewController.h" + +@interface WOCHoldIssueViewController () + +@end + +@implementation WOCHoldIssueViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view. +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +- (void)openSite:(NSURL*)url { + if ([[UIApplication sharedApplication] canOpenURL:url]) { + [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) { + APILog(@"URL opened..."); + }]; + } +} + +// MARK: - IBAction +- (IBAction)onSignInButtonClick:(id)sender { + if (self.phoneNo != nil) { + [self openSite:[NSURL URLWithString:[NSString stringWithFormat:@"https://wallofcoins.com/signin/%@/",self.phoneNo]]]; + } +} + +@end diff --git a/PivxWallet/Wallofcoins/WOCMedia.xcassets/Contents.json b/PivxWallet/Wallofcoins/WOCMedia.xcassets/Contents.json new file mode 100644 index 00000000..da4a164c --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCMedia.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/PivxWallet/Wallofcoins/WOCMedia.xcassets/barcode.imageset/Contents.json b/PivxWallet/Wallofcoins/WOCMedia.xcassets/barcode.imageset/Contents.json new file mode 100644 index 00000000..d28eb8aa --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCMedia.xcassets/barcode.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "download.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/PivxWallet/Wallofcoins/WOCMedia.xcassets/barcode.imageset/download.png b/PivxWallet/Wallofcoins/WOCMedia.xcassets/barcode.imageset/download.png new file mode 100644 index 0000000000000000000000000000000000000000..bc5de272d234c56da6d5040dbf7e2649da131b40 GIT binary patch literal 373 zcmV-*0gC>KP)YKj3`8F-0V(xwMBOa#&Ge7r0~nyn0Q{H~yLOXJQe{~<>@>{~)Q}vSco5giBNV;{ zi~^vAGgi~BLY_4Vx+EZR_H2@(tW;(b=-YlAu&qCV@(=KMl~#*qQvL?svqOI>0h-xIjZ>?rEud#oI*h2I_(U5vsLz!PtQ!i(k!3TG(s9J-5SRMq63 zjHJYyR*SM3dmZS_`kvo{%jOd(ABMtns7c^0U?}T;C-EFh61c)!UGFsAwVFdMsOue? zBrS$+(k)bMa@s))>^Rx;I!b43IG}Ka7tPogwwYN6hJen=o<$q*=GjiYO*=@u=yy6` zIMCluIPKq4{uR!lrVmqH=^odoKPk*aT0o9<9kigxQGeb$NUKHRF1G*I=r8dTdHd9E T@g#%900000NkvXXu0mjfW}~P} literal 0 HcmV?d00001 diff --git a/PivxWallet/Wallofcoins/WOCMedia.xcassets/dropdown_icon.imageset/Contents.json b/PivxWallet/Wallofcoins/WOCMedia.xcassets/dropdown_icon.imageset/Contents.json new file mode 100644 index 00000000..8e193b0b --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCMedia.xcassets/dropdown_icon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "dropdown_icon.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/PivxWallet/Wallofcoins/WOCMedia.xcassets/dropdown_icon.imageset/dropdown_icon.png b/PivxWallet/Wallofcoins/WOCMedia.xcassets/dropdown_icon.imageset/dropdown_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..0b610ecff8f76a9b89b5097975eb3eddee706327 GIT binary patch literal 1187 zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1|+Qw)-3{3jKx9jP7LeL$-HD>VB*dUi71Ki z^|4CM&(%vz$xlkvtH>8? ztx|+H{+JOY(tXU6h&ZnOBlp z1hfpQ8|FaVDxhZB=!1d_Dfl390~Q5FjvbecK0KoBxcFVQCIgd&o2QFohzIZ9Y0=qI zjv~iPV{@12sxA~@S~$r>#Y94JsY0WQfJUyI(=XFcN7pRiT%`ESSNY!i>Fk2@e=)9E zv}jSq%l|WSIt#Df^p?4BckayMy6SU3-=E1a_0Cy*v4g+;u=>uJcV63d^cMW`Q2E5Y z|MkOyAJe1ResEUJ^ij+GTX%njYjvrCWAMr=sb;gcZjD-NE~4=(PF%;~@y8u&$BD(2QBD1esTPs|eW#2D>l699iko@qe|Lq2t6y@;_4MoJ}j%n-b?L zYT#%*^GvzJ`h{_eD|#mH?F!dxKfKU6>b%p!39Bz=?3r6)|JP;Jv&w({N(M?#8Eko3 znDS!o`z9}|X4#NaC@8Yh_Smi0FUxlOTzI}-arLo=EX5^@ORU}=eDvYpPUmaYCk2H? zoHi-lx*fIlTchZgqIoI?j*NfW-hbh9imH9-bIRCw#sZJGidSB@PPn$j;m9+i>k_wT zJ>~orcxK`iJGFv^0Tu@)K9zHdn$9)Dv|drd=@$Ey?pb+fijq(gYWm2qMef8Bc zndhH#(waX1{3Ewud&8_}mJ_ViR%J1i*V@fremAdv+UtsmcSDYNyyxrF)^jKqm(-S= z&oKS;(_EKo=CALx3r{8emXFbzy6sQhe&N##T8{?2oMX5nLTA>7tv9u&o(f;e7x}jG zjnRAs6|3)2k-b-DEH|EgHcy97J2P)4Tx062|}Rb6NtRTMtEb7vzY&QokOg>Hg1+lHrgWS zWcKdPn90sKGrRqvPeo9CG3uKX#J{(IASm?@+di}}l?o-=)F3E6wD^Ni=!>T7nL9I? zX}YoAW$t|Qo$sD|?zw001?ah|SeB6#0T!CBEf+H4bBB+JJu8rehoBb*p;u8ID_yBf z0ya+zcePvJL&AGs+11_tpRKn>9TgyPA7ZoSs0)aX0r00)%XR^J`jH<$>RKN5V(7Oq zK*TS4xZz{h!*f1C3ECFkK$#7nA@pGN!$;%jYvwjAKwmYb0gKL(K8 z-kPtb5${A?tlI~wzMrJ6wTdBr=Y%%%EaEMQ&o}4FQ^DA)s*}Z>!FI&AHCpoWI|RUq zx?7s@$8!5^Q=anY%X@i5{QA6kNcMelpE>R6eCYFpmMsVTrI(b06~u#xf1yS} z_UGdMvD``!0~u->P=lA4?YN`hilQ|3tHka)7T{2CGqw zjZfMwx$5irQN_*|e4l)UHmiYuz74Yp1t^#>hrJ3-SOXDcC_o0^7T9R1gAN8V6s;5) zieI5-7aQlmJn}lUna#nz!j%5V$X|o`xX!dHWQRV27P1=rj;t2bW$~+pTw@bIek?Zv zKPDL<64`^#UNTAck#RBsB6*5DP4<%UA_FqU$I>2EH_cM;u)Q~SI+rg`Rn{L_AC5qq~L$#SMj%U z$6Cz0vP{G5Y*=%5RT^yu;}-DInZ=349rJPVM6C3K^oO)8y(fJr{l>k`ead~!ea?NsT>_Ci%bnxC;Vy6=b6>{xYV#Ue-+LB$ z7`JEXmTRm^AtP)R9u{)KHsMiWGV&)32xCG~*nyU<>-!d;FP=Re4r3qYr~6#KE>;1F z`>_J_P5xC?ROxV(DIHdCO*p$HRQI@7^PwV@Pvuf+5K}u-6REM(K@W$s zrgorh0{i?O)v0c>QtHxU-hBdD(>iYJ4b2sIOVX2K8m~4gmYVA5h^QEb$V`rCQ-|7Z zS{nuL-t>?3n=-o(6I(7vocj#GzCZEo`!3>+v;dYIfPu#&ZWzzX2i^rZ^Mu;6+rb@? zNPG+6)c5T6zxpzGe*M(x+{AON=PiJ>H#?ob-|uwRK0yDg0B4PV0id6JRZw95ZvX%R zib+I4R7efol)Fm=F%XB(*Kzm&3po@O5z$7l^v|*vEG?`B>jOI*5p3-2ENsL=5G_Ph zMASkH->>g??8vYeZnK`=fj{_2GBcTMCfO7Uf2@ui`Dclpg9kXvF)uT8nurQ0@h3dN zD$GDbnqc-a+<_9OxyQBwlaNcpL@&ZMq?3lmx5O>MDAd&e-g&ryP@*i`CG!@b3_-17 z%}NsE-|*Qx-JqBLs~i8c+v6v;xq)im4f;xx_s7~FnS35fU^eZ_{*Pxf(sn^RXrUJ{ z73t_h-r>!R_1blu`jJjyDhbric0u+%=mTjSPC)iesF6Pda}LrONe22lNna@25R^bW zk+iEZkpBv5WP#qHtx6x@>uz>y6(hfu#oOhpDzt$4ex+^60(LH1T(vc+-jcQI%Wq?w zC;PWT#$&v?C91DpPD$r+05_nw$Lg(XybsEA1kIN(f$n@i_?zSXv35P4Tx062|}Rb6NtRTMtEb7vzY&QokOg>Hg1+lHrgWS zWcKdPn90sKGrRqvPeo9CG3uKX#J{(IASm?@+di}}l?o-=)F3E6wD^Ni=!>T7nL9I? zX}YoAW$t|Qo$sD|?zw001?ah|SeB6#0T!CBEf+H4bBB+JJu8rehoBb*p;u8ID_yBf z0ya+zcePvJL&AGs+11_tpRKn>9TgyPA7ZoSs0)aX0r00)%XR^J`jH<$>RKN5V(7Oq zK*TS4xZz{h!*f1C3ECFkK$#7nA@pGN!$;%jYvwjAKwmYb0gKL(K8 z-kPtb5${A?tlI~wzMrJ6wTdBr=Y%%%EaEMQ&o}4FQ^DA)s*}Z>!FI&AHCpoWI|RUq zx?7s@$8!5^Q=anY%X@i5{QA6kNcMelpE>R6eCYFpmMsVTrI(b06~u#xf1yS} z_UGdMvD``!0~u->P=lA4?YN`hilQ|3tHka)7T{2CGqw zjZfMwx$5irQN_*|e4l)UHmiYuz74Yp1t^#>hrJ3-SOXDcC_o0^7T9R1gAN8V6s;5) zieI5-7aQlmJn}lUna#nz!j%5V$X|o`xX!dHWQRV27P1=rj;t2bW$~+pTw@bIek?Zv zKPDL<64`^#UNTAck#RBsB6*5DP4<%UA_FqU$I>2EH_cM;u)Q~SI+rg`Rn{L_AC5qq~L$#SMj%U z$6Cz0vP{G5Y*=%5RT^yu;}-DInZ=349rJPVM6C3K^oO)8y(fJr{l>k`ead~!ea?NsT>_Ci%bnxC;Vy6=b6>{xYV#Ue-+LB$ z7`JEXmTRm^AtP)R9u{)KHsMiWGV&)32xCG~*nyU<>-!d;FP=Re4r3qYr~6#KE>;1F z`>_J_P5xC?ROxV(DIHdCO*p$HRQI@7^PwV@Pvuf+5K}u-6REM(K@W$s zrgorh0{i?O)v0c>QtHxU-hBdD(>iYJ4b2sIOVX2K8m~4gmYVA5h^QEb$V`rCQ-|7Z zS{nuL-t>?3n=-o(6I(7vocj#GzCZEo`!3>+v;dYIfPu#&ZWzzX2i^rZ^Mu;6+rb@? zNPG+6)c5T6zxpzGe*M(x+{AON=PiJ>H#?ob-|uwRK0yDg0B4PV0id6JRZw95ZvX%S ze@R3^RA>e5nayexK@^2!)Wn70PjC?zS@{DZE+k-{A^H%Jyo8vC5YboAoe$tvce+qS zC7>=62%_R9s1f{0zBAfPPjMBW0zYWfU&e~~|-2`i(5FQ@a8CwD3cE)BY#69o@R25KH+*dT*2lF7= zp24h3Kwa~^h^e1614oUoZC6y2TYw&k#9I@m5$!dX8f*aH@B?2tEdWiFpmw zt(I+*iwi(s*s`7CLLKelvXk=-a0$2q4Ny}aR<*lf%d6L#dj+eadI=l@Wm6uvi}LAr z!ND?_^KhZTaR1VY=#Tz6bMIj1E8^Uk^Ht>+alK>80tN!Qc99p*_KxHo$U87*1@bL4 zW&y_z-xoXJ78!o}%awF|=PP2|T)Xj$xZW|P7y1BGe~~MjnmN}VsQG#iw#sDA)y%oZ zOmnDl3!6FROfuJCg@LM&<7pAj9ADz~tIC-x;%4Tx09b{kR|i;A$rhellF$-*l@dDA3@BYnqy~^)1W}10kU$7A1p%=kiz~Qx z5y7&eq9}_UfyIUe3u_0v3%V#M>*6XlEN>EuSa#q0zIXG@z5kta&YU`DZU9i_Fa-i0 z3INFDi-mzv^n@u1iB!^EAP2O8GO!2AOqNJMkBA6`EP$WIXM=C9SM30iKCjtH*ZP+J zuNNVOEn>mvaX4~QM665zkcj}0x>*9D7yx-QIBz;zERf;7Gf`mZ*n9-Qak|w zOe>EQ6A!T=#KHWTVc`(FL(E}`d=nwIg1C~yW=Qh{V}_mQiWxBwLw(pYVOErs-x>gX zVhY>Oe{dd8&BzLo+F%0lK~Z+J|FF$@9N(}(U3hysGdKcb3y5E`d4W-b>k#w=;t1)Q z@SWht=Y@q1`b8*Zi)8-7cS5_E6C=%;BLGAbu`niT&^BUBDmQ=uaR9_Q9AQw@pufbU z0-mhSU`&Ybg_5Y)K_5v0Y<{eCO=(>$U<&;M2V+HQ0&xfvut64>3GXbx2c3WlM1Tvj zWhf0WK_(njXn`#pfsl(2hY)gzK!%J%2)ah-!xB;%0iKJ!kOJig<)mw5 z!6AKlx8H3)(u``_b_lj^PO?C5G=j=plb7J|bw%dnl7JB>k12EA%8*0zv7rNXGQ4 z5i6(#!WmrFrR9D9lC^KO+kKI@@X>W4tCW;)>H_K_TqRs4+$UTIRQUXZ&_?Kn=nmm7 z{N4I)RI)~5kOoKANCmLJ$PF8E@?=`Rwexe%2G{v&1q2)6q{~*3QZwP;%6LR0`IA5_ zhWAvNwB1*^3;bGdOMa6MptdhPehyG;R2t5Hj&>VfpL9*BB|nwFLQf!=UX?$<7JQ~k z^T1vl_9_e%*wXgWdTHBeHMAGB`=2>zH)wy-+GtxK zUv>oc=UqoJr8rPX6l;nTg-$^z#_;Dz@qx&cVnPX}XhUic#ggJj88Z@(;acYnWtjWL z{vNbA0aAx6fiLSWOvowaU=I2FwU5*%y@>k7&WeSyTrgWE zFOuzczD!Q=Mg56nT?oz~Q)M~)j%~Oh?tn932MPyNoQ^x;K0|o0D-HK0S*CDrNcF<~ za93#``=T$f{;Tz)cLtm2PP8QY6D>c}iGIW&VgP(PNau;;h`|uMNx8)A9I^C}_stUI z3b|<V$mWBEpa_(J6<{qW2b;k*Pz`FqesCBx z!5(`CTmY9r8@L0{lP>TS^nq7k06`EELPpdPUBn16M{E#B#1-*E{E<*33Q0hcku-#l zNRWJF5mJJzLduaXNHww#X+TaO=a4JNEu<6aLHmsBoeh?eq3PQ5{T){XQb)N;d8RC{Y_3dKp01pyT&jFP`I2(4ioA-2imwV&Wu8if zN`uM`m3~!qRR`5@)lAi;s=HLrsdlT8)GXBe)l$?7)wZggRC}n7shg_%s=@~oMw(@h2{~>4lPW}LW`lr(^{^zU#nf~owk8C zU7M}FM7vh|s`hK0F*-gvY@K4AJvwbV?{ulU{<;~uD|HX+-qXYNto0)GX6tRzJFV9{ zMq`Y}7}l8LG5g2d)<^ZN^`rFX=x^0;)$cbjGzc^h7_2uqY0zt^W$0s=Zn(zqs9}$h zx{;R=*JzE=F{39`O)8zrqn1%mQTvSbjf0FO##@Xp8V{IQn#7tEnCvmRXR2W8YMN@g z#qc;!)ibBkw(7u74->u0YH zZ)0z!ccu3OA5)(cpDLfn^s)4GdJX;AB-$k5q(hTl`?~wi^*!!~`33qF`(5-`^N;l} z_rD)t5|9?KJD@MnDR55U@gPD_NYKil8w>*mi&4$!3w8;f8+-WB~S zW>U=Zm^-mnv69&4IOVvcxazpq@qY2E;yb2{n=*IGg#^6>ZbE$`DKRdwDzSg6|J1cp zyONxeijvx=Sx(EDc5b@fbl&tMGn8jAXBAtO5UEwo0rdKS(;W zy|OE^-^`AieIQ3Qho94$Yn{6!_iTD17)s;19ctC`H1e8;d;_Z~hVgk^AGt zCF7T@U-GdyrTBaat)#T%{ZiJ_^FKNKRQA)SWvR<9E_YtOX$5fwe?|LB@0B}OsjkXf z^>Fp%)pcvAYl_#rTsvd!xzY)xo7X9TB(4x9ri{Q?eKAmF#`8FL_`4{*e96 z2V4)-9yC9=;gI^F;yR=*x32Fn=Ws`TLj9G7;D+W#kH$m4+W)$v$+)TFh~|;yM-`41 z9{qGI?^yqF!SUV`X(t{w&uG4La>~i;ry@^XJRNfS?3sWwCtK(($Ig15Z939<1{oiEm1a=BE0+3j-Um5Eo5UiH3u;+o&JGuIi{FSLcVU1^VP zzj-6+M#s&Ro87l~x1Qh5zCCbf0sM$BzNd1p^uGT6%HPNSzNf>v<4C7pXX}IL2X`K_ z9zOj;^vC!%z4ZJRXqx)v(Ti3TO@8aJ*9+>@}^uFxF*bj{# zLq6X9l=R+9uGLC0ejK*P6Mda4Tx062|}Rb6NtRTMtEb7vzY&QokOg>Hg1+lHrgWS zWcKdPn90sKGrRqvPeo9CG3uKX#J{(IASm?@+di}}l?o-=)F3E6wD^Ni=!>T7nL9I? zX}YoAW$t|Qo$sD|?zw001?ah|SeB6#0T!CBEf+H4bBB+JJu8rehoBb*p;u8ID_yBf z0ya+zcePvJL&AGs+11_tpRKn>9TgyPA7ZoSs0)aX0r00)%XR^J`jH<$>RKN5V(7Oq zK*TS4xZz{h!*f1C3ECFkK$#7nA@pGN!$;%jYvwjAKwmYb0gKL(K8 z-kPtb5${A?tlI~wzMrJ6wTdBr=Y%%%EaEMQ&o}4FQ^DA)s*}Z>!FI&AHCpoWI|RUq zx?7s@$8!5^Q=anY%X@i5{QA6kNcMelpE>R6eCYFpmMsVTrI(b06~u#xf1yS} z_UGdMvD``!0~u->P=lA4?YN`hilQ|3tHka)7T{2CGqw zjZfMwx$5irQN_*|e4l)UHmiYuz74Yp1t^#>hrJ3-SOXDcC_o0^7T9R1gAN8V6s;5) zieI5-7aQlmJn}lUna#nz!j%5V$X|o`xX!dHWQRV27P1=rj;t2bW$~+pTw@bIek?Zv zKPDL<64`^#UNTAck#RBsB6*5DP4<%UA_FqU$I>2EH_cM;u)Q~SI+rg`Rn{L_AC5qq~L$#SMj%U z$6Cz0vP{G5Y*=%5RT^yu;}-DInZ=349rJPVM6C3K^oO)8y(fJr{l>k`ead~!ea?NsT>_Ci%bnxC;Vy6=b6>{xYV#Ue-+LB$ z7`JEXmTRm^AtP)R9u{)KHsMiWGV&)32xCG~*nyU<>-!d;FP=Re4r3qYr~6#KE>;1F z`>_J_P5xC?ROxV(DIHdCO*p$HRQI@7^PwV@Pvuf+5K}u-6REM(K@W$s zrgorh0{i?O)v0c>QtHxU-hBdD(>iYJ4b2sIOVX2K8m~4gmYVA5h^QEb$V`rCQ-|7Z zS{nuL-t>?3n=-o(6I(7vocj#GzCZEo`!3>+v;dYIfPu#&ZWzzX2i^rZ^Mu;6+rb@? zNPG+6)c5T6zxpzGe*M(x+{AON=PiJ>H#?ob-|uwRK0yDg0B4PV0id6JRZw95ZvX%Q z$4Nv%R7eeDU>F5MDg^%j{~rp(VKi|x(BNPo{sF|_fmofYmH-V50phPf3JwN7qi!C+VM!HC zoT@aMPpDf|z+4Kn1i7%&fQb{LSqLeB$ph2(TA(H1WDR8BfQgUNgFgfS0)7iLx{zRr P00000NkvXXu0mjfMTl=L literal 0 HcmV?d00001 diff --git a/PivxWallet/Wallofcoins/WOCMedia.xcassets/ic_arrow_back_white.imageset/ic_arrow_back_white_24dp@2x.png b/PivxWallet/Wallofcoins/WOCMedia.xcassets/ic_arrow_back_white.imageset/ic_arrow_back_white_24dp@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..313982a42b64ace75d0eed8b6e81bfeb2abe7998 GIT binary patch literal 1571 zcmV+;2Hg3HP)4Tx062|}Rb6NtRTMtEb7vzY&QokOg>Hg1+lHrgWS zWcKdPn90sKGrRqvPeo9CG3uKX#J{(IASm?@+di}}l?o-=)F3E6wD^Ni=!>T7nL9I? zX}YoAW$t|Qo$sD|?zw001?ah|SeB6#0T!CBEf+H4bBB+JJu8rehoBb*p;u8ID_yBf z0ya+zcePvJL&AGs+11_tpRKn>9TgyPA7ZoSs0)aX0r00)%XR^J`jH<$>RKN5V(7Oq zK*TS4xZz{h!*f1C3ECFkK$#7nA@pGN!$;%jYvwjAKwmYb0gKL(K8 z-kPtb5${A?tlI~wzMrJ6wTdBr=Y%%%EaEMQ&o}4FQ^DA)s*}Z>!FI&AHCpoWI|RUq zx?7s@$8!5^Q=anY%X@i5{QA6kNcMelpE>R6eCYFpmMsVTrI(b06~u#xf1yS} z_UGdMvD``!0~u->P=lA4?YN`hilQ|3tHka)7T{2CGqw zjZfMwx$5irQN_*|e4l)UHmiYuz74Yp1t^#>hrJ3-SOXDcC_o0^7T9R1gAN8V6s;5) zieI5-7aQlmJn}lUna#nz!j%5V$X|o`xX!dHWQRV27P1=rj;t2bW$~+pTw@bIek?Zv zKPDL<64`^#UNTAck#RBsB6*5DP4<%UA_FqU$I>2EH_cM;u)Q~SI+rg`Rn{L_AC5qq~L$#SMj%U z$6Cz0vP{G5Y*=%5RT^yu;}-DInZ=349rJPVM6C3K^oO)8y(fJr{l>k`ead~!ea?NsT>_Ci%bnxC;Vy6=b6>{xYV#Ue-+LB$ z7`JEXmTRm^AtP)R9u{)KHsMiWGV&)32xCG~*nyU<>-!d;FP=Re4r3qYr~6#KE>;1F z`>_J_P5xC?ROxV(DIHdCO*p$HRQI@7^PwV@Pvuf+5K}u-6REM(K@W$s zrgorh0{i?O)v0c>QtHxU-hBdD(>iYJ4b2sIOVX2K8m~4gmYVA5h^QEb$V`rCQ-|7Z zS{nuL-t>?3n=-o(6I(7vocj#GzCZEo`!3>+v;dYIfPu#&ZWzzX2i^rZ^Mu;6+rb@? zNPG+6)c5T6zxpzGe*M(x+{AON=PiJ>H#?ob-|uwRK0yDg0B4PV0id6JRZw95ZvX%R z(Md!>RA>e5m`zT@Fc5_sKnSs5!#%hM|EB;6)Y5ApSRrwcUVzK6cgr9_z-!kWEj?(XYFFW z0!}w=A6$<;n+c;1pl8T<3j61B&+s6OMUPqmIY6{+%=XC5u17OrQ~^@po6O(wY&(oa zk6J763&;G9M~=d%f_Wuulldo}B>~>H=XKg70p7;EPMaja+nCpBlLYv>JOJ-^dtfxT zqjJSHy#cAB>>OD&-g#zxg4{5_PG1;vK8BN`D8{oCIT-|;im?mC1TVdxh@5aHLNEQI z-QvL3to5CSE9PzBrFR+GoMqsTa~oanFLf=5eZDgSgz%auh-q6CLT{m$E&@9pkOG{z z!U=)BMAr1IYOnOC$Ow@xr<`J)Yn!+(bXuomMw+F=T#r#F;N~J6X#0@GU-Q?F;6%Em zgyDoO5@{53h7-0(sGLq}JGDh3IVYN@lOnNKM=Sci<#bX`EJP&sqmMuh5XP0*&EG5f z*d5kuqVECQN6egf=l&>q;3hx-*JXzs8JKg)i~+7lr1^V28J089%s^%!Gw{C|_yS=< VkdHK*xX}Or002ovPDHLkV1gH_|Kb1u literal 0 HcmV?d00001 diff --git a/PivxWallet/Wallofcoins/WOCMedia.xcassets/ic_arrow_back_white.imageset/ic_arrow_back_white_24dp@3x.png b/PivxWallet/Wallofcoins/WOCMedia.xcassets/ic_arrow_back_white.imageset/ic_arrow_back_white_24dp@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..ffdb7cb7375ba74e4c0771e2237b0cb13ee9a384 GIT binary patch literal 3765 zcmV;m4odNfP)4Tx09b{kR|i;A$rhellF$-*l@dDA3@BYnqy~^)1W}10kU$7A1p%=kiz~Qx z5y7&eq9}_UfyIUe3u_0v3%V#M>*6XlEN>EuSa#q0zIXG@z5kta&YU`DZU9i_Fa-i0 z3INFDi-mzv^n@u1iB!^EAP2O8GO!2AOqNJMkBA6`EP$WIXM=C9SM30iKCjtH*ZP+J zuNNVOEn>mvaX4~QM665zkcj}0x>*9D7yx-QIBz;zERf;7Gf`mZ*n9-Qak|w zOe>EQ6A!T=#KHWTVc`(FL(E}`d=nwIg1C~yW=Qh{V}_mQiWxBwLw(pYVOErs-x>gX zVhY>Oe{dd8&BzLo+F%0lK~Z+J|FF$@9N(}(U3hysGdKcb3y5E`d4W-b>k#w=;t1)Q z@SWht=Y@q1`b8*Zi)8-7cS5_E6C=%;BLGAbu`niT&^BUBDmQ=uaR9_Q9AQw@pufbU z0-mhSU`&Ybg_5Y)K_5v0Y<{eCO=(>$U<&;M2V+HQ0&xfvut64>3GXbx2c3WlM1Tvj zWhf0WK_(njXn`#pfsl(2hY)gzK!%J%2)ah-!xB;%0iKJ!kOJig<)mw5 z!6AKlx8H3)(u``_b_lj^PO?C5G=j=plb7J|bw%dnl7JB>k12EA%8*0zv7rNXGQ4 z5i6(#!WmrFrR9D9lC^KO+kKI@@X>W4tCW;)>H_K_TqRs4+$UTIRQUXZ&_?Kn=nmm7 z{N4I)RI)~5kOoKANCmLJ$PF8E@?=`Rwexe%2G{v&1q2)6q{~*3QZwP;%6LR0`IA5_ zhWAvNwB1*^3;bGdOMa6MptdhPehyG;R2t5Hj&>VfpL9*BB|nwFLQf!=UX?$<7JQ~k z^T1vl_9_e%*wXgWdTHBeHMAGB`=2>zH)wy-+GtxK zUv>oc=UqoJr8rPX6l;nTg-$^z#_;Dz@qx&cVnPX}XhUic#ggJj88Z@(;acYnWtjWL z{vNbA0aAx6fiLSWOvowaU=I2FwU5*%y@>k7&WeSyTrgWE zFOuzczD!Q=Mg56nT?oz~Q)M~)j%~Oh?tn932MPyNoQ^x;K0|o0D-HK0S*CDrNcF<~ za93#``=T$f{;Tz)cLtm2PP8QY6D>c}iGIW&VgP(PNau;;h`|uMNx8)A9I^C}_stUI z3b|<V$mWBEpa_(J6<{qW2b;k*Pz`FqesCBx z!5(`CTmY9r8@L0{lP>TS^nq7k06`EELPpdPUBn16M{E#B#1-*E{E<*33Q0hcku-#l zNRWJF5mJJzLduaXNHww#X+TaO=a4JNEu<6aLHmsBoeh?eq3PQ5{T){XQb)N;d8RC{Y_3dKp01pyT&jFP`I2(4ioA-2imwV&Wu8if zN`uM`m3~!qRR`5@)lAi;s=HLrsdlT8)GXBe)l$?7)wZggRC}n7shg_%s=@~oMw(@h2{~>4lPW}LW`lr(^{^zU#nf~owk8C zU7M}FM7vh|s`hK0F*-gvY@K4AJvwbV?{ulU{<;~uD|HX+-qXYNto0)GX6tRzJFV9{ zMq`Y}7}l8LG5g2d)<^ZN^`rFX=x^0;)$cbjGzc^h7_2uqY0zt^W$0s=Zn(zqs9}$h zx{;R=*JzE=F{39`O)8zrqn1%mQTvSbjf0FO##@Xp8V{IQn#7tEnCvmRXR2W8YMN@g z#qc;!)ibBkw(7u74->u0YH zZ)0z!ccu3OA5)(cpDLfn^s)4GdJX;AB-$k5q(hTl`?~wi^*!!~`33qF`(5-`^N;l} z_rD)t5|9?KJD@MnDR55U@gPD_NYKil8w>*mi&4$!3w8;f8+-WB~S zW>U=Zm^-mnv69&4IOVvcxazpq@qY2E;yb2{n=*IGg#^6>ZbE$`DKRdwDzSg6|J1cp zyONxeijvx=Sx(EDc5b@fbl&tMGn8jAXBAtO5UEwo0rdKS(;W zy|OE^-^`AieIQ3Qho94$Yn{6!_iTD17)s;19ctC`H1e8;d;_Z~hVgk^AGt zCF7T@U-GdyrTBaat)#T%{ZiJ_^FKNKRQA)SWvR<9E_YtOX$5fwe?|LB@0B}OsjkXf z^>Fp%)pcvAYl_#rTsvd!xzY)xo7X9TB(4x9ri{Q?eKAmF#`8FL_`4{*e96 z2V4)-9yC9=;gI^F;yR=*x32Fn=Ws`TLj9G7;D+W#kH$m4+W)$v$+)TFh~|;yM-`41 z9{qGI?^yqF!SUV`X(t{w&uG4La>~i;ry@^XJRNfS?3sWwCtK(($Ig15Z939<1{oiEm1a=BE0+3j-Um5Eo5UiH3u;+o&JGuIi{FSLcVU1^VP zzj-6+M#s&Ro87l~x1Qh5zCCbf0sM$BzNd1p^uGT6%HPNSzNf>v<4C7pXX}IL2X`K_ z9zOj;^vC!%z4ZJRXqx)v(Ti3TO@8aJ*9+>@}^uFxF*bj{# zLq6X9l=9}G3E-xHEUwvdmTB5T zQQ}PA*z?mYCM+u1Q~TrDitHY!?CW{i7pIg2p%ux5G9i=z>d!rt384f~zttY9rJ|{X z{ZtJ8DqWvyFjBGO7?Jd#dpfs>EK<^f<{Y9Ez3LWD2WmNQI?i-lR1Dz2(STey;~*!_ zD9DX726E(#fLuBKAZJc5$eq&%3gGmBLO60z5Jw6MI1Ej-e)g~-tn6HrU4GW zd@r5Jl++J$PH6<>N*V*Tq#vt=8wI(M#z9Ub4akM01Feys`m^x$-9ZqLkpJNEHEt zpmYdQRXPYr(+7IryPosj+dcd5?#z5M-^`pn=TCuI7&6fE&;kGe24f>V>(gEQbcs?^ zo_?Xu z`TG4h7wUN^IkS9iX< z@czc(;mOzXQDVf&wbo}bWZEiyEYvJ6vVg4bW$oIGo(7?MB4j^#+ep-7-}l|^+4PdrN98+b^UT~{` zL?rPuxz&tp-&7blfAMperoyP0@*u@x2!NW6!}JYB>{R*^_ZL6#l?3&;TIT$Yc`|L6 z0zblS*C5z!9eXVa?*ZxMq6+?#r>avi&$yf6cf01m+sCi^Q)b_qGKzGI zuZP|w=V6O3B(Bad4RS43J2Z2`Gq|en-}#h8E(6t?AjHJECa%Y&om|5H>?Cqw)=nr!x%4&Wu&vixDD@MY})kd1((A}pnOCJDGL)tmNthti9!Jb zeJo8ipuUZ{kpwc!7=Mu*PB8`oijbUx(<#PQf~Xearkw@FDcEPJm4O!V!v!=B0K2x} zKst27wM{PiSeH#&vsgxFo_LVDUZPiqG>+a|J3NENjbdCEk-^ADt*>px#5t$yJxJ-r zn@z>8Qw$TeAv>YRCOy~2!Wh3X@!aSxXc+Y5ij$}osi5|4H+7a8quINe@F@q%X>n8j zlV2#O1F79>u~~!fw2^e{iBz+8nMgPJo3?;Dt@EeUuq$;TbsEWXZO9S-M} zX63!TczyIbs=8~;bqqD;J9cdqx<>{~Dw=;8cu(2VfgCK*Adq`UE!nrNZZ14fx6xQ# z0FpM^G5P6aOFB|glPU%fLmI;!!>M)arxA!Xo8~+@Mn@#h@{JH1s}D^sHHJp`hIb*C zRf3o9H!)=LN-{-fQ76Y7{~R>vp@_wh(0FFN@fNNU$6~GVh35;+7ybukwxU<>=4OU1 z$SkmIOKdZ2gAQ2r;|ooLo>UaztU|1wNmOPhWn*k4FW>!Yl#VO0##s55+LaMX1@*mz zZVH((-+tqfDVJ%G`AVotKc$eT(4w$hPhLMwpO8Gm%+D#D>Ya*DuIW@v$w|R-u5dnL zdz!+Vc9bTTvYa-Wib=g=GAnvPbV@{-Wt_!O3VxZ=#qkpmMlBjvHb+M`YmCL3IdJ3j>7kA5ej0a3)Y%7f_&HZ&8?WgUc z62h^E!VHBsa}4sjqtk)u66P`k(1Epw<`0Xm$Xzk3G^c&k61CH*#!hT=Wwp4>Y*glx2Lp>MmQggidLL?Kvd+Hb<|u-l9v z-MyMIPKJ7juQ~|XQQWEGxW}QB7M><+8r&z|hwO`%GA;*{N0#%Bz_gN~6l#n<&CA?UJ^q5H*#xxn$ViJDc(HOf`)J*&N>H7Y(EJ~;3)kih?uPvv$G zpJ5(4Zw_mr+#I5a@7?#`~n6H=2{ zQ{m!0R1&ddxgxtVzA~v;>NnQp5?D0c{nmW2Z|qmPQ70Rl5~HH+VEhemExwt8^8 zvwJiXIqEA#ugXT4?hP^uXnj~rUZ6%DHcTR_#^T0bPrk1kMlZ)AknEDZVvLkXms*oSfqlj8#EJHr!5OH{^>aPCyX>j#VeI*gJ3y_{ zZ>4?}Llu&m@oHJo3tjIAi}+qSHs*lHCgs7*@mJQe%)k`t9^L_^^6Zk2E(jdoqy-NC(_%Qx$Vr`l=CmlEw?C$gspBENZdwEbbIx)h%)IWG~zWkHj zMgzomqiHE>tvh&s#ZE0x6-=yt74&4dWarqt{E>NsG(urUu{CPlZpVobY>!r$srhSo z%71!#=*7$BA;+XwcI)_=SJC-lKW(d=0xX@3hzUQ~PskXR84U!_Yew#fpS=GzFJoD4 ziOf&ckclqYtoW*gCGt>8Q-Xm_z?o=)Z^v6q5uZP9NVLXqzl**YWu;!IZY}R47w*y@ zRdKYqo!e1GURBbA`f>h8!}jPz72(IH?>%cNn<<}^+Lh!3c8I+#<Cxu z;(J?FKfY|V$Sg9m;<6I~08&zK8#o$nZl>xQ;170j3%KqM4)qT_{RagA)I(KIkN)mx z7f`6b9|ENssv-2tLiO}~CWZ)sewm_Y0`o~Aa$ghhpM%n z!Qb%Hn}(1V8Xc$#fnYEgFh(96fb@jOs;HvBCH7_A{BbQb78<2O(DQ15>tAy9v(b($dLOaqYxLm~eQhW7UO zKd>{+Z`iNAeuq;(bEXRO4t4jl*YoywN1#rrY04|9|BCWoihp?i0fhepya4?Z_=n;T z;2959OQg5^X^GAXp((2l`7hbu_Ue$cD*aKl-!1tiJ?)7mtvcjC{ne!X>qRsH03ew+ z*1Ko}r&${vFd?;KquMO8Ef0BL>zVwS;>tJL_3%5OEB$IOpB1xoW^?EYWe#@qct8} zU=3-G5)VvZUT^o2*?O&@ig!j9`=HVTYX;+lR3ujz`9yO`pmWlJ^}{N_dv$(w+uB|N zjW@5LoOlZ-)Z-G{x#*@GE2EekP>Uujc@!2eSth+V`f8tPCfSV0^;g|Vdd$bPJ`p{` za2^w4)rwP4+9Eb;ttlt44PUxD6klq@xN8^dA555&G?@z4u%G)BDBj*VpixfW_N22Y zISZ|G4mTxYZIp{HK?2*HsaE7@aYyTYhK~$NLY|3zDCh`~=aG09jv(GmKcst5w+*1@ z*;Qg;oqjAP7@X{5UJ@d86~OfarJTIFt6=T^;GJ#mu6o-03z;K049--h8@=aqkHSLu zL-&>(twi6n1X~87gc;TWokI|bgGNL{fh1dOA>S9`)T5)CXBpqWx!xX5;ynu6dbt3b nbP23oVl#6~VM%70z27FrJo9w0rzXMe?1>xeTj)L4agP5Nz38MC literal 0 HcmV?d00001 diff --git a/PivxWallet/Wallofcoins/WOCMedia.xcassets/woc-icon.imageset/Contents.json b/PivxWallet/Wallofcoins/WOCMedia.xcassets/woc-icon.imageset/Contents.json new file mode 100644 index 00000000..a12badad --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCMedia.xcassets/woc-icon.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "Main Logo (Color).pdf", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/PivxWallet/Wallofcoins/WOCMedia.xcassets/woc-icon.imageset/Main Logo (Color).pdf b/PivxWallet/Wallofcoins/WOCMedia.xcassets/woc-icon.imageset/Main Logo (Color).pdf new file mode 100644 index 0000000000000000000000000000000000000000..0805785b897d6cedc2a28f02da995df14755fe55 GIT binary patch literal 14264 zcma)j1yo#3vn>!pa0u=aB)Gc;cX#)}-Q8V-ySsZ}@Zhe&oeicCub30S%?^jYz-|CV0m~DVCj|J?Epmd@&={= zP($9p0bt`q#01h%1T}?hZJa=DM-2yqv{JX`+_Zm3JG{C{h{5KkCIvg08h(MoL?brUlZh(#P z@0t5OAOFmusJWFBzyV}h)Cy!z7+_>;3?O>-K^kCV>SP8&Vqj(e1I5wF0bpQ_0PD6K zoz+%N&Rw7R1ip)(Ok037yfZf^{+UeNkH7#di?J1e*YPR$@q>EP^C`B_iblp`q)I#K zB?`9j0%7n==Ln(ik?oJY$qnD9Yx%QOCzEf*;yu3V5PR5R`Z0@aGwQUpnK8?QIJ+1AHr6W}?sXdz;oz=YD{_1-E zaYYD-zGNMU#ZtK4H~%D?qcP_b1)NYzHu`qQIubiA_Qdtm=y<8?{(jojT+ers{HM`i zwelRn&m`OE`4P38PqMTb7Z%hMXK^y-Og@PUA?q`)K7hx?4paA+#issGNozYf1Z7R< z5pyGo?vq6|6DKueghrV~F>{<<^oXqjh7L?GBkHi8pQl|)F-;4xrbq|7NiUOp>W7C9!g{GkCWa?A_AD zYMKD0I6Wwg} zyq%xI8nVeP2MTMv*}RL?M!t*5W*S$U?7YJvf*0RaGAB5R#;W)Iu_JZHHeenpQoFuOg!h8(|UAbE97Yh z)D&U;$mXwSOAty(sCxf1?UDtmqV|45t@hodG4bA*#IQqDvA~|@z{K5w^j4W3v#IxV zTxM571=FPpSqaZ**?ZD1jU?QUZlh*x=i)KMt}+wfBoIFTFtb#YsZOl+5s1#E;U1cI|*a4Rl z0T?IC8(+22cQHZ_@wuy7UrVy+MdSKXwMbHR?wik9sY%iUZOIn};Eh$un? z%zf3^t}~EVhOgpkez)fQ*JO-4JMl|94*P41&gvi2UWuYAq)pr z%?a-v8WCAzNmttBSzK*i4t;fM$Z5Zo!zF zA(<7e=a}x2t7P)3NdA)3M@``DfSLG_I6lAF%BCf7o12Vylq^COhjqj8WkUNgP0-&7 zqtLnT;}@F2rRbV$hi`S2RHON->?;)Lh(<#(6D;*s1z(hel{z(@szh&Cqle=#G=QIZ z2hoO9(nA~HB~I$jggT#=Na$3k9}#?FLdFd5&&~AQleZ}=n;OXj<& z!;pxs^6n}&mEI<{jwhVoa7Ul&qse7jWY##98&u3_{I;c$L>J0pcsM2iEKJ`zvac7q zyY`MjL&n$CvE}r)F`UWJtsD3(sZNGK#Z{$=r7+&>U1h5E6O+8Ge9n+rl_iUBHBct) zG6z)-C{oR3J1kML;(c_y5J9I&^_{#(APi@&EA(Mmy=lsLO97CeP@ZU%j>riPq-JNH zEw;8$wKhLUjO!%<(i=)mm)PJjahD)bKYx!YTIK>}tD&gfU9wJFw}WM+4oc?CLD6z4 zH7}Eb-u@D>NY7R4J|jZm^3!YrP)1WLJuUjPQKhJlbFFfzAsf{Qzpl|L`45)6cXw+8 zGiJRb_6JOPRhVU&PR_>E4DGZV$rrlchthXP-#r-YxZP!Ni%v8(g^gMa}Xe<}wZlkAFjZGCi~GC$-?jG#-bc~tuq=1c2{ z0_oec5{v3r8NJ4e>#Q1el0T;NXJfPNS$RuueYQLa~ zHL^}oF;BcsUbRN3lM>^#RxP3GNcNJN@RSVT3xdn~!C1cTp%~1w#ZURn(91=$)L2%^ zN%J8rc(=3bdnsnSxHn*n)&vM|xtsowSyT8mF+kdzC8ws=L%B%d!6N{fHy$dyUb~-$ z{)l*8l7;GN<0>h_@=`sAhCTfTm#sxYTm+yZ2^D+wNa#6Y6K|9tflVRLo>s+klWW$} zA41itSEss9ed2lhuw0$FGfu+!^yM8q`)CQh#za7Z3~DaawphS*Ce#Qeu`ZXOY~tuQ zu9K)jn}lc`lUr|&-4F6Ti-uGCEtSeRD^98FTcPb9?jB>CI2Wt~hv`>M&D!@GCx+JZ z-zgsVp@aJDBo~?CN62sYwBmFuOryyv6jd;+$CApa$yi-G)-{F4<78T1tgx?Icj3~pm(VWfuk-hX=3KR(I8+C80)0ol~UnhP3Fu& zX0MV<7}r`dP0Pm0t}7~SsppGoO7u25`vxH}$2nT(N}c|V4B>_T18H(CrJyFxuvJ#6CQB=UA0H?lk$%Xsc|8NpobdI)Dl#t%8AbNx&W_F`1)XS_Oo zZq?&q6ko?XrH#VdOc(Bu972bWIFgyU-X&Cm+lUo$H8et9B_{hw9(FfhBwY4$JYM7{ zIP@#VPV>BUyNRDxi_6Dt(p=Ig0+D3Tdk;3$ytn7RC9AZ7I~|qu<${T9(N$7Cnv)O% z^O)*$F3@ML3%qWY*ljj?dnF3I3R})wFiT~U64dt_9*I`S`P$QUh?9+nHsXFIcJed3 zB%_D`-M(*bekphx`vsxPfTlrPBb_pkgpe*tWL1XQ1T56TA4WvQ{t5fdB6&82 z8xt>$2%ED0WRpZM$L+mqU7Vu4pFW0a|HK32Wtl+-a{69`X{Yf-&k8ddl4)V1O#%dk zh`9FB(j6?3#f>h)SE&PTi?g{ceq%cB6El*Y2jIy9GJwQ~vg~kkP%7o@v~CKh{*;DIg0F#cMRP z`Qb__W(Qn8ur~cbb6tUlsAm2s@Q+`}<4y0{IOQRPx+6^0wW(HiANI~Tr1^YW;yyGA(}Sl6v$xifOT<{R#cTvrCZ z;*W12MLM#gMN*D#@=^Nyg+=B06BV6=5^w zTx$G*dcp1t;oiS{EZ0BNAY=LoiDAwzWtL*o@-Q#plVE>$%gzkUO5XP8F;5V$iMO1HX2!zcxSH15~f43Co5M))y){0A7peU!Mf_1uN0ahwU&?E z$uFP#nPY09`Mux)JVYMAZ)S_GyJL~Bp^k+Go2&q6aPxOVT-Sq8ba2pVYGsLVyKsg;fo0@G1zF<%%iezAa!03@YIT!rR-^Xlc?)m$=E0t=6 zr0B6yN^$;|qoCqVYnY3HFT-#uF6j|q8({TWP30eoD%Y>lGM#j@mbKn%9nEc61kp%y z>*Dg_aT8Qcg+s=bvc-TK*P4a7xk5~!Sk>|-o^ z2Nkse0oyj}l!!o;5wMX3pkA5S|9aiwN0&@nk!+YlL`aRv&P1VT+**=esKfXzeVOoE z5>ejH!soAeoL{`+daR*x;-1MK#c~A#{p*r$D%GH7>63}o*J3WfUZhtX{79b@oovI= zx>nshJjSPzZyOFvDwr^o&@W2rzdr>xh`Q4{Tc#Kg#agKk^>0*Je`1REH&S?h966Z~ zRz}Lg>+|S(1|F8UQ6d=m0p5~5P$J531!=y(XNag`jgifpvnAn9(J`#mKZQi`KN^PF zPm>fOFzD+;-=S|2YSH+IA~)FO+`$5?1I0L5O3VX)E#!D#=Qb7%e%6pHXcb|(Z-`;s zbSMe{&+fIV69O9)`0CPS16WvbG((Zso$ZDIOTo=dM7t1@!%2kt$(491G_Fkpr?fmK z0+UD&z`$gS9b#VWB0H4Tl8xP2*+q;qKDNTU=}oSev?R^7381bWC1e^3u|bwWf(f1A zW1G3>tcGzlj5MmF7z9{Z1?OE?_28~i$jZORE3nJSW|E?8gThj*2Gqk>R1{9<*6 zu}Y{yq6)r2-l`5_KEwzZg+_JzGMK((4KFiz!^i?WEljK9cSBVPN4yLIJVgdgNS=|b zyrN)CgJ7ohJ^we32SRuA5{nKM-MT}PM^#5y>|72|YN@p!z^Kt2@g4=w;Vu#&v5Zx_ zH#VblV{#x-8M01b<|W4z8rYk}-lJ^w-$Al|N0eLaqbW)gW5+RzP#WaNN92gAq$NA+6Qm5#*1F z;MgJxN2AE7;pCc3b8GO@6^%Hy8F$6qvy45zNLwz2(0zS{% zx~7aBRfmb#q8asaNC3t=nFs=mh*1ckIR+FQQZn>S1TD#0W}h<|hRN?=_TnkOLz9Yx zq#(ZUhanzsMlm_1-K?|4)fx}7FGL7y{#gMY?PkfPGL}iCb=UYbJd@;1YwlJbyD&JC zjK^tYrM~RQ{e|_+N*PbU&{=C9Tvx^`lAXUD{mGiC#AigGe>#22)&%iXo9!fi-#Yw8 z9f$ZFLN!}5w$RKRN(q+bOW?frJ_NTG76b%G-zD0L5cq!3(*pJfQ@G@gFCii@8?&!88bVLQ^P1dvC6lCEDk|-rwgoI&`r#Pmwd-9kbt~v zD(0{UpiB}C$0f^noV4feJBXWhE0$_9(xsIh&5e!B1_ZJQLJ4bod*%5M3FUF&h_iobQjmN@ChpzzC$%KUFk##=r`tbCKb*lbI zfZmq`K%b&l(Y0xp)uODH6czYE0fp(hkp+#+K>|ycTs3m~=Jyq;?yDpSw zqT#in4+_ZpcrK6wjELw!t-LcOg&6~H4CFRc->^Kehqs0uSq(ZX3CBfMx0s7#1{C3Q zWTx3FKdNs8f5pG06oXLy+9Ln!5xNnYkBLHsptJGl^-NvUDtW!k;deAUoM%VU7I~PQt=jnoJfk8gLEDS6$+g!&|V1+ zg#Lsf3%boS(Wu{l(zm+}LdZVm9oYMZ38AT~wF%`0IkhjTbdxL#^=8x}Q_#1;XV^tD z!Q0DB9<_@pmjz@*l#f}i0KgK$pfw7tl$ z`!#CMEeVYr!-Fan$}Jo(YtHQW{=HDtTNZSA$Z+$gnALhb0F@EmxH&U;Tf<6}D%^|7 znIi#MSSXpzILDz+kZ&Tv&CLX`(7r5IRvzJ6pZ;l`K2FlR1{QmTVCHMVvH?v{8^z{! zP4-Oo(}mWYT*I9GIhftBB7Ui-$ZmZ%BB@zGW>5(B9w!QN%hS$Sq)=ivG!G(_vA4ea zNPnL|eyVxYugwNjwXD1trz^!|OYT!oX36RX7^!9YbAf&6eGc7q-c$M5j?NCTCK>nBm8@eJ1ya=Gz>?rx8z>z^kC=?H;t}zvOXSW4Vi{Mm0Ol)$po0( zNZMX~NMD*ZUG%+rnkts@9$ZCmsUyDnAc>SbmsXe~8XLdJFE~%M zI|D}sXcu|3K|#j*BBG{{htq@y#x=+NR04C!;31ZAZ@YK90CS70JX(2zpgC13?#5|iY4(s zCs19cNOnjS;S=7BYmiZeNpyQrHSV~*9KUDRCs^ldJ&FSyx8I92`8 z3C`(WZv>FkMC-hb3bWWDk^O!?EvT^%9z~{Gtx0n}E4V5|E>m=uzDUNdI1BWmp}<&TFWR1bv6-KCpRBobBkFvaFUJ~}O7#_$HW%y-#6@xzA`okS!X z9(Sr(O%nifLZrBIr2!bc42~!YLtwtP&nIY)E=jLXUd5-(yaQ(jMz!o5N4KSqzV&eG zi7!|5G13_AKYs?#W~<^PC{_T`!54VfX7tJxpD8%{NOgo|f97udz%l0BG=e$~IQj;m z2*rw?1V)#1iF%i-&(&6Ol3U#YYd1Kc_J*xjr`uZ(O^R&DaiBGh+J3BiD~3fi8jr0} z(Bb*1f|w1tH4G7_f8AO*00zfaM)rea)Jsi=(^a_Ww=r-(wA^FN0`0~hOr-Lau` zwEV^skcFyn^}g&46G+kN0jK1g*%?G)$`S|gwR>OPv@WA4Q8q3h&PN*D%7cWt%~(h}%%r^;ab+)dxB@SqCR>-ZBVVQ2tG2lD z=IV}czJzO5OG3@nT+aJ50D7bf-C^-p>+p;*=-&c_kOl%hz8;8RO=NWnq!{Ybb zi~OgY@0b0MG=qH^u};BH&HKwd+ZP-@RlZ>mNq{m-^o|T4LTlj9W63jB&>m0pCJ%1_ zFQcSNZj6WCn30wOx=3@k9%*5!IEmTpA_0Ug@JSmfi5uf8GY5vX-mNZc)_8Cs-oDTk zW!e;fk-~hS8QmF%Xg!^#_L==Yp&vZMolpWBw@@zcKwIx~VA- z0B4VvD{$Gu^(H)y%Op@=>5>{j@8|u7-AzR~6-;SPdAZ$kYG?!}F_d({#%W?OnBY@q zO|YpQr0!iFd~F5|vQwXE6#vHbiupON=c;*93uT^YA+Sk6)L9IJCT?m=aVh5Nq9~$) zs$>88rYU@>A_l!LFpa3vcSIa9!#(*-%%;2xA@Ex&cK6hc4CAh^0Shya-zvGEyv&+6WLZ{}%ApEpcL?rb2?gqBJ4V#&_={=__t`%59PhI+O+i9ih+(EV zOc=124F_Wz!LO0mAUxu zKXF84?yM_;eh^K?L?@8i=M8a;#D;gI{4J7q>|;z@xlY-Kw@E6Y4(Eu1CO*zb?Fuqr z1}37Hz@@ZhaWNatpXpT4JMajtv%8Rkzm|JlUqV|;D#7Xf=zmJ72++k+Ih0$`K0d3Q~lApv5*Kq+^g5&fa~_j7+>( zUCOJfd2E=TS$v&JXV}h-^rP$#K@7A(R4zzvUrqNf)`V$%&Gs)C!(}K)2rk+&*OXei zM>h;A!9ZD7I{Fkyc4jOahw`uV!s$wB(W5k2F4xoiCN|iH3a1%0C+mFZc$#qMjF7x# z?TR1GDS>4H_&z7v6eDv{`$Uk;Z|^T!ENWPY$ex65okCnj8>&<0rs*l3m9I0_haLQE z?8Id+3mXC-2plo$-d0U@G*DGcqt$Bea%Rki&Epl>yJYsx(0pqoM4kl?+gGBn zsFynCi_4>cs>XSSi9JbX440pSl1OzXpm)dPbkg}j$)i#Z-Dw^3+HUjlyrg2Dfm?0! zufai4APC3$Qw{Sh`{r;TRS&S9l4@_&bfJ}@g@&1Y?}c0KgGxEFTPVdT-I#tg0l4HHUc-v0W49XN(_-PpTsl*uc0q)e-tRwFBW|kPoLffT`ar_5qrW{l&nsMYN4!X(MEd** zh!cV&N~5y_-X&f`C*)Z@LY2)qzMlouuEuo{XRzQt29_IdsvOg}J|MY<#x~=Z z@x0~dYa?gZUvK17Lb8{NZ+1SVn~Q^2eA}1WT4m}xK(B4bfBznklB}VGU=q{oTfCzM z?_Y9UM$dsRmlU>P%0=$SLJ!Zie!GX#5t$*q_E4Ky_-65tuV8~ih(C(qERA@JRk2KJ za07Y)TGOs0_N-Ac%CFq}%ySX>ODb`TaO+E+Wn_>n#2VAH)av&%IrKZohU?&oQQz#& zXvs}j@qUl6olr;Du=f$+b=`BldfJ_z^HD>6t-|fS<`0u>Cjx23o@T}5;23chzn)H3 zp}bWqjwH1#5(x5-{R+TMh^#R29pw|`oVcF9hHjQrHez$$hs>g*-)2h=74%LD;z{~I zwmp_|%V9X>bi=?Wx)Ce7i07|Q)6@0^Y2iRMla?H4V?*@jh9d5S`m>-h3rrXLn{K|9 zhu9|v;Q3<2XOi^18sPa{J%8qqeQ~Julv7<&DbxWsHP_mfyLM(RBZa~M;6aeuVwHx; z%cF*4C$l%xq7+j80++%KbE||u!RmtUZGaq$b?bBy5SNb?`iA>x9-hV@;zx?3j_@DnYC3UmVVk$|zni>INV;9==*UZV4s z(ybgaO1TNsIo1?0&^hmsALjK+!(e$=-`nC@=;x%^eiR?svEb10!?aEFMcurW zwYI-#oP` zT=?sHfcws7HsX&OuB;7WY-h$6jG&j8xJyMVeD&+XaN8Ow`qq&(%%a=u!aI~g{nUZ5 zGqI`CPBF$5x>H6I?;Oz0Ov_V2q;dY0F+d~VDWr0n04$&Y#q~so^*4=y<+HT+Xh{M7+OZDg{crfs# zVJQ39w>^VOhJL1D?@0WErD^ssfq3x#li&5^Xs*>!e zh3{=Vb^T$3Z^3w`GYU^ffrg>+X#x1CkVXVQT|3x}+q=#3#gDhaJN z2#sEqn}TY4A`{y>Rh)lv9kd_|mfoP9$m!$d%!lIj`eE{eJz?N@Jg<=T$kB7zMz(&jVkR8)AM>PR30!Q>)`}_#Cc%>B*)kT2wr6PS2`N$>D z1Sg52J|ZyIp?^i7@)nz%4Ike>?@S7qwhF;_7x)n=!i#<9?l<`;s}>_&8j+Dnig>$s|k)cEJ#)8L{9n%}Ey;x|=6J(p8{U~hXUMG*B#{pfe{ z9rbH#IX@QFyRp5CI^EOmHy!)nXkk@gO?8pRGV)gKH=yXf@*4Z@ zb0G{89QIk9A|&BUB9JN|LpugZCj9(T3z!iv(jvlxO}$dU*XXbh%RZ=eT_t^Z6q?B7 z!mvw9oNY4&2ZsJI8L!0!{aNaf5d;2{6%2uA&riio~` zyJ+Vy_T!Tj&SMI@&ZeMG@c^7xGOJI4vRzd>i}f?;UfAK&TGga-xkZ^Fw~#=0 zFTR`KbMJavK!fIh(4g)#y6g6a&L#*Zo>nec)BfE+Dj`xhN7aL~XIt|j-YKbv&4NnB zmL=r@>na=-xvMYpl*+wW|2Y{^^PG~JU0o^G?5`TxHK^QQsyf{Zvc6iZ(5syV^9!hn zyOH`Or(^!A%*FN0_VifO3^&sw3;7kUPR@mN$~?wl*moxHP`Iw84koztF4wFWox>;W zy_`jkkvP4A2u2<&=_QU*j!ZbtskTGasy(77=&9cS3WtT`N4@7nFWK)NI3*uB~`p zI0uBIJpaI_c!r+S>|3~JiQ1Q|Ht2^t>r|0KeCml3!(~7^RRBgveOkzGv$RpIsx$Tl zSEY2WsP}oGj5xI8rSvF-C9uV8Fp|e8minp1mU0~ z-hmWH9l|I^Cs?D<^D}TqOvhQ&%Py~m+c?TLG76zYh=(Nxa(+d!dEcgF`BFw%x%$S< zP=A0+K2xrLgZCK%ZtHc`J4hVTg}C$6{X;vGC_UI)|*_Fw1lc#$!th;T!;7BtZ^fz!E`cRRm!0V_>)3- z$Yef=jpyqpEVXzSds@OfdEDX^1nG0=s9q@%bosb-Z8bP5HF+X~sDKF3F}blfP~CWkyJ<-DqL-TEs$7{n<>&aD{-2!0sn7&OnI#me zdd!6wU0Z;WFKI5Rh@k(zy2}=a6_R*&1!ra&%3oA@?5O9`;p3 ze--tiXzAj-k`qmgjX*N|uH|}ZsB9%~*@GtgUoe6g7qXp~uw2@+8cHK07*|fmFOB!Khi#rQLafxjhHMB%w;$eG3qq%ct)0gS z9;M`~%CHOccZeMqeaZjXavam~%S^)<`p)zW{~Fo52|W+3^plF!G4W`_sXh8(ajl4s zCQsu?uor2k>phX~&8gdq!L0JqPODx_d{D5h8T0nGle^!=?ecW7gfKdt=-Q2!q>a9 zsHMZl_qzIye=GbaJ>%8RKW_iMiu9u94vtPlpfG=XA#Lza<6nb*?f+-AvbmELh(hv5 zlD#h3Ym%{nmh3gj{!XypG5@XgKQHd@8T-wz`Ewrr)#xi1kfGh zf(^8DUITdzj)etuv;EP2%}F)@=zb0MbyvN<{~0tZNawFz#{P=;+7H5f)%jymK>7TN z18OsaChYeUg#Y`=0g{32Ff+d=bW%WO0Z2u)=W&lyh z{zDIxK%m<7Z)1OF(0|Annc3JuJL}){7@1f&{@VuoYpMH7&&k2S+zR0ECml}7+yn4? zy66>cZ9%pF&srg2V`5A6n=b}hLJ3gq~+ k#9#tE&0?9q?nSt-CY>|xA&jf59DzcctjR6 zFo>ywFr#OX$_Jnzdx@v7EBie*ULgZZHf`f{pwKo?7sn8f<7=-4@--;%Fb7=!eP7bv zaKl>NN9~=7)r?o#B+lREzTYm9_&b|_pY!K+#o7F;l;&zrw>hMoe)UaE+KUO6+jS#V zwe@Z~x31awWvRiY$3Yv^tJg7PPbyTMF?mk*fw>_TzYeAzmc4$?Ape~u*E)vBEFZ$< zKE*!yZ*iv~N#zPhKr(aHq70QeE`c5uj7L3pFdp^TQF+{Bhm7*WV%tvPb;^auuBzPG nlRWkINyq1(=IyARQ_U#0Bhz~F;)kt3A24{j`njxgN@xNA#C&lC literal 0 HcmV?d00001 diff --git a/PivxWallet/Wallofcoins/WOCPasswordViewController.h b/PivxWallet/Wallofcoins/WOCPasswordViewController.h new file mode 100644 index 00000000..33d23c3d --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCPasswordViewController.h @@ -0,0 +1,28 @@ +// +// WOCPasswordViewController.h +// Wallofcoins +// +// Created by Genitrust on 27/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" +@interface WOCPasswordViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *offerId; +@property (strong, nonatomic) NSString *phoneNo; + +@property (weak, nonatomic) IBOutlet UIView *mainView; +@property (weak, nonatomic) IBOutlet UILabel *WOCLinkLabel; +@property (weak, nonatomic) IBOutlet UIButton *WOCLinkButton; +@property (weak, nonatomic) IBOutlet UITextField *passwordTextfield; +@property (weak, nonatomic) IBOutlet UIButton *loginButton; +@property (weak, nonatomic) IBOutlet UIButton *forgotPasswordButton; + +- (IBAction)onLinkButtonClick:(id)sender; +- (IBAction)onLoginButtonClick:(id)sender; +- (IBAction)onForgotPasswordButtonClick:(id)sender; +- (IBAction)onCloseButtonClick:(id)sender; + +@end diff --git a/PivxWallet/Wallofcoins/WOCPasswordViewController.m b/PivxWallet/Wallofcoins/WOCPasswordViewController.m new file mode 100644 index 00000000..2defaf80 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCPasswordViewController.m @@ -0,0 +1,219 @@ +// +// WOCPasswordViewController.m +// Wallofcoins +// +// Created by Genitrust on 27/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCPasswordViewController.h" +#import "WOCBuyingWizardInputVarificationCodeViewController.h" +#import "APIManager.h" +#import "WOCConstants.h" +#import "WOCAlertController.h" +#import "MBProgressHUD.h" + +@interface WOCPasswordViewController () + +@end + +@implementation WOCPasswordViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7]; + + self.mainView.layer.cornerRadius = 3.0; + self.mainView.layer.masksToBounds = YES; + + [self setShadowOnButton:self.loginButton]; + [self setShadowOnButton:self.forgotPasswordButton]; + + NSMutableAttributedString *titleString = [[NSMutableAttributedString alloc] initWithString:self.WOCLinkButton.titleLabel.text]; + [titleString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(29, 13)]; + [titleString addAttribute:NSForegroundColorAttributeName value:[UIColor darkGrayColor] range:NSMakeRange(29, 13)]; + [self.WOCLinkButton setAttributedTitle:titleString forState:UIControlStateNormal]; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + + +// MARK: - API + +- (void)login:(NSString*)phoneNo password:(NSString*)password { + NSDictionary *params = @{ + WOCApiBodyPassword: password, + WOCApiBodyJsonParameter: @"YES" + }; + + [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDict, NSError *error) { + if (error == nil) { + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + [self storeDeviceInfoLocally]; + + [self getDeviceId:phoneNo]; + } + else { + dispatch_async(dispatch_get_main_queue(), ^{ + if (error.userInfo != nil) { + if (error.userInfo[@"detail"] != nil) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self]; + } + }); + } + }]; +} + +- (void)registerDevice:(NSString*)phoneNo { + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; + + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *params = @{ + WOCApiBodyName: WOCApiBodyDeviceName_IOS, + WOCApiBodyCode: deviceCode, + WOCApiBodyJsonParameter:@"YES" + }; + + [[APIManager sharedInstance] registerDevice:params response:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^(void) { + [hud hideAnimated:YES]; + }); + + if (error == nil) { + NSDictionary *response = (NSDictionary*)responseDict; + if (response.count > 0) { + NSString *deviceId = [NSString stringWithFormat:@"%@",[response valueForKey:WOCApiResponseId]]; + [self authorize:phoneNo deviceId:deviceId]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + }]; +} + +- (void)getDeviceId:(NSString*)phoneNo { + dispatch_async(dispatch_get_main_queue(), ^(void){ + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; + + [[APIManager sharedInstance] getDevice:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^(void){ + [hud hideAnimated:YES]; + }); + + if (error == nil) { + if ([responseDict isKindOfClass:[NSArray class]]) { + NSArray *response = (NSArray*)responseDict; + if (response.count > 0) { + NSDictionary *dictionary = [response lastObject]; + NSString *deviceId = [NSString stringWithFormat:@"%@",[dictionary valueForKey:@"id"]]; + + if (deviceId.length > 0 && (![deviceId isEqualToString:@"(null)"])) { + [self.defaults setValue:deviceId forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self authorize:phoneNo deviceId:deviceId]; + } + } + else { + [self registerDevice:phoneNo]; + } + } + else { + [self registerDevice:phoneNo]; + } + } + else { + [self registerDevice:phoneNo]; + //[[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + }]; + }); +} + +- (void)authorize:(NSString*)phoneNo deviceId:(NSString*)deviceId { + + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; + + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + + NSDictionary *params = @{ + WOCApiBodyDeviceCode: deviceCode, + WOCApiBodyDeviceId: deviceId, + WOCApiBodyJsonParameter: @"YES" + }; + + [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^(void){ + [hud hideAnimated:YES]; + }); + + if (error == nil) { + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiResponseDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self storeDeviceInfoLocally]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [self dismissViewControllerAnimated:YES completion:nil]; + //move to step 8 + [[NSNotificationCenter defaultCenter] postNotificationName:WOCNotificationObserverNameBuyDashStep8 object:phoneNo]; + }); + } + else { + dispatch_async(dispatch_get_main_queue(), ^{ + + [self registerDevice:phoneNo]; + }); + } + }]; +} +// MARK: - IBAction + +- (IBAction)onLinkButtonClick:(id)sender { + NSURL *url = [NSURL URLWithString:@"https://wallofcoins.com/"]; + if ([[UIApplication sharedApplication] canOpenURL:url]) { + [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; + } +} + +- (IBAction)onLoginButtonClick:(id)sender { + NSString *password = [self.passwordTextfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + if ([password length] > 0) { + [self login:self.phoneNo password:password]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter password." viewController:self.navigationController.visibleViewController]; + } +} + +- (IBAction)onForgotPasswordButtonClick:(id)sender { + NSURL *url = [NSURL URLWithString:@"https://wallofcoins.com/en/forgotPassword/"]; + if ([[UIApplication sharedApplication] canOpenURL:url]) { + [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; + } +} + +- (IBAction)onCloseButtonClick:(id)sender { + [self dismissViewControllerAnimated:YES completion:nil]; +} + +@end + diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAddNewBankViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAddNewBankViewController.h new file mode 100644 index 00000000..03a4fd0c --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAddNewBankViewController.h @@ -0,0 +1,23 @@ +// +// WOCSellingWizardPaymentCenterViewController.h +// Wallofcoins +// +// Created by Genitrust on 23/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" +@interface WOCSellingAddNewBankViewController : WOCBaseViewController + +@property (weak, nonatomic) IBOutlet UITextField *txtPaymentCenter; +@property (weak, nonatomic) IBOutlet UITextField *txtAccoutName; +@property (weak, nonatomic) IBOutlet UITextField *txtAccoutNumber; +@property (weak, nonatomic) IBOutlet UITextField *txtConfirmAccoutNumber; +@property (weak, nonatomic) IBOutlet UIButton *btnNext; + +- (IBAction)nextStepClicked:(id)sender; +- (IBAction)useMostRecentBankAccoutClick:(id)sender; + +@end + diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAddNewBankViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAddNewBankViewController.m new file mode 100644 index 00000000..23f0e2fc --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAddNewBankViewController.m @@ -0,0 +1,127 @@ +// +// WOCSellingWizardPaymentCenterViewController.m +// Wallofcoins +// +// Created by Genitrust on 23/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCSellingAddNewBankViewController.h" +#import "WOCSellingWizardInputAmountViewController.h" +#import "APIManager.h" +#import "WOCAlertController.h" +#import "WOCSellingWizardPaymentCenterViewController.h" + +@interface WOCSellingAddNewBankViewController () + +@property (strong, nonatomic) NSArray *paymentCenters; +@property (strong, nonatomic) UIPickerView *pickerView; +@property (strong, nonatomic) NSString *bankId; + +@end + +@implementation WOCSellingAddNewBankViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + [self setShadowOnButton:self.btnNext]; + + self.pickerView = [[UIPickerView alloc] init]; + self.pickerView.delegate = self; + self.pickerView.dataSource = self; + self.txtPaymentCenter.inputView = self.pickerView; + + [self getPaymentCenters]; +} + +// MARK: - API + +- (void)getPaymentCenters { + + [[APIManager sharedInstance] getAvailablePaymentCenters:^(id responseDict, NSError *error) { + if (error == nil) { + if ([responseDict isKindOfClass:[NSArray class]]) { + NSArray *responseArray = [[NSArray alloc] initWithArray:(NSArray *)responseDict]; + NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]; + self.paymentCenters = [responseArray sortedArrayUsingDescriptors:@[sort]]; + [self.pickerView reloadAllComponents]; + } + } + }]; +} + +// MARK: - IBAction + +- (IBAction)nextStepClicked:(id)sender { + + if ([self.bankId length] > 0 && self.txtAccoutName.text.length > 0 + && self.txtAccoutNumber.text.length > 0 + && self.txtConfirmAccoutNumber.text.length > 0 && [self.txtAccoutNumber.text isEqualToString:self.txtConfirmAccoutNumber.text]) { + WOCSellingWizardInputAmountViewController *inputAmountViewController = (WOCSellingWizardInputAmountViewController*)[self getViewController:@"WOCSellingWizardInputAmountViewController"];; + inputAmountViewController.bankId = self.bankId; + + NSString *bankInfo = [NSString stringWithFormat:@"%@ (-%@)",self.txtPaymentCenter.text,self.bankId]; + [self.defaults setObject:bankInfo forKey:WOCUserDefaultsLocalBankInfo]; + [self.defaults synchronize]; + + [self.defaults setObject:self.txtAccoutName.text forKey:WOCUserDefaultsLocalBankName]; + [self.defaults synchronize]; + + [self.defaults setObject:self.txtConfirmAccoutNumber.text forKey:WOCUserDefaultsLocalBankAccountNumber]; + [self.defaults synchronize]; + + [self.defaults setObject:self.bankId forKey:WOCUserDefaultsLocalBankAccount]; + [self.defaults synchronize]; + + [self pushViewController:inputAmountViewController animated:YES]; + return; + } + else { + + if ([self.bankId length] == 0 ) { + [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Select payment center." viewController:self.navigationController.visibleViewController]; + } + else if (self.txtAccoutName.text.length == 0) { + + [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Please enter account name." viewController:self.navigationController.visibleViewController]; + } + else if (self.txtAccoutNumber.text.length == 0) { + + [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Please enter account number." viewController:self.navigationController.visibleViewController]; + } + else if (self.txtConfirmAccoutNumber.text.length == 0) { + + [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Please enter confirm account number." viewController:self.navigationController.visibleViewController]; + } + else if (![self.txtAccoutNumber.text isEqualToString:self.txtConfirmAccoutNumber.text]) { + [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Account number and confirm account number not matched." viewController:self.navigationController.visibleViewController]; + } + } +} + +// MARK: UIPickerView Delegates + +- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView { + return 1; +} + +- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component { + return self.paymentCenters.count; +} + +- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { + return self.paymentCenters[row][@"name"]; +} + +- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { + self.txtPaymentCenter.text = self.paymentCenters[row][@"name"]; + self.bankId = [NSString stringWithFormat:@"%@",self.paymentCenters[row][@"id"]]; +} + +- (IBAction)useMostRecentBankAccoutClick:(id)sender { + WOCSellingWizardPaymentCenterViewController *paymentCenterViewController = (WOCSellingWizardPaymentCenterViewController*)[self getViewController:@"WOCSellingWizardPaymentCenterViewController"]; + [self pushViewController:paymentCenterViewController animated:YES]; +} +@end + diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdsInstructionsViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdsInstructionsViewController.h new file mode 100644 index 00000000..ff628a45 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdsInstructionsViewController.h @@ -0,0 +1,30 @@ +// +// WOCSellingAdsInstructionsViewController.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" + +// Enter Phone Number Screen +@interface WOCSellingAdsInstructionsViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *accountInformation; +@property (strong, nonatomic) NSString *currentPrice; +@property (strong, nonatomic) NSString *AdvertiseId; +@property (weak, nonatomic) IBOutlet UITextField *bankNameTextfield; +@property (weak, nonatomic) IBOutlet UITextField *accountNameTextfield; +@property (weak, nonatomic) IBOutlet UITextField *accountNumberTextfield; +@property (weak, nonatomic) IBOutlet UITextField *availableCryptoTextfield; +@property (weak, nonatomic) IBOutlet UITextField *txtEmail; +@property (weak, nonatomic) IBOutlet UITextField *currentPriceTextfield; +@property (weak, nonatomic) IBOutlet UIButton *editYourCurrentRateButton; +@property (strong, nonatomic) IBOutlet UIButton *advancedOptionsButton; +- (IBAction)onEditYourCurrentRateButtonClick:(UIButton *)sender; +- (IBAction)backToHomeScreenAction:(id)sender; +- (IBAction)onAdvancedOptionsButtonClick:(UIButton *)sender; + +@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdsInstructionsViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdsInstructionsViewController.m new file mode 100644 index 00000000..2637eb40 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdsInstructionsViewController.m @@ -0,0 +1,133 @@ +// +// WOCSellingVerifyDetailViewController.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCSellingAdsInstructionsViewController.h" +#import "WOCSellingAdvancedOptionsInstructionsViewController.h" +#import "BRAppDelegate.h" +#import "APIManager.h" +#import "WOCConstants.h" + + +@interface WOCSellingAdsInstructionsViewController () + +@property (strong, nonatomic) NSArray *countries; +@property (strong, nonatomic) UIPickerView *pickerView; +@property (strong, nonatomic) NSString *countryCode; +@property (strong, nonatomic) NSString *purchaseCode; +@property (strong, nonatomic) NSString *holdId; +@property (strong, nonatomic) NSString *deviceName; +@end + +@implementation WOCSellingAdsInstructionsViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + [self setShadowOnButton:self.editYourCurrentRateButton]; + + if (self.accountInformation != nil && self.accountInformation.length > 0) { + self.bankNameTextfield.text = self.accountInformation; + } + +// if (self.currentPrice != nil && self.currentPrice.length > 0){ +// self.txtCurrentPrice.text = self.currentPrice; +// } + + self.availableCryptoTextfield.text = [NSString stringWithFormat:@"%@ 0.000",WOCCurrencySymbol]; + + NSString *emailAddress = [self.defaults objectForKey:WOCUserDefaultsLocalEmail]; + if (emailAddress != nil && emailAddress.length > 0) { + self.txtEmail.text = emailAddress; + } + + NSString *bankAccountInfo = [self.defaults objectForKey:WOCUserDefaultsLocalBankInfo]; + if (bankAccountInfo != nil && bankAccountInfo.length > 0) { + self.bankNameTextfield.text = bankAccountInfo; + } + + NSString *bankAccount = [self.defaults objectForKey:WOCUserDefaultsLocalBankAccountNumber]; + if (bankAccount != nil && bankAccount.length > 0) { + self.accountNumberTextfield.text = bankAccount; + } + + NSString *bankName = [self.defaults objectForKey:WOCUserDefaultsLocalBankName]; + if (bankName != nil && bankName.length > 0) { + self.accountNameTextfield.text = bankName; + } + + NSString *currentPrice = [self.defaults objectForKey:WOCUserDefaultsLocalPrice]; + if (currentPrice != nil && currentPrice.length > 0) { + self.currentPriceTextfield.text = [NSString stringWithFormat:@"$ %@",currentPrice]; + } + self.accountNumberTextfield.userInteractionEnabled = NO; + self.accountNameTextfield.userInteractionEnabled = NO; + self.bankNameTextfield.userInteractionEnabled = NO; + self.availableCryptoTextfield.userInteractionEnabled = NO; + self.currentPriceTextfield.userInteractionEnabled = NO; + self.txtEmail.userInteractionEnabled = NO; + [self loadAdData]; +} + +- (void)loadAdData +{ + if (self.AdvertiseId != nil && self.AdvertiseId.length > 0) { + [[APIManager sharedInstance] getDetailFromADId:self.AdvertiseId response:^(id responseDict, NSError *error) { + APILog(@"responseDict = %@",responseDict); + + self.bankNameTextfield.text = self.accountInformation; + self.availableCryptoTextfield.text = [NSString stringWithFormat:@"%@ 0.000",WOCCurrencySymbol]; + + //self.txtEmail.text = REMOVE_NULL_VALUE(responseDict[@""]); + self.bankNameTextfield.text = REMOVE_NULL_VALUE(responseDict[@""]); + self.accountNumberTextfield.text = REMOVE_NULL_VALUE(responseDict[@""]); + self.accountNameTextfield.text = REMOVE_NULL_VALUE(responseDict[@""]); + self.currentPriceTextfield.text = [NSString stringWithFormat:@"$ %@",REMOVE_NULL_VALUE(responseDict[@"currentPrice"])]; + + /* + balance = "0.00000000"; + buyCurrency = USD; + currentPrice = "1.20"; + dynamicPrice = 0; + fundingAddress = "(Not Available - Needs Verification)"; + id = 90; + maxPayment = 0; + minPayment = 0; + onHold = "0.00000000"; + primaryMarket = ""; + publicBalance = "0.00000000"; + published = 0; + secondaryMarket = ""; + sellCrypto = DASH; + sellerFee = ""; + userEnabled = 1; + verified = 0; + */ + }]; + } +} + +- (IBAction)onAdvancedOptionsButtonClick:(id)sender +{ + [self.defaults setBool:NO forKey:@"isBeforeCreateAd"]; + [self.defaults synchronize]; + + WOCSellingAdvancedOptionsInstructionsViewController *sellingAdvancedOptionsInstructionsViewController = [self getViewController:@"WOCSellingAdvancedOptionsInstructionsViewController"]; + [self pushViewController:sellingAdvancedOptionsInstructionsViewController animated:YES]; + [sellingAdvancedOptionsInstructionsViewController setupUI]; +} + +- (IBAction)onEditYourCurrentRateButtonClick:(UIButton *)sender { + APILog(@"Edit Your current rate button clicked"); +} + +- (IBAction)backToHomeScreenAction:(id)sender { + [self backToMainView]; +} + +@end + diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdvancedOptionsInstructionsViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdvancedOptionsInstructionsViewController.h new file mode 100644 index 00000000..63453407 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdvancedOptionsInstructionsViewController.h @@ -0,0 +1,21 @@ +// +// WOCSellingAdvancedOptionsInstructionsViewController.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" + +// Enter Phone Number Screen +@interface WOCSellingAdvancedOptionsInstructionsViewController : WOCBaseViewController +@property (assign, nonatomic) BOOL isBeforeCreateAd; +@property (weak, nonatomic) IBOutlet UITextField *maxLimitTextfield; +@property (weak, nonatomic) IBOutlet UITextField *minLimitTextfield; +@property (weak, nonatomic) IBOutlet UIButton *saveButton; +- (IBAction)onSaveButtonClick:(id)sender; +- (void)loadVarificationScreen; +- (void)setupUI; +@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdvancedOptionsInstructionsViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdvancedOptionsInstructionsViewController.m new file mode 100644 index 00000000..f8b83291 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdvancedOptionsInstructionsViewController.m @@ -0,0 +1,83 @@ +// +// WOCSellingAdvancedOptionsInstructionsViewController.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCSellingAdvancedOptionsInstructionsViewController.h" +#import "WOCSellingVerifyDetailViewController.h" +#import "WOCSellingAdsInstructionsViewController.h" + +@interface WOCSellingAdvancedOptionsInstructionsViewController () + +@end + +@implementation WOCSellingAdvancedOptionsInstructionsViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + [self setShadowOnButton:self.saveButton]; + + NSString *minDeposit = [self.defaults objectForKey:WOCUserDefaultsLocalMinDeposit]; + if (minDeposit != nil && minDeposit.length > 0){ + self.minLimitTextfield.text = minDeposit; + } + + NSString *maxDeposit = [self.defaults objectForKey:WOCUserDefaultsLocalMaxDeposit]; + if (maxDeposit != nil && maxDeposit.length > 0){ + self.maxLimitTextfield.text = maxDeposit; + } +} + +- (void)viewWillAppear:(BOOL)animated { + + [self setupUI]; +} + +- (void)setupUI { + + self.isBeforeCreateAd = [self.defaults boolForKey:@"isBeforeCreateAd"]; + if (self.isBeforeCreateAd == YES) { + [self.saveButton setTitle:@"NEXT" forState:UIControlStateNormal]; + } + else { + [self.saveButton setTitle:@"Save" forState:UIControlStateNormal]; + } +} + +// MARK: - IBAction +- (IBAction)onSaveButtonClick:(id)sender { + + if ([self.minLimitTextfield.text length] == 0) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter minimum deposit limit." viewController:self.navigationController.visibleViewController]; + } + else if ([self.maxLimitTextfield.text length] == 0) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter maximum deposit limit." viewController:self.navigationController.visibleViewController]; + } + else { + + [self.defaults setObject:self.minLimitTextfield.text forKey:WOCUserDefaultsLocalMinDeposit]; + [self.defaults synchronize]; + + [self.defaults setObject:self.maxLimitTextfield.text forKey:WOCUserDefaultsLocalMaxDeposit]; + [self.defaults synchronize]; + + if (self.isBeforeCreateAd) { + [self loadVarificationScreen]; + } + else { + WOCSellingAdsInstructionsViewController *myViewController = [self getViewController:@"WOCSellingAdsInstructionsViewController"]; + [self pushViewController:myViewController animated:YES]; + } + } +} + +- (void)loadVarificationScreen { + WOCSellingVerifyDetailViewController *verifyDetailViewController = (WOCSellingVerifyDetailViewController*)[self getViewController:@"WOCSellingVerifyDetailViewController"]; + [self pushViewController:verifyDetailViewController animated:YES]; +} +@end + diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingCreatePasswordViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingCreatePasswordViewController.h new file mode 100644 index 00000000..b7e800b4 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingCreatePasswordViewController.h @@ -0,0 +1,27 @@ +// +// WOCSellingCreatePasswordViewController.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" +@interface WOCSellingCreatePasswordViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *purchaseCode; +@property (strong, nonatomic) NSString *offerId; +@property (strong, nonatomic) NSString *holdId; +@property (strong, nonatomic) NSString *phoneNo; +@property (strong, nonatomic) NSString *emailId; +@property (strong, nonatomic) NSString *deviceCode; +@property (strong, nonatomic) NSString *deviceName; + +@property (weak, nonatomic) IBOutlet UILabel *descLabel; +@property (weak, nonatomic) IBOutlet UITextField *purchaseCodeTextfield; +@property (weak, nonatomic) IBOutlet UIButton *confirmVarificationCodeButton; +- (IBAction)onConfirmVerificationCode:(UIButton *)sender; +- (IBAction)onResendCodeButtonClick:(UIButton *)sender; + +@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingCreatePasswordViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingCreatePasswordViewController.m new file mode 100644 index 00000000..c26c56e8 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingCreatePasswordViewController.m @@ -0,0 +1,82 @@ +// +// WOCSellingCreatePasswordViewController.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCSellingCreatePasswordViewController.h" +#import "WOCSellingInstructionsViewController.h" +#import "WOCSellingSummaryViewController.h" +#import "APIManager.h" +#import "WOCConstants.h" +#import "WOCAlertController.h" +#import "BRRootViewController.h" +#import "BRAppDelegate.h" +#import "MBProgressHUD.h" + +@interface WOCSellingCreatePasswordViewController () + +@end + +@implementation WOCSellingCreatePasswordViewController + +- (void)viewDidLoad { + + [super viewDidLoad]; + + [self setShadowOnButton:self.confirmVarificationCodeButton]; + + NSString *userDeviceName = @""; + if (self.deviceName != nil) { + userDeviceName = [NSString stringWithFormat:@"named %@",self.deviceName]; + } + self.descLabel.text = [NSString stringWithFormat:@"You are already signed up with an app %@. Congratulations! Now type a secure password to continue.",userDeviceName]; + if (self.purchaseCode != nil) { + self.purchaseCodeTextfield.text = REMOVE_NULL_VALUE(self.purchaseCode); + } + else { + self.purchaseCodeTextfield.text = @""; + } + self.purchaseCodeTextfield.delegate = self; +} + +- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { + + if(textField.text.length == 4 && string.length == 1) + { + [self performSelector:@selector(onConfirmVerificationCode:) withObject:self afterDelay:1.0]; + } + return YES; +} + +// MARK: - IBAction +- (IBAction)onConfirmVerificationCode:(UIButton *)sender { + + NSString *txtCode = [self.purchaseCodeTextfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + + if ([txtCode length] == 5) { + WOCSellingInstructionsViewController *instructionsViewController = [self getViewController:@"WOCSellingInstructionsViewController"]; + instructionsViewController.purchaseCode = txtCode; + instructionsViewController.holdId = self.holdId; + instructionsViewController.phoneNo = self.phoneNo; + [self pushViewController:instructionsViewController animated:YES]; + } + else if ([txtCode length] == 0) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:@"Enter Purchase Code" viewController:self.navigationController.visibleViewController]; + } + else if ([txtCode length] != 5) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:@"Enter Valid Purchase Code" viewController:self.navigationController.visibleViewController]; + } +} + +- (IBAction)onResendCodeButtonClick:(UIButton *)sender { + APILog(@"onResendCodeButtonClick"); +} +@end +/* Resend Code + Problems receiving your code? Your mobile phone must be able to receive text messages. If you are sure you typed your mobile number correctly, double check that you are in an area with good mobile service signal. Also, try texting the word "Start" to (217) 672-6467. This will "unblock" our service from sending you text messages. + + If you still need help, contact us toll-free: 866-841-COIN (866-841-2646). + */ diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingInstructionsViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingInstructionsViewController.h new file mode 100644 index 00000000..d3c0e999 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingInstructionsViewController.h @@ -0,0 +1,47 @@ +// +// WOCSellingInstructionsViewController.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" +@interface WOCSellingInstructionsViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *purchaseCode; +@property (strong, nonatomic) NSString *holdId; +@property (strong, nonatomic) NSString *offerId; +@property (strong, nonatomic) NSString *phoneNo; +@property (strong, nonatomic) NSDictionary *orderDict; +@property (assign, nonatomic) BOOL isFromSend; +@property (assign, nonatomic) BOOL isFromOffer; + +@property (weak, nonatomic) IBOutlet UIImageView *imgView; +@property (weak, nonatomic) IBOutlet UILabel *lblBankName; +@property (weak, nonatomic) IBOutlet UILabel *lblPhone; +@property (weak, nonatomic) IBOutlet UIButton *btnCheckLocation; + +@property (weak, nonatomic) IBOutlet UILabel *lblAccountName; +@property (weak, nonatomic) IBOutlet UILabel *lblAccountNo; +@property (weak, nonatomic) IBOutlet UILabel *lblCashDeposit; +@property (weak, nonatomic) IBOutlet UILabel *lblDepositDue; +@property (weak, nonatomic) IBOutlet UIButton *btnDepositFinished; +@property (weak, nonatomic) IBOutlet UIButton *btnCancelOrder; + +@property (weak, nonatomic) IBOutlet UILabel *lblInstructions; +@property (weak, nonatomic) IBOutlet UITextView *txtInstruction; +@property (weak, nonatomic) IBOutlet UIButton *btnWallOfCoins; +@property (weak, nonatomic) IBOutlet UILabel *lblLoginPhone; +@property (weak, nonatomic) IBOutlet UIButton *btnSignOut; + +- (IBAction)showMapClicked:(id)sender; +- (IBAction)depositFinishedClicked:(id)sender; +- (IBAction)cancelOrderClicked:(id)sender; +- (IBAction)wallOfCoinsClicked:(id)sender; +- (IBAction)onSignOutButtonClick:(id)sender; +- (void)captureHold:(NSString*)purchaseCode holdId:(NSString*)holdId ; +- (void)deleteHold:(NSString*)holdId count:(NSUInteger)count; + +@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingInstructionsViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingInstructionsViewController.m new file mode 100644 index 00000000..638f8f5d --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingInstructionsViewController.m @@ -0,0 +1,633 @@ +// +// WOCSellingInstructionsViewController.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCSellingInstructionsViewController.h" +#import "WOCSellingSummaryViewController.h" +#import "WOCSellingWizardHomeViewController.h" +#import "APIManager.h" +#import "WOCConstants.h" +#import "BRRootViewController.h" +#import "BRAppDelegate.h" +#import "WOCAlertController.h" +#import "WOCLocationManager.h" +#import "MBProgressHUD.h" + +@interface WOCSellingInstructionsViewController () + +@property (strong, nonatomic) NSString *orderId; +@property (strong, nonatomic) NSString *dueTime; +@property (assign, nonatomic) int minutes; +@property (strong, nonatomic) NSTimer *timer; +@property (strong, nonatomic) NSString *locationUrl; +@end + +@implementation WOCSellingInstructionsViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + [self setShadowOnButton:self.btnDepositFinished]; + [self setShadowOnButton:self.btnCancelOrder]; + [self setShadowOnButton:self.btnWallOfCoins]; + [self setShadowOnButton:self.btnSignOut]; + + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + NSString *loginPhone = [NSString stringWithFormat:@"Your wallet is signed into Wall of Coins using your mobile number %@",phoneNo]; + self.lblLoginPhone.text = loginPhone; + + if (self.orderDict.count > 0) { + [self updateData:self.orderDict]; + } + + self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"navigation_back"] style:UIBarButtonItemStylePlain target:self action:@selector(back:)]; + + if (!self.isFromSend && !self.isFromOffer) { + if ([self.purchaseCode length] > 0 && [self.holdId length] > 0) { + [self captureHold:self.purchaseCode holdId:self.holdId]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Please enter purchase code." viewController:self.navigationController.visibleViewController]; + } + } + else if (self.isFromOffer) { + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + if (self.offerId != nil && [self.offerId length] > 0) { + [self createHold:self.offerId phoneNo:phoneNo]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Please select offer." viewController:self.navigationController.visibleViewController]; + [self.navigationController popViewControllerAnimated:YES]; + } + } + + NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"If you have any questions, there is a live chat window at wallofcoins.com or you may call the phone number that sent you a text message." attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15.5]}]; + + [attributedString addAttribute:NSLinkAttributeName + value:@"https://wallofcoins.com" + range:[[attributedString string] rangeOfString:@"wallofcoins.com"]]; + + + NSDictionary *linkAttributes = @{ + NSForegroundColorAttributeName: [UIColor blackColor], + NSUnderlineColorAttributeName: [UIColor blackColor], + NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle) + }; + + // assume that textView is a UITextView previously created (either by code or Interface Builder) + self.txtInstruction.linkTextAttributes = linkAttributes; // customizes the appearance of links + self.txtInstruction.attributedText = attributedString; + self.txtInstruction.delegate = self; +} + + +- (void)pushToHome +{ + dispatch_async(dispatch_get_main_queue(), ^{ + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:WOCBuyingStoryboard bundle:nil]; + WOCSellingWizardHomeViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"WOCSellingWizardHomeViewController"]; + vc.isFromSend = YES; + UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:vc]; + navigationController.navigationBar.tintColor = [UIColor whiteColor]; + BRAppDelegate *appDelegate = (BRAppDelegate*)[[UIApplication sharedApplication] delegate]; + appDelegate.window.rootViewController = navigationController; + }); + return; + + BOOL viewFound = NO; + + for (UIViewController *controller in self.navigationController.viewControllers) { + if ([controller isKindOfClass:[WOCSellingWizardHomeViewController class]]) { + [self.navigationController popToViewController:controller animated:NO]; + viewFound = YES; + break; + } + } + + if (viewFound == NO) { + dispatch_async(dispatch_get_main_queue(), ^{ + WOCSellingWizardHomeViewController *homeViewController = [self getViewController:@"WOCSellingWizardHomeViewController"]; + [self pushViewController:homeViewController animated:YES]; + }); + } +} + +- (void)back:(id)sender { + [self pushToBuyingSummary]; +} + +- (void)pushToBuyingSummary { + dispatch_async(dispatch_get_main_queue(), ^{ + WOCSellingSummaryViewController *summaryViewController = [self getViewController:@"WOCSellingSummaryViewController"]; + summaryViewController.phoneNo = self.phoneNo; + summaryViewController.isHideSuccessAlert = YES; + [self pushViewController:summaryViewController animated:YES]; + }); +} + +- (void)pushToStep1 { + [self backToMainView]; +} + +- (void)openSite:(NSURL*)url { + if ([[UIApplication sharedApplication] canOpenURL:url]) { + [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) { + APILog(@"URL opened..."); + }]; + } +} + +- (void)stopTimer { + dispatch_async(dispatch_get_main_queue(), ^{ + [self.timer invalidate]; + }); +} + +- (void)showDepositAlert { + UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Confirmation!" message:@"Are you sure you finished making the payment?" preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + [self confirmDeposit]; + }]; + + UIAlertAction *noAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + }]; + + [alert addAction:yesAction]; + [alert addAction:noAction]; + [self presentViewController:alert animated:YES completion:nil]; +} + +- (void)showCancelOrderAlert { + + UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Confirmation!" message:@"Are you sure you want to cancel order?" preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + [self cancelOrder]; + }]; + + UIAlertAction *noAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + }]; + + [alert addAction:yesAction]; + [alert addAction:noAction]; + [self presentViewController:alert animated:YES completion:nil]; +} + +- (void)updateData:(NSDictionary*)dictionary { + NSString *bankLogo = REMOVE_NULL_VALUE([dictionary valueForKey:@"bankLogo"]); + NSString *bankName = REMOVE_NULL_VALUE([dictionary valueForKey:@"bankName"]); + NSString *phoneNo = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([[dictionary valueForKey:@"nearestBranch"] valueForKey:@"phone"])]; + NSString *accountName = REMOVE_NULL_VALUE([dictionary valueForKey:@"nameOnAccount"]); + NSString *accountNo = REMOVE_NULL_VALUE([dictionary valueForKey:@"account"]); + float depositAmount = [[dictionary valueForKey:@"payment"] floatValue]; + NSString *depositDue = REMOVE_NULL_VALUE([dictionary valueForKey:@"paymentDue"]); + NSString *totalDash = REMOVE_NULL_VALUE([dictionary valueForKey:@"total"]); + self.orderId = REMOVE_NULL_VALUE([dictionary valueForKey:@"id"]); + + //bankLogo + if (![[dictionary valueForKey:@"bankLogo"] isEqual:[NSNull null]] && [bankLogo length] > 0) { + self.imgView.image = [UIImage imageNamed:@"ic_account_balance_black"]; + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), + ^{ + NSURL *imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",bankLogo]]; + NSData *imageData = [NSData dataWithContentsOfURL:imageURL]; + + //This is your completion handler + dispatch_sync(dispatch_get_main_queue(), ^{ + //If self.image is atomic (not declared with nonatomic) + // you could have set it directly above + if (imageData != nil) { + self.imgView.image = [UIImage imageWithData:imageData]; + } + else { + self.imgView.image = [UIImage imageNamed:@"ic_account_balance_black"]; + } + }); + }); + } + else { + self.imgView.image = [UIImage imageNamed:@"ic_account_balance_black"]; + } + + //bankLocationUrl + if ([dictionary valueForKey:@"bankUrl"] != [NSNull null]) { + [self.btnCheckLocation setTitle:@"Check locations" forState:UIControlStateNormal]; + self.locationUrl = [dictionary valueForKey:@"bankUrl"]; + if ([[dictionary valueForKey:@"nearestBranch"] class] != [NSNull class]) { + if([dictionary valueForKey:@"nearestBranch"][@"address"] != nil) { + if ([[[dictionary valueForKey:@"nearestBranch"] valueForKey:@"address"] length] > 0) { + [self.btnCheckLocation setHidden:YES]; + }} + } + } + + self.lblBankName.text = bankName; + self.lblPhone.text = [NSString stringWithFormat:@"Location's phone #: %@",phoneNo]; + self.lblAccountName.text = [NSString stringWithFormat:@"Name on Account: %@",accountName]; + self.lblAccountNo.text = [NSString stringWithFormat:@"Account #: %@",accountNo]; + self.lblCashDeposit.text = [NSString stringWithFormat:@"Cash to Deposit: $%.02f",depositAmount]; + + NSNumber *num = [NSNumber numberWithDouble:([totalDash doubleValue] * 1000000)]; + self.lblInstructions.text = [NSString stringWithFormat:@"You are ordering: %@ %@ (%@ %@)",totalDash,WOCCurrencySpecial, [self getCryptoPrice:num],WOCCurrencySymbolMinor]; + + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; + formatter.dateFormat = API_DATE_FORMAT; + NSDate *local = [formatter dateFromString:depositDue]; + APILog(@"local: %@",local); + + formatter.dateFormat = LOCAL_DATE_FORMAT; + NSString *localTime = [formatter stringFromDate:local]; + APILog(@"localTime: %@",localTime); + self.dueTime = localTime; + + NSString *currentTime = [formatter stringFromDate:[NSDate date]]; + APILog(@"currentTime UTC : %@",currentTime); + + NSMutableAttributedString *timeString = [self dateDiffrenceBetweenTwoDates:currentTime endDate:localTime]; + NSMutableAttributedString *dueString = [[NSMutableAttributedString alloc] initWithString:@"Deposit Due: "]; + [dueString appendAttributedString:timeString]; + + self.lblDepositDue.attributedText = dueString; + + self.timer = [[NSTimer alloc] init]; + self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(checkTime) userInfo:nil repeats:YES]; + + if ([[dictionary valueForKey:@"account"] length] > 16) { + NSArray *accountArr = [NSJSONSerialization JSONObjectWithData:[[dictionary valueForKey:@"account"] dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:nil]; + NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"displaySort" ascending:YES comparator:^NSComparisonResult(id obj1, id obj2) { + float aObj1 = [(NSString *)obj1 floatValue]; + float aObj2 = [(NSString *)obj2 floatValue]; + return aObj1 > aObj2; + }]; + + NSArray *accountArray = [accountArr sortedArrayUsingDescriptors:@[sort]]; + if (accountArray.count > 2) { + self.lblPhone.text = [NSString stringWithFormat:@"Name: %@ %@",REMOVE_NULL_VALUE([[accountArray objectAtIndex:0] valueForKey:@"value"]), REMOVE_NULL_VALUE([[accountArray objectAtIndex:2] valueForKey:@"value"])]; + } + + if (accountArray.count > 3) { + self.lblAccountName.text = [NSString stringWithFormat:@"Country of Birth: %@",REMOVE_NULL_VALUE([[accountArray objectAtIndex:3] valueForKey:@"value"])]; + } + + if (accountArray.count > 1) { + self.lblAccountNo.text = [NSString stringWithFormat:@"Pick-up State: %@",REMOVE_NULL_VALUE([[accountArray objectAtIndex:1] valueForKey:@"value"])]; + } + } +} + +- (void)checkTime { + + if (self.minutes > 0) { + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; + formatter.dateFormat = LOCAL_DATE_FORMAT; + NSString *currentTime = [formatter stringFromDate:[NSDate date]]; + NSMutableAttributedString *timeString = [self dateDiffrenceBetweenTwoDates:currentTime endDate:self.dueTime]; + NSMutableAttributedString *dueString = [[NSMutableAttributedString alloc] initWithString:@"Deposit Due: "]; + [dueString appendAttributedString:timeString]; + self.lblDepositDue.attributedText = dueString; + } + else { + self.lblDepositDue.text = @"Deposit Due: time expired"; + [self stopTimer]; + } +} + +- (NSMutableAttributedString*)dateDiffrenceBetweenTwoDates:(NSString*)startDate endDate:(NSString*)endDate { + NSMutableAttributedString *timeLeft = [[NSMutableAttributedString alloc] init]; + + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; + formatter.dateFormat = LOCAL_DATE_FORMAT; + + NSDate *startDateT = [formatter dateFromString:startDate]; + NSDate *endDateT = [formatter dateFromString:endDate]; + + NSDateComponents *components; + + NSInteger days; + NSInteger hours; + NSInteger minutes = 0; + NSInteger seconds = 0; + + components = [[NSCalendar currentCalendar] components:NSCalendarUnitDay fromDate:startDateT toDate:endDateT options:0]; + days = [components day]; + components = [[NSCalendar currentCalendar] components:NSCalendarUnitHour fromDate:startDateT toDate:endDateT options:0]; + hours = [components hour]; + components = [[NSCalendar currentCalendar] components:NSCalendarUnitMinute fromDate:startDateT toDate:endDateT options:0]; + minutes = [components minute]; + components = [[NSCalendar currentCalendar] components:NSCalendarUnitSecond fromDate:startDateT toDate:endDateT options:0]; + seconds = [components second]; + NSString *secondsInString = [NSString stringWithFormat:@"%ld ", (long)minutes]; + + self.minutes = [secondsInString intValue]; + + NSInteger daysN = (int) (floor(seconds / (3600 * 24))); + if(daysN) seconds -= daysN * 3600 * 24; + + NSInteger hoursN = (int) (floor(seconds / 3600)); + if(hoursN) seconds -= hoursN * 3600; + + NSInteger minutesN = (int) (floor(seconds / 60)); + if(minutesN) seconds -= minutesN * 60; + + if(daysN) { + [timeLeft appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%ld Days ", (long)daysN*1]]]; + } + + if(hoursN) { + [timeLeft appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat: @"%ld Hour ", (long)hoursN*1]]]; + } + + if(minutesN) { + [timeLeft appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat: @"%ld Minutes ",(long)minutesN*1]]]; + } + + return timeLeft; +} + +// MARK: - API + +- (void)createHold:(NSString*)offerId phoneNo:(NSString*)phone { + + dispatch_async(dispatch_get_main_queue(), ^{ + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + NSDictionary *params ; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + params = @{ + WOCApiBodyOffer: [NSString stringWithFormat:@"%@==",offerId], + WOCApiBodyJsonParameter:@"YES" + }; + } + else { + params = @{ + WOCApiBodyOffer: [NSString stringWithFormat:@"%@==",offerId], + WOCApiBodyPhoneNumber: phone, + WOCApiBodyDeviceName: WOCApiBodyDeviceName_IOS, + WOCApiBodyDeviceCode: deviceCode, + WOCApiBodyJsonParameter:@"YES" + }; + } + + [[APIManager sharedInstance] createHold:params response:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^{ + [hud hideAnimated:YES]; + }); + + if (error == nil) { + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + if ([responseDictionary valueForKey:WOCApiResponseToken] != nil && (![[responseDictionary valueForKey:WOCApiResponseToken] isEqualToString:@"(null)"])) + { + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiResponseToken]] forKey:WOCUserDefaultsAuthToken]; + [self.defaults setValue:phone forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + } + + NSString *holdId = [NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiResponseId]]; + self.holdId = holdId; + + NSString *purchaseCode = [NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiResponsePurchaseCde]]; + self.purchaseCode = purchaseCode; + + [self captureHold:purchaseCode holdId:holdId]; + } + else if (error.code == 403 ) { + [self getHold]; + } + else if (error.code == 500 ) { + [self pushToBuyingSummary]; + } + }]; + }); +} + +- (void)getHold { + [[APIManager sharedInstance] getHold:^(id responseDict, NSError *error) { + if (error == nil) { + APILog(@"Hold with Hold Id: %@.",responseDict); + + if ([responseDict isKindOfClass:[NSArray class]]) { + NSArray *holdArray = (NSArray*)responseDict; + if (holdArray.count > 0) { + NSUInteger count = holdArray.count; + NSUInteger activeHodCount = 0; + + for (int i = 0; i < holdArray.count; i++) { + count -= count; + + NSDictionary *holdDict = [holdArray objectAtIndex:i]; + NSString *holdId = [holdDict valueForKey:WOCApiResponseId]; + NSString *holdStatus = [holdDict valueForKey:WOCApiResponseHoldsStatus]; + if (holdStatus != nil) { + if ([holdStatus isEqualToString:@"AC"]) { + if (holdId) { + activeHodCount = activeHodCount + 1; + [self deleteHold:holdId count:count]; + } + } + } + else { + if (holdId) { + activeHodCount = activeHodCount + 1; + [self deleteHold:holdId count:count]; + } + } + } + + if (activeHodCount == 0 ) { + [self getOrderList]; + } + } + else { + [self getOrderList]; + } + } + else { + [self getOrderList]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + }]; +} + +- (void)deleteHold:(NSString*)holdId count:(NSUInteger)count { + + NSDictionary *params = @{ + }; + + [[APIManager sharedInstance] deleteHold:holdId response:^(id responseDict, NSError *error) { + + if (error == nil) { + APILog(@"Hold deleted."); + + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + [self createHold:self.offerId phoneNo:phoneNo]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + }]; +} + +- (void)captureHold:(NSString*)purchaseCode holdId:(NSString*)holdId { + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + NSDictionary *params = @{ + WOCApiBodyVerificationCode: purchaseCode, + WOCApiBodyJsonParameter: @"YES" + }; + + [[APIManager sharedInstance] captureHold:params holdId:self.holdId response:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^{ + [hud hideAnimated:YES]; + }); + + if (error == nil) { + if ([responseDict isKindOfClass:[NSArray class]]) + { + NSArray *response = [[NSArray alloc] initWithArray:(NSArray*)responseDict]; + if (response.count > 0) { + if ([[response objectAtIndex:0] isKindOfClass:[NSDictionary class]]) { + [self updateData:[response objectAtIndex:0]]; + } + } + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + [self.navigationController popViewControllerAnimated:YES]; + } + }]; +} + +- (void)confirmDeposit { + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + if (self.orderId != nil) { + + [[APIManager sharedInstance] confirmDeposit:self.orderId response:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^{ + [hud hideAnimated:YES]; + }); + + if (error == nil) { + [self stopTimer]; + [self pushToBuyingSummary]; + } + else { + + dispatch_async(dispatch_get_main_queue(), ^{ + if (error.userInfo != nil) { + if (error.userInfo[@"detail"] != nil) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self.navigationController.visibleViewController]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + }); + } + }]; + } +} + +- (void)cancelOrder { + + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + if (self.orderId != nil) { + + [[APIManager sharedInstance] cancelOrder:self.orderId response:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^{ + [hud hideAnimated:YES]; + }); + + if (error == nil) { + [self stopTimer]; + [self backToMainView]; + } + else { + dispatch_async(dispatch_get_main_queue(), ^{ + if (error.userInfo != nil) { + if (error.userInfo[@"detail"] != nil) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self.navigationController.visibleViewController]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + }); + } + }]; + } +} + +// MARK: - IBAction + +- (IBAction)showMapClicked:(id)sender { + if (self.locationUrl != nil) { + if (![self.locationUrl hasPrefix:@"http"]) { + self.locationUrl = [NSString stringWithFormat:@"https://%@",self.locationUrl]; + } + + if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:self.locationUrl]]) { + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.locationUrl] options:@{} completionHandler:^(BOOL success) { + APILog(@"URL opened."); + }]; + } + } + else { + // Your location from latitude and longitude + double latitude = [[self.defaults valueForKey:WOCUserDefaultsLocalLocationLatitude] doubleValue]; + double longitude = [[self.defaults valueForKey:WOCUserDefaultsLocalLocationLongitude] doubleValue]; + + NSString* directionsURL = [NSString stringWithFormat:@"http://maps.apple.com/?saddr=%f,%f&daddr=%f,%f", latitude, longitude, latitude, longitude]; + if ([[UIApplication sharedApplication] respondsToSelector:@selector(openURL:options:completionHandler:)]) { + [[UIApplication sharedApplication] openURL:[NSURL URLWithString: directionsURL] options:@{} completionHandler:^(BOOL success) {}]; + } + } +} + +- (IBAction)depositFinishedClicked:(id)sender { + [self showDepositAlert]; +} + +- (IBAction)cancelOrderClicked:(id)sender { + [self showCancelOrderAlert]; +} + +- (IBAction)wallOfCoinsClicked:(id)sender { + [self openSite:[NSURL URLWithString:@"https://wallofcoins.com"]]; +} + +- (IBAction)onSignOutButtonClick:(id)sender { + [self signOutWOC]; +} + +// MARK: - UITextView Delegate + +- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange { + if ([[URL scheme] isEqualToString:@"https"]) { + [self openSite:URL]; + return NO; + } + return YES; +} + +@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingPasswordViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingPasswordViewController.h new file mode 100644 index 00000000..ae68f8ec --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingPasswordViewController.h @@ -0,0 +1,28 @@ +// +// WOCPasswordViewController.h +// Wallofcoins +// +// Created by Genitrust on 27/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" +@interface WOCSellingPasswordViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *offerId; +@property (strong, nonatomic) NSString *phoneNo; + +@property (weak, nonatomic) IBOutlet UIView *mainView; +@property (weak, nonatomic) IBOutlet UILabel *WOCLinkLabel; +@property (weak, nonatomic) IBOutlet UIButton *WOCLinkButton; +@property (weak, nonatomic) IBOutlet UITextField *passwordTextField; +@property (weak, nonatomic) IBOutlet UIButton *loginButton; +@property (weak, nonatomic) IBOutlet UIButton *forgotPasswordButton; + +- (IBAction)onLinkButtonClick:(id)sender; +- (IBAction)onLoginButtonClick:(id)sender; +- (IBAction)onForgotPasswordButtonClick:(id)sender; +- (IBAction)onCloseButtonClick:(id)sender; + +@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingPasswordViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingPasswordViewController.m new file mode 100644 index 00000000..cb5aa4ff --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingPasswordViewController.m @@ -0,0 +1,218 @@ +// +// WOCPasswordViewController.m +// Wallofcoins +// +// Created by Genitrust on 27/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCSellingPasswordViewController.h" +#import "WOCSellingWizardConfirmCodeViewController.h" +#import "APIManager.h" +#import "WOCConstants.h" +#import "WOCAlertController.h" +#import "MBProgressHUD.h" + +@interface WOCSellingPasswordViewController () + +@end + +@implementation WOCSellingPasswordViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7]; + + self.mainView.layer.cornerRadius = 3.0; + self.mainView.layer.masksToBounds = YES; + + [self setShadowOnButton:self.loginButton]; + [self setShadowOnButton:self.forgotPasswordButton]; + + NSMutableAttributedString *titleString = [[NSMutableAttributedString alloc] initWithString:self.WOCLinkButton.titleLabel.text]; + [titleString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(29, 13)]; + [titleString addAttribute:NSForegroundColorAttributeName value:[UIColor darkGrayColor] range:NSMakeRange(29, 13)]; + [self.WOCLinkButton setAttributedTitle:titleString forState:UIControlStateNormal]; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +// MARK: - API + +- (void)login:(NSString*)phoneNo password:(NSString*)password { + NSDictionary *params = @{ + WOCApiBodyPassword: password, + WOCApiBodyJsonParameter: @"YES" + }; + + [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDict, NSError *error) { + if (error == nil) { + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + [self storeDeviceInfoLocally]; + + [self getDeviceId:phoneNo]; + } + else { + dispatch_async(dispatch_get_main_queue(), ^{ + if (error.userInfo != nil) { + if (error.userInfo[@"detail"] != nil) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self]; + } + }); + } + }]; +} + +- (void)registerDevice:(NSString*)phoneNo { + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; + + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *params = @{ + WOCApiBodyName: WOCApiBodyDeviceName_IOS, + WOCApiBodyCode: deviceCode, + WOCApiBodyJsonParameter:@"YES" + }; + + [[APIManager sharedInstance] registerDevice:params response:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^(void) { + [hud hideAnimated:YES]; + }); + + if (error == nil) { + NSDictionary *response = (NSDictionary*)responseDict; + if (response.count > 0) { + NSString *deviceId = [NSString stringWithFormat:@"%@",[response valueForKey:WOCApiResponseId]]; + [self authorize:phoneNo deviceId:deviceId]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + }]; +} + +- (void)getDeviceId:(NSString*)phoneNo { + dispatch_async(dispatch_get_main_queue(), ^(void){ + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; + + [[APIManager sharedInstance] getDevice:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^(void){ + [hud hideAnimated:YES]; + }); + + if (error == nil) { + if ([responseDict isKindOfClass:[NSArray class]]) { + NSArray *response = (NSArray*)responseDict; + if (response.count > 0) { + NSDictionary *dictionary = [response lastObject]; + NSString *deviceId = [NSString stringWithFormat:@"%@",[dictionary valueForKey:@"id"]]; + + if (deviceId.length > 0 && (![deviceId isEqualToString:@"(null)"])) { + [self.defaults setValue:deviceId forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self authorize:phoneNo deviceId:deviceId]; + } + } + else { + [self registerDevice:phoneNo]; + } + } + else { + [self registerDevice:phoneNo]; + } + } + else { + [self registerDevice:phoneNo]; + //[[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + }]; + }); +} + +- (void)authorize:(NSString*)phoneNo deviceId:(NSString*)deviceId { + + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; + + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + + NSDictionary *params = @{ + WOCApiBodyDeviceCode: deviceCode, + WOCApiBodyDeviceId: deviceId, + WOCApiBodyJsonParameter: @"YES" + }; + + [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^(void){ + [hud hideAnimated:YES]; + }); + + if (error == nil) { + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiResponseDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self storeDeviceInfoLocally]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [self dismissViewControllerAnimated:YES completion:nil]; + //move to step 8 + [[NSNotificationCenter defaultCenter] postNotificationName:WOCNotificationObserverNameBuyDashStep8 object:phoneNo]; + }); + } + else { + dispatch_async(dispatch_get_main_queue(), ^{ + + [self registerDevice:phoneNo]; + }); + } + }]; +} +// MARK: - IBAction + +- (IBAction)onLinkButtonClick:(id)sender { + NSURL *url = [NSURL URLWithString:@"https://wallofcoins.com/"]; + if ([[UIApplication sharedApplication] canOpenURL:url]) { + [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; + } +} + +- (IBAction)onLoginButtonClick:(id)sender { + NSString *password = [self.passwordTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + if ([password length] > 0) { + [self login:self.phoneNo password:password]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter password." viewController:self.navigationController.visibleViewController]; + } +} + +- (IBAction)onForgotPasswordButtonClick:(id)sender { + NSURL *url = [NSURL URLWithString:@"https://wallofcoins.com/en/forgotPassword/"]; + if ([[UIApplication sharedApplication] canOpenURL:url]) { + [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; + } +} + +- (IBAction)onCloseButtonClick:(id)sender { + [self dismissViewControllerAnimated:YES completion:nil]; +} + +@end + diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSignInViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSignInViewController.h new file mode 100644 index 00000000..88465203 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSignInViewController.h @@ -0,0 +1,26 @@ +// +// WOCSellingWizardOfferListViewController.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" +@interface WOCSellingSignInViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *discoveryId; +@property (strong, nonatomic) NSString *amount; +@property (weak, nonatomic) IBOutlet UIButton *signupButton; +@property (weak, nonatomic) IBOutlet UIButton *sighInButton; + +@property (weak, nonatomic) IBOutlet UILabel *instructionLabel; +@property (weak, nonatomic) IBOutlet UITableView *numberListTableView; + +- (IBAction)onExistingAccoutButtonClick:(id)sender; +- (IBAction)onSignUpButtonClick:(id)sender; + +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *tableHeighConstrain; + +@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSignInViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSignInViewController.m new file mode 100644 index 00000000..07fe83b9 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSignInViewController.m @@ -0,0 +1,260 @@ +// +// WOCSellingWizardOfferListViewController.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCSellingSignInViewController.h" +#import "WOCSellingWizardInputPhoineNumberViewController.h" +#import "WOCSellingInstructionsViewController.h" +#import "WOCSellingSummaryViewController.h" +#import "BRRootViewController.h" +#import "BRAppDelegate.h" +#import "WOCOfferCell.h" +#import "APIManager.h" +#import "BRWalletManager.h" +#import "WOCAlertController.h" +#import "MBProgressHUD.h" +#import "WOCSellingWizardHomeViewController.h" +#import "WOCSellingSingUpViewController.h" + +@interface WOCSellingSignInViewController () + +@property (strong, nonatomic) NSArray *offers; +@property (assign, nonatomic) BOOL incremented; + +@end + +@implementation WOCSellingSignInViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.instructionLabel.text = [NSString stringWithFormat:@"Below are offers for at least $%@. You must click the ORDER button before you receive instructions to pay at the Cash Payment center.",self.amount]; + [self setShadowOnButton:self.signupButton]; + [self setShadowOnButton:self.signupButton]; +} + +- (void)viewWillAppear:(BOOL)animated { + [self getLocalDevices]; + self.title = @"SignIN"; +} + +- (void)getLocalDevices { + + if ([self.defaults objectForKey:WOCUserDefaultsLocalDeviceInfo] != nil) { + if ([[self.defaults objectForKey:WOCUserDefaultsLocalDeviceInfo] isKindOfClass:[NSDictionary class]]) { + NSMutableDictionary *deviceInfoDict = [NSMutableDictionary dictionaryWithDictionary:[self.defaults objectForKey:WOCUserDefaultsLocalDeviceInfo]]; + if (deviceInfoDict != nil) { + self.offers = deviceInfoDict.allKeys; + [self.numberListTableView reloadData]; + } + } + } +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +- (void)pushToStep7:(NSInteger)sender { + NSIndexPath *indexPath = [NSIndexPath indexPathForRow:sender inSection:0]; + NSString *phoneNumber = self.offers[indexPath.row]; + APILog(@"phoneNumber = %@",phoneNumber); + + [self.defaults setObject:phoneNumber forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + [self refereshToken]; + [self performSelector:@selector(backToMainView) withObject:nil afterDelay:2.0]; +} + +// MARK: - API +- (void)getOffers { + if (self.discoveryId != nil && [self.discoveryId length] > 0) { + [[APIManager sharedInstance] discoveryInputs:self.discoveryId response:^(id responseDict, NSError *error) { + if (error == nil) { + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + + if ([[responseDictionary valueForKey:@"singleDeposit"] isKindOfClass:[NSArray class]]) { + NSArray *offersArray = [[NSArray alloc] initWithArray:(NSArray*)[responseDictionary valueForKey:@"singleDeposit"]]; + self.offers = [[NSArray alloc] initWithArray:offersArray]; + + if ([[responseDictionary valueForKey:@"incremented"] boolValue]) { + self.incremented = true; + self.instructionLabel.text = [NSString stringWithFormat:@"Below are offers for at least $%@. You must click the ORDER button before you receive instructions to pay at the Cash Payment center.",self.amount]; + } + else { + self.incremented = false; + self.instructionLabel.text = [NSString stringWithFormat:@"Below are offers for $%@. You must click the ORDER button before you receive instructions to pay at the Cash Payment center.",self.amount]; + } + } + [self.numberListTableView reloadData]; + } + else { + dispatch_async(dispatch_get_main_queue(), ^{ + if (error.userInfo != nil) { + if (error.userInfo[@"detail"] != nil) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self.navigationController.visibleViewController]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + }); + } + }]; + } +} + +- (void)getOrders:(NSInteger)sender { + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + NSDictionary *params = @{ + }; + + [[APIManager sharedInstance] getOrders:nil response:^(id responseDict, NSError *error) { + + dispatch_async(dispatch_get_main_queue(), ^(void){ + [hud hideAnimated:YES]; + }); + + if (error == nil) { + + if ([responseDict isKindOfClass:[NSArray class]]) { + + NSArray *orders = [[NSArray alloc] initWithArray:(NSArray*)responseDict]; + + if (orders.count > 0) { + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + NSPredicate *wdvPredicate = [NSPredicate predicateWithFormat:@"status == 'WD'"]; + NSArray *wdArray = [orders filteredArrayUsingPredicate:wdvPredicate]; + NSDictionary *orderDict = (NSDictionary*)[orders objectAtIndex:0]; + NSString *status = [NSString stringWithFormat:@"%@",[orderDict valueForKey:@"status"]]; + + if ([status isEqualToString:@"WD"]) { + WOCSellingInstructionsViewController *sellingInstructionsViewController = [self getViewController:@"WOCSellingInstructionsViewController"]; + sellingInstructionsViewController.phoneNo = phoneNo; + sellingInstructionsViewController.isFromSend = YES; + sellingInstructionsViewController.isFromOffer = NO; + sellingInstructionsViewController.orderDict = (NSDictionary*)[orders objectAtIndex:0]; + [self pushViewController:sellingInstructionsViewController animated:YES]; + } + else if (orders.count > 0) { + WOCSellingSummaryViewController *sellingSummaryViewController = [self getViewController:@"WOCSellingSummaryViewController"]; + sellingSummaryViewController.phoneNo = phoneNo; + sellingSummaryViewController.orders = orders; + sellingSummaryViewController.isFromSend = YES; + [self pushViewController:sellingSummaryViewController animated:YES]; + } + else { + [self backToMainView]; + } + } + else { + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + WOCSellingInstructionsViewController *sellingInstructionsViewController = [self getViewController:@"WOCSellingInstructionsViewController"]; + sellingInstructionsViewController.phoneNo = phoneNo; + sellingInstructionsViewController.isFromSend = NO; + sellingInstructionsViewController.isFromOffer = YES; + NSIndexPath *indexPath = [NSIndexPath indexPathForRow:sender inSection:0]; + NSDictionary *offerDict = self.offers[indexPath.row]; + sellingInstructionsViewController.offerId = [NSString stringWithFormat:@"%@",[offerDict valueForKey:WOCApiResponseId]]; + [self pushViewController:sellingInstructionsViewController animated:YES]; + } + } + else { + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + WOCSellingInstructionsViewController *sellingInstructionsViewController = [self getViewController:@"WOCSellingInstructionsViewController"]; + sellingInstructionsViewController.phoneNo = phoneNo; + sellingInstructionsViewController.isFromSend = NO; + sellingInstructionsViewController.isFromOffer = YES; + NSIndexPath *indexPath = [NSIndexPath indexPathForRow:sender inSection:0]; + NSDictionary *offerDict = self.offers[indexPath.row]; + sellingInstructionsViewController.offerId = [NSString stringWithFormat:@"%@",[offerDict valueForKey:WOCApiResponseId]]; + [self pushViewController:sellingInstructionsViewController animated:YES]; + } + } + else { + [self pushToStep1]; + dispatch_async(dispatch_get_main_queue(), ^{ + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Token expired." viewController:self]; + }); + } + }]; +} + +- (void)pushToStep1 { + [self backToMainView]; +} +// MARK: - IBAction +- (void)signInPhoneClicked:(UIButton *)sender { + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + if (token != nil && (![token isEqualToString:@"(null)"])) { + [self getOrderList]; + } + else { + [self pushToStep7:[sender tag]]; + } +} + +- (IBAction)onExistingAccoutButtonClick:(id)sender { + WOCSellingWizardInputPhoineNumberViewController *sellingWizardInputPhoneNumberViewController = [self getViewController:@"WOCSellingWizardInputPhoineNumberViewController"]; + sellingWizardInputPhoneNumberViewController.isForLoginOny = YES; + [self pushViewController:sellingWizardInputPhoneNumberViewController animated:YES]; +} +- (IBAction)onSignUpButtonClick:(id)sender { + + WOCSellingSingUpViewController *singUpViewController = [self getViewController:@"WOCSellingSingUpViewController"]; + [self pushViewController:singUpViewController animated:YES]; + + //NSURL *url = [NSURL URLWithString:@"https://wallofcoins.com/signup/"]; + //if ([[UIApplication sharedApplication] canOpenURL:url]) { + // [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; + //} +} + +- (IBAction)checkLocationClicked:(id)sender { + + NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[sender tag] inSection:0]; + NSDictionary *offerDict = self.offers[indexPath.row]; + if (![[offerDict valueForKey:@"bankLocationUrl"] isEqual:[NSNull null]]) { + NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",[offerDict valueForKey:@"bankLocationUrl"]]]; + if ([[UIApplication sharedApplication] canOpenURL:url]) { + [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) { + APILog(@"URL opened!"); + }]; + } + } +} + +// MARK: - UITableView DataSource + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return self.offers.count; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + WOCOfferCell *cell = [tableView dequeueReusableCellWithIdentifier:@"offerCell"]; + cell.backgroundColor = [UIColor clearColor]; + NSString *phoneNumber = self.offers[indexPath.row]; + [cell.orderButton setTitle:[NSString stringWithFormat:@"SIGN IN: %@",phoneNumber] forState:UIControlStateNormal]; + [cell.orderButton setTitle:@"" forState:UIControlStateSelected]; + [cell.orderButton addTarget:self action:@selector(signInPhoneClicked:) forControlEvents:UIControlEventTouchUpInside]; + cell.orderButton.tag = indexPath.row; + + return cell; +} + +// MARK: - UITableView Delegate +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { + return 50.0; +} + +@end + diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSingUpViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSingUpViewController.h new file mode 100644 index 00000000..49456679 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSingUpViewController.h @@ -0,0 +1,28 @@ +// +// WOCSellingSingUpViewController.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" + +// Enter Phone Number Screen +@interface WOCSellingSingUpViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *offerId; +@property (strong, nonatomic) NSString *emailId; +@property (assign, nonatomic) BOOL isActiveHoldChecked; +@property (assign, nonatomic) BOOL isForLoginOny; +@property (weak, nonatomic) IBOutlet UIButton *nextButton; +@property (weak, nonatomic) IBOutlet UITextField *countryCodeTextfield; +@property (weak, nonatomic) IBOutlet UITextField *phoneNumberTextfield; +@property (weak, nonatomic) IBOutlet UITextField *emailTextfield; +@property (weak, nonatomic) IBOutlet UITextField *confirmEmailTextfield; +@property (weak, nonatomic) IBOutlet UITextField *passwordTextfield; + +- (IBAction)onNextButtonClick:(id)sender; + +@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSingUpViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSingUpViewController.m new file mode 100644 index 00000000..14e3b282 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSingUpViewController.m @@ -0,0 +1,741 @@ +// +// WOCSellingWizardInputPhoineNumberViewController.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCSellingSingUpViewController.h" +#import "WOCSellingWizardConfirmCodeViewController.h" +#import "WOCSellingInstructionsViewController.h" +#import "WOCSellingSummaryViewController.h" +#import "WOCPasswordViewController.h" +#import "BRRootViewController.h" +#import "BRAppDelegate.h" +#import "APIManager.h" +#import "WOCConstants.h" +#import "WOCAlertController.h" +#import "MBProgressHUD.h" +#import "WOCHoldIssueViewController.h" +#import "WOCSellingWizardHomeViewController.h" +#import "WOCSellingCreatePasswordViewController.h" + +@interface WOCSellingSingUpViewController () + +@property (strong, nonatomic) NSArray *countries; +@property (strong, nonatomic) UIPickerView *pickerView; +@property (strong, nonatomic) NSString *countryCode; +@property (strong, nonatomic) NSString *purchaseCode; +@property (strong, nonatomic) NSString *holdId; +@property (strong, nonatomic) NSString *deviceName; +@end + +@implementation WOCSellingSingUpViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + [self setShadowOnButton:self.nextButton]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(openBuyDashStep8:) name:WOCNotificationObserverNameBuyDashStep8 object:nil]; + + self.pickerView = [[UIPickerView alloc] init]; + self.pickerView.delegate = self; + self.pickerView.dataSource = self; + self.countryCodeTextfield.inputView = self.pickerView; + + [self loadJSON]; +} + +- (void)loadJSON { + // Retrieve local JSON file called example.json + NSString *filePath = [[NSBundle mainBundle] pathForResource:@"countries" ofType:@"json"]; + + // Load the file into an NSData object called JSONData + NSError *error = nil; + NSData *JSONData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:&error]; + + // Create an Objective-C object from JSON Data + NSDictionary *countriesDict = [NSJSONSerialization JSONObjectWithData:JSONData options:NSJSONReadingMutableContainers error:nil]; + NSArray *countries = [countriesDict valueForKey:@"countries"]; + + self.countries = countries; + if (self.countries.count > 0) { + self.countryCodeTextfield.text = [NSString stringWithFormat:@"%@ (%@)",self.countries[0][@"name"],self.countries[0][@"code"]]; + self.countryCode = [NSString stringWithFormat:@"%@",self.countries[0][@"code"]]; + } + + [self.pickerView reloadAllComponents]; +} + +- (void)openBuyDashStep8:(NSNotification*)notification { + + NSString *phoneNo = [NSString stringWithFormat:@"%@",notification.object]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + + [self createHoldAfterAuthorize:phoneNo]; +} + +// MARK: - API + +- (void)checkPhone:(NSString*)phone code:(NSString*)countryCode { + + NSDictionary *params = @{ + }; + + NSString *phoneNo = [NSString stringWithFormat:@"%@%@",countryCode,phone]; + [self.defaults setObject:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + + [[APIManager sharedInstance] authorizeDevice:nil phone:phoneNo response:^(id responseDict, NSError *error) { + + if (error == nil) { + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + if ([responseDictionary valueForKey:@"recentDeviceName"] != nil) { + self.deviceName = [responseDictionary valueForKey:@"recentDeviceName"]; + } + + if ([[responseDictionary valueForKey:@"availableAuthSources"] isKindOfClass:[NSArray class]]) { + NSArray *availableAuthSource = (NSArray*)[responseDictionary valueForKey:@"availableAuthSources"]; + if (availableAuthSource.count > 0) { + if ([[availableAuthSource objectAtIndex:0] isEqualToString:@"password"]) { + [self login:phoneNo password:self.passwordTextfield.text]; + } + else if ([[availableAuthSource objectAtIndex:0] isEqualToString:@"device"]) { + //[self createHoldAfterAuthorize:phoneNo]; + [self resetPassword]; + } + } + } + else if ([responseDictionary valueForKey:@"response"] != nil) { + if ([[responseDictionary valueForKey:@"response"] isEqualToString:@"error"]) { + [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + [self resetPassword]; + } + } + } + else { + if ([error code] == 404 || [error code] == 0) { + //new number + [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + [self registerUser]; + //[self createHold:phoneNo]; + } + else { + dispatch_async(dispatch_get_main_queue(), ^{ + if (error.userInfo != nil) { + if (error.userInfo[@"detail"] != nil) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self.navigationController.visibleViewController]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + }); + } + } + }]; +} + +- (void)login:(NSString*)phoneNo { + + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + NSString *deviceId = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceId]; + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *params = @{ + WOCApiBodyDeviceCode: deviceCode + }; + + if (deviceId != nil) { + + params = @{ + WOCApiBodyDeviceCode: deviceCode, + WOCApiBodyDeviceId: deviceId, + WOCApiBodyJsonParameter: @"YES" + }; + + [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDict, NSError *error) { + + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + if (error == nil) { + if (responseDictionary != nil) { + [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self storeDeviceInfoLocally]; + [self backToMainView]; + } + } + else { + + [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + + BOOL isNewPhone = YES; + if (error.code == 400) { + if (error.userInfo != nil) { + NSString *errorDetail = error.userInfo[@"detail"]; + if (errorDetail != nil) { + if ([errorDetail isEqualToString:@"Unable to authorize your phone number. Password may be incorrect."]) { + isNewPhone = NO; + } + } + } + } + if (isNewPhone) { + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + [self backToMainView]; + } + else { + [self openHoldIssueVC]; + } + } + }]; + } +} + +- (void)createHold:(NSString*)phoneNo { + + if (!self.isForLoginOny) { + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *params; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + params = @{ + WOCApiBodyOffer: [NSString stringWithFormat:@"%@==",self.offerId], + WOCApiBodyJsonParameter:@"YES" + }; + } + else { + params = @{ + WOCApiBodyOffer: [NSString stringWithFormat:@"%@==",self.offerId], + WOCApiBodyPhoneNumber: phoneNo, + WOCApiBodyDeviceName: WOCApiBodyDeviceName_IOS, + WOCApiBodyDeviceCode: deviceCode, + WOCApiBodyJsonParameter:@"YES" + }; + + if (self.emailId != nil && self.emailId.length > 0) { + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:params]; + [dict setObject:self.emailId forKey:WOCApiBodyEmail]; + params = (NSDictionary*)dict; + } + } + + [[APIManager sharedInstance] createHold:params response:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^(void) { + [hud hideAnimated:YES]; + }); + + if (error == nil) { + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + if ([responseDictionary valueForKey:WOCApiResponseToken] != nil && (![[responseDictionary valueForKey:WOCApiResponseToken] isEqualToString:@"(null)"])) { + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiResponseToken]] forKey:WOCUserDefaultsAuthToken]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self storeDeviceInfoLocally]; + } + + NSString *holdId = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([responseDictionary valueForKey:WOCApiResponseId])]; + self.holdId = holdId; + + NSString *purchaseCode = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([responseDictionary valueForKey:WOCApiResponsePurchaseCde])]; + if (![purchaseCode isKindOfClass:[NSNull class]]) { + self.purchaseCode = purchaseCode; + } + else { + self.purchaseCode = @""; + } + WOCSellingWizardConfirmCodeViewController *confirmCodeViewController = [self getViewController:@"WOCSellingWizardConfirmCodeViewController"]; + confirmCodeViewController.phoneNo = phoneNo; + confirmCodeViewController.offerId = self.offerId; + confirmCodeViewController.purchaseCode = self.purchaseCode; + confirmCodeViewController.deviceCode = deviceCode; + confirmCodeViewController.emailId = self.emailId; + confirmCodeViewController.holdId = self.holdId; + [self pushViewController:confirmCodeViewController animated:YES]; + } + else if (error.code == 403 ) { + [self resolveActiveHoldIssue:phoneNo]; + } + else if (error.code == 401 ) { + [self registerDevice:phoneNo]; + } + }]; + } + else { + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + if (token != nil && (![token isEqualToString:@"(null)"])) { + [self getOrderList]; + } + else { + UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Error" message:@"Please select an offer and then try to register/login with app." preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + [self backToMainView]; + }]; + [alert addAction:okAction]; + [self presentViewController:alert animated:YES completion:nil]; + } + } +} + +- (void)resolveActiveHoldIssue:(NSString*)phoneNo { + + if (!self.isActiveHoldChecked) { + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + if (token != nil && (![token isEqualToString:@"(null)"])) { + /*you receive Status 403 from POST /api/v1/holds/ + IF YOU HAVE a token or the deviceId/deviceCode, login with that device -- you will use the token to get a list of holds so that you can cancel the holds. IF THERE ARE NO HOLDS, then you will bring the user to the Buy Summary, where they will see their latest WD orders. + */ + self.isActiveHoldChecked = YES; + [self getHold]; + } + else { + NSString *deviceID = [self getDeviceIDFromPhoneNumber:phoneNo]; + if (deviceID.length > 0 && (![deviceID isEqualToString:@"(null)"])) { + [self.defaults setObject:deviceID forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self login:phoneNo]; + } + else { + [self openHoldIssueVC]; + } + } + } +} + +- (void)openHoldIssueVC { + /* + IF YOU DO NOT HAVE the token or deviceId/deviceCode in local storage, then you will need to show a new view that says, "You already have an open hold or a pending order with Wall of Coins. Before you can create a new order, you must finish these orders." and then show a yellow button w/ blue text (just like the "BUY MORE {Crypto Currency} WITH CASH" button), and when they press that button, you will bring them to this website link: + https://wallofcoins.com/signin/1-2397776832/ + https://wallofcoins.com/signin/{phone_country_code}-{local_phone_number}/ + */ + NSString *txtPhone = [self.phoneNumberTextfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + NSString *txtcountryCode = [self.countryCode stringByReplacingOccurrencesOfString:@"+" withString:@""]; + WOCHoldIssueViewController *aViewController = [self getViewController:@"WOCHoldIssueViewController"]; + aViewController.phoneNo = [NSString stringWithFormat:@"%@-%@",txtcountryCode,txtPhone]; + [self pushViewController:aViewController animated:YES]; +} + +- (void)resolvePandingOrderIssue { + + [self getOrderList]; +} + +- (void)getHold { + + [[APIManager sharedInstance] getHold:^(id responseDict, NSError *error) { + if (error == nil) { + APILog(@"Hold with Hold Id: %@.",responseDict); + if ([responseDict isKindOfClass:[NSArray class]]) { + NSArray *holdArray = (NSArray*)responseDict; + if (holdArray.count > 0) { + NSUInteger count = holdArray.count; + NSUInteger activeHodCount = 0; + + for (int i = 0; i < holdArray.count; i++) { + count -= count; + + NSDictionary *holdDict = [holdArray objectAtIndex:i]; + NSString *holdId = [holdDict valueForKey:WOCApiResponseId]; + NSString *holdStatus = [holdDict valueForKey:WOCApiResponseHoldsStatus]; + + if (holdStatus != nil) { + if ([holdStatus isEqualToString:@"AC"]) { + if (holdId) { + activeHodCount = activeHodCount + 1; + [self deleteHold:holdId count:count]; + } + } + } + else { + if (holdId) { + activeHodCount = activeHodCount + 1; + [self deleteHold:holdId count:count]; + } + } + } + + if (activeHodCount == 0 ) { + [self resolvePandingOrderIssue]; + } + } + else { + [self resolvePandingOrderIssue]; + } + } + else { + [self resolvePandingOrderIssue]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + }]; +} + +- (void)deleteHold:(NSString*)holdId count:(NSUInteger)count { + + NSDictionary *params = @{ + }; + + [[APIManager sharedInstance] deleteHold:holdId response:^(id responseDict, NSError *error) { + if (error == nil) { + APILog(@"Hold deleted."); + + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + [self createHoldAfterAuthorize:phoneNo]; + } + }]; +} + +- (void)registerDevice:(NSString*)phoneNo { + + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *params = @{ + WOCApiBodyName: WOCApiBodyDeviceName_IOS, + WOCApiBodyCode: deviceCode, + WOCApiBodyJsonParameter:@"YES" + }; + + [[APIManager sharedInstance] registerDevice:params response:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^(void) { + [hud hideAnimated:YES]; + }); + + if (error == nil) { + NSDictionary *response = (NSDictionary*)responseDict; + if (response.count > 0) { + NSString *deviceId = [NSString stringWithFormat:@"%@",[response valueForKey:WOCApiResponseId]]; + [self authorize:phoneNo deviceId:deviceId]; + } + } + else { + + [self pushToStep1]; + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + }]; +} + +- (void)authorize:(NSString*)phoneNo deviceId:(NSString*)deviceId { + + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *params = @{ + WOCApiBodyDeviceCode: deviceCode, + WOCApiBodyJsonParameter: @"YES" + }; + + if (deviceId != nil && (![deviceId isEqualToString:@"(null)"])) { + params = @{ + WOCApiBodyDeviceCode: deviceCode, + WOCApiBodyDeviceId: deviceId, + WOCApiBodyJsonParameter: @"YES" + }; + } + + [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDict, NSError *error) { + if (error == nil) { + + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + + [self storeDeviceInfoLocally]; + [self backToMainView]; + //[self createHoldAfterAuthorize:phoneNo]; + } + else { + + [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + }]; +} + +- (void)createHoldAfterAuthorize:(NSString*)phoneNo { + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + [self createHold:phoneNo]; + } + else { + NSString *deviceID = [self getDeviceIDFromPhoneNumber:phoneNo]; + if (deviceID != nil) { + [self.defaults setObject:deviceID forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self login:phoneNo]; + } + else { + [self createHold:phoneNo]; + } + } +} + +// MARK: - IBAction +- (IBAction)onNextButtonClick:(id)sender { + + NSString *txtPhone = [self.phoneNumberTextfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + + if ([self.countryCode length] == 0) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Select country code." viewController:self.navigationController.visibleViewController]; + } + else if ([txtPhone length] == 0) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter phone number." viewController:self.navigationController.visibleViewController]; + } + else if ([self.emailTextfield.text length] == 0) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter email number." viewController:self.navigationController.visibleViewController]; + } + else if ([self isValidEmail:self.emailTextfield.text] == 0) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter valid email number." viewController:self.navigationController.visibleViewController]; + } + else if ([self.passwordTextfield.text length] == 0) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter password number." viewController:self.navigationController.visibleViewController]; + } + else if (![self.emailTextfield.text isEqualToString:self.confirmEmailTextfield.text]) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter email and confirm email does not metched." viewController:self.navigationController.visibleViewController]; + } + else if ([txtPhone length] == 10) { + self.isActiveHoldChecked = NO; + [self checkPhone:txtPhone code:self.countryCode]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter valid phone number." viewController:self.navigationController.visibleViewController]; + } +} + +// MARK: - UIPickerView Delegates + +- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView { + return 1; +} + +- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component { + return self.countries.count; +} + +- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { + return [NSString stringWithFormat:@"%@ (%@)",self.countries[row][@"name"],self.countries[row][@"code"]]; +} + +- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { + self.countryCodeTextfield.text = [NSString stringWithFormat:@"%@ (%@)",self.countries[row][@"name"],self.countries[row][@"code"]]; + self.countryCode = [NSString stringWithFormat:@"%@",self.countries[row][@"code"]]; +} + +- (void)pushToStep1 { + [self storeDeviceInfoLocally]; + [self backToMainView]; +} + +- (void)registerUser { + + NSString *phoneNumber = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *params = @{ + WOCApiBodyPhoneNumber: phoneNumber, + WOCApiBodyEmail: self.emailTextfield.text, + WOCApiBodyPassword: self.passwordTextfield.text, + WOCApiBodyJsonParameter: @"YES" + }; + + [[APIManager sharedInstance] registerUser:params response:^(id responseDict, NSError *error) { + + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + if (error == nil) { + BOOL isError = NO; + + if (responseDictionary != nil) { + if ([responseDictionary valueForKey:@"response"] != nil) { + if ([[responseDictionary valueForKey:@"response"] isEqualToString:@"error"]) { + // Error + isError = YES; + } + } + } + + if (isError) { + [self openHoldIssueVC]; + } + else { + [self login:phoneNumber password:self.passwordTextfield.text]; + } + } + else { + [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + + BOOL isNewPhone = YES; + if (error.code == 400) { + if (error.userInfo != nil) { + NSString *errorDetail = error.userInfo[@"detail"]; + if (errorDetail != nil) { + if ([errorDetail isEqualToString:@"Unable to authorize your phone number. Password may be incorrect."]) { + isNewPhone = NO; + } + } + } + } + + if (isNewPhone) { + [self.defaults setValue:phoneNumber forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + + [self registrationCompleted]; + } + else { + [self openHoldIssueVC]; + } + } + }]; +} + +- (void)resetPassword { + + NSString *phoneNumber = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + + NSDictionary *params = @{ + @"password1": self.passwordTextfield.text, + @"password2": self.passwordTextfield.text, + WOCApiBodyJsonParameter: @"YES" + }; + + [[APIManager sharedInstance] resetPassword:params phone:phoneNumber response:^(id responseDict, NSError *error) { + + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + if (error == nil) { + if (responseDictionary != nil) { + if ([[responseDictionary valueForKey:@"response"] isEqualToString:@"error"]) { + // Error + [self openHoldIssueVC]; + } + else { + [self registrationCompleted]; + } + //[self login:self.txtEmail.text password:self.txtPasword.text]; + //[self createHoldAfterAuthorize:phoneNumber]; + } + } + else { + [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + + BOOL isNewPhone = YES; + if (error.code == 400) { + if (error.userInfo != nil) { + NSString *errorDetail = error.userInfo[@"detail"]; + if (errorDetail != nil) { + if ([errorDetail isEqualToString:@"Unable to authorize your phone number. Password may be incorrect."]) { + isNewPhone = NO; + } + } + } + } + if (isNewPhone) { + [self.defaults setValue:phoneNumber forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + //[self createHoldAfterAuthorize:phoneNumber]; + [self registrationCompleted]; + } + else { + [self openHoldIssueVC]; + } + } + }]; +} + +- (void)login:(NSString*)phoneNo password:(NSString*)password { + NSDictionary *params = @{ + WOCApiBodyPassword: password, + WOCApiBodyJsonParameter: @"YES" + }; + + [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDictionary, NSError *error) { + if (error == nil) { + if (responseDictionary != nil) { + [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self registerDevice:phoneNo]; + [self backToMainView]; + } + } + else { + dispatch_async(dispatch_get_main_queue(), ^{ + if (error.userInfo != nil) { + if (error.userInfo[@"detail"] != nil) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self]; + } + }); + } + }]; +} + +- (void)registrationCompleted { + + NSString *phoneNumber = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + + WOCSellingCreatePasswordViewController *createPasswordViewController = [self getViewController:@"WOCSellingCreatePasswordViewController"]; + + if (self.deviceName != nil) { + createPasswordViewController.deviceName = self.deviceName; + } + createPasswordViewController.offerId = self.offerId; + createPasswordViewController.purchaseCode = self.purchaseCode; + createPasswordViewController.deviceCode = deviceCode; + createPasswordViewController.emailId = self.emailId; + createPasswordViewController.holdId = self.holdId; + [self pushViewController:createPasswordViewController animated:YES]; + //[self login:phoneNumber]; +} +@end + diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSummaryViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSummaryViewController.h new file mode 100644 index 00000000..5e8d2ef7 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSummaryViewController.h @@ -0,0 +1,25 @@ +// +// WOCSellingSummaryViewController.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" +@interface WOCSellingSummaryViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *phoneNo; +@property (strong, nonatomic) NSArray *orders; +@property (assign, nonatomic) BOOL isFromSend; +@property (assign, nonatomic) BOOL isHideSuccessAlert; +@property (weak, nonatomic) IBOutlet UITextView *instructionTextField; +@property (weak, nonatomic) IBOutlet UILabel *instructionLabel; +@property (weak, nonatomic) IBOutlet UITableView *sellingSummaryTableView; +@property (weak, nonatomic) IBOutlet UIButton *buyMoreDashButton; + +- (IBAction)onBuyMoreDashButtonClick:(id)sender; +- (void)displayAlert; + +@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSummaryViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSummaryViewController.m new file mode 100644 index 00000000..01313916 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSummaryViewController.m @@ -0,0 +1,476 @@ +// +// WOCSellingSummaryViewController.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#define WD @"WD" +#define WDV @"WDV" +#define RERR @"RERR" +#define DERR @"DERR" +#define RSD @"RSD" +#define RMIT @"RMIT" +#define UCRV @"UCRV" +#define PAYP @"PAYP" +#define SENT @"SENT" + +#define STATUS_WD @"Waiting Deposit" +#define STATUS_WDV @"Waiting Deposit Verification" +#define STATUS_RERR @"Issue with Receipt" +#define STATUS_DERR @"Issue with Deposit" +#define STATUS_RSD @"Reserved for Deposit" +#define STATUS_RMIT @"Remit Address Missing" +#define STATUS_UCRV @"Under Review" +#define STATUS_PAYP @"Done - Pending Delivery" +#define STATUS_SENT @"Done - Units Delivered" + +#import "WOCSellingSummaryViewController.h" +#import "WOCSummaryCell.h" +#import "WOCSignOutCell.h" +#import "WOCSellingWizardHomeViewController.h" +#import "WOCSellingWizardInputAmountViewController.h" +#import "APIManager.h" +#import "BRRootViewController.h" +#import "BRAppDelegate.h" +#import +#import "WOCAlertController.h" +#import "MBProgressHUD.h" +#import "WOCAsyncImageView.h" + +@interface WOCSellingSummaryViewController () + +@property (strong, nonatomic) NSArray *wdOrders; +@property (strong, nonatomic) NSArray *otherOrders; + +@end + +@implementation WOCSellingSummaryViewController + +- (void)viewDidLoad { + + [super viewDidLoad]; + + self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"navigation_back"] style:UIBarButtonItemStylePlain target:self action:@selector(back:)]; + + [self setShadowOnButton:self.buyMoreDashButton]; + [self setAttributedString]; + + if (self.orders.count == 0) { + + [self reloadOrderTable]; + + [self getOrders]; + + if (!self.isHideSuccessAlert) { + [self displayAlert]; + } + } + else { + + NSPredicate *wdvPredicate = [NSPredicate predicateWithFormat:@"status == 'WD'"]; + NSArray *wdvArray = [self.orders filteredArrayUsingPredicate:wdvPredicate]; + self.wdOrders = [[NSArray alloc] initWithArray:wdvArray]; + + NSPredicate *otherPredicate = [NSPredicate predicateWithFormat:@"status == 'WDV' || status == 'RERR' || status == 'DERR' || status == 'RSD' || status == 'RMIT' || status == 'UCRV' || status == 'PAYP' || status == 'SENT' || status == 'ACAN'"]; + NSArray *otherArray = [self.orders filteredArrayUsingPredicate:otherPredicate]; + self.otherOrders = [[NSArray alloc] initWithArray:otherArray]; + + APILog(@"wdvArray count: %lu, otherArray count: %lu",(unsigned long)wdvArray.count,(unsigned long)otherArray.count); + + [self reloadOrderTable]; + } +} + +- (void)setAttributedString { + + NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"Wall of Coins will verify your payment. This usually takes up to 10 minutes. To expedite your order, take a picture of your receipt and click here to email your receipt to Wall of Coins." attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]}]; + + [attributedString addAttribute:NSLinkAttributeName + value:@"support@wallofcoins.com" + range:[[attributedString string] rangeOfString:@"click here"]]; + + + NSDictionary *linkAttributes = @{NSForegroundColorAttributeName: [UIColor blackColor], + NSUnderlineColorAttributeName: [UIColor blackColor], + NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle)}; + + self.instructionTextField.linkTextAttributes = linkAttributes; + self.instructionTextField.attributedText = attributedString; + self.instructionTextField.delegate = self; +} + +- (void)back:(id)sender { + + [self backToMainView]; +} + +- (NSString*)checkStatus:(NSString*)status { + + NSString *string = @""; + + if ([status isEqualToString:WD]) { + string = [NSString stringWithFormat:@"Status: %@",STATUS_WD]; + } + else if ([status isEqualToString:WDV]) { + string = [NSString stringWithFormat:@"Status: %@",STATUS_WDV]; + } + else if ([status isEqualToString:RERR]) { + string = [NSString stringWithFormat:@"Status: %@",STATUS_RERR]; + } + else if ([status isEqualToString:DERR]) { + string = [NSString stringWithFormat:@"Status: %@",STATUS_DERR]; + } + else if ([status isEqualToString:RMIT]) { + string = [NSString stringWithFormat:@"Status: %@",STATUS_RMIT]; + } + else if ([status isEqualToString:UCRV]) { + string = [NSString stringWithFormat:@"Status: %@",STATUS_UCRV]; + } + else if ([status isEqualToString:PAYP]) { + string = [NSString stringWithFormat:@"Status: %@",STATUS_PAYP]; + } + else if ([status isEqualToString:SENT]) { + string = [NSString stringWithFormat:@"Status: %@",STATUS_SENT]; + } + + return string; +} + +- (void)displayAlert { + + [[WOCAlertController sharedInstance] alertshowWithTitle:@"" message:[NSString stringWithFormat:@"Thank you for making the payment!\nOnce we verify your payment, we will send the %@ to your wallet!",WOCCurrency] viewController:self]; +} + +// MARK: - IBAction + +- (IBAction)onBuyMoreDashButtonClick:(id)sender { + [self backToMainView]; +} + +- (IBAction)onSignOutButtonClick:(id)sender { + [self signOutWOC]; +} + +- (IBAction)wallOfCoinsClicked:(id)sender { + + NSURL *url = [NSURL URLWithString:@"https://wallofcoins.com"]; + if ([[UIApplication sharedApplication] canOpenURL:url]) { + [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) { + APILog(@"URL opened..."); + }]; + } +} + +// MARK: - API +- (void)getOrders { + + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + NSDictionary *params = @{ + }; + + [[APIManager sharedInstance] getIncomingOrders:nil response:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^{ + [hud hideAnimated:YES]; + }); + + if (error == nil) { + if ([responseDict isKindOfClass:[NSArray class]]) { + NSArray *response = [[NSArray alloc] initWithArray:(NSArray*)responseDict]; + self.orders = response; + + NSPredicate *wdvPredicate = [NSPredicate predicateWithFormat:@"status == 'WD'"]; + NSArray *wdvArray = [self.orders filteredArrayUsingPredicate:wdvPredicate]; + self.wdOrders = [[NSArray alloc] initWithArray:wdvArray]; + + NSPredicate *otherPredicate = [NSPredicate predicateWithFormat:@"status == 'WDV' || status == 'RERR' || status == 'DERR' || status == 'RSD' || status == 'RMIT' || status == 'UCRV' || status == 'PAYP' || status == 'SENT' || status == 'ACAN'"]; + NSArray *otherArray = [self.orders filteredArrayUsingPredicate:otherPredicate]; + self.otherOrders = [[NSArray alloc] initWithArray:otherArray]; + + APILog(@"wdvArray count: %lu, otherArray count: %lu",(unsigned long)wdvArray.count,(unsigned long)otherArray.count); + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + + [self reloadOrderTable]; + + }]; +} + +- (void)reloadOrderTable{ + if (self.orders.count > 0) { + self.instructionTextField.text = @"Wall of Coins will verify your payment. This usually takes up to 10 minutes. To expedite your order, take a picture of your receipt and click here to email your receipt to Wall of Coins."; + } + else { + self.instructionTextField.text = [NSString stringWithFormat:@"You have no order history with %@ for iOS. To see your full order history across all devices, visit %@",WOCCryptoCurrency,BASE_URL_PRODUCTION]; + } + self.instructionLabel.hidden = YES; + self.instructionTextField.hidden = NO; + [self.sellingSummaryTableView reloadData]; +} + +#pragma mark - UITableView DataSource + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 4; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + + if (section == 0) { + return self.wdOrders.count; + } + else if (section == 1) { + return 1; + } + else if (section == 2) { + return 1; + } + else { + return self.otherOrders.count; + } +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + + if (indexPath.section == 1) { + WOCSignOutCell *cell = [tableView dequeueReusableCellWithIdentifier:@"linkCell"]; + [cell.signOutButton addTarget:self action:@selector(wallOfCoinsClicked:) forControlEvents:UIControlEventTouchUpInside]; + return cell; + } + else if (indexPath.section == 2) { + WOCSignOutCell *cell = [tableView dequeueReusableCellWithIdentifier:@"signOutCell"]; + cell.descriptionLabel.text = [NSString stringWithFormat:@"Your wallet is signed into Wall of Coins using your mobile number %@",self.phoneNo]; + [cell.signOutButton addTarget:self action:@selector(onSignOutButtonClick:) forControlEvents:UIControlEventTouchUpInside]; + return cell; + } + else { + + static const NSInteger IMAGE_VIEW_TAG = 98; + NSString *cellIdentifier = @"offerCell"; + + WOCSummaryCell *cell = [tableView dequeueReusableCellWithIdentifier:@"summaryCell"]; + + NSDictionary *orderDict = [[NSDictionary alloc] init]; + /* + { + bankAccount = + { + bankBusiness = + { + country = us; + icon = "https://woc-staging-static.s3.amazonaws.com/logos/icon_us_Genitrust2x.png"; + id = 14; + logo = "https://woc-staging-static.s3.amazonaws.com/logos/logo_us_Genitrust2x.png"; + name = Genitrust; + payFields = 0; + url = "http://genitrust.com/"; + }; + id = 78; + name = "Sujal Bandhara"; + number = ABC1234567890; + }; + gross = "6.70454545"; + id = 397; + payment = "2.95"; + paymentDue = "2018-03-26T12:55:33.093147+05:30"; + status = DERR; + } + */ + NSMutableDictionary *sellingOrderDict = [NSMutableDictionary dictionaryWithCapacity:0]; + + if (indexPath.section == 0) { + orderDict = self.wdOrders[indexPath.row]; + if (orderDict[@"bankAccount"] != nil) { + if (orderDict[@"bankAccount"][@"bankBusiness"] != nil) { + sellingOrderDict = orderDict[@"bankAccount"][@"bankBusiness"]; + } + } + } + else { + orderDict = self.otherOrders[indexPath.row]; + if (orderDict[@"bankAccount"] != nil) { + if (orderDict[@"bankAccount"][@"bankBusiness"] != nil) { + sellingOrderDict = orderDict[@"bankAccount"][@"bankBusiness"]; + } + } + } + + if (![[sellingOrderDict valueForKey:@"number"] isEqual:[NSNull null]]) { + if ([[sellingOrderDict valueForKey:@"number"] length] > 16) { + cell = [tableView dequeueReusableCellWithIdentifier:@"summaryCell1"]; + + NSArray *accountArr = [NSJSONSerialization JSONObjectWithData:[[sellingOrderDict valueForKey:@"number"] dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:nil]; + NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"displaySort" ascending:YES comparator:^NSComparisonResult(id obj1, id obj2) { + float aObj1 = [(NSString *)obj1 floatValue]; + float aObj2 = [(NSString *)obj2 floatValue]; + return aObj1 > aObj2; + }]; + NSArray *accountArray = [accountArr sortedArrayUsingDescriptors:@[sort]]; + cell.phoneLabel.hidden = YES; + if (accountArray.count > 0) { + cell.firstNameLabel.text = [NSString stringWithFormat:@"First Name: %@",REMOVE_NULL_VALUE([[accountArray objectAtIndex:0] valueForKey:@"value"])]; + } + if (accountArray.count > 2) { + cell.lastNameLabel.text = [NSString stringWithFormat:@"Last Name: %@",REMOVE_NULL_VALUE([[accountArray objectAtIndex:2] valueForKey:@"value"])]; + } + if (accountArray.count > 3) { + cell.birthCountryLabel.text = [NSString stringWithFormat:@"Country of Birth: %@",REMOVE_NULL_VALUE([[accountArray objectAtIndex:3] valueForKey:@"value"])]; + } + if (accountArray.count > 1) { + cell.pickupStateLabel.text = [NSString stringWithFormat:@"Pick-up State: %@",REMOVE_NULL_VALUE([[accountArray objectAtIndex:1] valueForKey:@"value"])]; + } + } + } + else { + NSString *phoneNo = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([[orderDict valueForKey:@"bankAccount"] valueForKey:@"number"])]; + cell.phoneLabel.text = [NSString stringWithFormat:@"Acct: -%@",phoneNo]; + + } + NSString *bankLogo = REMOVE_NULL_VALUE([sellingOrderDict valueForKey:@"logo"]); + NSString *bankIcon = REMOVE_NULL_VALUE([sellingOrderDict valueForKey:@"icon"]); + NSString *bankName = REMOVE_NULL_VALUE([sellingOrderDict valueForKey:@"name"]); + + float depositAmount = [[orderDict valueForKey:@"payment"] floatValue]; + NSString *totalDash = REMOVE_NULL_VALUE([orderDict valueForKey:@"gross"]); + NSString *status = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([orderDict valueForKey:@"status"])]; + + UIView *cellView = cell.bankImageView.superview; + + WOCAsyncImageView *imageView = (WOCAsyncImageView *)[cellView viewWithTag:IMAGE_VIEW_TAG]; + + if (imageView == nil) { + imageView = [[WOCAsyncImageView alloc] initWithFrame:cell.bankImageView.frame]; + imageView.contentMode = UIViewContentModeScaleAspectFill; + imageView.clipsToBounds = YES; + imageView.image = [UIImage imageNamed:@"ic_account_balance_black"]; + imageView.tag = IMAGE_VIEW_TAG; + [cellView addSubview:imageView]; + } + + cell.bankImageView.hidden = YES; + imageView.hidden = NO; + + //get image view + //cancel loading previous image for cell + [[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:imageView]; + //bankLogo + if ([bankLogo length] > 0) { + + imageView.imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",bankLogo]]; + } + else if ([bankIcon length] > 0) { + + imageView.imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",bankIcon]]; + //cell.imgView.image = [UIImage imageNamed:@"ic_account_balance_black"]; + } + + cell.nameLabel.text = bankName; + if ([[[orderDict valueForKey:@"nearestBranch"] valueForKey:@"phone"] isEqual:[NSNull null]]) { + [cell.phoneLabel setHidden:YES]; + } + cell.cashDepositLabel.text = [NSString stringWithFormat:@"Verified Deposits: $%.02f",depositAmount]; + + NSNumber *num = [NSNumber numberWithDouble:([totalDash doubleValue] * 1000000)]; + NSNumberFormatter *numFormatter = [[NSNumberFormatter alloc] init]; + [numFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4]; + [numFormatter setNumberStyle:NSNumberFormatterDecimalStyle]; + //[numFormatter setAllowsFloats:YES]; + [numFormatter setAlwaysShowsDecimalSeparator:YES]; + //[numFormatter setDecimalSeparator:@"."]; + [numFormatter setUsesGroupingSeparator:YES]; + [numFormatter setGroupingSeparator:@","]; + [numFormatter setGroupingSize:3]; + NSString *stringNum = [numFormatter stringFromNumber:num]; + cell.totalDashLabel.text = [NSString stringWithFormat:@"Available %@: %@ (%@ %@)",WOCCurrencySpecial,totalDash,stringNum,WOCCurrencySymbolMinor]; + cell.statusLabel.text = [self checkStatus:status]; + + return cell; + } +} + +// MARK: - UITableView Delegate + +- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { + + if (section == 3) { + UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.sellingSummaryTableView.frame.size.width, 50)]; + headerView.backgroundColor = [UIColor colorWithRed:250.0/255.0 green:250.0/255.0 blue:250.0/255.0 alpha:1.0]; + UILabel *lblTitle = [[UILabel alloc] initWithFrame:CGRectMake(15, 5, headerView.frame.size.width - 30, headerView.frame.size.height - 15)]; + lblTitle.text = @"Incoming Order History"; + lblTitle.font = [UIFont systemFontOfSize:14.0 weight:UIFontWeightMedium]; + lblTitle.textAlignment = NSTextAlignmentCenter; + lblTitle.backgroundColor = [UIColor whiteColor]; + lblTitle.layer.cornerRadius = 10.0; + lblTitle.layer.masksToBounds = YES; + + [self setShadowOnView:lblTitle]; + [headerView addSubview:lblTitle]; + return headerView; + } + return nil; +} + +- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { + + if (section == 3) { + if (self.otherOrders.count > 0) { + return 50; + } + } + return 0; +} + +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { + + if (indexPath.section == 1 || indexPath.section == 2) { + return 110.0; + } + else { + NSDictionary *orderDict = [[NSDictionary alloc] init]; + if (indexPath.section == 0) { + orderDict = self.wdOrders[indexPath.row]; + if (![[orderDict valueForKey:@"account"] isEqual:[NSNull null]]) { + if ([[orderDict valueForKey:@"account"] length] > 16) { + return 250.0; + } + } + } + else { + orderDict = self.otherOrders[indexPath.row]; + } + return 185.0; + } +} + +#pragma mark - UITextView Delegate +- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange { + + if ([[URL absoluteString] hasPrefix:@"support"]) { + if([MFMailComposeViewController canSendMail]) { + MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init]; + mailController.mailComposeDelegate = self; + + NSDictionary *orderDict = [self.orders objectAtIndex:0]; + [mailController setSubject:[NSString stringWithFormat:@"Order #{%@} - {%@}",[orderDict valueForKey:@"id"],self.phoneNo]]; + [mailController setToRecipients:[NSArray arrayWithObject:@"support@wallofcoins.com"]]; + [mailController setMessageBody:@"" isHTML:NO]; + [self presentViewController:mailController animated:YES completion:nil]; + } + return NO; + } + return YES; +} + +#pragma mark - MFMailComposer Delegate +- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { + + [self dismissViewControllerAnimated:YES completion:nil]; +} + +@end + diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingVerifyDetailViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingVerifyDetailViewController.h new file mode 100644 index 00000000..e6e9b922 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingVerifyDetailViewController.h @@ -0,0 +1,30 @@ +// +// WOCSellingVerifyDetailViewController.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" + +// Enter Phone Number Screen +@interface WOCSellingVerifyDetailViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *accountInformation; +@property (strong, nonatomic) NSString *currentPrice; +@property (weak, nonatomic) IBOutlet UITextField *accountCodeTextfield; +@property (weak, nonatomic) IBOutlet UITextField *phoneNumberTextfield; +@property (weak, nonatomic) IBOutlet UITextField *emailTextfield; +@property (weak, nonatomic) IBOutlet UITextField *currentPriceTextfield; +@property (weak, nonatomic) IBOutlet UIButton *nextButton; + +@property (strong, nonatomic) NSString *offerId; +@property (strong, nonatomic) NSString *emailId; +@property (assign, nonatomic) BOOL isActiveHoldChecked; +@property (assign, nonatomic) BOOL isForLoginOny; +@property (weak, nonatomic) IBOutlet UITextField *confirmEmailTextfield; + +- (IBAction)onNextButtonClick:(id)sender; +@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingVerifyDetailViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingVerifyDetailViewController.m new file mode 100644 index 00000000..1a472fc6 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingVerifyDetailViewController.m @@ -0,0 +1,790 @@ +// +// WOCSellingVerifyDetailViewController.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCSellingVerifyDetailViewController.h" +#import "WOCSellingWizardConfirmCodeViewController.h" +#import "WOCSellingInstructionsViewController.h" +#import "WOCSellingSummaryViewController.h" +#import "WOCPasswordViewController.h" +#import "BRRootViewController.h" +#import "BRAppDelegate.h" +#import "APIManager.h" +#import "WOCConstants.h" +#import "WOCAlertController.h" +#import "MBProgressHUD.h" +#import "WOCHoldIssueViewController.h" +#import "WOCSellingWizardHomeViewController.h" +#import "WOCSellingCreatePasswordViewController.h" + +@interface WOCSellingVerifyDetailViewController () + +@property (strong, nonatomic) NSArray *countries; +@property (strong, nonatomic) UIPickerView *pickerView; +@property (strong, nonatomic) NSString *countryCode; +@property (strong, nonatomic) NSString *purchaseCode; +@property (strong, nonatomic) NSString *holdId; +@property (strong, nonatomic) NSString *deviceName; +@end + +@implementation WOCSellingVerifyDetailViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + [self setShadowOnButton:self.nextButton]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(openBuyDashStep8:) name:WOCNotificationObserverNameBuyDashStep8 object:nil]; + + if (self.accountInformation != nil && self.accountInformation.length > 0) { + self.accountCodeTextfield.text = self.accountInformation; + } + if (self.currentPrice != nil && self.currentPrice.length > 0) { + self.currentPriceTextfield.text = [NSString stringWithFormat:@"$ %@",self.currentPrice]; + } + + NSString *phoneNumber = [self.defaults objectForKey:WOCUserDefaultsLocalPhoneNumber]; + if (phoneNumber != nil && phoneNumber.length > 0) { + self.phoneNumberTextfield.text = phoneNumber; + } + + NSString *emailAddress = [self.defaults objectForKey:WOCUserDefaultsLocalEmail]; + if (emailAddress != nil && emailAddress.length > 0) { + self.emailTextfield.text = emailAddress; + } + else { + self.emailTextfield.text = @""; + } + + NSString *bankInfo = [self.defaults objectForKey:WOCUserDefaultsLocalBankInfo]; + if (bankInfo != nil && bankInfo.length > 0) { + self.accountCodeTextfield.text = bankInfo; + } + else { + self.accountCodeTextfield.text = @""; + } + + NSString *txtCurrentPrice = [self.defaults objectForKey:WOCUserDefaultsLocalPrice]; + if (txtCurrentPrice != nil && txtCurrentPrice.length > 0) { + self.currentPriceTextfield.text = txtCurrentPrice; + } + else { + self.currentPriceTextfield.text = @"0"; + } + + self.accountCodeTextfield.userInteractionEnabled = NO; + self.phoneNumberTextfield.userInteractionEnabled = NO; + self.currentPriceTextfield.userInteractionEnabled = NO; + self.emailTextfield.userInteractionEnabled = NO; +} + +- (void)loadCountyData { + self.pickerView = [[UIPickerView alloc] init]; + self.pickerView.delegate = self; + self.pickerView.dataSource = self; + + [self loadJSON]; +} + +- (void)loadJSON { + // Retrieve local JSON file called example.json + NSString *filePath = [[NSBundle mainBundle] pathForResource:@"countries" ofType:@"json"]; + + // Load the file into an NSData object called JSONData + NSError *error = nil; + NSData *JSONData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:&error]; + + // Create an Objective-C object from JSON Data + NSDictionary *countriesDict = [NSJSONSerialization JSONObjectWithData:JSONData options:NSJSONReadingMutableContainers error:nil]; + NSArray *countries = [countriesDict valueForKey:@"countries"]; + + self.countries = countries; + if (self.countries.count > 0) { + self.accountCodeTextfield.text = [NSString stringWithFormat:@"%@ (%@)",self.countries[0][@"name"],self.countries[0][@"code"]]; + self.countryCode = [NSString stringWithFormat:@"%@",self.countries[0][@"code"]]; + } + + [self.pickerView reloadAllComponents]; +} + +- (void)openBuyDashStep8:(NSNotification*)notification { + + NSString *phoneNo = [NSString stringWithFormat:@"%@",notification.object]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + + [self createHoldAfterAuthorize:phoneNo]; +} + +// MARK: - API + +- (void)checkPhone:(NSString*)phone code:(NSString*)countryCode { + + NSDictionary *params = @{ + }; + + NSString *phoneNo = [NSString stringWithFormat:@"%@%@",countryCode,phone]; + [self.defaults setObject:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + + [[APIManager sharedInstance] authorizeDevice:nil phone:phoneNo response:^(id responseDict, NSError *error) { + + if (error == nil) { + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + + if ([responseDictionary valueForKey:@"recentDeviceName"] != nil) { + self.deviceName = [responseDictionary valueForKey:@"recentDeviceName"]; + } + + if ([[responseDictionary valueForKey:@"availableAuthSources"] isKindOfClass:[NSArray class]]) { + NSArray *availableAuthSource = (NSArray*)[responseDictionary valueForKey:@"availableAuthSources"]; + if (availableAuthSource.count > 0) { + if ([[availableAuthSource objectAtIndex:0] isEqualToString:@"password"]) { + [self login:phoneNo password:self.currentPriceTextfield.text]; + } + else if ([[availableAuthSource objectAtIndex:0] isEqualToString:@"device"]) { + //[self createHoldAfterAuthorize:phoneNo]; + [self resetPassword]; + } + } + } + else if ([responseDictionary valueForKey:@"response"] != nil) { + if ([[responseDictionary valueForKey:@"response"] isEqualToString:@"error"]) { + [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + [self resetPassword]; + } + } + } + else { + + if ([error code] == 404 || [error code] == 0) { + //new number + [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + [self registerUser]; + //[self createHold:phoneNo]; + } + else { + dispatch_async(dispatch_get_main_queue(), ^{ + if (error.userInfo != nil) { + if (error.userInfo[@"detail"] != nil) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self.navigationController.visibleViewController]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + }); + } + } + }]; +} + +- (void)login:(NSString*)phoneNo { + + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + NSString *deviceId = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceId]; + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *params = @{ + WOCApiBodyDeviceCode: deviceCode + }; + + if (deviceId != nil) { + params = @{ + WOCApiBodyDeviceCode: deviceCode, + WOCApiBodyDeviceId: deviceId, + WOCApiBodyJsonParameter: @"YES" + }; + [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDict, NSError *error) { + + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + if (error == nil) { + if (responseDictionary != nil) { + [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self storeDeviceInfoLocally]; + [self backToMainView]; + } + } + else { + + [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + + BOOL isNewPhone = YES; + if (error.code == 400) { + if (error.userInfo != nil) { + NSString *errorDetail = error.userInfo[@"detail"]; + if (errorDetail != nil) { + if ([errorDetail isEqualToString:@"Unable to authorize your phone number. Password may be incorrect."]) { + isNewPhone = NO; + } + } + } + } + if (isNewPhone) { + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + [self backToMainView]; + } + else { + [self openHoldIssueVC]; + } + } + }]; + } +} + +- (void)createHold:(NSString*)phoneNo { + + if (!self.isForLoginOny) { + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *params; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + params = @{ + WOCApiBodyOffer: [NSString stringWithFormat:@"%@==",self.offerId], + WOCApiBodyJsonParameter:@"YES" + }; + } + else { + params = @{ + WOCApiBodyOffer: [NSString stringWithFormat:@"%@==",self.offerId], + WOCApiBodyPhoneNumber: phoneNo, + WOCApiBodyDeviceName: WOCApiBodyDeviceName_IOS, + WOCApiBodyDeviceCode: deviceCode, + WOCApiBodyJsonParameter:@"YES" + }; + + if (self.emailId != nil && self.emailId.length > 0) { + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:params]; + [dict setObject:self.emailId forKey:WOCApiBodyEmail]; + params = (NSDictionary*)dict; + } + } + + [[APIManager sharedInstance] createHold:params response:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^(void) { + [hud hideAnimated:YES]; + }); + + if (error == nil) { + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + if ([responseDictionary valueForKey:WOCApiResponseToken] != nil && (![[responseDictionary valueForKey:WOCApiResponseToken] isEqualToString:@"(null)"])) { + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiResponseToken]] forKey:WOCUserDefaultsAuthToken]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self storeDeviceInfoLocally]; + } + + NSString *holdId = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([responseDictionary valueForKey:WOCApiResponseId])]; + self.holdId = holdId; + + NSString *purchaseCode = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([responseDictionary valueForKey:WOCApiResponsePurchaseCde])]; + if (![purchaseCode isKindOfClass:[NSNull class]]) { + self.purchaseCode = purchaseCode; + } + else { + self.purchaseCode = @""; + } + + WOCSellingWizardConfirmCodeViewController *sellingWizardConfirmCodeViewController = [self getViewController:@"WOCSellingWizardConfirmCodeViewController"]; + sellingWizardConfirmCodeViewController.phoneNo = phoneNo; + sellingWizardConfirmCodeViewController.offerId = self.offerId; + sellingWizardConfirmCodeViewController.purchaseCode = self.purchaseCode; + sellingWizardConfirmCodeViewController.deviceCode = deviceCode; + sellingWizardConfirmCodeViewController.emailId = self.emailId; + sellingWizardConfirmCodeViewController.holdId = self.holdId; + [self pushViewController:sellingWizardConfirmCodeViewController animated:YES]; + } + else if (error.code == 403) { + [self resolveActiveHoldIssue:phoneNo]; + } + else if (error.code == 401) { + [self registerDevice:phoneNo]; + } + }]; + } + else { + + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + if (token != nil && (![token isEqualToString:@"(null)"])) { + [self getOrderList]; + } + else { + + UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Error" message:@"Please select an offer and then try to register/login with app." preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + [self backToMainView]; + }]; + + [alert addAction:okAction]; + [self presentViewController:alert animated:YES completion:nil]; + + } + } +} + +-(void)resolveActiveHoldIssue:(NSString*)phoneNo { + + if (!self.isActiveHoldChecked) { + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + /*you receive Status 403 from POST /api/v1/holds/ + IF YOU HAVE a token or the deviceId/deviceCode, login with that device -- you will use the token to get a list of holds so that you can cancel the holds. IF THERE ARE NO HOLDS, then you will bring the user to the Buy Summary, where they will see their latest WD orders. + */ + self.isActiveHoldChecked = YES; + [self getHold]; + } + else { + NSString *deviceID = [self getDeviceIDFromPhoneNumber:phoneNo]; + if (deviceID.length > 0 && (![deviceID isEqualToString:@"(null)"])) { + [self.defaults setObject:deviceID forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self login:phoneNo]; + } + else { + [self openHoldIssueVC]; + } + } + } +} + +- (void)openHoldIssueVC { + /* + IF YOU DO NOT HAVE the token or deviceId/deviceCode in local storage, then you will need to show a new view that says, "You already have an open hold or a pending order with Wall of Coins. Before you can create a new order, you must finish these orders." and then show a yellow button w/ blue text (just like the "BUY MORE {Crypto Currency} WITH CASH" button), and when they press that button, you will bring them to this website link: + https://wallofcoins.com/signin/1-2397776832/ + https://wallofcoins.com/signin/{phone_country_code}-{local_phone_number}/ + */ + NSString *txtPhone = [self.phoneNumberTextfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + NSString *txtAccountCode = [self.countryCode stringByReplacingOccurrencesOfString:@"+" withString:@""]; + WOCHoldIssueViewController *aViewController = [self getViewController:@"WOCHoldIssueViewController"]; + aViewController.phoneNo = [NSString stringWithFormat:@"%@-%@",txtAccountCode,txtPhone]; + [self pushViewController:aViewController animated:YES]; +} + +- (void)resolvePandingOrderIssue { + + [self getOrderList]; +} + +- (void)getHold { + + [[APIManager sharedInstance] getHold:^(id responseDict, NSError *error) { + if (error == nil) { + APILog(@"Hold with Hold Id: %@.",responseDict); + if ([responseDict isKindOfClass:[NSArray class]]) { + NSArray *holdArray = (NSArray*)responseDict; + if (holdArray.count > 0) { + NSUInteger count = holdArray.count; + NSUInteger activeHodCount = 0; + + for (int i = 0; i < holdArray.count; i++) { + count -= count; + + NSDictionary *holdDict = [holdArray objectAtIndex:i]; + NSString *holdId = [holdDict valueForKey:WOCApiResponseId]; + NSString *holdStatus = [holdDict valueForKey:WOCApiResponseHoldsStatus]; + + if (holdStatus != nil) { + if ([holdStatus isEqualToString:@"AC"]) { + if (holdId) { + activeHodCount = activeHodCount + 1; + [self deleteHold:holdId count:count]; + } + } + } + else { + if (holdId) { + activeHodCount = activeHodCount + 1; + [self deleteHold:holdId count:count]; + } + } + } + + if (activeHodCount == 0) { + [self resolvePandingOrderIssue]; + } + } + else { + [self resolvePandingOrderIssue]; + } + } + else { + [self resolvePandingOrderIssue]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + }]; +} + +- (void)deleteHold:(NSString*)holdId count:(NSUInteger)count { + + NSDictionary *params = @{ + }; + + [[APIManager sharedInstance] deleteHold:holdId response:^(id responseDict, NSError *error) { + if (error == nil) { + APILog(@"Hold deleted."); + + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + [self createHoldAfterAuthorize:phoneNo]; + } + }]; +} + +- (void)registerDevice:(NSString*)phoneNo { + + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *params = @{ + WOCApiBodyName: WOCApiBodyDeviceName_IOS, + WOCApiBodyCode: deviceCode, + WOCApiBodyJsonParameter:@"YES" + }; + + [[APIManager sharedInstance] registerDevice:params response:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^(void) { + [hud hideAnimated:YES]; + }); + + if (error == nil) { + NSDictionary *response = (NSDictionary*)responseDict; + if (response.count > 0) { + NSString *deviceId = [NSString stringWithFormat:@"%@",[response valueForKey:WOCApiResponseId]]; + [self authorize:phoneNo deviceId:deviceId]; + } + } + else { + [self pushToStep1]; + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + }]; +} + +- (void)authorize:(NSString*)phoneNo deviceId:(NSString*)deviceId { + + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *params = @{ + WOCApiBodyDeviceCode: deviceCode, + WOCApiBodyJsonParameter: @"YES" + }; + + if (deviceId != nil && (![deviceId isEqualToString:@"(null)"])) { + params = @{ + WOCApiBodyDeviceCode: deviceCode, + WOCApiBodyDeviceId: deviceId, + WOCApiBodyJsonParameter: @"YES" + }; + } + + [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDict, NSError *error) { + if (error == nil) { + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + + [self storeDeviceInfoLocally]; + [self backToMainView]; + //[self createHoldAfterAuthorize:phoneNo]; + } + else { + [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + }]; +} + +- (void)createHoldAfterAuthorize:(NSString*)phoneNo { + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + [self createHold:phoneNo]; + } + else { + NSString *deviceID = [self getDeviceIDFromPhoneNumber:phoneNo]; + if (deviceID != nil) { + [self.defaults setObject:deviceID forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self login:phoneNo]; + } + else { + [self createHold:phoneNo]; + } + } +} + +// MARK: - IBAction +- (IBAction)onNextButtonClick:(id)sender { + + NSString *txtPhone = [self.phoneNumberTextfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + + if ([txtPhone length] == 0) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter phone number." viewController:self.navigationController.visibleViewController]; + } + else if ([self.emailTextfield.text length] == 0) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter email number." viewController:self.navigationController.visibleViewController]; + } + else if ([self isValidEmail:self.emailTextfield.text] == 0) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter valid email number." viewController:self.navigationController.visibleViewController]; + } + else if ([self.currentPriceTextfield.text length] == 0) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter password number." viewController:self.navigationController.visibleViewController]; + } + else if ([txtPhone length] > 10) { + [self openVerificationCodeScreen]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter valid phone number." viewController:self.navigationController.visibleViewController]; + } +} + +// MARK: - UIPickerView Delegates + +- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView { + return 1; +} + +- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component { + return self.countries.count; +} + +- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { + return [NSString stringWithFormat:@"%@ (%@)",self.countries[row][@"name"],self.countries[row][@"code"]]; +} + +- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { + self.accountCodeTextfield.text = [NSString stringWithFormat:@"%@ (%@)",self.countries[row][@"name"],self.countries[row][@"code"]]; + self.countryCode = [NSString stringWithFormat:@"%@",self.countries[row][@"code"]]; +} + +- (void)pushToStep1 { + [self storeDeviceInfoLocally]; + [self backToMainView]; +} + +- (void)registerUser { + + NSString *phoneNumber = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *params = @{ + WOCApiBodyPhoneNumber: phoneNumber, + WOCApiBodyEmail: self.emailTextfield.text, + WOCApiBodyPassword: self.currentPriceTextfield.text, + WOCApiBodyJsonParameter: @"YES" + }; + + [[APIManager sharedInstance] registerUser:params response:^(id responseDict, NSError *error) { + + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + if (error == nil) { + BOOL isError = NO; + if (responseDictionary != nil) { + if ([responseDictionary valueForKey:@"response"] != nil) { + if ([[responseDictionary valueForKey:@"response"] isEqualToString:@"error"]) { + // Error + isError = YES; + } + } + } + + if (isError) { + [self openHoldIssueVC]; + } + else { + [self login:phoneNumber password:self.currentPriceTextfield.text]; + } + } + else { + + [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + + BOOL isNewPhone = YES; + if (error.code == 400) { + if (error.userInfo != nil) { + NSString *errorDetail = error.userInfo[@"detail"]; + if (errorDetail != nil) { + if ([errorDetail isEqualToString:@"Unable to authorize your phone number. Password may be incorrect."]) { + isNewPhone = NO; + } + } + } + } + + if (isNewPhone) { + [self.defaults setValue:phoneNumber forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + + [self registrationCompleted]; + } + else { + [self openHoldIssueVC]; + } + } + }]; +} + +- (void)resetPassword { + + NSString *phoneNumber = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + + NSDictionary *params = @{ + @"password1": self.currentPriceTextfield.text, + @"password2": self.currentPriceTextfield.text, + WOCApiBodyJsonParameter: @"YES" + }; + + [[APIManager sharedInstance] resetPassword:params phone:phoneNumber response:^(id responseDict, NSError *error) { + + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + if (error == nil) { + if (responseDictionary != nil) { + if ([[responseDictionary valueForKey:@"response"] isEqualToString:@"error"]) { + // Error + [self openHoldIssueVC]; + } + else { + [self registrationCompleted]; + } + } + } + else { + [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + + BOOL isNewPhone = YES; + if (error.code == 400) { + if (error.userInfo != nil) { + NSString *errorDetail = error.userInfo[@"detail"]; + if (errorDetail != nil) { + if ([errorDetail isEqualToString:@"Unable to authorize your phone number. Password may be incorrect."]) { + isNewPhone = NO; + } + } + } + } + + if (isNewPhone) { + [self.defaults setValue:phoneNumber forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + //[self createHoldAfterAuthorize:phoneNumber]; + [self registrationCompleted]; + } + else { + [self openHoldIssueVC]; + } + } + }]; +} + +- (void)login:(NSString*)phoneNo password:(NSString*)password { + NSDictionary *params = @{ + WOCApiBodyPassword: password, + WOCApiBodyJsonParameter: @"YES" + }; + + [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDictionary, NSError *error) { + if (error == nil) { + if (responseDictionary != nil) { + [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self registerDevice:phoneNo]; + [self backToMainView]; + } + } + else { + dispatch_async(dispatch_get_main_queue(), ^{ + if (error.userInfo != nil) { + if (error.userInfo[@"detail"] != nil) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self]; + } + }); + } + }]; +} + +- (void)registrationCompleted { + + NSString *phoneNumber = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + + WOCSellingCreatePasswordViewController *createPasswordViewController = [self getViewController:@"WOCSellingCreatePasswordViewController"]; + + if (self.deviceName != nil) { + createPasswordViewController.deviceName = self.deviceName; + } + createPasswordViewController.offerId = self.offerId; + createPasswordViewController.purchaseCode = self.purchaseCode; + createPasswordViewController.deviceCode = deviceCode; + createPasswordViewController.emailId = self.emailId; + createPasswordViewController.holdId = self.holdId; + [self pushViewController:createPasswordViewController animated:YES]; + //[self login:phoneNumber]; +} + +- (void)openVerificationCodeScreen { + + NSString *phoneNumber = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + + WOCSellingWizardConfirmCodeViewController *confirmCodeViewController = [self getViewController:@"WOCSellingWizardConfirmCodeViewController"]; + confirmCodeViewController.emailId = self.emailId; + confirmCodeViewController.holdId = self.holdId; + [self pushViewController:confirmCodeViewController animated:YES]; + //[self login:phoneNumber]; +} +@end + diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardConfirmCodeViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardConfirmCodeViewController.h new file mode 100644 index 00000000..70e761b0 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardConfirmCodeViewController.h @@ -0,0 +1,30 @@ +// +// WOCSellingWizardConfirmCodeViewController.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" + +//WOCSellingWizardConfirmCodeViewController + +@interface WOCSellingWizardConfirmCodeViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *purchaseCode; +@property (strong, nonatomic) NSString *offerId; +@property (strong, nonatomic) NSString *holdId; +@property (strong, nonatomic) NSString *phoneNo; +@property (strong, nonatomic) NSString *emailId; +@property (strong, nonatomic) NSString *deviceCode; + +@property (weak, nonatomic) IBOutlet UILabel *descriptionLabel; +@property (weak, nonatomic) IBOutlet UITextField *confirmCodeTextfield; +@property (weak, nonatomic) IBOutlet UIButton *confirmVarificationCodeButton; + +- (IBAction)onConfirmVarificationCodeClicked:(id)sender; + + +@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardConfirmCodeViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardConfirmCodeViewController.m new file mode 100644 index 00000000..0c189542 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardConfirmCodeViewController.m @@ -0,0 +1,116 @@ +// +// WOCSellingWizardConfirmCodeViewController.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCSellingWizardConfirmCodeViewController.h" +#import "WOCSellingAdsInstructionsViewController.h" +#import "WOCSellingSummaryViewController.h" +#import "APIManager.h" +#import "WOCConstants.h" +#import "WOCAlertController.h" +#import "BRRootViewController.h" +#import "BRAppDelegate.h" +#import "MBProgressHUD.h" + +@interface WOCSellingWizardConfirmCodeViewController () + +@end + +@implementation WOCSellingWizardConfirmCodeViewController + +- (void)viewDidLoad { + + [super viewDidLoad]; + + [self setShadowOnButton:self.confirmVarificationCodeButton]; + + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + + self.descriptionLabel.text = [NSString stringWithFormat:@"The Mobile phone %@ will receive a verification code within 10 seconds.When you receive the code, input it below.",phoneNo]; + if (self.purchaseCode != nil) { + self.confirmCodeTextfield.text = REMOVE_NULL_VALUE(self.purchaseCode); + } else { + self.confirmCodeTextfield.text = @""; + } + self.confirmCodeTextfield.delegate = self; + [self.confirmCodeTextfield becomeFirstResponder] ; +} + +- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { + + if(textField.text.length == 4 && string.length == 1) + { + [self performSelector:@selector(onConfirmVarificationCodeClicked:) withObject:self afterDelay:1.0]; + } + return YES; +} + +// MARK: - IBAction + +- (IBAction)onConfirmVarificationCodeClicked:(id)sender { + + NSString *txtCode = [self.confirmCodeTextfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + if ([txtCode length] == 5) { + + NSString *emailAddress = REMOVE_NULL_VALUE([self.defaults objectForKey:WOCUserDefaultsLocalEmail]); + NSString *bankAccountInfo = REMOVE_NULL_VALUE([self.defaults objectForKey:WOCUserDefaultsLocalBankInfo]); + NSString *bankAccountID = REMOVE_NULL_VALUE([self.defaults objectForKey:WOCUserDefaultsLocalBankAccount]); + NSString *bankAccount = REMOVE_NULL_VALUE([self.defaults objectForKey:WOCUserDefaultsLocalBankAccountNumber]); + NSString *bankName = REMOVE_NULL_VALUE([self.defaults objectForKey:WOCUserDefaultsLocalBankName]); + NSString *currentPrice = REMOVE_NULL_VALUE([self.defaults objectForKey:WOCUserDefaultsLocalPrice]); + NSString *deviceCode = REMOVE_NULL_VALUE([self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]); + NSString *deviceId = REMOVE_NULL_VALUE([self.defaults valueForKey:WOCUserDefaultsLocalDeviceId]); + NSString *token = REMOVE_NULL_VALUE([self.defaults valueForKey:WOCUserDefaultsAuthToken]); + NSString *phoneNumber = REMOVE_NULL_VALUE([self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]); + NSString *phoneCode = REMOVE_NULL_VALUE([self.defaults valueForKey:WOCUserDefaultsLocalCountryCode]); + phoneNumber = [phoneNumber stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%@",phoneCode] withString:@""]; + phoneCode = [phoneCode stringByReplacingOccurrencesOfString:@"+" withString:@""]; + + NSDictionary *params = @{ + WOCApiBodyDeviceCode: deviceCode + }; + + if (deviceId != nil) { + + params = @{ + WOCApiBodyPhoneNumber:phoneNumber, + WOCApiBodyEmail:emailAddress, + @"phoneCode": phoneCode, + @"bankBusiness": bankAccountID, + @"sellCrypto": WOCCryptoCurrency, + @"userEnabled": @"true", + @"dynamicPrice": @"false", + @"currentPrice": currentPrice, + @"name": bankName, + @"number": bankAccount, + @"number2": bankAccount, + WOCApiBodyDeviceCode: deviceCode, + WOCApiBodyDeviceId: deviceId, + WOCApiBodyJsonParameter: @"YES" + }; + [[APIManager sharedInstance] createAd:params response:^(id responseDict, NSError *error) { + + if (error == nil) { + + } + + WOCSellingAdsInstructionsViewController *adsInstructionsViewController = [self getViewController:@"WOCSellingAdsInstructionsViewController"]; + adsInstructionsViewController.AdvertiseId = @"90"; + [self pushViewController:adsInstructionsViewController animated:YES]; + }]; + } + } + else if ([txtCode length] == 0 ) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:@"Enter Purchase Code" viewController:self.navigationController.visibleViewController]; + } + else if ([txtCode length] != 5 ) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:@"Enter Valid Purchase Code" viewController:self.navigationController.visibleViewController]; + } +} + +@end + diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardHomeViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardHomeViewController.h new file mode 100644 index 00000000..05d58749 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardHomeViewController.h @@ -0,0 +1,29 @@ +// +// WOCSellingWizardHomeViewController.h +// Wallofcoins +// +// Created by Genitrust on 23/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" + + +//WOCSellingWizardHomeViewController +// Find My Location Screen +@interface WOCSellingWizardHomeViewController : WOCBaseViewController + +@property (weak, nonatomic) IBOutlet UIView *signoutView; +@property (weak, nonatomic) IBOutlet UILabel *descriptionLabel; +@property (weak, nonatomic) IBOutlet UIButton *signOutButton; +@property (weak, nonatomic) IBOutlet UIButton *orderListButton; +@property (weak, nonatomic) IBOutlet UIButton *sellYourCryptoButton; +@property (assign, nonatomic) BOOL isFromSend; + +- (void)setLogoutButton; +- (IBAction)onBackButtonClick:(id)sender; +- (IBAction)onSignOutButtonClick:(id)sender; +- (IBAction)onSellYourCryptoButtonClick:(id)sender; + +@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardHomeViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardHomeViewController.m new file mode 100644 index 00000000..2473af00 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardHomeViewController.m @@ -0,0 +1,136 @@ +// +// WOCSellingWizardHomeViewController.m +// Wallofcoins +// +// Created by Genitrust on 23/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCSellingWizardHomeViewController.h" +#import "WOCLocationManager.h" +#import "WOCSellingWizardZipCodeViewController.h" +#import "WOCSellingWizardPaymentCenterViewController.h" +#import "WOCSellingWizardInputAmountViewController.h" +#import "WOCConstants.h" +#import "BRAppDelegate.h" +#import "BRRootViewController.h" +#import "MBProgressHUD.h" +#import "APIManager.h" +#import "WOCAlertController.h" +#import "WOCSellingWizardInputEmailViewController.h" +#import "WOCSellingWizardInputPhoineNumberViewController.h" + +@interface WOCSellingWizardHomeViewController () + +@property (strong, nonatomic) NSString *zipCode; + +@end + +@implementation WOCSellingWizardHomeViewController + +- (void)viewDidLoad { + + self.isBackButtonRequire = YES; + + [super viewDidLoad]; + + [self.defaults removeObjectForKey:WOCUserDefaultsLocalLocationLatitude]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalLocationLongitude]; + + [[NSNotificationCenter defaultCenter] removeObserver:WOCNotificationObserverNameBuyDashStep1]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setLogoutButton) name:WOCNotificationObserverNameBuyDashStep1 object:nil]; + + [self.sellYourCryptoButton setTitle:[NSString stringWithFormat:@"SELL YOUR %@",WOCCurrencySpecial] forState:UIControlStateNormal]; + [self setShadowOnButton:self.sellYourCryptoButton]; +} + +- (void)viewWillAppear:(BOOL)animated { + + [super viewWillAppear:animated]; + [self setLogoutButton]; +} + +- (void)viewWillDisappear:(BOOL)animated { + + [super viewWillDisappear:animated]; +} + +- (void)setLogoutButton { + + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + NSString *loginPhone = [NSString stringWithFormat:@"Your wallet is signed into Wall of Coins using your mobile number %@",phoneNo]; + self.descriptionLabel.text = loginPhone; + [self.signOutButton setTitle:@"SIGN OUT" forState:UIControlStateNormal]; + self.signoutView.hidden = NO; + self.orderListButton.hidden = NO; + } + else { + NSString *loginPhone = [NSString stringWithFormat:@"Do you already have an order?"]; + self.descriptionLabel.text = loginPhone; + [self.signOutButton setTitle:@"SIGN IN HERE" forState:UIControlStateNormal]; + self.signoutView.hidden = NO; + self.orderListButton.hidden = YES; + } + + [self setShadowOnButton:self.signOutButton]; + [self setShadowOnButton:self.orderListButton]; +} + +- (void)back:(id)sender { + + [self backToRoot]; +} + +// MARK: - API +- (void)signOut:(NSString*)phone { + + [self signOutWOC]; +} + +- (IBAction)onOrderListClick:(id)sender { + + [self getOrderList]; +} + +// MARK: - IBAction + +- (IBAction)onBackButtonClick:(id)sender { + APILog(@"onBackButtonClick"); + [self backToRoot]; +} + +- (IBAction)onSignOutButtonClick:(id)sender { + + UIButton * btn = (UIButton*) sender; + if (btn != nil) { + if ([btn.titleLabel.text isEqualToString:@"SIGN IN HERE"]) { + [self push:@"WOCSellingSignInViewController"]; + } + else { + [self signOutWOC]; + } + } + [self performSelector:@selector(setLogoutButton) withObject:nil afterDelay:1.0]; +} + +- (IBAction)onSellYourCryptoButtonClick:(id)sender { + + [self refereshToken]; + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + + if (phoneNo == nil || phoneNo.length == 0) + { + WOCSellingWizardInputPhoineNumberViewController *inputPhoneNumberViewController = [self getViewController:@"WOCSellingWizardInputPhoineNumberViewController"]; + inputPhoneNumberViewController.offerId = @""; + inputPhoneNumberViewController.emailId = @""; + [self pushViewController:inputPhoneNumberViewController animated:YES]; + } + else { + WOCSellingWizardInputEmailViewController *inputEmailViewController = [self getViewController:@"WOCSellingWizardInputEmailViewController"]; + [self pushViewController:inputEmailViewController animated:YES]; + } +} +@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputAmountViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputAmountViewController.h new file mode 100644 index 00000000..a7e0bc36 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputAmountViewController.h @@ -0,0 +1,30 @@ +// +// WOCSellingWizardInputAmountViewController.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" +//WOCSellingWizardInputAmountViewController +// Get Offer with Amount +@interface WOCSellingWizardInputAmountViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *bankId; +@property (strong, nonatomic) NSString *zipCode; +@property (strong, nonatomic) NSDictionary *bankDict; + +@property (weak, nonatomic) IBOutlet UITextField *dashTextfield; +@property (weak, nonatomic) IBOutlet UITextField *dollarTextfield; +@property (weak, nonatomic) IBOutlet UIView *line1; +@property (weak, nonatomic) IBOutlet UIView *line2; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *line1Height; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *line2HeightConstant; +@property (weak, nonatomic) IBOutlet UIButton *getOffersButton; +@property (weak, nonatomic) IBOutlet UILabel *titleLabel; + +- (IBAction)getOffersButtonClick:(id)sender; + +@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputAmountViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputAmountViewController.m new file mode 100644 index 00000000..a6020e37 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputAmountViewController.m @@ -0,0 +1,186 @@ +// +// WOCSellingWizardInputAmountViewController.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCSellingWizardInputAmountViewController.h" +#import "WOCSellingWizardOfferListViewController.h" +#import "WOCConstants.h" +#import "APIManager.h" +#import "WOCLocationManager.h" +#import +#import "BRWalletManager.h" +#import "WOCAlertController.h" +#import "BRAppDelegate.h" +#import "WOCSellingVerifyDetailViewController.h" +#import "WOCSellingAdvancedOptionsInstructionsViewController.h" + +static const int dashTextField = 101; +static const int dollarTextField = 102; + +//#define dashTextField 101 +//#define dollarTextField 102 + +@interface WOCSellingWizardInputAmountViewController () + +@end + +@implementation WOCSellingWizardInputAmountViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + [self setShadowOnButton:self.getOffersButton]; + self.titleLabel.text = [NSString stringWithFormat:@"How much do you want per %@?",WOCCurrency]; + self.dashTextfield.text = @"Price Per Coin"; + self.dashTextfield.delegate = self; + self.dollarTextfield.delegate = self; + self.dashTextfield.userInteractionEnabled = NO; + self.line1Height.constant = 1; + self.line2HeightConstant.constant = 2; + [self.dollarTextfield becomeFirstResponder]; +} + +// MARK: - IBAction + +- (IBAction)getOffersButtonClick:(id)sender { + + NSString *dollarString = [self.dollarTextfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + + if ([dollarString length] > 0 && [dollarString intValue] != 0) { + + if ([dollarString intValue] <10000000) { + + [self loadVarificationScreen]; + + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Amount must be less than $100000." viewController:self.navigationController.visibleViewController]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Enter amount." viewController:self.navigationController.visibleViewController]; + } +} + +// MARK: - API +- (void)sendUserData:(NSString*)amount zipCode:(NSString*)zipCode bankId:(NSString*)bankId { + + if (self.dashTextfield != nil) { + [self.dashTextfield resignFirstResponder]; + } + + if (self.dollarTextfield != nil) { + [self.dollarTextfield resignFirstResponder]; + } + + BRWalletManager *manager = [BRWalletManager sharedInstance]; + NSString *cryptoAddress = manager.wallet.receiveAddress; + APILog(@"cryptoAddress = %@",cryptoAddress); + + NSDictionary *params = @{ + WOCApiBodyCryptoAmount: @"0", + WOCApiBodyUsdAmount: amount, + WOCApiBodyCrypto: WOCCryptoCurrency, + WOCApiBodyCryptoAddress:cryptoAddress, + WOCApiBodyJsonParameter: @"YES" + }; + + //Receive Crypto Currency Address... + NSString *latitude = [self.defaults valueForKey:WOCUserDefaultsLocalLocationLatitude]; + NSString *longitude = [self.defaults valueForKey:WOCUserDefaultsLocalLocationLongitude]; + + if (latitude == nil && longitude == nil) { + latitude = @""; + longitude = @""; + } + + if (latitude.length > 0 && longitude.length > 0) { + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:params]; + [dict setObject:@{WOCApiBodyLatitude:latitude , + WOCApiBodyLongitude:longitude } forKey:WOCApiBodyBrowserLocation]; + params = (NSDictionary*)dict; + } + + if (zipCode != nil && zipCode.length > 0) { + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:params]; + [dict setObject:zipCode forKey:WOCApiBodyZipCode]; + params = (NSDictionary*)dict; + } + + if (bankId != nil && bankId.length > 0) { + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:params]; + [dict setObject:bankId forKey:WOCApiBodyBank]; + params = (NSDictionary*)dict; + } + + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:params]; + + if (bankId == nil || bankId.length == 0) { + NSString *countryCodeFromLatLong = [self.defaults objectForKey:WOCApiBodyCountryCode]; + + if (countryCodeFromLatLong == nil) { + NSString *countryCode = [[NSLocale currentLocale] objectForKey: NSLocaleCountryCode]; + [dict setObject:countryCode.lowercaseString forKey:WOCApiBodyCountry]; + } + else { + [dict setObject:countryCodeFromLatLong.lowercaseString forKey:WOCApiBodyCountry]; + } + } + //[dict setObject:@"us" forKey:WOCApiBodyCountry]; + + params = (NSDictionary*)dict; + + [[APIManager sharedInstance] discoverInfo:params response:^(id responseDict, NSError *error) { + if (error == nil) { + NSDictionary *dictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + + if ([dictionary valueForKey:@"id"] != nil) { + WOCSellingWizardOfferListViewController *offerListViewController = (WOCSellingWizardOfferListViewController*)[self getViewController:@"WOCSellingWizardOfferListViewController"];; + offerListViewController.discoveryId = [NSString stringWithFormat:@"%@",[dictionary valueForKey:@"id"]]; + offerListViewController.amount = self.dollarTextfield.text; + [self pushViewController:offerListViewController animated:YES]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Error in getting offers. Please try after some time." viewController:self.navigationController.visibleViewController]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + }]; +} + + +- (void)loadVarificationScreen { + + [self.defaults setObject:self.dollarTextfield.text forKey:WOCUserDefaultsLocalPrice]; + [self.defaults synchronize]; + + [self.defaults setBool:YES forKey:@"isBeforeCreateAd"]; + [self.defaults synchronize]; + + WOCSellingAdvancedOptionsInstructionsViewController *sellingAdvancedOptionsInstructionsViewController = [self getViewController:@"WOCSellingAdvancedOptionsInstructionsViewController"]; + [self pushViewController:sellingAdvancedOptionsInstructionsViewController animated:YES]; + [sellingAdvancedOptionsInstructionsViewController setupUI]; +} + +// MARK: - UITextField Delegates + +- (void)textFieldDidBeginEditing:(UITextField *)textField { + + if (textField.tag == dashTextField) { + self.line1Height.constant = 2; + self.line2HeightConstant.constant = 1; + } + else { + self.line1Height.constant = 1; + self.line2HeightConstant.constant = 2; + } +} + +@end + diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputEmailViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputEmailViewController.h new file mode 100644 index 00000000..56216914 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputEmailViewController.h @@ -0,0 +1,24 @@ +// +// WOCSellingWizardInputEmailViewController.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" +//WOCSellingWizardInputEmailViewController + +// Enter Email Address Screen +@interface WOCSellingWizardInputEmailViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *offerId; + +@property (weak, nonatomic) IBOutlet UIButton *nextButton; +@property (weak, nonatomic) IBOutlet UITextField *emailTextField; + +- (IBAction)onDoNotSendMeEmailButtonClick:(id)sender; +- (IBAction)onNextButtonClick:(id)sender; + +@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputEmailViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputEmailViewController.m new file mode 100644 index 00000000..65c5cf82 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputEmailViewController.m @@ -0,0 +1,70 @@ +// +// WOCBuyingWizardInputEmailViewController.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCSellingWizardInputEmailViewController.h" +#import "WOCSellingWizardInputPhoineNumberViewController.h" +#import "WOCAlertController.h" +#import "WOCConstants.h" +#import "WOCSellingWizardPaymentCenterViewController.h" + +@interface WOCSellingWizardInputEmailViewController () + +@end + +@implementation WOCSellingWizardInputEmailViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + [self setShadowOnButton:self.nextButton]; + + if ([self.defaults objectForKey:WOCUserDefaultsLocalEmail] != nil) { + NSString *emailStr = [self.defaults objectForKey:WOCUserDefaultsLocalEmail]; + self.emailTextField.text = emailStr; + } +} + +- (BOOL)validateEmailWithString:(NSString*)checkString { + + BOOL stricterFilter = NO; // Discussion http://blog.logichigh.com/2010/09/02/validating-an-e-mail-address/ + NSString *stricterFilterString = @"[A-Z0-9a-z\\._%+-]+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2,4}"; + NSString *laxString = @".+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2}[A-Za-z]*"; + NSString *emailRegex = stricterFilter ? stricterFilterString : laxString; + NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex]; + return [emailTest evaluateWithObject:checkString]; +} + +// MARK: - IBAction + +- (IBAction)onDoNotSendMeEmailButtonClick:(id)sender { + + [self.defaults removeObjectForKey:WOCUserDefaultsLocalEmail]; + + WOCSellingWizardPaymentCenterViewController *paymentCenterViewController = [self getViewController:@"WOCSellingWizardPaymentCenterViewController"]; + [self pushViewController:paymentCenterViewController animated:YES]; +} + +- (IBAction)onNextButtonClick:(id)sender { + + NSString *emailStr = [self.emailTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + + if ([emailStr length] == 0) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter email." viewController:self.navigationController.visibleViewController]; + } + else if (![self validateEmailWithString:emailStr]) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter valid email." viewController:self.navigationController.visibleViewController]; + } + else { + + [self.defaults setObject:emailStr forKey:WOCUserDefaultsLocalEmail]; + WOCSellingWizardPaymentCenterViewController *paymentCenterViewController = [self getViewController:@"WOCSellingWizardPaymentCenterViewController"]; + [self pushViewController:paymentCenterViewController animated:YES]; + } +} +@end + diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputPhoineNumberViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputPhoineNumberViewController.h new file mode 100644 index 00000000..2260b86f --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputPhoineNumberViewController.h @@ -0,0 +1,26 @@ +// +// WOCSellingWizardInputPhoineNumberViewController.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" +//WOCSellingWizardInputPhoineNumberViewController + +// Enter Phone Number Screen +@interface WOCSellingWizardInputPhoineNumberViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *offerId; +@property (strong, nonatomic) NSString *emailId; +@property (assign, nonatomic) BOOL isActiveHoldChecked; +@property (assign, nonatomic) BOOL isForLoginOny; +@property (weak, nonatomic) IBOutlet UIButton *nextButton; +@property (weak, nonatomic) IBOutlet UITextField *countryCodeTextfield; +@property (weak, nonatomic) IBOutlet UITextField *phoneNumberTextfield; + +- (IBAction)onNextButtonClicked:(id)sender; + +@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputPhoineNumberViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputPhoineNumberViewController.m new file mode 100644 index 00000000..826efa71 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputPhoineNumberViewController.m @@ -0,0 +1,490 @@ +// +// WOCSellingWizardInputPhoineNumberViewController.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCSellingWizardInputPhoineNumberViewController.h" +#import "WOCSellingWizardConfirmCodeViewController.h" +#import "WOCSellingInstructionsViewController.h" +#import "WOCSellingSummaryViewController.h" +#import "WOCPasswordViewController.h" +#import "BRRootViewController.h" +#import "BRAppDelegate.h" +#import "APIManager.h" +#import "WOCConstants.h" +#import "WOCAlertController.h" +#import "MBProgressHUD.h" +#import "WOCHoldIssueViewController.h" +#import "WOCSellingWizardHomeViewController.h" +#import "WOCSellingCreatePasswordViewController.h" +#import "WOCSellingSingUpViewController.h" + +@interface WOCSellingWizardInputPhoineNumberViewController () + +@property (strong, nonatomic) NSArray *countries; +@property (strong, nonatomic) UIPickerView *pickerView; +@property (strong, nonatomic) NSString *countryCode; +@property (strong, nonatomic) NSString *purchaseCode; +@property (strong, nonatomic) NSString *holdId; + +@end + +@implementation WOCSellingWizardInputPhoineNumberViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + [self setShadowOnButton:self.nextButton]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(openBuyDashStep8:) name:WOCNotificationObserverNameBuyDashStep8 object:nil]; + + self.pickerView = [[UIPickerView alloc] init]; + self.pickerView.delegate = self; + self.pickerView.dataSource = self; + self.countryCodeTextfield.inputView = self.pickerView; + + [self loadJSON]; +} + +- (void)loadJSON { + // Retrieve local JSON file called example.json + NSString *filePath = [[NSBundle mainBundle] pathForResource:@"countries" ofType:@"json"]; + + // Load the file into an NSData object called JSONData + NSError *error = nil; + NSData *JSONData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:&error]; + + // Create an Objective-C object from JSON Data + NSDictionary *countriesDict = [NSJSONSerialization JSONObjectWithData:JSONData options:NSJSONReadingMutableContainers error:nil]; + NSArray *countries = [countriesDict valueForKey:@"countries"]; + + self.countries = countries; + if (self.countries.count > 0) { + self.countryCodeTextfield.text = [NSString stringWithFormat:@"%@ (%@)",self.countries[0][@"name"],self.countries[0][@"code"]]; + self.countryCode = [NSString stringWithFormat:@"%@",self.countries[0][@"code"]]; + } + + [self.pickerView reloadAllComponents]; +} + +- (void)openBuyDashStep8:(NSNotification*)notification { + + NSString *phoneNo = [NSString stringWithFormat:@"%@",notification.object]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + + [self push:@"WOCSellingWizardInputEmailViewController"]; +} + +// MARK: - API + +- (void)checkPhone:(NSString*)phone code:(NSString*)countryCode { + + NSDictionary *params = @{ + }; + + NSString *phoneNo = [NSString stringWithFormat:@"%@%@",countryCode,phone]; + + + [[APIManager sharedInstance] authorizeDevice:nil phone:phoneNo response:^(id responseDict, NSError *error) { + + if (error == nil) { + + [self.defaults setObject:countryCode forKey:WOCUserDefaultsLocalCountryCode]; + [self.defaults synchronize]; + + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + + if ([[responseDictionary valueForKey:@"availableAuthSources"] isKindOfClass:[NSArray class]]) { + NSArray *availableAuthSource = (NSArray*)[responseDictionary valueForKey:@"availableAuthSources"]; + if (availableAuthSource.count > 0) { + if ([[availableAuthSource objectAtIndex:0] isEqualToString:@"password"]) { + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:WOCBuyingStoryboard bundle:nil]; + + WOCPasswordViewController *passwordViewController = [storyboard instantiateViewControllerWithIdentifier:@"WOCPasswordViewController"]; + passwordViewController.phoneNo = phoneNo; + passwordViewController.modalTransitionStyle = UIModalPresentationOverCurrentContext; + [self.navigationController presentViewController:passwordViewController animated:YES completion:nil]; + } + else if ([[availableAuthSource objectAtIndex:0] isEqualToString:@"device"]) { + [self createHoldAfterAuthorize:phoneNo]; + } + } + } + } + else { + + if ([error code] == 404) { + //new number + [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + + [self createHold:phoneNo]; + } + else { + dispatch_async(dispatch_get_main_queue(), ^{ + if (error.userInfo != nil) { + if (error.userInfo[@"detail"] != nil) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self.navigationController.visibleViewController]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + }); + } + } + }]; +} + +- (void)login:(NSString*)phoneNo { + + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + NSString *deviceId = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceId]; + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *params = @{ + WOCApiBodyDeviceCode: deviceCode + }; + + if (deviceId != nil) { + + params = @{ + WOCApiBodyDeviceCode: deviceCode, + WOCApiBodyDeviceId: deviceId, + WOCApiBodyJsonParameter: @"YES" + }; + + [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDict, NSError *error) { + + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + if (error == nil) { + + if (responseDictionary != nil) { + [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self storeDeviceInfoLocally]; + [self createHoldAfterAuthorize:phoneNo]; + } + } + else { + + [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + + BOOL isNewPhone = YES; + + if (error.code == 400) { + if (error.userInfo != nil) { + NSString *errorDetail = error.userInfo[@"detail"]; + if (errorDetail != nil) { + if ([errorDetail isEqualToString:@"Unable to authorize your phone number. Password may be incorrect."]) { + isNewPhone = FALSE; + } + } + } + } + if (isNewPhone) { + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + [self createHoldAfterAuthorize:phoneNo]; + } + else { + [self openHoldIssueVC]; + } + } + }]; + } +} + +- (void)createHold:(NSString*)phoneNo { + + if (!self.isForLoginOny) { + WOCSellingSingUpViewController *sellingSingUpViewController = [self getViewController:@"WOCSellingSingUpViewController"]; + [self pushViewController:sellingSingUpViewController animated:YES]; + } + else { + + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + if (token != nil && (![token isEqualToString:@"(null)"])) { + [self getOrderList]; + } + else { + + UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Error" message:@"Please select an offer and then try to register/login with app." preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + [self backToMainView]; + }]; + + [alert addAction:okAction]; + [self presentViewController:alert animated:YES completion:nil]; + + } + } +} + +- (void)resolveActiveHoldIssue:(NSString*)phoneNo { + + if (!self.isActiveHoldChecked) { + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + if (token != nil && (![token isEqualToString:@"(null)"])) { + /*you receive Status 403 from POST /api/v1/holds/ + IF YOU HAVE a token or the deviceId/deviceCode, login with that device -- you will use the token to get a list of holds so that you can cancel the holds. IF THERE ARE NO HOLDS, then you will bring the user to the Buy Summary, where they will see their latest WD orders. + */ + self.isActiveHoldChecked = YES; + [self getHold]; + } + else { + + + NSString *deviceID = [self getDeviceIDFromPhoneNumber:phoneNo]; + if (deviceID.length > 0 && (![deviceID isEqualToString:@"(null)"])) { + [self.defaults setObject:deviceID forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self login:phoneNo]; + } + else { + [self openHoldIssueVC]; + } + } + } +} + +- (void)openHoldIssueVC { + /* + IF YOU DO NOT HAVE the token or deviceId/deviceCode in local storage, then you will need to show a new view that says, "You already have an open hold or a pending order with Wall of Coins. Before you can create a new order, you must finish these orders." and then show a yellow button w/ blue text (just like the "BUY MORE {Crypto Currency} WITH CASH" button), and when they press that button, you will bring them to this website link: + https://wallofcoins.com/signin/1-2397776832/ + https://wallofcoins.com/signin/{phone_country_code}-{local_phone_number}/ + */ + NSString *txtPhone = [self.phoneNumberTextfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + NSString *txtcountryCode = [self.countryCode stringByReplacingOccurrencesOfString:@"+" withString:@""]; + WOCHoldIssueViewController *aViewController = [self getViewController:@"WOCHoldIssueViewController"]; + aViewController.phoneNo = [NSString stringWithFormat:@"%@-%@",txtcountryCode,txtPhone]; + [self pushViewController:aViewController animated:YES]; +} + +- (void)resolvePandingOrderIssue { + + [self getOrderList]; +} + +- (void)getHold { + + [[APIManager sharedInstance] getHold:^(id responseDict, NSError *error) { + if (error == nil) { + APILog(@"Hold with Hold Id: %@.",responseDict); + if ([responseDict isKindOfClass:[NSArray class]]) { + NSArray *holdArray = (NSArray*)responseDict; + if (holdArray.count > 0) { + NSUInteger count = holdArray.count; + NSUInteger activeHodCount = 0; + + for (int i = 0; i < holdArray.count; i++) { + count -= count; + + NSDictionary *holdDict = [holdArray objectAtIndex:i]; + NSString *holdId = [holdDict valueForKey:WOCApiResponseId]; + NSString *holdStatus = [holdDict valueForKey:WOCApiResponseHoldsStatus]; + + if (holdStatus != nil) { + if ([holdStatus isEqualToString:@"AC"]) { + if (holdId) { + activeHodCount = activeHodCount + 1; + [self deleteHold:holdId count:count]; + } + } + } + else { + if (holdId) { + activeHodCount = activeHodCount + 1; + [self deleteHold:holdId count:count]; + } + } + } + + if (activeHodCount == 0 ) { + [self resolvePandingOrderIssue]; + } + } + else { + [self resolvePandingOrderIssue]; + } + } + else { + [self resolvePandingOrderIssue]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + }]; +} + +- (void)deleteHold:(NSString*)holdId count:(NSUInteger)count { + + NSDictionary *params = @{ + }; + + [[APIManager sharedInstance] deleteHold:holdId response:^(id responseDict, NSError *error) { + if (error == nil) { + APILog(@"Hold deleted."); + + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + [self createHoldAfterAuthorize:phoneNo]; + } + }]; +} + +- (void)registerDevice:(NSString*)phoneNo { + + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *params = @{ + WOCApiBodyName: WOCApiBodyDeviceName_IOS, + WOCApiBodyCode: deviceCode, + WOCApiBodyJsonParameter:@"YES" + }; + + [[APIManager sharedInstance] registerDevice:params response:^(id responseDict, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^(void) { + [hud hideAnimated:YES]; + }); + + if (error == nil) { + NSDictionary *response = (NSDictionary*)responseDict; + if (response.count > 0) { + NSString *deviceId = [NSString stringWithFormat:@"%@",[response valueForKey:WOCApiResponseId]]; + [self authorize:phoneNo deviceId:deviceId]; + } + } + else { + + [self pushToStep1]; + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + }]; +} + +- (void)authorize:(NSString*)phoneNo deviceId:(NSString*)deviceId { + + NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + NSDictionary *params = @{ + WOCApiBodyDeviceCode: deviceCode, + WOCApiBodyJsonParameter: @"YES" + }; + + if (deviceId != nil && (![deviceId isEqualToString:@"(null)"])) { + params = @{ + WOCApiBodyDeviceCode: deviceCode, + WOCApiBodyDeviceId: deviceId, + WOCApiBodyJsonParameter: @"YES" + }; + } + + [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDict, NSError *error) { + if (error == nil) { + + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + + [self storeDeviceInfoLocally]; + [self createHoldAfterAuthorize:phoneNo]; + } + else { + + [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; + } + }]; +} + +- (void)createHoldAfterAuthorize:(NSString*)phoneNo { + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + + if (token != nil && (![token isEqualToString:@"(null)"])) { + [self push:@"WOCSellingWizardInputEmailViewController"]; + } + else { + NSString *deviceID = [self getDeviceIDFromPhoneNumber:phoneNo]; + if (deviceID != nil) { + [self.defaults setObject:deviceID forKey:WOCUserDefaultsLocalDeviceId]; + [self.defaults synchronize]; + [self login:phoneNo]; + } + else { + [self createHold:phoneNo]; + } + } +} + +// MARK: - IBAction +- (IBAction)onNextButtonClicked:(id)sender { + + NSString *txtPhone = [self.phoneNumberTextfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + + if ([self.countryCode length] == 0) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Select country code." viewController:self.navigationController.visibleViewController]; + } + else if ([txtPhone length] == 0) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter phone number." viewController:self.navigationController.visibleViewController]; + } + else if ([txtPhone length] == 10) { + self.isActiveHoldChecked = NO; + [self checkPhone:txtPhone code:self.countryCode]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter valid phone number." viewController:self.navigationController.visibleViewController]; + } +} + +// MARK: - UIPickerView Delegates + +- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView { + return 1; +} + +- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component { + return self.countries.count; +} + +- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { + return [NSString stringWithFormat:@"%@ (%@)",self.countries[row][@"name"],self.countries[row][@"code"]]; +} + +- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { + self.countryCodeTextfield.text = [NSString stringWithFormat:@"%@ (%@)",self.countries[row][@"name"],self.countries[row][@"code"]]; + self.countryCode = [NSString stringWithFormat:@"%@",self.countries[row][@"code"]]; +} + +- (void)pushToStep1 { + [self storeDeviceInfoLocally]; + [self backToMainView]; +} + +@end + diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardOfferListViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardOfferListViewController.h new file mode 100644 index 00000000..27ddc51e --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardOfferListViewController.h @@ -0,0 +1,25 @@ +// +// WOCSellingWizardOfferListViewController.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" + +//WOCSellingWizardOfferListViewController + +// Offer List ViewController +@interface WOCSellingWizardOfferListViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *discoveryId; +@property (strong, nonatomic) NSString *amount; + +@property (weak, nonatomic) IBOutlet UILabel *instructionLabel; +@property (weak, nonatomic) IBOutlet UITableView *offerListtTableView; + +- (IBAction)orderClicked:(id)sender; +- (NSIndexPath*)getIndexPathfromTag:(NSInteger)tag; +@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardOfferListViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardOfferListViewController.m new file mode 100644 index 00000000..0a8bcbf0 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardOfferListViewController.m @@ -0,0 +1,496 @@ +// +// WOCSellingWizardOfferListViewController.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCSellingWizardOfferListViewController.h" +#import "WOCSellingWizardInputEmailViewController.h" +#import "WOCSellingInstructionsViewController.h" +#import "WOCSellingSummaryViewController.h" +#import "BRRootViewController.h" +#import "BRAppDelegate.h" +#import "WOCOfferCell.h" +#import "APIManager.h" +#import "BRWalletManager.h" +#import "WOCAlertController.h" +#import "MBProgressHUD.h" +#import "WOCSellingWizardHomeViewController.h" +#import "WOCAsyncImageView.h" + +@interface WOCSellingWizardOfferListViewController () + +@property (strong, nonatomic) NSArray *offers; +@property (strong, nonatomic) NSMutableDictionary *offersDict; + +@property (assign, nonatomic) BOOL incremented; +@property (assign, nonatomic) BOOL isExtendedSearch; +@end + +@implementation WOCSellingWizardOfferListViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.instructionLabel.text = [NSString stringWithFormat:@"Below are offers for at least $%@. You must click the ORDER button before you receive instructions to pay at the Cash Payment center.",self.amount]; + [self getOffers]; +} + +- (void)pushToStep6:(NSInteger)sender { + + NSIndexPath *indexPath = [self getIndexPathfromTag:sender]; + NSString *key = self.offersDict.allKeys[indexPath.section]; + NSArray *offerArray = self.offersDict[key]; + NSDictionary *offerDict = offerArray[indexPath.row]; + WOCSellingWizardInputEmailViewController *inputEmailViewController = (WOCSellingWizardInputEmailViewController*)[self getViewController:@"WOCSellingWizardInputEmailViewController"]; + inputEmailViewController.offerId = [NSString stringWithFormat:@"%@",[offerDict valueForKey:@"id"]]; + [self pushViewController:inputEmailViewController animated:YES]; +} + +// MARK: - API + +- (void)getOffers { + + self.offersDict = [NSMutableDictionary dictionaryWithCapacity:0]; + if (self.discoveryId != nil && [self.discoveryId length] > 0) { + + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + [[APIManager sharedInstance] discoveryInputs:self.discoveryId response:^(id responseDict, NSError *error) { + + dispatch_async(dispatch_get_main_queue(), ^{ + [hud hideAnimated:YES]; + }); + + if (error == nil) { + + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + + if ([[responseDictionary valueForKey:@"isExtendedSearch"] boolValue]) { + self.isExtendedSearch = YES; + + self.instructionLabel.text = [NSString stringWithFormat:@"Most Convenient Options While $%@ is not available, we gathered the closest options.You must click the ORDER button before you receive instructions to pay at the Cash Payment center.",self.amount]; + } + else { + self.isExtendedSearch = NO; + + if ([[responseDictionary valueForKey:@"incremented"] boolValue]) { + self.incremented = YES; + self.instructionLabel.text = [NSString stringWithFormat:@"Below are offers for at least $%@. You must click the ORDER button before you receive instructions to pay at the Cash Payment center.",self.amount]; + } + else { + self.incremented = NO; + self.instructionLabel.text = [NSString stringWithFormat:@"Below are offers for $%@. You must click the ORDER button before you receive instructions to pay at the Cash Payment center.",self.amount]; + } + } + + if ([responseDictionary valueForKey:@"singleDeposit"] != nil) { + + if ([[responseDictionary valueForKey:@"singleDeposit"] isKindOfClass:[NSArray class]] ) { + + NSArray *offersArray = [[NSArray alloc] initWithArray:(NSArray*)[responseDictionary valueForKey:@"singleDeposit"]]; + self.offers = [[NSArray alloc] initWithArray:offersArray]; + if (offersArray.count > 0) { + self.offersDict[@""] = offersArray; + } + } + } + + if ([responseDictionary valueForKey:@"doubleDeposit"] != nil) { + + if ([[responseDictionary valueForKey:@"doubleDeposit"] isKindOfClass:[NSArray class]] ) { + + NSArray *offersArray = [[NSArray alloc] initWithArray:(NSArray*)[responseDictionary valueForKey:@"doubleDeposit"]]; + NSArray *doubleOffer = [self getOffersFromDoubleDeposit:offersArray]; + if (doubleOffer.count > 0) { + if (self.isExtendedSearch) { + NSString *key = [NSString stringWithFormat:@"Best Value options: more %@ for under $%@ cash.",WOCCurrency,self.amount]; + self.offersDict[key] = doubleOffer; + } + else { + NSString *key = [NSString stringWithFormat:@"Best Value options: more %@ for $%@ cash.",WOCCurrency,self.amount]; + self.offersDict[key] = doubleOffer; + } + } + } + } + + if ([responseDictionary valueForKey:@"multipleBanks"] != nil) { + + if ([[responseDictionary valueForKey:@"multipleBanks"] isKindOfClass:[NSArray class]] ) { + + NSArray *offersArray = [[NSArray alloc] initWithArray:(NSArray*)[responseDictionary valueForKey:@"multipleBanks"]]; + NSArray *multipleBankOffer = [self getOffersFromDoubleDeposit:offersArray]; NSArray *doubleOffer = [self getOffersFromDoubleDeposit:offersArray]; + if (multipleBankOffer.count > 0) { + if (self.isExtendedSearch) { + NSString *key = [NSString stringWithFormat:@"Best Value options: more %@ for under $%@ cash from multiple banks.",WOCCurrency,self.amount]; + self.offersDict[key] = multipleBankOffer; + } + else { + NSString *key = [NSString stringWithFormat:@"Best Value options: more %@ for $%@ cash from multiple banks.",WOCCurrency,self.amount]; + self.offersDict[key] = multipleBankOffer; + } + } + } + } + + dispatch_async(dispatch_get_main_queue(), ^{ + [self.offerListtTableView reloadData]; + }); + + } + else { + dispatch_async(dispatch_get_main_queue(), ^{ + if (error.userInfo != nil) { + if (error.userInfo[@"detail"] != nil) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self.navigationController.visibleViewController]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + }); + } + }]; + } +} + +- (NSArray*)getOffersFromDoubleDeposit:(NSArray*)doubleDepositOffers +{ + NSMutableArray *signleDepositOfferArray = [NSMutableArray arrayWithCapacity:0]; + for (NSDictionary *offerDictionary in doubleDepositOffers) + { + NSMutableDictionary *reviceOfferDict = [[NSMutableDictionary alloc] initWithCapacity:0]; + reviceOfferDict[@"deposit"] = @{ + @"currency": REMOVE_NULL_VALUE(offerDictionary[@"totalDeposit"][@"currency"]), + @"amount": REMOVE_NULL_VALUE(offerDictionary[@"totalDeposit"][@"amount"]) + }; + reviceOfferDict[@"id"] = offerDictionary[@"id"]; + + if (offerDictionary[@"firstOffer"] != nil) { + NSDictionary *firstOfferDict = offerDictionary[@"firstOffer"]; + + reviceOfferDict[@"crypto"] = firstOfferDict[@"crypto"]; + reviceOfferDict[@"amount"] = @{ + @"DASH" : REMOVE_NULL_VALUE(firstOfferDict[@"amount"][@"DASH"]), + @"dots" : REMOVE_NULL_VALUE(firstOfferDict[@"amount"][@"dots"]), + @"bits" : REMOVE_NULL_VALUE(firstOfferDict[@"amount"][@"bits"]), + @"BTC" : REMOVE_NULL_VALUE(firstOfferDict[@"amount"][@"BTC"]) + }; + reviceOfferDict[@"discoveryId"] = REMOVE_NULL_VALUE(firstOfferDict[@"discoveryId"]); + reviceOfferDict[@"distance"] = REMOVE_NULL_VALUE(firstOfferDict[@"distance"]); + reviceOfferDict[@"address"] = REMOVE_NULL_VALUE(firstOfferDict[@"address"] ); + reviceOfferDict[@"state"] = REMOVE_NULL_VALUE(firstOfferDict[@"state"]) ; + reviceOfferDict[@"bankName"] = REMOVE_NULL_VALUE(firstOfferDict[@"bankName"]) ; + reviceOfferDict[@"bankLogo"] = REMOVE_NULL_VALUE(firstOfferDict[@"bankLogo"]) ; + reviceOfferDict[@"bankIcon"] = REMOVE_NULL_VALUE(firstOfferDict[@"bankIcon"]) ; + reviceOfferDict[@"bankLocationUrl"] = REMOVE_NULL_VALUE(firstOfferDict[@"bankLocationUrl"]); + reviceOfferDict[@"city"] = REMOVE_NULL_VALUE(firstOfferDict[@"city"]); + + + if (offerDictionary[@"secondOffer"] != nil) { + NSDictionary *secondOffer = offerDictionary[@"secondOffer"]; + if (![REMOVE_NULL_VALUE(firstOfferDict[@"bankName"]) isEqualToString:REMOVE_NULL_VALUE(secondOffer[@"bankName"])]) { + reviceOfferDict[@"isMultipleBank"] = @YES; + reviceOfferDict[@"otherBankName"] = REMOVE_NULL_VALUE(secondOffer[@"bankName"]); + reviceOfferDict[@"otherBankLogo"] = REMOVE_NULL_VALUE(secondOffer[@"bankLogo"]); + } + + NSDictionary *amountDict = firstOfferDict[@"amount"]; + NSDictionary *secondAmountDict = offerDictionary[@"secondOffer"]; + + NSNumber *firstOfferMinorNumber = [NSNumber numberWithFloat:[NSString stringWithFormat:@"%@",[REMOVE_NULL_VALUE(firstOfferDict[@"amount"][WOCCryptoCurrencySmall]) stringByReplacingOccurrencesOfString:@"," withString:@""]].floatValue]; + + NSNumber *secondOfferMinorNumber = [NSNumber numberWithFloat:[NSString stringWithFormat:@"%@",[REMOVE_NULL_VALUE(secondOffer[@"amount"][WOCCryptoCurrencySmall]) stringByReplacingOccurrencesOfString:@"," withString:@""]].floatValue]; + + NSNumber *totoalMinorNumber = [NSNumber numberWithFloat:(firstOfferMinorNumber.longLongValue + secondOfferMinorNumber.floatValue)] ; + + NSString *totalMinorStr = [self getCryptoPrice:totoalMinorNumber]; + APILog(@"totalMinorStr = %@",totalMinorStr); + + NSNumber *firstOfferMajorNumber = [NSNumber numberWithFloat:[NSString stringWithFormat:@"%@",[REMOVE_NULL_VALUE(firstOfferDict[@"amount"][WOCCryptoCurrency]) stringByReplacingOccurrencesOfString:@"," withString:@""]].floatValue]; + + NSNumber *secondOfferMajorNumber = [NSNumber numberWithFloat:[NSString stringWithFormat:@"%@",[REMOVE_NULL_VALUE(secondOffer[@"amount"][WOCCryptoCurrency]) stringByReplacingOccurrencesOfString:@"," withString:@""]].floatValue]; + + NSNumber *totoalMajorNumber = [NSNumber numberWithFloat:(firstOfferMajorNumber.longLongValue + secondOfferMajorNumber.floatValue)] ; + + NSString *totalMajorStr = [self getCryptoPrice:totoalMajorNumber]; + APILog(@"totalMajorStr = %@",totalMajorStr); + + reviceOfferDict[@"amount"] = @{ + WOCCryptoCurrency : totalMajorStr, + WOCCryptoCurrencySmall : totalMinorStr, + @"bits" : [NSNumber numberWithFloat:([amountDict[@"bits"] floatValue] + [secondAmountDict[@"bits"] floatValue])], + @"BTC" : [NSNumber numberWithFloat:([amountDict[@"BTC"] floatValue] + [secondAmountDict[@"BTC"] floatValue])] + }; + } + + [signleDepositOfferArray addObject:reviceOfferDict]; + } + } + return (NSArray*)signleDepositOfferArray; +} + +- (void)getOrders:(NSInteger)sender { + + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + NSDictionary *params = @{ + }; + + [[APIManager sharedInstance] getOrders:nil response:^(id responseDict, NSError *error) { + + dispatch_async(dispatch_get_main_queue(), ^(void){ + [hud hideAnimated:YES]; + }); + + NSString *phoneNo = [[NSUserDefaults standardUserDefaults] valueForKey:WOCUserDefaultsLocalPhoneNumber]; + + if (error == nil) { + if ([responseDict isKindOfClass:[NSArray class]]) { + NSArray *orders = [[NSArray alloc] initWithArray:(NSArray*)responseDict]; + if (orders.count > 0) { + NSPredicate *wdvPredicate = [NSPredicate predicateWithFormat:@"status == 'WD'"]; + NSArray *wdArray = [orders filteredArrayUsingPredicate:wdvPredicate]; + if (wdArray.count > 0) { + NSDictionary *orderDict = (NSDictionary*)[wdArray objectAtIndex:0]; + NSString *status = [NSString stringWithFormat:@"%@",[orderDict valueForKey:@"status"]]; + if ([status isEqualToString:@"WD"]) { + WOCSellingInstructionsViewController *instructionsViewController = [self getViewController:@"WOCSellingInstructionsViewController"]; + instructionsViewController.phoneNo = phoneNo; + instructionsViewController.isFromSend = YES; + instructionsViewController.isFromOffer = NO; + instructionsViewController.orderDict = orderDict; + [self pushViewController:instructionsViewController animated:YES]; + return ; + } + } + } + } + + WOCSellingInstructionsViewController *instructionsViewController = [self getViewController:@"WOCSellingInstructionsViewController"]; + instructionsViewController.phoneNo = phoneNo; + instructionsViewController.isFromSend = NO; + instructionsViewController.isFromOffer = YES; + + NSIndexPath *indexPath = [self getIndexPathfromTag:sender]; + NSString *key = self.offersDict.allKeys[indexPath.section]; + NSArray *offerArray = self.offersDict[key]; + NSDictionary *offerDict = offerArray[indexPath.row]; + + instructionsViewController.offerId = [NSString stringWithFormat:@"%@",[offerDict valueForKey:WOCApiResponseId]]; + [self pushViewController:instructionsViewController animated:YES]; + } + else { + [self refereshToken]; + } + }]; +} + +// MARK: - IBAction + +- (IBAction)orderClicked:(id)sender { + + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + if (token != nil && (![token isEqualToString:@"(null)"])) { + [self getOrders:[sender tag]]; + } + else { + [self pushToStep6:[sender tag]]; + } +} + +- (IBAction)checkLocationClicked:(id)sender { + + NSIndexPath *indexPath = [self getIndexPathfromTag:[sender tag]]; + NSString *key = self.offersDict.allKeys[indexPath.section]; + NSArray *offerArray = self.offersDict[key]; + NSDictionary *offerDict = offerArray[indexPath.row]; + + if (![[offerDict valueForKey:@"bankLocationUrl"] isEqual:[NSNull null]]) { + NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",[offerDict valueForKey:@"bankLocationUrl"]]]; + if ([[UIApplication sharedApplication] canOpenURL:url]) { + [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) { + APILog(@"URL opened!"); + }]; + } + } +} + +// MARK: - UITableView DataSource +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + + return self.offersDict.allKeys.count; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + + NSString *key = self.offersDict.allKeys[section]; + NSArray *offerArray = self.offersDict[key]; + return offerArray.count; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + + static const NSInteger IMAGE_VIEW_TAG = 98; + static const NSInteger OTHER_IMAGE_VIEW_TAG = 99; + NSString *cellIdentifier = @"offerCell"; + WOCOfferCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; + UIView *cellView = cell.bankImageView.superview; + + WOCAsyncImageView *imageView = (WOCAsyncImageView *)[cellView viewWithTag:IMAGE_VIEW_TAG]; + WOCAsyncImageView *otherImageView = (WOCAsyncImageView *)[cellView viewWithTag:OTHER_IMAGE_VIEW_TAG]; + + if (imageView == nil) { + imageView = [[WOCAsyncImageView alloc] initWithFrame:cell.bankImageView.frame]; + imageView.contentMode = UIViewContentModeScaleAspectFill; + imageView.clipsToBounds = YES; + imageView.image = [UIImage imageNamed:@"ic_account_balance_black"]; + imageView.tag = IMAGE_VIEW_TAG; + [cellView addSubview:imageView]; + } + + if (otherImageView == nil) { + + otherImageView = [[WOCAsyncImageView alloc] initWithFrame:cell.otherBankImageView.frame]; + otherImageView.contentMode = UIViewContentModeScaleAspectFill; + otherImageView.clipsToBounds = YES; + otherImageView.image = [UIImage imageNamed:@"ic_account_balance_black"]; + otherImageView.tag = OTHER_IMAGE_VIEW_TAG; + [cellView addSubview:otherImageView]; + otherImageView.hidden = YES; + } + + cell.bankImageView.hidden = YES; + cell.otherBankImageView.hidden = YES; + otherImageView.hidden = YES; + imageView.hidden = NO; + + //get image view + //cancel loading previous image for cell + [[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:imageView]; + [[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:otherImageView]; + + NSString *key = self.offersDict.allKeys[indexPath.section]; + NSArray *offerArray = self.offersDict[key]; + + NSDictionary *offerDict = offerArray[indexPath.row]; + if (self.incremented || self.isExtendedSearch) { + cell.dollarLabel.hidden = NO; + } + else { + cell.dollarLabel.hidden = NO; + } + + NSString *dashAmount = [NSString stringWithFormat:@"%@ %@",WOCCurrencySymbol,REMOVE_NULL_VALUE([[offerDict valueForKey:@"amount"] valueForKey:WOCCryptoCurrency])]; + NSString *bits = [NSString stringWithFormat:@"(%@ %@)",WOCCurrencySymbolMinor,REMOVE_NULL_VALUE([[offerDict valueForKey:@"amount"] valueForKey:WOCCryptoCurrencySmall])]; + NSString *dollarAmount = [NSString stringWithFormat:@"Pay $%@",REMOVE_NULL_VALUE([[offerDict valueForKey:@"deposit"] valueForKey:@"amount"])]; + NSString *bankName = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([offerDict valueForKey:@"bankName"])]; + NSString *bankAddress = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([offerDict valueForKey:@"address"])]; + NSString *bankLocationUrl = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([offerDict valueForKey:@"bankLocationUrl"])]; + NSString *bankLogo = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([offerDict valueForKey:@"bankLogo"])]; + NSString *bankIcon = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([offerDict valueForKey:@"bankIcon"])]; + NSString *otherbankLogo = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([offerDict valueForKey:@"otherBankLogo"])]; + + cell.locationLabel.font = [UIFont systemFontOfSize:12]; + cell.dashTitleLabel.text = dashAmount; + cell.dashSubTitleLabel.text = bits; + cell.dollarLabel.text = dollarAmount; + cell.bankNameLabel.text = bankName; + cell.locationLabel.text = bankAddress; + + if (bankLocationUrl.length > 0) { + cell.locationButton.hidden = NO; + cell.locationButton.tag = indexPath.section * 100000 + indexPath.row; + [cell.locationButton addTarget:self action:@selector(checkLocationClicked:) forControlEvents:UIControlEventTouchUpInside]; + } + + if (offerDict[@"isMultipleBank"] != nil) { + + BOOL isMultipleBank = [offerDict valueForKey:@"isMultipleBank"]; + + if (isMultipleBank) { + bankAddress = [offerDict valueForKey:@"otherBankName"]; + cell.locationLabel.font = cell.bankNameLabel.font; + } + + + if ([otherbankLogo length] > 0) { + otherImageView.hidden = NO; + //load the image + otherImageView.imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",otherbankLogo]]; + } + } + + + //bankLogo + if ([bankLogo length] > 0) { + + imageView.imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",bankLogo]]; + } + else if ([bankIcon length] > 0) { + + imageView.imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",bankIcon]]; + + cell.bankImageView.image = [UIImage imageNamed:@"ic_account_balance_black"]; + } + + cell.orderButton.tag = indexPath.section * 100000 + indexPath.row; + [cell.orderButton addTarget:self action:@selector(orderClicked:) forControlEvents:UIControlEventTouchUpInside]; + + return cell; +} + +// MARK: - UITableView Delegate + +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { + + NSString *key = self.offersDict.allKeys[indexPath.section]; + NSArray *offerArray = self.offersDict[key]; + NSDictionary *offerDict = offerArray[indexPath.row]; + if (offerDict[@"isMultipleBank"] != nil) { + BOOL isMultipleBank = [offerDict valueForKey:@"isMultipleBank"]; + if (isMultipleBank) { + return 150.0; + } + } + return 125.0; +} + +- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { + float height = 20.0; + if (section > 0) { + height = 50.0; + } + NSString *key = self.offersDict.allKeys[section]; + UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, tableView.frame.size.width, height)]; + UILabel *lblHeader = [[UILabel alloc] initWithFrame:CGRectMake(10.0, 0.0, headerView.frame.size.width-20.0, height)]; + lblHeader.text = key; + lblHeader.numberOfLines = 2.0; + lblHeader.backgroundColor = [UIColor colorWithRed:250.0/255.0 green:250.0/255.0 blue:250.0/255.0 alpha:1.0]; + lblHeader.textAlignment = NSTextAlignmentCenter; + [headerView addSubview:lblHeader]; + return headerView; +} + +- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { + if (section > 0){ + return 50.0; + } + return 20.0; +} + +- (NSIndexPath*)getIndexPathfromTag:(NSInteger)tag { + + int row = tag % 100000; + int section = tag / 100000; + NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section]; + return indexPath; +} +@end + diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardPaymentCenterViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardPaymentCenterViewController.h new file mode 100644 index 00000000..5d824438 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardPaymentCenterViewController.h @@ -0,0 +1,22 @@ +// +// WOCSellingWizardPaymentCenterViewController.h +// Wallofcoins +// +// Created by Genitrust on 23/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" + +//WOCSellingWizardPaymentCenterViewController + +@interface WOCSellingWizardPaymentCenterViewController : WOCBaseViewController + +@property (weak, nonatomic) IBOutlet UITextField *paymentCenterTextfield; +@property (weak, nonatomic) IBOutlet UIButton *nextButton; + +- (IBAction)onNextButtonClick:(id)sender; +- (IBAction)onUseNewAccountButtonClick:(id)sender; + +@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardPaymentCenterViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardPaymentCenterViewController.m new file mode 100644 index 00000000..f6726c3b --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardPaymentCenterViewController.m @@ -0,0 +1,104 @@ +// +// WOCSellingWizardPaymentCenterViewController.m +// Wallofcoins +// +// Created by Genitrust on 23/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCSellingWizardPaymentCenterViewController.h" +#import "WOCSellingWizardInputAmountViewController.h" +#import "APIManager.h" +#import "WOCAlertController.h" +#import "WOCSellingAddNewBankViewController.h" +@interface WOCSellingWizardPaymentCenterViewController () + +@property (strong, nonatomic) NSArray *paymentCenters; +@property (strong, nonatomic) UIPickerView *pickerView; +@property (strong, nonatomic) NSString *bankId; + +@end + +@implementation WOCSellingWizardPaymentCenterViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + [self setShadowOnButton:self.nextButton]; + + self.pickerView = [[UIPickerView alloc] init]; + self.pickerView.delegate = self; + self.pickerView.dataSource = self; + self.paymentCenterTextfield.inputView = self.pickerView; + + [self getPaymentCenters]; +} + +// MARK: - API + +- (void)getPaymentCenters { + + [[APIManager sharedInstance] getAvailablePaymentCenters:^(id responseDict, NSError *error) { + if (error == nil) { + if ([responseDict isKindOfClass:[NSArray class]]) { + NSArray *responseArray = [[NSArray alloc] initWithArray:(NSArray *)responseDict]; + NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]; + self.paymentCenters = [responseArray sortedArrayUsingDescriptors:@[sort]]; + [self.pickerView reloadAllComponents]; + } + } + }]; +} + +// MARK: - IBAction + +- (IBAction)onNextButtonClick:(id)sender { + + if ([self.bankId length] > 0) { + WOCSellingWizardInputAmountViewController *inputAmountViewController = (WOCSellingWizardInputAmountViewController*)[self getViewController:@"WOCSellingWizardInputAmountViewController"];; + inputAmountViewController.bankId = self.bankId; + NSString *bankInfo = [NSString stringWithFormat:@"%@ (-%@)",self.paymentCenterTextfield.text,self.bankId]; + [self.defaults setObject:bankInfo forKey:WOCUserDefaultsLocalBankInfo]; + [self.defaults synchronize]; + + [self.defaults setObject:self.paymentCenterTextfield.text forKey:WOCUserDefaultsLocalBankName]; + [self.defaults synchronize]; + + [self.defaults setObject:self.bankId forKey:WOCUserDefaultsLocalBankAccount]; + [self.defaults synchronize]; + + [self pushViewController:inputAmountViewController animated:YES]; + return; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Select payment center." viewController:self.navigationController.visibleViewController]; + } +} + +- (IBAction)onUseNewAccountButtonClick:(id)sender { + + WOCSellingAddNewBankViewController *addNewBankViewController = (WOCSellingAddNewBankViewController*)[self getViewController:@"WOCSellingAddNewBankViewController"]; + [self pushViewController:addNewBankViewController animated:YES]; +} + +// MARK: UIPickerView Delegates + +- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView { + return 1; +} + +- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component { + return self.paymentCenters.count; +} + +- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { + return self.paymentCenters[row][@"name"]; +} + +- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { + self.paymentCenterTextfield.text = self.paymentCenters[row][@"name"]; + self.bankId = [NSString stringWithFormat:@"%@",self.paymentCenters[row][@"id"]]; +} + +@end + diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardZipCodeViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardZipCodeViewController.h new file mode 100644 index 00000000..e96916d9 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardZipCodeViewController.h @@ -0,0 +1,23 @@ +// +// WOCSellingWizardZipCodeViewController.h +// Wallofcoins +// +// Created by Genitrust on 23/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" + +////WOCSellingWizardZipCodeViewController + +// Enter ZipCode +@interface WOCSellingWizardZipCodeViewController : WOCBaseViewController + +@property (weak, nonatomic) IBOutlet UITextField *txtZipCode; +@property (weak, nonatomic) IBOutlet UIButton *btnNext; +@property (assign, nonatomic) BOOL isZipCodeBlank; + +- (IBAction)nextClicked:(id)sender; + +@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardZipCodeViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardZipCodeViewController.m new file mode 100644 index 00000000..acf8e826 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardZipCodeViewController.m @@ -0,0 +1,102 @@ +// +// WOCSellingWizardZipCodeViewController.m +// Wallofcoins +// +// Created by Genitrust on 23/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCSellingWizardZipCodeViewController.h" +#import "WOCSellingWizardPaymentCenterViewController.h" +#import "WOCSellingWizardInputAmountViewController.h" +#import "APIManager.h" +#import "WOCLocationManager.h" +#import +#import +#import +@interface WOCSellingWizardZipCodeViewController () + +@end + + +@implementation WOCSellingWizardZipCodeViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.navigationItem.backBarButtonItem.title = @""; + [self setShadowOnButton:self.btnNext]; +} + +// MARK: - IBAction + +- (IBAction)nextClicked:(id)sender { + + [self.defaults removeObjectForKey:WOCApiBodyCountryCode]; + + [self.defaults synchronize]; + + NSString *zipCode = [self.txtZipCode.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + + if ([zipCode length] == 0) { + [self push:@"WOCSellingWizardPaymentCenterViewController"]; + } + else if ([zipCode length] < 5 || [zipCode length] > 6 ) { + [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Enter valid zipcode" viewController:self.navigationController.visibleViewController]; + } + else { + [self setCountryWithZipCode:zipCode]; + + WOCSellingWizardInputAmountViewController *inputAmountViewController = (WOCSellingWizardInputAmountViewController*)[self getViewController:@"WOCSellingWizardInputAmountViewController"];; + inputAmountViewController.zipCode = zipCode; + [self pushViewController:inputAmountViewController animated:YES]; + } +} + +- (void)setCountryWithZipCode:(NSString*)zipCode { + + CLGeocoder* geoCoder = [[CLGeocoder alloc] init]; + CNMutablePostalAddress *postalAddress = [[CNMutablePostalAddress alloc] init]; + postalAddress.postalCode = zipCode; + postalAddress.country = @"us"; + postalAddress.state = @""; + if (@available(iOS 11.0, *)) { + [geoCoder geocodePostalAddress:postalAddress completionHandler:^(NSArray *placemarks, NSError *error) { + if ([placemarks count] > 0) { + CLPlacemark* placemark = [placemarks objectAtIndex:0]; + [self.defaults setObject:[placemark ISOcountryCode].lowercaseString forKey:WOCApiBodyCountryCode]; + [self.defaults synchronize]; + APILog(@"%@",[placemark description]); + APILog(@"======> country code is %@",[placemark ISOcountryCode]); + } + else { + APILog(@"Error in featching Country ="); + } + }]; + } + else { + // Fallback on earlier versions + [geoCoder geocodeAddressDictionary:@{(NSString*)kABPersonAddressZIPKey : zipCode,(NSString*)kABPersonAddressCountryCodeKey : @"us"} + completionHandler:^(NSArray *placemarks, NSError *error) { + if ([placemarks count] > 0) { + CLPlacemark* placemark = [placemarks objectAtIndex:0]; + + NSString* city = placemark.addressDictionary[(NSString*)kABPersonAddressCityKey]; + NSString* state = placemark.addressDictionary[(NSString*)kABPersonAddressStateKey]; + NSString* country = placemark.addressDictionary[(NSString*)kABPersonAddressCountryCodeKey]; + + [self.defaults setObject:country.lowercaseString forKey:WOCApiBodyCountryCode]; + [self.defaults synchronize]; + APILog(@"%@",[placemark description]); + APILog(@"======> country code is city [%@] state [%@] country [%@]",city,state,country); + + } else { + // Lookup Failed + APILog(@"Error in featching Country ="); + } + }]; + } +} + +@end + diff --git a/PivxWallet/Wallofcoins/WOCSignInViewController.h b/PivxWallet/Wallofcoins/WOCSignInViewController.h new file mode 100644 index 00000000..01e57a70 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSignInViewController.h @@ -0,0 +1,26 @@ +// +// WOCBuyingWizardOfferListViewController.h +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import +#import "WOCBaseViewController.h" +@interface WOCSignInViewController : WOCBaseViewController + +@property (strong, nonatomic) NSString *discoveryId; +@property (strong, nonatomic) NSString *amount; +@property (weak, nonatomic) IBOutlet UIButton *signupButton; +@property (weak, nonatomic) IBOutlet UIButton *sighInButton; + +@property (weak, nonatomic) IBOutlet UILabel *instructionLabel; +@property (weak, nonatomic) IBOutlet UITableView *numberListingTableView; + +- (IBAction)onExistingAccoutButtonClick:(id)sender; +- (IBAction)onSignUpButtonClick:(id)sender; + +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *tableHeighConstrain; + +@end diff --git a/PivxWallet/Wallofcoins/WOCSignInViewController.m b/PivxWallet/Wallofcoins/WOCSignInViewController.m new file mode 100644 index 00000000..17c4e6a0 --- /dev/null +++ b/PivxWallet/Wallofcoins/WOCSignInViewController.m @@ -0,0 +1,258 @@ +// +// WOCBuyingWizardOfferListViewController.m +// Wallofcoins +// +// Created by Genitrust on 24/01/18. +// Copyright (c) 2018 Wallofcoins. All rights reserved. +// + +#import "WOCSignInViewController.h" +#import "WOCBuyingWizardInputPhoneNumberViewController.h" +#import "WOCBuyingInstructionsViewController.h" +#import "WOCBuyingSummaryViewController.h" +#import "BRRootViewController.h" +#import "BRAppDelegate.h" +#import "WOCOfferCell.h" +#import "APIManager.h" +#import "BRWalletManager.h" +#import "WOCAlertController.h" +#import "MBProgressHUD.h" +#import "WOCBuyingWizardHomeViewController.h" + +@interface WOCSignInViewController () + +@property (strong, nonatomic) NSArray *offers; +@property (assign) BOOL incremented; + +@end + +@implementation WOCSignInViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.instructionLabel.text = [NSString stringWithFormat:@"Below are offers for at least $%@. You must click the ORDER button before you receive instructions to pay at the Cash Payment center.",self.amount]; + [self setShadowOnButton:self.signupButton]; + [self setShadowOnButton:self.sighInButton]; + [self.signupButton setTitleColor:WOCTHEMECOLOR forState:UIControlStateNormal]; + [self.sighInButton setTitleColor:WOCTHEMECOLOR forState:UIControlStateNormal]; +} + +- (void)viewWillAppear:(BOOL)animated { + [self getLocalDevices]; + self.title = @"SignIN"; +} + +- (void)getLocalDevices { + + if ([self.defaults objectForKey:WOCUserDefaultsLocalDeviceInfo] != nil) { + + if ([[self.defaults objectForKey:WOCUserDefaultsLocalDeviceInfo] isKindOfClass:[NSDictionary class]]) { + NSMutableDictionary *deviceInfoDict = [NSMutableDictionary dictionaryWithDictionary:[self.defaults objectForKey:WOCUserDefaultsLocalDeviceInfo]]; + if (deviceInfoDict != nil) { + self.offers = deviceInfoDict.allKeys; + [self.numberListingTableView reloadData]; + } + } + } +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +- (void)pushToStep7:(NSInteger)sender { + NSIndexPath *indexPath = [NSIndexPath indexPathForRow:sender inSection:0]; + NSString *phoneNumber = self.offers[indexPath.row]; + APILog(@"phoneNumber = %@",phoneNumber); + + [self.defaults setObject:phoneNumber forKey:WOCUserDefaultsLocalPhoneNumber]; + [self.defaults synchronize]; + [self refereshToken]; + [self performSelector:@selector(backToMainView) withObject:nil afterDelay:2.0]; +} + +// MARK: - API +- (void)getOffers { + if (self.discoveryId != nil && [self.discoveryId length] > 0) { + [[APIManager sharedInstance] discoveryInputs:self.discoveryId response:^(id responseDict, NSError *error) { + if (error == nil) { + NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; + + if ([[responseDictionary valueForKey:@"singleDeposit"] isKindOfClass:[NSArray class]]) { + NSArray *offersArray = [[NSArray alloc] initWithArray:(NSArray*)[responseDictionary valueForKey:@"singleDeposit"]]; + self.offers = [[NSArray alloc] initWithArray:offersArray]; + + if ([[responseDictionary valueForKey:@"incremented"] boolValue]) { + self.incremented = true; + self.instructionLabel.text = [NSString stringWithFormat:@"Below are offers for at least $%@. You must click the ORDER button before you receive instructions to pay at the Cash Payment center.",self.amount]; + } + else { + self.incremented = false; + self.instructionLabel.text = [NSString stringWithFormat:@"Below are offers for $%@. You must click the ORDER button before you receive instructions to pay at the Cash Payment center.",self.amount]; + } + } + [self.numberListingTableView reloadData]; + } + else { + dispatch_async(dispatch_get_main_queue(), ^{ + if (error.userInfo != nil) { + if (error.userInfo[@"detail"] != nil) { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self.navigationController.visibleViewController]; + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + } + else { + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; + } + }); + } + }]; + } +} + +- (void)getOrders:(NSInteger)sender { + MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; + + NSDictionary *params = @{ + }; + + [[APIManager sharedInstance] getOrders:nil response:^(id responseDict, NSError *error) { + + dispatch_async(dispatch_get_main_queue(), ^(void){ + [hud hideAnimated:YES]; + }); + + if (error == nil) { + if ([responseDict isKindOfClass:[NSArray class]]) { + NSArray *orders = [[NSArray alloc] initWithArray:(NSArray*)responseDict]; + if (orders.count > 0) { + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + NSPredicate *wdvPredicate = [NSPredicate predicateWithFormat:@"status == 'WD'"]; + NSArray *wdArray = [orders filteredArrayUsingPredicate:wdvPredicate]; + NSDictionary *orderDict = (NSDictionary*)[orders objectAtIndex:0]; + NSString *status = [NSString stringWithFormat:@"%@",[orderDict valueForKey:@"status"]]; + + if ([status isEqualToString:@"WD"]) { + WOCBuyingInstructionsViewController *buyingInstructionsViewController = [self getViewController:@"WOCBuyingInstructionsViewController"]; + buyingInstructionsViewController.phoneNo = phoneNo; + buyingInstructionsViewController.isFromSend = YES; + buyingInstructionsViewController.isFromOffer = NO; + buyingInstructionsViewController.orderDict = (NSDictionary*)[orders objectAtIndex:0]; + [self pushViewController:buyingInstructionsViewController animated:YES]; + } + else if (orders.count > 0) { + WOCBuyingSummaryViewController *buyingSummaryViewController = [self getViewController:@"WOCBuyingSummaryViewController"]; + buyingSummaryViewController.phoneNo = phoneNo; + buyingSummaryViewController.orders = orders; + buyingSummaryViewController.isFromSend = YES; + [self pushViewController:buyingSummaryViewController animated:YES]; + } + else { + [self backToMainView]; + } + } + else { + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + WOCBuyingInstructionsViewController *buyingInstructionsViewController = [self getViewController:@"WOCBuyingInstructionsViewController"]; + buyingInstructionsViewController.phoneNo = phoneNo; + buyingInstructionsViewController.isFromSend = NO; + buyingInstructionsViewController.isFromOffer = YES; + NSIndexPath *indexPath = [NSIndexPath indexPathForRow:sender inSection:0]; + NSDictionary *offerDict = self.offers[indexPath.row]; + buyingInstructionsViewController.offerId = [NSString stringWithFormat:@"%@",[offerDict valueForKey:WOCApiResponseId]]; + [self pushViewController:buyingInstructionsViewController animated:YES]; + } + } + else { + NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; + WOCBuyingInstructionsViewController *buyingInstructionsViewController = [self getViewController:@"WOCBuyingInstructionsViewController"]; + buyingInstructionsViewController.phoneNo = phoneNo; + buyingInstructionsViewController.isFromSend = NO; + buyingInstructionsViewController.isFromOffer = YES; + NSIndexPath *indexPath = [NSIndexPath indexPathForRow:sender inSection:0]; + NSDictionary *offerDict = self.offers[indexPath.row]; + buyingInstructionsViewController.offerId = [NSString stringWithFormat:@"%@",[offerDict valueForKey:WOCApiResponseId]]; + [self pushViewController:buyingInstructionsViewController animated:YES]; + } + } + else { + [self pushToStep1]; + dispatch_async(dispatch_get_main_queue(), ^{ + [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Token expired." viewController:self]; + }); + } + }]; +} + +- (void)pushToStep1 { + [self backToMainView]; +} + +// MARK: - IBAction +- (void)signInPhoneButtonClick:(UIButton *)sender { + NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; + if (token != nil && (![token isEqualToString:@"(null)"])) { + [self getOrderList]; + } + else { + [self pushToStep7:[sender tag]]; + } +} + +- (IBAction)onExistingAccoutButtonClick:(id)sender { + WOCBuyingWizardInputPhoneNumberViewController *buyingWizardInputPhoneNumberViewController = [self getViewController:@"WOCBuyingWizardInputPhoneNumberViewController"]; + buyingWizardInputPhoneNumberViewController.isForLoginOny = YES; + [self pushViewController:buyingWizardInputPhoneNumberViewController animated:YES]; +} + +- (IBAction)onSignUpButtonClick:(id)sender { + NSURL *url = [NSURL URLWithString:@"https://wallofcoins.com/signup/"]; + if ([[UIApplication sharedApplication] canOpenURL:url]) { + [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; + } +} + +- (IBAction)checkLocationClicked:(id)sender { + + NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[sender tag] inSection:0]; + NSDictionary *offerDict = self.offers[indexPath.row]; + if (![[offerDict valueForKey:@"bankLocationUrl"] isEqual:[NSNull null]]) { + NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",[offerDict valueForKey:@"bankLocationUrl"]]]; + if ([[UIApplication sharedApplication] canOpenURL:url]) { + [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) { + APILog(@"URL opened!"); + }]; + } + } +} + +// MARK: - UITableView DataSource + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return self.offers.count; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + WOCOfferCell *cell = [tableView dequeueReusableCellWithIdentifier:@"offerCell"]; + cell.backgroundColor = [UIColor clearColor]; + NSString *phoneNumber = self.offers[indexPath.row]; + [cell.orderButton setTitle:[NSString stringWithFormat:@"SIGN IN: %@",phoneNumber] forState:UIControlStateNormal]; + [cell.orderButton setTitle:@"" forState:UIControlStateSelected]; + [cell.orderButton addTarget:self action:@selector(signInPhoneButtonClick:) forControlEvents:UIControlEventTouchUpInside]; + cell.orderButton.tag = indexPath.row; + [cell.orderButton setTitleColor:WOCTHEMECOLOR forState:UIControlStateNormal]; + + return cell; +} + +// MARK: - UITableView Delegate +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { + return 50.0; +} + +@end + diff --git a/WallofCoins-README.md b/WallofCoins-README.md new file mode 100644 index 00000000..2692005e --- /dev/null +++ b/WallofCoins-README.md @@ -0,0 +1,704 @@ +### Wall of Coins Platform API + +To receive sales affiliate commissions, you must have a Publisher account with Wall of Coins. Visit this page for more information: https://wallofcoins.com/developer-api + +API endpoints: + +* Production: https://wallofcoins.com/api/v1 +* Development: https://woc.reference.genitrust.com/api/v1 + +### **Authentication methods** + +WOC API supports authentication via auth token. + +#### **Auth token:** + +In order to be authenticated you should send a token within every API request. Token must be sent in request header called **‘X-Coins-Api-Token’**. Token must not be expired. Token must have a valid signature and all needed authentication data. Token will look like a long **base64** encoded string: **YXV0aDo2OjE0MjE1OTU1ODN8MDk3NTAyYmE1YzM4YWY4MzUxYTg1NDU2ODFjN2U4ODgyZDhkYmY0Yg==** Each token has a limited lifetime (currently 3 hours, but it can be changed). Token expiration time is always returned by API. Your application should care about automatical token renewal before it expires. + + +#### GET AVAILABLE PAYMENT CENTERS (OPTIONAL) + +API for get payment center list using GET method... + +```http +GET https://woc.reference.genitrust.com/api/v1/banks/ +``` + +##### Response : + +```json +[ +{ +"id": 14, +"name": "Genitrust", +"url": "http://genitrust.com/", +"logo": null, +"icon": null, +"country": "us", +"payFields": false +} +] +``` +This method is optional. + + + +#### SEARCH & DISCOVERY + +An API for discover available option, which will return Discovery ID along with list of information. + + + +```http + +HEADER: +X-Coins-Publisher: ## +Content-Type: application/json + +POST https://woc.reference.genitrust.com/api/v1/discoveryInputs/ +``` + +##### Request : + +```json +{ +"cryptoAddress": "", +"usdAmount": "500", +"crypto": "DASH", +"bank": "", +"zipCode": "34236", +"browserLocation": { +"latitude": 27.3331293, +"longitude": -82.5456374 +} +} +``` + +* Publisher Id: an Unique ID generated for commit transections. +* cryptoAddress: Cryptographic Address for user, it's optional parameter. +* usdAmount: Amount in USD (Need to apply conversation from DASH to USD) +* crypto: crypto type either DASH or BTC for bitcoin. +* bank: Selected bank ID from bank list. pass empty if selected none. +* zipCode: zip code of user, need to take input from user. +* browserLocation: Need to pass user device latitude and Longitude. +Note: when you specify the browserLocation parameter, it must have real values (latitude,longitude) and browserLocation will be used. When browserLocation is not set, you must have zipCode set to a valid zipCode. when zipCode is not set, you must specify the bank. +bank > browser location > zip code > country (get this value by phone # country code, by 'country' parameter +should be used by the most specific location to the broadest location. so for example, bank is the most direct, then browser location, then zip code, then country. +##### Response : + +```json +{ +"id": "935c882fe79e39e1acd98a801d8ce420", +"usdAmount": "500", +"cryptoAmount": "0", +"crypto": "DASH", +"fiat": "USD", +"zipCode": "34236", +"bank": 5, +"state": null, +"cryptoAddress": "", +"createdIp": "182.76.224.130", +"browserLocation": { +"latitude": 27.3331293, +"longitude": -82.5456374 +}, +"publisher": null +} +``` + + +#### GET OFFERS + +An API for fetch all offers for received Discovery ID. + +```http +GET https://woc.reference.genitrust.com/api/v1/discoveryInputs//offers/ +``` + +##### Response : + +```json +{ +"singleDeposit": [{ +"id": "eyJ1c2QiOiAiNTA2LjAw...", +"deposit": { +"currency": "USD", +"amount": "506.00" +}, +"crypto": "DASH", +"amount": { +"DASH": "52.081", +"dots": "52,081,512.22", +"bits": "52,081,512.22", +"BTC": "52.081" +}, +"discoveryId": "1260e3afa4f03a195ac1e73c965c797", +"distance": 0, +"address": "", +"state": "", +"bankName": "MoneyGram", +"bankLogo": "/media/logos/logo_us_MoneyGram.png", +"bankIcon": "/media/logos/icon_us_MoneyGram.png", +"bankLocationUrl": "https://secure.moneygram.com/locations", +"city": ""} +], +"doubleDeposit": [{ +"id": "eyJkaSI6IC...", +"firstOffer": { +"deposit": { +"currency": "USD", +"amount": "462.00" +}, +"crypto": "DASH", +"amount": { +"DASH": "44.809", +"dots": "44,809,058.44", +"bits": "44,809,058.44", +"BTC": "44.809" +}, +"discoveryId": "1260e3afa4f03a195ac1e73c965c797", +"distance": 0.9639473391774286, +"address": "240 N Washington Blvd, #100", +"state": "FL", +"bankName": "Chase", +"bankLogo": "/media/logos/logo_us_Chase.png", +"bankIcon": "/media/logos/icon_us_Chase.png", +"bankLocationUrl": null, +"city": "Sarasota" +}, +"secondOffer": { +"deposit": { +"currency": "USD", +"amount": "38.00" +}, +"crypto": "DASH", +"amount": { +"DASH": "0.368", +"dots": "368,122.62", +"bits": "368,122.62", +"BTC": "0.368" +}, +"discoveryId": "1260e3afa4f03a195ac1e73c965c797", +"distance": 0.9639473391774286, +"address": "240 N Washington Blvd, #100", +"state": "FL", +"bankName": "Chase", +"bankLogo": "/media/logos/logo_us_Chase.png", +"bankIcon": "/media/logos/icon_us_Chase.png", +"bankLocationUrl": null, +"city": "Sarasota" +}, +"totalAmount": { +"bits": "45,177,181.06", +"BTC": "45.177" +}, +"totalDeposit": { +"currency": "USD", +"amount": "500.00" +} +}], +"multipleBanks": [], +"isExtendedSearch": false, +"incremented": true +} +``` + +When they Discovery Input offers object contains... + +``` +{ +. . . +incremented: true +} +``` + +This means that the search amount (for example "$25") was not available for all offers--some offers that are available REQUIRE the end user (buyer) to deposit slightly more than $25. This is what is meant by the term ```incremented``` so buyer need to pay that incremented amount for buy dash. +singleDeposit - gets offers directly from seller's Ads +doubleDeposit - combine Ads from the same bankBusiness to fill amount of needed coins +multipleBanks - combine Ads from different banks +isExtendedSearch - True if there is no enough coins for buyers amount of cash and we try to look for Ads that can supply at least half of needed coins. +and we try ExtendedSearch only if there is no bankBusiness in DI and buyer provide location. + +We display singleDeposit at first and then doubleDeposit and multipleBanks + + +#### GET AUTH DETAILS + +**GET /api/v1/auth//** + +This endpoint will return HTTP 404 if phone is not registered in our system, otherwise it will return a list of available authentication methods. + +**GET /api/v1/auth/15005550001/** + +```http +HEADER: +X-Coins-Publisher: ## +Content-Type: application/json +``` +It need X-Coins-Publisher as a header parameter. + + +##### Request : + +``` +{ +"phone": "15005550001", +"availableAuthSources": [ +"device" +] +} +``` +This endpoint will return HTTP 404 if phone is not registered in our system then call Create Hold +, otherwise it will return a list of available authentication methods. + +#### POST AUTH DETAILS (PASSWORD) + +**POST /api/v1/auth//authorize** + +This endpoint will return **token** and use that **token** as **auth token** to create hold. You must need to pass **deviceId** with **password** in this API. + +**POST /api/v1/auth/15005550001/authorize/** + +```http +HEADER: +X-Coins-Publisher: ## +Content-Type: application/json +``` +It need X-Coins-Publisher as a header parameter. + + +##### Request : + +``` +{ +"deviceId" : "768", +"password" : "abc123", +"publisherId" : "52" +} +``` + +##### Response : + +``` +{ +accessedOn = "2018-02-16T06:28:41.745351Z", +authSource = password; +createdOn = "2014-08-29T02:19:45.826334Z"; +email = ""; +phone = 12397776832; +token = "YXV0aDoxOjE1MTg3NzMzMjF8OWFjMWQ5ZmNiOGU1OWZhOThhNTg3YWM2YjBlZWUxMDk1NGM3NGI3OQ=="; +tokenExpiresAt = "2018-02-16T09:28:41.742641Z"; +} +``` + +#### POST AUTH DETAILS (DEVICE) + +**POST /api/v1/auth//authorize** + +This endpoint will return **token** and use that **token** as **auth token** to create hold. You must need to pass **deviceId** with **deviceCode** in this API. + +**POST /api/v1/auth/15005550001/authorize/** + +```http +HEADER: +X-Coins-Publisher: ## +Content-Type: application/json +``` +It need X-Coins-Publisher as a header parameter. + + +##### Request : + +``` +{ +"deviceId" : 769, +"deviceCode" : "C1813921-DD87-4BE6-9F73-D78B603CF1C8", +"publisherId" : "52" +} +``` + +##### Response : + +``` +{ +accessedOn = "2018-02-16T06:28:41.745351Z", +authSource = password; +createdOn = "2014-08-29T02:19:45.826334Z"; +email = ""; +phone = 12397776832; +token = "YXV0aDoxOjE1MTg3NzMzMjF8OWFjMWQ5ZmNiOGU1OWZhOThhNTg3YWM2YjBlZWUxMDk1NGM3NGI3OQ=="; +tokenExpiresAt = "2018-02-16T09:28:41.742641Z"; +} +``` + +#### CREATE HOLD + +##### (NEW USER REGISTER USING PHONE NUMBER) +From offer list on offer click we have to create an hold on offer for generate initial request. + +```http +HEADER: +X-Coins-Publisher: ## +Content-Type: application/json + +POST https://woc.reference.genitrust.com/api/v1/holds/ +``` + +It need X-Coins-Publisher as a header parameter. + +##### Request : + +```json +{ +"publisherId": "", +"offer": "eyJ1c2QiOiAiNTA...", +"phone": "+19411101467", +"deviceName": "Ref Client", +"deviceCode": "device-code-is-a-password_and_MUST_be_30_characters_or_more" +} +``` + +##### (Existing user request for create hold) + +```http +HEADER: +X-Coins-Api-Token: ZGV2aWNlOjQ0NT... +X-Coins-Publisher: ## +Content-Type: application/json + +POST https://woc.reference.genitrust.com/api/v1/holds/ +``` + +It need X-Coins-Publisher and X-Coins-Api-Token as a header parameter. + +##### Request : + +```json +{ +"publisherId": "", +"offer": "eyJ1c2QiOiAiNTA...", +"phone": "+19411101467", +"deviceName": "Ref Client", +"deviceCode": "device-code-is-a-password_and_MUST_be_30_characters_or_more" +} +``` + + +##### Response : + +```json +{ +"id": "999fd1b03f78309988a64701cfaaae37", +"expirationTime": "2017-08-21T10:08:40.592Z", +"discoveryInput": "1260e3afa4f03a195ac1e73c965c797", +"holds": [{ +"amount": "53.65853659", +"currentPrice": "9.43", +"status": "" +}], +"token": "ZGV2aWNlOjQ0N...", +"tokenExpiresAt": "2017-08-21T13:05:40.535Z", +"__PURCHASE_CODE": "CK99K" +} +``` + + +##### Status Code : + +* 201 returned when the hold is created +* 400 returned when one of the parameters are missing! for example, if you're creating a new device... you need "phone", "deviceName", and "deviceCode". +* 401 will be "returned when a X-Coins-Api-Token is required or the phone number supplied needs password". +* 403 will have details: "Not permitted to create a hold while an open hold or order with status WD is current." +* 404 returned when the offer no-longer is available (either the time expired or the ad will now be negative.) + +if you get status code 403, then you have to delete active hold first then need to create hold again. As you have **auth token** available, you need to call Get Hold API by passing **auth token** as **X-Coins-Api-Token** in header, which will return active hold in response. Get Hold API returns array of hold in response, then user need to delete active hold with status is equal to “AC” by calling Delete Hold API by passing **auth token** as **X-Coins-Api-Token** in header. Suppose user do not get any active holds then it means that there is some pending order. so you need to get all orders and find pending order with status = "WD" and give option to confirm deposite Or cancel Order functionality. +##### Hold Status : + +PE = Pending +AC = Active, waiting for Order +CAP = Captured +EX = Expired +CAN = Canceled + +This API will send purchase code to user's device on his register phone number and it will be same +as `__PURCHASE_CODE` value. + +#### GET HOLD + +**GET /api/v1/holds/** + +This endpoint will return active **holdId**. You must need to pass **auth token** as **X-Coins-Api-Token** in header of this API. + +```http +HEADER: +X-Coins-Publisher: ## +X-Coins-Api-Token: ZGV2aWN.. +``` +It need X-Coins-Publisher and X-Coins-Api-Token as a header parameter. + +##### Response + +``` +[ +{ +"id": "ec11665efc6eeb8e8ca083360c70a659", +"expirationTime": "2018-02-16T06:38:14.408227Z", +"discoveryInput": "8f4a39a2ca29607da6d8c891e8318b26" +} +] +``` + +Use **id** as **holdId** to delete an active hold. + +#### DELETE HOLD + +**POST /api/v1/holds/** + +This endpoint will delete an active hold. You must need to pass **auth token** as **X-Coins-Api-Token** in header of this API. + +```http +HEADER: +X-Coins-Publisher: ## +X-Coins-Api-Token: ZGV2aWN.. +``` +It need X-Coins-Publisher and X-Coins-Api-Token as a header parameter. + +##### Response : +204 NO CONTENT + +#### CAPTURE HOLD + +We have to match user input code with `__PURCHASE_CODE` and if verify, we have to proceed further. + +```http +HEADER: +X-Coins-Api-Token: ZGV2aWNlOjQ0NT... +X-Coins-Publisher: ## +Content-Type: application/json + +POST https://woc.reference.genitrust.com/api/v1/holds//capture/ +``` + +#####Request : + +``` +{ +"publisherId": "", +"verificationCode": "CK99K" +} +``` + +##### Response : + + +```json +[ +{ +"id": 81, +"total": "52.08151222", +"payment": "506.0000000437", +"paymentDue": "2017-08-21T12:15:49.024Z", +"bankName": "MoneyGram", +"nameOnAccount": "", +"account": "[{\"displaySort\": 2.0, \"name\": \"birthCountry\", \"value\": \"US\", \"label\": \"Country of Birth\"}, {\"displaySort\": 0.5, \"name\": \"pickupState\", \"value\": \"Florida\", \"label\": \"Pick-up State\"}, {\"displaySort\": 1.0, \"name\": \"lastName\", \"value\": \"Genito\", \"label\": \"Last Name\"}, {\"displaySort\": 0.0, \"name\": \"firstName\", \"value\": \"Robert\", \"label\": \"First Name\"}]", +"status": "WD", +"nearestBranch": { +"city": "", +"state": "", +"name": "MoneyGram", +"phone": null, +"address": "" +}, +"bankUrl": "https://secure.moneygram.com", +"bankLogo": "/media/logos/logo_us_MoneyGram.png", +"bankIcon": "/media/logos/icon_us_MoneyGram.png", +"privateId": "c149c6e90e13de979ff12e0aaa2a9c4d9f88d510" +} +] +``` + + +it will confirm the user authentication with `__PURCHASE_CODE` and in next step we have to confirm or cancel request with Order ID received in last response. + + + +#### CONFIRM DEPOSIT + +```http +REQUEST HEADER: +X-Coins-Api-Token: ZGV2aWNlOjQ0NT... +X-Coins-Publisher: ## +Content-Type: application/json + +POST https://woc.reference.genitrust.com/api/v1/orders//confirmDeposit/ +``` + +##### Response : + +```json +{ +"id": 81, +"total": "52.08151222", +"payment": "506.00", +"paymentDue": "2017-08-21T12:15:49.024Z", +"bankName": "MoneyGram", +"nameOnAccount": "", +"account": "[{\"displaySort\": 2.0, \"name\": \"birthCountry\", \"value\": \"US\", \"label\": \"Country of Birth\"}, {\"displaySort\": 0.5, \"name\": \"pickupState\", \"value\": \"Florida\", \"label\": \"Pick-up State\"}, {\"displaySort\": 1.0, \"name\": \"lastName\", \"value\": \"Genito\", \"label\": \"Last Name\"}, {\"displaySort\": 0.0, \"name\": \"firstName\", \"value\": \"Robert\", \"label\": \"First Name\"}]", +"status": "WDV", +"nearestBranch": { +"city": "", +"state": "", +"name": "MoneyGram", +"phone": null, +"address": "" +}, +"bankUrl": "https://secure.moneygram.com", +"bankLogo": "/media/logos/logo_us_MoneyGram.png", +"bankIcon": "/media/logos/icon_us_MoneyGram.png", +"privateId": "c149c6e90e13de979ff12e0aaa2a9c4d9f88d510" +} +``` +This method used for confirm user order + +#### CANCEL ORDER + +```http +REQUEST HEADER: +X-Coins-Api-Token: ZGV2aWNlOjQ0NT... +X-Coins-Publisher: ## +Content-Type: application/json + +DELETE https://woc.reference.genitrust.com/api/v1/orders/{orderId}/? +``` + +##### Response : +204 NO CONTENT + +This method is used for cancel order by orderId created by user. + +#### ORDER LIST + +```http +REQUEST HEADER: +X-Coins-Api-Token: ZGV2aWNlOjQ0NT... +X-Coins-Publisher: ## +Content-Type: application/json + +GET https://woc.reference.genitrust.com/api/v1/orders/? +``` + + +##### Response : + +```json +[{ +"id": 100823, +"total": "0.43763420", +"payment": "5.52", +"paymentDue": "2018-02-08T11:06:06.842Z", +"bankName": "Money Gram", +"nameOnAccount": "", +"account": "[{\"displaySort\": 0.0, \"name\": \"firstName\", \"value\": \"Paul\", \"label\": \"First Name\"}, {\"displaySort\": 1.0, \"name\": \"lastName\", \"value\": \"Alberto\", \"label\": \"Last Name\"}, {\"displaySort\": 2.0, \"name\": \"birthCountry\", \"value\": \"USA\", \"label\": \"Country of Birth\"}, {\"displaySort\": 1.5, \"name\": \"pickupState\", \"value\": \"FL\", \"label\": \"Pick-up State\"}]", +"status": "WDV", +"nearestBranch": { +"city": "", +"state": "", +"name": "Money Gram", +"phone": null, +"address": "" +}, +"bankUrl": "https://moneygram.com/", +"bankLogo": "/media/logos/logo_us_Money%20Gram.png", +"bankIcon": "/media/logos/icon_us_Money%20Gram.png", +"privateId": "d674d55f9e", +"currencyName": "US Dollar", +"currencySymbol": "$", +"cryptoName": "Dash", +"cryptoSymbol": "\u0110" +}] +``` +This method is user for get user order list + +Below is the list of order status for user orders history: + +WD = Waiting Deposit +WDV = Waiting Deposit Verification +RERR = Issue with Receipt +DERR = Issue with Deposit +RSD = Reserved for Deposit +RMIT = Remit Address Missing +UCRV = Under Review +PAYP = Done - Pending Delivery +SENT = Done - Units Delivered + +If you get status = 'WD', then you will need to display 'Status: Waiting Deposit' to end user for all orders. + +#### CREATE DEVICE + +```http +HEADER: +X-Coins-Api-Token: ZGV2aWNlOjQ0NT... +X-Coins-Publisher: ## +Content-Type: application/json + +POST https://woc.reference.genitrust.com/api/v1/devices/ +``` + +#####Request : + +``` +{ +"name": "Test Device", +"code": "CK99K" +} +``` + +##### Response : + + +```json +{ +"id": 540, +"name": "Dash Wallet (Android)", +"createdOn": "2018-02-12T14:53:55.234Z" +} +``` +This method use for register new device with API. +DeviceID(id) will be used to as Header parameter in "api/v1/auth/{phone}/authorize/" API for +Authorize user + +#### GET DEVICES + +```http +HEADER: +X-Coins-Api-Token: ZGV2aWNlOjQ0NT... +X-Coins-Publisher: ## +Content-Type: application/json + +GET https://woc.reference.genitrust.com/api/v1/devices/ +``` + +##### Response : + + +```json +[ +{ +"id": 11, +"name": "rgenito", +"createdOn": "2015-05-13T00:17:49.210Z" +}, +{ +"id": 13, +"name": "rgenito", +"createdOn": "2015-08-05T00:00:43.421Z" +}, +{ +"id": 15, +"name": "rgenito", +"createdOn": "2015-12-07T17:32:45.992Z" +} +] +``` +This method is use for get all devices for user + From 1108777f553b6aaba1d676e6856e91bd81414835 Mon Sep 17 00:00:00 2001 From: Sujal Bandhara Date: Fri, 25 May 2018 11:15:10 +0530 Subject: [PATCH 2/3] Remove intermediate files Remove intermediate/unused files --- PivxWallet.xcodeproj/project.pbxproj | 116 - .../Wallofcoins/StoryBoard/wocSell.storyboard | 4153 +---------------- .../Wallofcoins/WOCBaseViewController.m | 34 - .../WOCBuyingWizardHomeViewController.m | 1 + .../WOCSellingAddNewBankViewController.h | 23 - .../WOCSellingAddNewBankViewController.m | 127 - .../WOCSellingAdsInstructionsViewController.h | 30 - .../WOCSellingAdsInstructionsViewController.m | 133 - ...dvancedOptionsInstructionsViewController.h | 21 - ...dvancedOptionsInstructionsViewController.m | 83 - .../WOCSellingCreatePasswordViewController.h | 27 - .../WOCSellingCreatePasswordViewController.m | 82 - .../WOCSellingInstructionsViewController.h | 47 - .../WOCSellingInstructionsViewController.m | 633 --- .../WOCSellingPasswordViewController.h | 28 - .../WOCSellingPasswordViewController.m | 218 - .../WOCSellingSignInViewController.h | 26 - .../WOCSellingSignInViewController.m | 260 -- .../WOCSellingSingUpViewController.h | 28 - .../WOCSellingSingUpViewController.m | 741 --- .../WOCSellingSummaryViewController.h | 25 - .../WOCSellingSummaryViewController.m | 476 -- .../WOCSellingVerifyDetailViewController.h | 30 - .../WOCSellingVerifyDetailViewController.m | 790 ---- ...OCSellingWizardConfirmCodeViewController.h | 30 - ...OCSellingWizardConfirmCodeViewController.m | 116 - .../WOCSellingWizardHomeViewController.h | 29 - .../WOCSellingWizardHomeViewController.m | 136 - ...OCSellingWizardInputAmountViewController.h | 30 - ...OCSellingWizardInputAmountViewController.m | 186 - ...WOCSellingWizardInputEmailViewController.h | 24 - ...WOCSellingWizardInputEmailViewController.m | 70 - ...ingWizardInputPhoineNumberViewController.h | 26 - ...ingWizardInputPhoineNumberViewController.m | 490 -- .../WOCSellingWizardOfferListViewController.h | 25 - .../WOCSellingWizardOfferListViewController.m | 496 -- ...SellingWizardPaymentCenterViewController.h | 22 - ...SellingWizardPaymentCenterViewController.m | 104 - .../WOCSellingWizardZipCodeViewController.h | 23 - .../WOCSellingWizardZipCodeViewController.m | 102 - 40 files changed, 13 insertions(+), 10028 deletions(-) delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingAddNewBankViewController.h delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingAddNewBankViewController.m delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdsInstructionsViewController.h delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdsInstructionsViewController.m delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdvancedOptionsInstructionsViewController.h delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdvancedOptionsInstructionsViewController.m delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingCreatePasswordViewController.h delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingCreatePasswordViewController.m delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingInstructionsViewController.h delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingInstructionsViewController.m delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingPasswordViewController.h delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingPasswordViewController.m delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingSignInViewController.h delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingSignInViewController.m delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingSingUpViewController.h delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingSingUpViewController.m delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingSummaryViewController.h delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingSummaryViewController.m delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingVerifyDetailViewController.h delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingVerifyDetailViewController.m delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardConfirmCodeViewController.h delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardConfirmCodeViewController.m delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardHomeViewController.h delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardHomeViewController.m delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputAmountViewController.h delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputAmountViewController.m delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputEmailViewController.h delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputEmailViewController.m delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputPhoineNumberViewController.h delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputPhoineNumberViewController.m delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardOfferListViewController.h delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardOfferListViewController.m delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardPaymentCenterViewController.h delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardPaymentCenterViewController.m delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardZipCodeViewController.h delete mode 100644 PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardZipCodeViewController.m diff --git a/PivxWallet.xcodeproj/project.pbxproj b/PivxWallet.xcodeproj/project.pbxproj index 31cf2dad..72347d5c 100644 --- a/PivxWallet.xcodeproj/project.pbxproj +++ b/PivxWallet.xcodeproj/project.pbxproj @@ -33,24 +33,6 @@ 04533BDE20998E4E00022EE3 /* WOCHoldIssueViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B9C20998E4E00022EE3 /* WOCHoldIssueViewController.m */; }; 04533BDF20998E4E00022EE3 /* WOCMedia.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 04533B9D20998E4E00022EE3 /* WOCMedia.xcassets */; }; 04533BE020998E4E00022EE3 /* WOCPasswordViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533B9F20998E4E00022EE3 /* WOCPasswordViewController.m */; }; - 04533BE120998E4E00022EE3 /* WOCSellingAddNewBankViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BA220998E4E00022EE3 /* WOCSellingAddNewBankViewController.m */; }; - 04533BE220998E4E00022EE3 /* WOCSellingAdsInstructionsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BA420998E4E00022EE3 /* WOCSellingAdsInstructionsViewController.m */; }; - 04533BE320998E4E00022EE3 /* WOCSellingAdvancedOptionsInstructionsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BA620998E4E00022EE3 /* WOCSellingAdvancedOptionsInstructionsViewController.m */; }; - 04533BE420998E4E00022EE3 /* WOCSellingCreatePasswordViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BA820998E4E00022EE3 /* WOCSellingCreatePasswordViewController.m */; }; - 04533BE520998E4E00022EE3 /* WOCSellingInstructionsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BAA20998E4E00022EE3 /* WOCSellingInstructionsViewController.m */; }; - 04533BE620998E4E00022EE3 /* WOCSellingPasswordViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BAC20998E4E00022EE3 /* WOCSellingPasswordViewController.m */; }; - 04533BE720998E4E00022EE3 /* WOCSellingSignInViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BAE20998E4E00022EE3 /* WOCSellingSignInViewController.m */; }; - 04533BE820998E4E00022EE3 /* WOCSellingSingUpViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BB020998E4E00022EE3 /* WOCSellingSingUpViewController.m */; }; - 04533BE920998E4E00022EE3 /* WOCSellingSummaryViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BB220998E4E00022EE3 /* WOCSellingSummaryViewController.m */; }; - 04533BEA20998E4E00022EE3 /* WOCSellingVerifyDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BB420998E4E00022EE3 /* WOCSellingVerifyDetailViewController.m */; }; - 04533BEB20998E4E00022EE3 /* WOCSellingWizardConfirmCodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BB620998E4E00022EE3 /* WOCSellingWizardConfirmCodeViewController.m */; }; - 04533BEC20998E4E00022EE3 /* WOCSellingWizardHomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BB820998E4E00022EE3 /* WOCSellingWizardHomeViewController.m */; }; - 04533BED20998E4F00022EE3 /* WOCSellingWizardInputAmountViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BBA20998E4E00022EE3 /* WOCSellingWizardInputAmountViewController.m */; }; - 04533BEE20998E4F00022EE3 /* WOCSellingWizardInputEmailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BBC20998E4E00022EE3 /* WOCSellingWizardInputEmailViewController.m */; }; - 04533BEF20998E4F00022EE3 /* WOCSellingWizardInputPhoineNumberViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BBE20998E4E00022EE3 /* WOCSellingWizardInputPhoineNumberViewController.m */; }; - 04533BF020998E4F00022EE3 /* WOCSellingWizardOfferListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BC020998E4E00022EE3 /* WOCSellingWizardOfferListViewController.m */; }; - 04533BF120998E4F00022EE3 /* WOCSellingWizardPaymentCenterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BC220998E4E00022EE3 /* WOCSellingWizardPaymentCenterViewController.m */; }; - 04533BF220998E4F00022EE3 /* WOCSellingWizardZipCodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BC420998E4E00022EE3 /* WOCSellingWizardZipCodeViewController.m */; }; 04533BF320998E4F00022EE3 /* WOCSignInViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 04533BC620998E4E00022EE3 /* WOCSignInViewController.m */; }; 220128D31C753C670001CAC1 /* BRSocketHelpers.c in Sources */ = {isa = PBXBuildFile; fileRef = 220128D11C753C670001CAC1 /* BRSocketHelpers.c */; }; 2204604E1B9F61E600D07B61 /* BREventManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 2204604D1B9F61E600D07B61 /* BREventManager.m */; }; @@ -315,42 +297,6 @@ 04533B9D20998E4E00022EE3 /* WOCMedia.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = WOCMedia.xcassets; sourceTree = ""; }; 04533B9E20998E4E00022EE3 /* WOCPasswordViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCPasswordViewController.h; sourceTree = ""; }; 04533B9F20998E4E00022EE3 /* WOCPasswordViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCPasswordViewController.m; sourceTree = ""; }; - 04533BA120998E4E00022EE3 /* WOCSellingAddNewBankViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingAddNewBankViewController.h; sourceTree = ""; }; - 04533BA220998E4E00022EE3 /* WOCSellingAddNewBankViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingAddNewBankViewController.m; sourceTree = ""; }; - 04533BA320998E4E00022EE3 /* WOCSellingAdsInstructionsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingAdsInstructionsViewController.h; sourceTree = ""; }; - 04533BA420998E4E00022EE3 /* WOCSellingAdsInstructionsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingAdsInstructionsViewController.m; sourceTree = ""; }; - 04533BA520998E4E00022EE3 /* WOCSellingAdvancedOptionsInstructionsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingAdvancedOptionsInstructionsViewController.h; sourceTree = ""; }; - 04533BA620998E4E00022EE3 /* WOCSellingAdvancedOptionsInstructionsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingAdvancedOptionsInstructionsViewController.m; sourceTree = ""; }; - 04533BA720998E4E00022EE3 /* WOCSellingCreatePasswordViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingCreatePasswordViewController.h; sourceTree = ""; }; - 04533BA820998E4E00022EE3 /* WOCSellingCreatePasswordViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingCreatePasswordViewController.m; sourceTree = ""; }; - 04533BA920998E4E00022EE3 /* WOCSellingInstructionsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingInstructionsViewController.h; sourceTree = ""; }; - 04533BAA20998E4E00022EE3 /* WOCSellingInstructionsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingInstructionsViewController.m; sourceTree = ""; }; - 04533BAB20998E4E00022EE3 /* WOCSellingPasswordViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingPasswordViewController.h; sourceTree = ""; }; - 04533BAC20998E4E00022EE3 /* WOCSellingPasswordViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingPasswordViewController.m; sourceTree = ""; }; - 04533BAD20998E4E00022EE3 /* WOCSellingSignInViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingSignInViewController.h; sourceTree = ""; }; - 04533BAE20998E4E00022EE3 /* WOCSellingSignInViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingSignInViewController.m; sourceTree = ""; }; - 04533BAF20998E4E00022EE3 /* WOCSellingSingUpViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingSingUpViewController.h; sourceTree = ""; }; - 04533BB020998E4E00022EE3 /* WOCSellingSingUpViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingSingUpViewController.m; sourceTree = ""; }; - 04533BB120998E4E00022EE3 /* WOCSellingSummaryViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingSummaryViewController.h; sourceTree = ""; }; - 04533BB220998E4E00022EE3 /* WOCSellingSummaryViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingSummaryViewController.m; sourceTree = ""; }; - 04533BB320998E4E00022EE3 /* WOCSellingVerifyDetailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingVerifyDetailViewController.h; sourceTree = ""; }; - 04533BB420998E4E00022EE3 /* WOCSellingVerifyDetailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingVerifyDetailViewController.m; sourceTree = ""; }; - 04533BB520998E4E00022EE3 /* WOCSellingWizardConfirmCodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingWizardConfirmCodeViewController.h; sourceTree = ""; }; - 04533BB620998E4E00022EE3 /* WOCSellingWizardConfirmCodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingWizardConfirmCodeViewController.m; sourceTree = ""; }; - 04533BB720998E4E00022EE3 /* WOCSellingWizardHomeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingWizardHomeViewController.h; sourceTree = ""; }; - 04533BB820998E4E00022EE3 /* WOCSellingWizardHomeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingWizardHomeViewController.m; sourceTree = ""; }; - 04533BB920998E4E00022EE3 /* WOCSellingWizardInputAmountViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingWizardInputAmountViewController.h; sourceTree = ""; }; - 04533BBA20998E4E00022EE3 /* WOCSellingWizardInputAmountViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingWizardInputAmountViewController.m; sourceTree = ""; }; - 04533BBB20998E4E00022EE3 /* WOCSellingWizardInputEmailViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingWizardInputEmailViewController.h; sourceTree = ""; }; - 04533BBC20998E4E00022EE3 /* WOCSellingWizardInputEmailViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingWizardInputEmailViewController.m; sourceTree = ""; }; - 04533BBD20998E4E00022EE3 /* WOCSellingWizardInputPhoineNumberViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingWizardInputPhoineNumberViewController.h; sourceTree = ""; }; - 04533BBE20998E4E00022EE3 /* WOCSellingWizardInputPhoineNumberViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingWizardInputPhoineNumberViewController.m; sourceTree = ""; }; - 04533BBF20998E4E00022EE3 /* WOCSellingWizardOfferListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingWizardOfferListViewController.h; sourceTree = ""; }; - 04533BC020998E4E00022EE3 /* WOCSellingWizardOfferListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingWizardOfferListViewController.m; sourceTree = ""; }; - 04533BC120998E4E00022EE3 /* WOCSellingWizardPaymentCenterViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingWizardPaymentCenterViewController.h; sourceTree = ""; }; - 04533BC220998E4E00022EE3 /* WOCSellingWizardPaymentCenterViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingWizardPaymentCenterViewController.m; sourceTree = ""; }; - 04533BC320998E4E00022EE3 /* WOCSellingWizardZipCodeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSellingWizardZipCodeViewController.h; sourceTree = ""; }; - 04533BC420998E4E00022EE3 /* WOCSellingWizardZipCodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSellingWizardZipCodeViewController.m; sourceTree = ""; }; 04533BC520998E4E00022EE3 /* WOCSignInViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WOCSignInViewController.h; sourceTree = ""; }; 04533BC620998E4E00022EE3 /* WOCSignInViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WOCSignInViewController.m; sourceTree = ""; }; 220128D11C753C670001CAC1 /* BRSocketHelpers.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = BRSocketHelpers.c; sourceTree = ""; }; @@ -736,7 +682,6 @@ 04533B9D20998E4E00022EE3 /* WOCMedia.xcassets */, 04533B9E20998E4E00022EE3 /* WOCPasswordViewController.h */, 04533B9F20998E4E00022EE3 /* WOCPasswordViewController.m */, - 04533BA020998E4E00022EE3 /* WOCSellng */, 04533BC520998E4E00022EE3 /* WOCSignInViewController.h */, 04533BC620998E4E00022EE3 /* WOCSignInViewController.m */, ); @@ -803,49 +748,6 @@ path = AsyncImageView; sourceTree = ""; }; - 04533BA020998E4E00022EE3 /* WOCSellng */ = { - isa = PBXGroup; - children = ( - 04533BA120998E4E00022EE3 /* WOCSellingAddNewBankViewController.h */, - 04533BA220998E4E00022EE3 /* WOCSellingAddNewBankViewController.m */, - 04533BA320998E4E00022EE3 /* WOCSellingAdsInstructionsViewController.h */, - 04533BA420998E4E00022EE3 /* WOCSellingAdsInstructionsViewController.m */, - 04533BA520998E4E00022EE3 /* WOCSellingAdvancedOptionsInstructionsViewController.h */, - 04533BA620998E4E00022EE3 /* WOCSellingAdvancedOptionsInstructionsViewController.m */, - 04533BA720998E4E00022EE3 /* WOCSellingCreatePasswordViewController.h */, - 04533BA820998E4E00022EE3 /* WOCSellingCreatePasswordViewController.m */, - 04533BA920998E4E00022EE3 /* WOCSellingInstructionsViewController.h */, - 04533BAA20998E4E00022EE3 /* WOCSellingInstructionsViewController.m */, - 04533BAB20998E4E00022EE3 /* WOCSellingPasswordViewController.h */, - 04533BAC20998E4E00022EE3 /* WOCSellingPasswordViewController.m */, - 04533BAD20998E4E00022EE3 /* WOCSellingSignInViewController.h */, - 04533BAE20998E4E00022EE3 /* WOCSellingSignInViewController.m */, - 04533BAF20998E4E00022EE3 /* WOCSellingSingUpViewController.h */, - 04533BB020998E4E00022EE3 /* WOCSellingSingUpViewController.m */, - 04533BB120998E4E00022EE3 /* WOCSellingSummaryViewController.h */, - 04533BB220998E4E00022EE3 /* WOCSellingSummaryViewController.m */, - 04533BB320998E4E00022EE3 /* WOCSellingVerifyDetailViewController.h */, - 04533BB420998E4E00022EE3 /* WOCSellingVerifyDetailViewController.m */, - 04533BB520998E4E00022EE3 /* WOCSellingWizardConfirmCodeViewController.h */, - 04533BB620998E4E00022EE3 /* WOCSellingWizardConfirmCodeViewController.m */, - 04533BB720998E4E00022EE3 /* WOCSellingWizardHomeViewController.h */, - 04533BB820998E4E00022EE3 /* WOCSellingWizardHomeViewController.m */, - 04533BB920998E4E00022EE3 /* WOCSellingWizardInputAmountViewController.h */, - 04533BBA20998E4E00022EE3 /* WOCSellingWizardInputAmountViewController.m */, - 04533BBB20998E4E00022EE3 /* WOCSellingWizardInputEmailViewController.h */, - 04533BBC20998E4E00022EE3 /* WOCSellingWizardInputEmailViewController.m */, - 04533BBD20998E4E00022EE3 /* WOCSellingWizardInputPhoineNumberViewController.h */, - 04533BBE20998E4E00022EE3 /* WOCSellingWizardInputPhoineNumberViewController.m */, - 04533BBF20998E4E00022EE3 /* WOCSellingWizardOfferListViewController.h */, - 04533BC020998E4E00022EE3 /* WOCSellingWizardOfferListViewController.m */, - 04533BC120998E4E00022EE3 /* WOCSellingWizardPaymentCenterViewController.h */, - 04533BC220998E4E00022EE3 /* WOCSellingWizardPaymentCenterViewController.m */, - 04533BC320998E4E00022EE3 /* WOCSellingWizardZipCodeViewController.h */, - 04533BC420998E4E00022EE3 /* WOCSellingWizardZipCodeViewController.m */, - ); - path = WOCSellng; - sourceTree = ""; - }; 2B5735681FE04BEB00110745 /* PivxUtils */ = { isa = PBXGroup; children = ( @@ -1820,20 +1722,15 @@ 752E28AB19234AE300DB5A3C /* BRMerkleBlockEntity.m in Sources */, 04533BC920998E4E00022EE3 /* WOCOfferCell.m in Sources */, 04533BDE20998E4E00022EE3 /* WOCHoldIssueViewController.m in Sources */, - 04533BF120998E4F00022EE3 /* WOCSellingWizardPaymentCenterViewController.m in Sources */, 04533BD820998E4E00022EE3 /* WOCBuyingWizardPaymentCenterViewController.m in Sources */, - 04533BEE20998E4F00022EE3 /* WOCSellingWizardInputEmailViewController.m in Sources */, 2B8A1C9D1FEB594800C7427C /* EmptyTableCell.swift in Sources */, BA7B53501BDA9A2800355E8D /* BRAppleWatchData.m in Sources */, 04533BDC20998E4E00022EE3 /* WOCAlertController.m in Sources */, 2B57356E1FE04C4200110745 /* Utils.swift in Sources */, - 04533BEA20998E4E00022EE3 /* WOCSellingVerifyDetailViewController.m in Sources */, 04533BCB20998E4E00022EE3 /* WOCSummaryCell.m in Sources */, - 04533BE920998E4E00022EE3 /* WOCSellingSummaryViewController.m in Sources */, 752E28AC19234AE300DB5A3C /* BRPeerEntity.m in Sources */, FBF2680E1E419318001A1C8B /* DSShapeshiftEntity+CoreDataClass.m in Sources */, 2BBE61AB1FE48AF900D06CD7 /* EmptyCell.swift in Sources */, - 04533BE420998E4E00022EE3 /* WOCSellingCreatePasswordViewController.m in Sources */, 2BBE61A31FE4853B00D06CD7 /* AddressContactController.swift in Sources */, FBF268041E414B93001A1C8B /* NSData+Dash.m in Sources */, 04533BD620998E4E00022EE3 /* WOCBuyingWizardInputVarificationCodeViewController.m in Sources */, @@ -1853,11 +1750,8 @@ 04533BD020998E4E00022EE3 /* WOCBuyingInstructionsViewController.m in Sources */, 7548CF3719556FD700EF827F /* BRCopyLabel.m in Sources */, 752E28D119234C3600DB5A3C /* BRKey.m in Sources */, - 04533BE220998E4E00022EE3 /* WOCSellingAdsInstructionsViewController.m in Sources */, 04533BDA20998E4E00022EE3 /* WOCDefaultBaseViewController.m in Sources */, - 04533BED20998E4F00022EE3 /* WOCSellingWizardInputAmountViewController.m in Sources */, 84F68C8A1975E9E2002FC300 /* BRScanViewController.m in Sources */, - 04533BEC20998E4E00022EE3 /* WOCSellingWizardHomeViewController.m in Sources */, 2204604E1B9F61E600D07B61 /* BREventManager.m in Sources */, FBF267FD1E414AA2001A1C8B /* DSShapeshiftManager.m in Sources */, 752E28D219234C3600DB5A3C /* BRKey+BIP38.m in Sources */, @@ -1872,7 +1766,6 @@ 04533BD120998E4E00022EE3 /* WOCBuyingSummaryViewController.m in Sources */, 752E28DA19234C3600DB5A3C /* BRWallet.m in Sources */, FB021E561E47E17200D17638 /* FBShimmeringLayer.m in Sources */, - 04533BE320998E4E00022EE3 /* WOCSellingAdvancedOptionsInstructionsViewController.m in Sources */, 752E28DB19234C3600DB5A3C /* BRWalletManager.m in Sources */, 752E28D319234C3600DB5A3C /* BRMerkleBlock.m in Sources */, 04533BD220998E4E00022EE3 /* WOCBuyingWizardHomeViewController.m in Sources */, @@ -1884,8 +1777,6 @@ 752E28D819234C3600DB5A3C /* BRPeerManager.m in Sources */, 752E28D419234C3600DB5A3C /* BRPaymentProtocol.m in Sources */, 04533BD920998E4E00022EE3 /* WOCBuyingWizardZipCodeViewController.m in Sources */, - 04533BEF20998E4F00022EE3 /* WOCSellingWizardInputPhoineNumberViewController.m in Sources */, - 04533BE620998E4E00022EE3 /* WOCSellingPasswordViewController.m in Sources */, 752E28D519234C3600DB5A3C /* BRPaymentRequest.m in Sources */, 04533BD720998E4E00022EE3 /* WOCBuyingWizardOfferListViewController.m in Sources */, 7525B619192453840041C0F2 /* BRNavigationBar.m in Sources */, @@ -1904,32 +1795,25 @@ 220128D31C753C670001CAC1 /* BRSocketHelpers.c in Sources */, 752E28E919234DA200DB5A3C /* NSManagedObject+Sugar.m in Sources */, 04533BD520998E4E00022EE3 /* WOCBuyingWizardInputPhoneNumberViewController.m in Sources */, - 04533BE520998E4E00022EE3 /* WOCSellingInstructionsViewController.m in Sources */, BA7B53541BDAA0A800355E8D /* BRAppleWatchTransactionData.m in Sources */, FB021E571E47E17200D17638 /* FBShimmeringView.m in Sources */, 04533BDD20998E4E00022EE3 /* WOCLocationManager.m in Sources */, 04533BC820998E4E00022EE3 /* APIManager.m in Sources */, FBF267A11E414877001A1C8B /* NSString+Dash.m in Sources */, FB021E5B1E4DEFE800D17638 /* MBProgressHUD.m in Sources */, - 04533BF220998E4F00022EE3 /* WOCSellingWizardZipCodeViewController.m in Sources */, 751B2B5C1B68911700EA87FB /* BRTxHistoryViewController.m in Sources */, 752E28EA19234DA200DB5A3C /* NSMutableData+Bitcoin.m in Sources */, 752E28EB19234DA200DB5A3C /* NSString+Bitcoin.m in Sources */, 757C89521A2FCE420076B373 /* BRSettingsViewController.m in Sources */, 75D5F3D2191EC270004AB296 /* BRAppDelegate.m in Sources */, - 04533BE120998E4E00022EE3 /* WOCSellingAddNewBankViewController.m in Sources */, 759FBB36193290F600AB4465 /* BRRootViewController.m in Sources */, 752E289A192349CE00DB5A3C /* DashWallet.xcdatamodeld in Sources */, - 04533BEB20998E4E00022EE3 /* WOCSellingWizardConfirmCodeViewController.m in Sources */, - 04533BE820998E4E00022EE3 /* WOCSellingSingUpViewController.m in Sources */, 2BFA523C1FE0AC5C00A3C808 /* MenuController.swift in Sources */, - 04533BF020998E4F00022EE3 /* WOCSellingWizardOfferListViewController.m in Sources */, 04533BE020998E4E00022EE3 /* WOCPasswordViewController.m in Sources */, 6BA7F2911FDF048100C1027B /* quark.c in Sources */, 759FBB37193290F600AB4465 /* BRSendViewController.m in Sources */, 752E28F119234E8100DB5A3C /* Reachability.m in Sources */, 2BBE61A91FE48AEC00D06CD7 /* AddressContactCell.swift in Sources */, - 04533BE720998E4E00022EE3 /* WOCSellingSignInViewController.m in Sources */, 75D5F3CE191EC270004AB296 /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/PivxWallet/Wallofcoins/StoryBoard/wocSell.storyboard b/PivxWallet/Wallofcoins/StoryBoard/wocSell.storyboard index d2773969..4c16be24 100644 --- a/PivxWallet/Wallofcoins/StoryBoard/wocSell.storyboard +++ b/PivxWallet/Wallofcoins/StoryBoard/wocSell.storyboard @@ -1,22 +1,14 @@ - + - - - + - - - Helvetica - Helvetica-Bold - - @@ -27,4149 +19,28 @@ - + - - + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - If you have any questions, there is a live chat window at wallofcoins.com or you may call the phone number that sent you a text message. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Wall of Coins will verify your payment. This usually takes up to 10 minutes. To expedite your order, take a picture of your receipt and click here to email your receipt to Wall of Coins. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - - - - - - - - diff --git a/PivxWallet/Wallofcoins/WOCBaseViewController.m b/PivxWallet/Wallofcoins/WOCBaseViewController.m index dde83264..cdd4c685 100644 --- a/PivxWallet/Wallofcoins/WOCBaseViewController.m +++ b/PivxWallet/Wallofcoins/WOCBaseViewController.m @@ -11,10 +11,6 @@ #import "WOCBuyingSummaryViewController.h" #import "WOCBuyingWizardHomeViewController.h" -#import "WOCSellingWizardHomeViewController.h" -#import "WOCSellingInstructionsViewController.h" -#import "WOCSellingSummaryViewController.h" - @interface WOCBaseViewController () @end @@ -278,13 +274,6 @@ - (void)pushToWOCRoot { BRAppDelegate *appDelegate = (BRAppDelegate*)[[UIApplication sharedApplication] delegate]; appDelegate.window.rootViewController = navController; } - else { - WOCSellingWizardHomeViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"WOCSellingWizardHomeViewController"];// Or any VC with Id - vc.isFromSend = YES; - [navController.navigationBar setTintColor:[UIColor whiteColor]]; - BRAppDelegate *appDelegate = (BRAppDelegate*)[[UIApplication sharedApplication] delegate]; - appDelegate.window.rootViewController = navController; - } }); } @@ -337,14 +326,6 @@ - (void)loadOrdersWithResponse:(id)responseDict withError: (NSError *)error buyingInstructionsViewController.orderDict = orderDict; [self pushViewController:buyingInstructionsViewController animated:YES]; } - else { - WOCSellingInstructionsViewController *sellingInstructionsViewController = [self getViewController:@"WOCSellingInstructionsViewController"]; - sellingInstructionsViewController.phoneNo = phoneNo; - sellingInstructionsViewController.isFromSend = YES; - sellingInstructionsViewController.isFromOffer = NO; - sellingInstructionsViewController.orderDict = orderDict; - [self pushViewController:sellingInstructionsViewController animated:YES]; - } } } else { @@ -356,13 +337,6 @@ - (void)loadOrdersWithResponse:(id)responseDict withError: (NSError *)error buyingInstructionsViewController.isFromSend = YES; [self pushViewController:buyingInstructionsViewController animated:YES]; } - else { - WOCSellingSummaryViewController *sellingSummaryViewController = [self getViewController:@"WOCSellingSummaryViewController"]; - sellingSummaryViewController.phoneNo = phoneNo; - sellingSummaryViewController.orders = orders; - sellingSummaryViewController.isFromSend = YES; - [self pushViewController:sellingSummaryViewController animated:YES]; - } } } else { @@ -374,14 +348,6 @@ - (void)loadOrdersWithResponse:(id)responseDict withError: (NSError *)error buyingSummaryViewController.isHideSuccessAlert = YES; [self pushViewController:buyingSummaryViewController animated:YES]; } - else { - WOCSellingSummaryViewController *sellingSummaryViewController = [self getViewController:@"WOCSellingSummaryViewController"]; - sellingSummaryViewController.phoneNo = phoneNo; - sellingSummaryViewController.orders = orders; - sellingSummaryViewController.isFromSend = YES; - sellingSummaryViewController.isHideSuccessAlert = YES; - [self pushViewController:sellingSummaryViewController animated:YES]; - } } } else { diff --git a/PivxWallet/Wallofcoins/WOCBuyingWizardHomeViewController.m b/PivxWallet/Wallofcoins/WOCBuyingWizardHomeViewController.m index 970befb7..d82f1177 100644 --- a/PivxWallet/Wallofcoins/WOCBuyingWizardHomeViewController.m +++ b/PivxWallet/Wallofcoins/WOCBuyingWizardHomeViewController.m @@ -205,6 +205,7 @@ - (IBAction)onFindLocationButtonClick:(id)sender { [self refereshToken]; [self.defaults removeObjectForKey:WOCApiBodyCountryCode]; [self.defaults synchronize]; + if ([[WOCLocationManager sharedInstance] locationServiceEnabled]) { [self findZipCode]; [self.locationButton setUserInteractionEnabled:NO]; diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAddNewBankViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAddNewBankViewController.h deleted file mode 100644 index 03a4fd0c..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAddNewBankViewController.h +++ /dev/null @@ -1,23 +0,0 @@ -// -// WOCSellingWizardPaymentCenterViewController.h -// Wallofcoins -// -// Created by Genitrust on 23/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import -#import "WOCBaseViewController.h" -@interface WOCSellingAddNewBankViewController : WOCBaseViewController - -@property (weak, nonatomic) IBOutlet UITextField *txtPaymentCenter; -@property (weak, nonatomic) IBOutlet UITextField *txtAccoutName; -@property (weak, nonatomic) IBOutlet UITextField *txtAccoutNumber; -@property (weak, nonatomic) IBOutlet UITextField *txtConfirmAccoutNumber; -@property (weak, nonatomic) IBOutlet UIButton *btnNext; - -- (IBAction)nextStepClicked:(id)sender; -- (IBAction)useMostRecentBankAccoutClick:(id)sender; - -@end - diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAddNewBankViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAddNewBankViewController.m deleted file mode 100644 index 23f0e2fc..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAddNewBankViewController.m +++ /dev/null @@ -1,127 +0,0 @@ -// -// WOCSellingWizardPaymentCenterViewController.m -// Wallofcoins -// -// Created by Genitrust on 23/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import "WOCSellingAddNewBankViewController.h" -#import "WOCSellingWizardInputAmountViewController.h" -#import "APIManager.h" -#import "WOCAlertController.h" -#import "WOCSellingWizardPaymentCenterViewController.h" - -@interface WOCSellingAddNewBankViewController () - -@property (strong, nonatomic) NSArray *paymentCenters; -@property (strong, nonatomic) UIPickerView *pickerView; -@property (strong, nonatomic) NSString *bankId; - -@end - -@implementation WOCSellingAddNewBankViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - - [self setShadowOnButton:self.btnNext]; - - self.pickerView = [[UIPickerView alloc] init]; - self.pickerView.delegate = self; - self.pickerView.dataSource = self; - self.txtPaymentCenter.inputView = self.pickerView; - - [self getPaymentCenters]; -} - -// MARK: - API - -- (void)getPaymentCenters { - - [[APIManager sharedInstance] getAvailablePaymentCenters:^(id responseDict, NSError *error) { - if (error == nil) { - if ([responseDict isKindOfClass:[NSArray class]]) { - NSArray *responseArray = [[NSArray alloc] initWithArray:(NSArray *)responseDict]; - NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]; - self.paymentCenters = [responseArray sortedArrayUsingDescriptors:@[sort]]; - [self.pickerView reloadAllComponents]; - } - } - }]; -} - -// MARK: - IBAction - -- (IBAction)nextStepClicked:(id)sender { - - if ([self.bankId length] > 0 && self.txtAccoutName.text.length > 0 - && self.txtAccoutNumber.text.length > 0 - && self.txtConfirmAccoutNumber.text.length > 0 && [self.txtAccoutNumber.text isEqualToString:self.txtConfirmAccoutNumber.text]) { - WOCSellingWizardInputAmountViewController *inputAmountViewController = (WOCSellingWizardInputAmountViewController*)[self getViewController:@"WOCSellingWizardInputAmountViewController"];; - inputAmountViewController.bankId = self.bankId; - - NSString *bankInfo = [NSString stringWithFormat:@"%@ (-%@)",self.txtPaymentCenter.text,self.bankId]; - [self.defaults setObject:bankInfo forKey:WOCUserDefaultsLocalBankInfo]; - [self.defaults synchronize]; - - [self.defaults setObject:self.txtAccoutName.text forKey:WOCUserDefaultsLocalBankName]; - [self.defaults synchronize]; - - [self.defaults setObject:self.txtConfirmAccoutNumber.text forKey:WOCUserDefaultsLocalBankAccountNumber]; - [self.defaults synchronize]; - - [self.defaults setObject:self.bankId forKey:WOCUserDefaultsLocalBankAccount]; - [self.defaults synchronize]; - - [self pushViewController:inputAmountViewController animated:YES]; - return; - } - else { - - if ([self.bankId length] == 0 ) { - [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Select payment center." viewController:self.navigationController.visibleViewController]; - } - else if (self.txtAccoutName.text.length == 0) { - - [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Please enter account name." viewController:self.navigationController.visibleViewController]; - } - else if (self.txtAccoutNumber.text.length == 0) { - - [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Please enter account number." viewController:self.navigationController.visibleViewController]; - } - else if (self.txtConfirmAccoutNumber.text.length == 0) { - - [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Please enter confirm account number." viewController:self.navigationController.visibleViewController]; - } - else if (![self.txtAccoutNumber.text isEqualToString:self.txtConfirmAccoutNumber.text]) { - [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Account number and confirm account number not matched." viewController:self.navigationController.visibleViewController]; - } - } -} - -// MARK: UIPickerView Delegates - -- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView { - return 1; -} - -- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component { - return self.paymentCenters.count; -} - -- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { - return self.paymentCenters[row][@"name"]; -} - -- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { - self.txtPaymentCenter.text = self.paymentCenters[row][@"name"]; - self.bankId = [NSString stringWithFormat:@"%@",self.paymentCenters[row][@"id"]]; -} - -- (IBAction)useMostRecentBankAccoutClick:(id)sender { - WOCSellingWizardPaymentCenterViewController *paymentCenterViewController = (WOCSellingWizardPaymentCenterViewController*)[self getViewController:@"WOCSellingWizardPaymentCenterViewController"]; - [self pushViewController:paymentCenterViewController animated:YES]; -} -@end - diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdsInstructionsViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdsInstructionsViewController.h deleted file mode 100644 index ff628a45..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdsInstructionsViewController.h +++ /dev/null @@ -1,30 +0,0 @@ -// -// WOCSellingAdsInstructionsViewController.h -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import -#import "WOCBaseViewController.h" - -// Enter Phone Number Screen -@interface WOCSellingAdsInstructionsViewController : WOCBaseViewController - -@property (strong, nonatomic) NSString *accountInformation; -@property (strong, nonatomic) NSString *currentPrice; -@property (strong, nonatomic) NSString *AdvertiseId; -@property (weak, nonatomic) IBOutlet UITextField *bankNameTextfield; -@property (weak, nonatomic) IBOutlet UITextField *accountNameTextfield; -@property (weak, nonatomic) IBOutlet UITextField *accountNumberTextfield; -@property (weak, nonatomic) IBOutlet UITextField *availableCryptoTextfield; -@property (weak, nonatomic) IBOutlet UITextField *txtEmail; -@property (weak, nonatomic) IBOutlet UITextField *currentPriceTextfield; -@property (weak, nonatomic) IBOutlet UIButton *editYourCurrentRateButton; -@property (strong, nonatomic) IBOutlet UIButton *advancedOptionsButton; -- (IBAction)onEditYourCurrentRateButtonClick:(UIButton *)sender; -- (IBAction)backToHomeScreenAction:(id)sender; -- (IBAction)onAdvancedOptionsButtonClick:(UIButton *)sender; - -@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdsInstructionsViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdsInstructionsViewController.m deleted file mode 100644 index 2637eb40..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdsInstructionsViewController.m +++ /dev/null @@ -1,133 +0,0 @@ -// -// WOCSellingVerifyDetailViewController.m -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import "WOCSellingAdsInstructionsViewController.h" -#import "WOCSellingAdvancedOptionsInstructionsViewController.h" -#import "BRAppDelegate.h" -#import "APIManager.h" -#import "WOCConstants.h" - - -@interface WOCSellingAdsInstructionsViewController () - -@property (strong, nonatomic) NSArray *countries; -@property (strong, nonatomic) UIPickerView *pickerView; -@property (strong, nonatomic) NSString *countryCode; -@property (strong, nonatomic) NSString *purchaseCode; -@property (strong, nonatomic) NSString *holdId; -@property (strong, nonatomic) NSString *deviceName; -@end - -@implementation WOCSellingAdsInstructionsViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - - [self setShadowOnButton:self.editYourCurrentRateButton]; - - if (self.accountInformation != nil && self.accountInformation.length > 0) { - self.bankNameTextfield.text = self.accountInformation; - } - -// if (self.currentPrice != nil && self.currentPrice.length > 0){ -// self.txtCurrentPrice.text = self.currentPrice; -// } - - self.availableCryptoTextfield.text = [NSString stringWithFormat:@"%@ 0.000",WOCCurrencySymbol]; - - NSString *emailAddress = [self.defaults objectForKey:WOCUserDefaultsLocalEmail]; - if (emailAddress != nil && emailAddress.length > 0) { - self.txtEmail.text = emailAddress; - } - - NSString *bankAccountInfo = [self.defaults objectForKey:WOCUserDefaultsLocalBankInfo]; - if (bankAccountInfo != nil && bankAccountInfo.length > 0) { - self.bankNameTextfield.text = bankAccountInfo; - } - - NSString *bankAccount = [self.defaults objectForKey:WOCUserDefaultsLocalBankAccountNumber]; - if (bankAccount != nil && bankAccount.length > 0) { - self.accountNumberTextfield.text = bankAccount; - } - - NSString *bankName = [self.defaults objectForKey:WOCUserDefaultsLocalBankName]; - if (bankName != nil && bankName.length > 0) { - self.accountNameTextfield.text = bankName; - } - - NSString *currentPrice = [self.defaults objectForKey:WOCUserDefaultsLocalPrice]; - if (currentPrice != nil && currentPrice.length > 0) { - self.currentPriceTextfield.text = [NSString stringWithFormat:@"$ %@",currentPrice]; - } - self.accountNumberTextfield.userInteractionEnabled = NO; - self.accountNameTextfield.userInteractionEnabled = NO; - self.bankNameTextfield.userInteractionEnabled = NO; - self.availableCryptoTextfield.userInteractionEnabled = NO; - self.currentPriceTextfield.userInteractionEnabled = NO; - self.txtEmail.userInteractionEnabled = NO; - [self loadAdData]; -} - -- (void)loadAdData -{ - if (self.AdvertiseId != nil && self.AdvertiseId.length > 0) { - [[APIManager sharedInstance] getDetailFromADId:self.AdvertiseId response:^(id responseDict, NSError *error) { - APILog(@"responseDict = %@",responseDict); - - self.bankNameTextfield.text = self.accountInformation; - self.availableCryptoTextfield.text = [NSString stringWithFormat:@"%@ 0.000",WOCCurrencySymbol]; - - //self.txtEmail.text = REMOVE_NULL_VALUE(responseDict[@""]); - self.bankNameTextfield.text = REMOVE_NULL_VALUE(responseDict[@""]); - self.accountNumberTextfield.text = REMOVE_NULL_VALUE(responseDict[@""]); - self.accountNameTextfield.text = REMOVE_NULL_VALUE(responseDict[@""]); - self.currentPriceTextfield.text = [NSString stringWithFormat:@"$ %@",REMOVE_NULL_VALUE(responseDict[@"currentPrice"])]; - - /* - balance = "0.00000000"; - buyCurrency = USD; - currentPrice = "1.20"; - dynamicPrice = 0; - fundingAddress = "(Not Available - Needs Verification)"; - id = 90; - maxPayment = 0; - minPayment = 0; - onHold = "0.00000000"; - primaryMarket = ""; - publicBalance = "0.00000000"; - published = 0; - secondaryMarket = ""; - sellCrypto = DASH; - sellerFee = ""; - userEnabled = 1; - verified = 0; - */ - }]; - } -} - -- (IBAction)onAdvancedOptionsButtonClick:(id)sender -{ - [self.defaults setBool:NO forKey:@"isBeforeCreateAd"]; - [self.defaults synchronize]; - - WOCSellingAdvancedOptionsInstructionsViewController *sellingAdvancedOptionsInstructionsViewController = [self getViewController:@"WOCSellingAdvancedOptionsInstructionsViewController"]; - [self pushViewController:sellingAdvancedOptionsInstructionsViewController animated:YES]; - [sellingAdvancedOptionsInstructionsViewController setupUI]; -} - -- (IBAction)onEditYourCurrentRateButtonClick:(UIButton *)sender { - APILog(@"Edit Your current rate button clicked"); -} - -- (IBAction)backToHomeScreenAction:(id)sender { - [self backToMainView]; -} - -@end - diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdvancedOptionsInstructionsViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdvancedOptionsInstructionsViewController.h deleted file mode 100644 index 63453407..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdvancedOptionsInstructionsViewController.h +++ /dev/null @@ -1,21 +0,0 @@ -// -// WOCSellingAdvancedOptionsInstructionsViewController.h -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import -#import "WOCBaseViewController.h" - -// Enter Phone Number Screen -@interface WOCSellingAdvancedOptionsInstructionsViewController : WOCBaseViewController -@property (assign, nonatomic) BOOL isBeforeCreateAd; -@property (weak, nonatomic) IBOutlet UITextField *maxLimitTextfield; -@property (weak, nonatomic) IBOutlet UITextField *minLimitTextfield; -@property (weak, nonatomic) IBOutlet UIButton *saveButton; -- (IBAction)onSaveButtonClick:(id)sender; -- (void)loadVarificationScreen; -- (void)setupUI; -@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdvancedOptionsInstructionsViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdvancedOptionsInstructionsViewController.m deleted file mode 100644 index f8b83291..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingAdvancedOptionsInstructionsViewController.m +++ /dev/null @@ -1,83 +0,0 @@ -// -// WOCSellingAdvancedOptionsInstructionsViewController.m -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import "WOCSellingAdvancedOptionsInstructionsViewController.h" -#import "WOCSellingVerifyDetailViewController.h" -#import "WOCSellingAdsInstructionsViewController.h" - -@interface WOCSellingAdvancedOptionsInstructionsViewController () - -@end - -@implementation WOCSellingAdvancedOptionsInstructionsViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - - [self setShadowOnButton:self.saveButton]; - - NSString *minDeposit = [self.defaults objectForKey:WOCUserDefaultsLocalMinDeposit]; - if (minDeposit != nil && minDeposit.length > 0){ - self.minLimitTextfield.text = minDeposit; - } - - NSString *maxDeposit = [self.defaults objectForKey:WOCUserDefaultsLocalMaxDeposit]; - if (maxDeposit != nil && maxDeposit.length > 0){ - self.maxLimitTextfield.text = maxDeposit; - } -} - -- (void)viewWillAppear:(BOOL)animated { - - [self setupUI]; -} - -- (void)setupUI { - - self.isBeforeCreateAd = [self.defaults boolForKey:@"isBeforeCreateAd"]; - if (self.isBeforeCreateAd == YES) { - [self.saveButton setTitle:@"NEXT" forState:UIControlStateNormal]; - } - else { - [self.saveButton setTitle:@"Save" forState:UIControlStateNormal]; - } -} - -// MARK: - IBAction -- (IBAction)onSaveButtonClick:(id)sender { - - if ([self.minLimitTextfield.text length] == 0) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter minimum deposit limit." viewController:self.navigationController.visibleViewController]; - } - else if ([self.maxLimitTextfield.text length] == 0) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter maximum deposit limit." viewController:self.navigationController.visibleViewController]; - } - else { - - [self.defaults setObject:self.minLimitTextfield.text forKey:WOCUserDefaultsLocalMinDeposit]; - [self.defaults synchronize]; - - [self.defaults setObject:self.maxLimitTextfield.text forKey:WOCUserDefaultsLocalMaxDeposit]; - [self.defaults synchronize]; - - if (self.isBeforeCreateAd) { - [self loadVarificationScreen]; - } - else { - WOCSellingAdsInstructionsViewController *myViewController = [self getViewController:@"WOCSellingAdsInstructionsViewController"]; - [self pushViewController:myViewController animated:YES]; - } - } -} - -- (void)loadVarificationScreen { - WOCSellingVerifyDetailViewController *verifyDetailViewController = (WOCSellingVerifyDetailViewController*)[self getViewController:@"WOCSellingVerifyDetailViewController"]; - [self pushViewController:verifyDetailViewController animated:YES]; -} -@end - diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingCreatePasswordViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingCreatePasswordViewController.h deleted file mode 100644 index b7e800b4..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingCreatePasswordViewController.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// WOCSellingCreatePasswordViewController.h -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import -#import "WOCBaseViewController.h" -@interface WOCSellingCreatePasswordViewController : WOCBaseViewController - -@property (strong, nonatomic) NSString *purchaseCode; -@property (strong, nonatomic) NSString *offerId; -@property (strong, nonatomic) NSString *holdId; -@property (strong, nonatomic) NSString *phoneNo; -@property (strong, nonatomic) NSString *emailId; -@property (strong, nonatomic) NSString *deviceCode; -@property (strong, nonatomic) NSString *deviceName; - -@property (weak, nonatomic) IBOutlet UILabel *descLabel; -@property (weak, nonatomic) IBOutlet UITextField *purchaseCodeTextfield; -@property (weak, nonatomic) IBOutlet UIButton *confirmVarificationCodeButton; -- (IBAction)onConfirmVerificationCode:(UIButton *)sender; -- (IBAction)onResendCodeButtonClick:(UIButton *)sender; - -@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingCreatePasswordViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingCreatePasswordViewController.m deleted file mode 100644 index c26c56e8..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingCreatePasswordViewController.m +++ /dev/null @@ -1,82 +0,0 @@ -// -// WOCSellingCreatePasswordViewController.m -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import "WOCSellingCreatePasswordViewController.h" -#import "WOCSellingInstructionsViewController.h" -#import "WOCSellingSummaryViewController.h" -#import "APIManager.h" -#import "WOCConstants.h" -#import "WOCAlertController.h" -#import "BRRootViewController.h" -#import "BRAppDelegate.h" -#import "MBProgressHUD.h" - -@interface WOCSellingCreatePasswordViewController () - -@end - -@implementation WOCSellingCreatePasswordViewController - -- (void)viewDidLoad { - - [super viewDidLoad]; - - [self setShadowOnButton:self.confirmVarificationCodeButton]; - - NSString *userDeviceName = @""; - if (self.deviceName != nil) { - userDeviceName = [NSString stringWithFormat:@"named %@",self.deviceName]; - } - self.descLabel.text = [NSString stringWithFormat:@"You are already signed up with an app %@. Congratulations! Now type a secure password to continue.",userDeviceName]; - if (self.purchaseCode != nil) { - self.purchaseCodeTextfield.text = REMOVE_NULL_VALUE(self.purchaseCode); - } - else { - self.purchaseCodeTextfield.text = @""; - } - self.purchaseCodeTextfield.delegate = self; -} - -- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { - - if(textField.text.length == 4 && string.length == 1) - { - [self performSelector:@selector(onConfirmVerificationCode:) withObject:self afterDelay:1.0]; - } - return YES; -} - -// MARK: - IBAction -- (IBAction)onConfirmVerificationCode:(UIButton *)sender { - - NSString *txtCode = [self.purchaseCodeTextfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; - - if ([txtCode length] == 5) { - WOCSellingInstructionsViewController *instructionsViewController = [self getViewController:@"WOCSellingInstructionsViewController"]; - instructionsViewController.purchaseCode = txtCode; - instructionsViewController.holdId = self.holdId; - instructionsViewController.phoneNo = self.phoneNo; - [self pushViewController:instructionsViewController animated:YES]; - } - else if ([txtCode length] == 0) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:@"Enter Purchase Code" viewController:self.navigationController.visibleViewController]; - } - else if ([txtCode length] != 5) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:@"Enter Valid Purchase Code" viewController:self.navigationController.visibleViewController]; - } -} - -- (IBAction)onResendCodeButtonClick:(UIButton *)sender { - APILog(@"onResendCodeButtonClick"); -} -@end -/* Resend Code - Problems receiving your code? Your mobile phone must be able to receive text messages. If you are sure you typed your mobile number correctly, double check that you are in an area with good mobile service signal. Also, try texting the word "Start" to (217) 672-6467. This will "unblock" our service from sending you text messages. - - If you still need help, contact us toll-free: 866-841-COIN (866-841-2646). - */ diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingInstructionsViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingInstructionsViewController.h deleted file mode 100644 index d3c0e999..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingInstructionsViewController.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// WOCSellingInstructionsViewController.h -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import -#import "WOCBaseViewController.h" -@interface WOCSellingInstructionsViewController : WOCBaseViewController - -@property (strong, nonatomic) NSString *purchaseCode; -@property (strong, nonatomic) NSString *holdId; -@property (strong, nonatomic) NSString *offerId; -@property (strong, nonatomic) NSString *phoneNo; -@property (strong, nonatomic) NSDictionary *orderDict; -@property (assign, nonatomic) BOOL isFromSend; -@property (assign, nonatomic) BOOL isFromOffer; - -@property (weak, nonatomic) IBOutlet UIImageView *imgView; -@property (weak, nonatomic) IBOutlet UILabel *lblBankName; -@property (weak, nonatomic) IBOutlet UILabel *lblPhone; -@property (weak, nonatomic) IBOutlet UIButton *btnCheckLocation; - -@property (weak, nonatomic) IBOutlet UILabel *lblAccountName; -@property (weak, nonatomic) IBOutlet UILabel *lblAccountNo; -@property (weak, nonatomic) IBOutlet UILabel *lblCashDeposit; -@property (weak, nonatomic) IBOutlet UILabel *lblDepositDue; -@property (weak, nonatomic) IBOutlet UIButton *btnDepositFinished; -@property (weak, nonatomic) IBOutlet UIButton *btnCancelOrder; - -@property (weak, nonatomic) IBOutlet UILabel *lblInstructions; -@property (weak, nonatomic) IBOutlet UITextView *txtInstruction; -@property (weak, nonatomic) IBOutlet UIButton *btnWallOfCoins; -@property (weak, nonatomic) IBOutlet UILabel *lblLoginPhone; -@property (weak, nonatomic) IBOutlet UIButton *btnSignOut; - -- (IBAction)showMapClicked:(id)sender; -- (IBAction)depositFinishedClicked:(id)sender; -- (IBAction)cancelOrderClicked:(id)sender; -- (IBAction)wallOfCoinsClicked:(id)sender; -- (IBAction)onSignOutButtonClick:(id)sender; -- (void)captureHold:(NSString*)purchaseCode holdId:(NSString*)holdId ; -- (void)deleteHold:(NSString*)holdId count:(NSUInteger)count; - -@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingInstructionsViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingInstructionsViewController.m deleted file mode 100644 index 638f8f5d..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingInstructionsViewController.m +++ /dev/null @@ -1,633 +0,0 @@ -// -// WOCSellingInstructionsViewController.m -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import "WOCSellingInstructionsViewController.h" -#import "WOCSellingSummaryViewController.h" -#import "WOCSellingWizardHomeViewController.h" -#import "APIManager.h" -#import "WOCConstants.h" -#import "BRRootViewController.h" -#import "BRAppDelegate.h" -#import "WOCAlertController.h" -#import "WOCLocationManager.h" -#import "MBProgressHUD.h" - -@interface WOCSellingInstructionsViewController () - -@property (strong, nonatomic) NSString *orderId; -@property (strong, nonatomic) NSString *dueTime; -@property (assign, nonatomic) int minutes; -@property (strong, nonatomic) NSTimer *timer; -@property (strong, nonatomic) NSString *locationUrl; -@end - -@implementation WOCSellingInstructionsViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - - [self setShadowOnButton:self.btnDepositFinished]; - [self setShadowOnButton:self.btnCancelOrder]; - [self setShadowOnButton:self.btnWallOfCoins]; - [self setShadowOnButton:self.btnSignOut]; - - NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; - NSString *loginPhone = [NSString stringWithFormat:@"Your wallet is signed into Wall of Coins using your mobile number %@",phoneNo]; - self.lblLoginPhone.text = loginPhone; - - if (self.orderDict.count > 0) { - [self updateData:self.orderDict]; - } - - self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"navigation_back"] style:UIBarButtonItemStylePlain target:self action:@selector(back:)]; - - if (!self.isFromSend && !self.isFromOffer) { - if ([self.purchaseCode length] > 0 && [self.holdId length] > 0) { - [self captureHold:self.purchaseCode holdId:self.holdId]; - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Please enter purchase code." viewController:self.navigationController.visibleViewController]; - } - } - else if (self.isFromOffer) { - NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; - if (self.offerId != nil && [self.offerId length] > 0) { - [self createHold:self.offerId phoneNo:phoneNo]; - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Please select offer." viewController:self.navigationController.visibleViewController]; - [self.navigationController popViewControllerAnimated:YES]; - } - } - - NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"If you have any questions, there is a live chat window at wallofcoins.com or you may call the phone number that sent you a text message." attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15.5]}]; - - [attributedString addAttribute:NSLinkAttributeName - value:@"https://wallofcoins.com" - range:[[attributedString string] rangeOfString:@"wallofcoins.com"]]; - - - NSDictionary *linkAttributes = @{ - NSForegroundColorAttributeName: [UIColor blackColor], - NSUnderlineColorAttributeName: [UIColor blackColor], - NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle) - }; - - // assume that textView is a UITextView previously created (either by code or Interface Builder) - self.txtInstruction.linkTextAttributes = linkAttributes; // customizes the appearance of links - self.txtInstruction.attributedText = attributedString; - self.txtInstruction.delegate = self; -} - - -- (void)pushToHome -{ - dispatch_async(dispatch_get_main_queue(), ^{ - UIStoryboard *storyboard = [UIStoryboard storyboardWithName:WOCBuyingStoryboard bundle:nil]; - WOCSellingWizardHomeViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"WOCSellingWizardHomeViewController"]; - vc.isFromSend = YES; - UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:vc]; - navigationController.navigationBar.tintColor = [UIColor whiteColor]; - BRAppDelegate *appDelegate = (BRAppDelegate*)[[UIApplication sharedApplication] delegate]; - appDelegate.window.rootViewController = navigationController; - }); - return; - - BOOL viewFound = NO; - - for (UIViewController *controller in self.navigationController.viewControllers) { - if ([controller isKindOfClass:[WOCSellingWizardHomeViewController class]]) { - [self.navigationController popToViewController:controller animated:NO]; - viewFound = YES; - break; - } - } - - if (viewFound == NO) { - dispatch_async(dispatch_get_main_queue(), ^{ - WOCSellingWizardHomeViewController *homeViewController = [self getViewController:@"WOCSellingWizardHomeViewController"]; - [self pushViewController:homeViewController animated:YES]; - }); - } -} - -- (void)back:(id)sender { - [self pushToBuyingSummary]; -} - -- (void)pushToBuyingSummary { - dispatch_async(dispatch_get_main_queue(), ^{ - WOCSellingSummaryViewController *summaryViewController = [self getViewController:@"WOCSellingSummaryViewController"]; - summaryViewController.phoneNo = self.phoneNo; - summaryViewController.isHideSuccessAlert = YES; - [self pushViewController:summaryViewController animated:YES]; - }); -} - -- (void)pushToStep1 { - [self backToMainView]; -} - -- (void)openSite:(NSURL*)url { - if ([[UIApplication sharedApplication] canOpenURL:url]) { - [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) { - APILog(@"URL opened..."); - }]; - } -} - -- (void)stopTimer { - dispatch_async(dispatch_get_main_queue(), ^{ - [self.timer invalidate]; - }); -} - -- (void)showDepositAlert { - UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Confirmation!" message:@"Are you sure you finished making the payment?" preferredStyle:UIAlertControllerStyleAlert]; - - UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { - [self confirmDeposit]; - }]; - - UIAlertAction *noAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { - }]; - - [alert addAction:yesAction]; - [alert addAction:noAction]; - [self presentViewController:alert animated:YES completion:nil]; -} - -- (void)showCancelOrderAlert { - - UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Confirmation!" message:@"Are you sure you want to cancel order?" preferredStyle:UIAlertControllerStyleAlert]; - - UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { - [self cancelOrder]; - }]; - - UIAlertAction *noAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { - }]; - - [alert addAction:yesAction]; - [alert addAction:noAction]; - [self presentViewController:alert animated:YES completion:nil]; -} - -- (void)updateData:(NSDictionary*)dictionary { - NSString *bankLogo = REMOVE_NULL_VALUE([dictionary valueForKey:@"bankLogo"]); - NSString *bankName = REMOVE_NULL_VALUE([dictionary valueForKey:@"bankName"]); - NSString *phoneNo = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([[dictionary valueForKey:@"nearestBranch"] valueForKey:@"phone"])]; - NSString *accountName = REMOVE_NULL_VALUE([dictionary valueForKey:@"nameOnAccount"]); - NSString *accountNo = REMOVE_NULL_VALUE([dictionary valueForKey:@"account"]); - float depositAmount = [[dictionary valueForKey:@"payment"] floatValue]; - NSString *depositDue = REMOVE_NULL_VALUE([dictionary valueForKey:@"paymentDue"]); - NSString *totalDash = REMOVE_NULL_VALUE([dictionary valueForKey:@"total"]); - self.orderId = REMOVE_NULL_VALUE([dictionary valueForKey:@"id"]); - - //bankLogo - if (![[dictionary valueForKey:@"bankLogo"] isEqual:[NSNull null]] && [bankLogo length] > 0) { - self.imgView.image = [UIImage imageNamed:@"ic_account_balance_black"]; - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), - ^{ - NSURL *imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",bankLogo]]; - NSData *imageData = [NSData dataWithContentsOfURL:imageURL]; - - //This is your completion handler - dispatch_sync(dispatch_get_main_queue(), ^{ - //If self.image is atomic (not declared with nonatomic) - // you could have set it directly above - if (imageData != nil) { - self.imgView.image = [UIImage imageWithData:imageData]; - } - else { - self.imgView.image = [UIImage imageNamed:@"ic_account_balance_black"]; - } - }); - }); - } - else { - self.imgView.image = [UIImage imageNamed:@"ic_account_balance_black"]; - } - - //bankLocationUrl - if ([dictionary valueForKey:@"bankUrl"] != [NSNull null]) { - [self.btnCheckLocation setTitle:@"Check locations" forState:UIControlStateNormal]; - self.locationUrl = [dictionary valueForKey:@"bankUrl"]; - if ([[dictionary valueForKey:@"nearestBranch"] class] != [NSNull class]) { - if([dictionary valueForKey:@"nearestBranch"][@"address"] != nil) { - if ([[[dictionary valueForKey:@"nearestBranch"] valueForKey:@"address"] length] > 0) { - [self.btnCheckLocation setHidden:YES]; - }} - } - } - - self.lblBankName.text = bankName; - self.lblPhone.text = [NSString stringWithFormat:@"Location's phone #: %@",phoneNo]; - self.lblAccountName.text = [NSString stringWithFormat:@"Name on Account: %@",accountName]; - self.lblAccountNo.text = [NSString stringWithFormat:@"Account #: %@",accountNo]; - self.lblCashDeposit.text = [NSString stringWithFormat:@"Cash to Deposit: $%.02f",depositAmount]; - - NSNumber *num = [NSNumber numberWithDouble:([totalDash doubleValue] * 1000000)]; - self.lblInstructions.text = [NSString stringWithFormat:@"You are ordering: %@ %@ (%@ %@)",totalDash,WOCCurrencySpecial, [self getCryptoPrice:num],WOCCurrencySymbolMinor]; - - NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; - formatter.dateFormat = API_DATE_FORMAT; - NSDate *local = [formatter dateFromString:depositDue]; - APILog(@"local: %@",local); - - formatter.dateFormat = LOCAL_DATE_FORMAT; - NSString *localTime = [formatter stringFromDate:local]; - APILog(@"localTime: %@",localTime); - self.dueTime = localTime; - - NSString *currentTime = [formatter stringFromDate:[NSDate date]]; - APILog(@"currentTime UTC : %@",currentTime); - - NSMutableAttributedString *timeString = [self dateDiffrenceBetweenTwoDates:currentTime endDate:localTime]; - NSMutableAttributedString *dueString = [[NSMutableAttributedString alloc] initWithString:@"Deposit Due: "]; - [dueString appendAttributedString:timeString]; - - self.lblDepositDue.attributedText = dueString; - - self.timer = [[NSTimer alloc] init]; - self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(checkTime) userInfo:nil repeats:YES]; - - if ([[dictionary valueForKey:@"account"] length] > 16) { - NSArray *accountArr = [NSJSONSerialization JSONObjectWithData:[[dictionary valueForKey:@"account"] dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:nil]; - NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"displaySort" ascending:YES comparator:^NSComparisonResult(id obj1, id obj2) { - float aObj1 = [(NSString *)obj1 floatValue]; - float aObj2 = [(NSString *)obj2 floatValue]; - return aObj1 > aObj2; - }]; - - NSArray *accountArray = [accountArr sortedArrayUsingDescriptors:@[sort]]; - if (accountArray.count > 2) { - self.lblPhone.text = [NSString stringWithFormat:@"Name: %@ %@",REMOVE_NULL_VALUE([[accountArray objectAtIndex:0] valueForKey:@"value"]), REMOVE_NULL_VALUE([[accountArray objectAtIndex:2] valueForKey:@"value"])]; - } - - if (accountArray.count > 3) { - self.lblAccountName.text = [NSString stringWithFormat:@"Country of Birth: %@",REMOVE_NULL_VALUE([[accountArray objectAtIndex:3] valueForKey:@"value"])]; - } - - if (accountArray.count > 1) { - self.lblAccountNo.text = [NSString stringWithFormat:@"Pick-up State: %@",REMOVE_NULL_VALUE([[accountArray objectAtIndex:1] valueForKey:@"value"])]; - } - } -} - -- (void)checkTime { - - if (self.minutes > 0) { - NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; - formatter.dateFormat = LOCAL_DATE_FORMAT; - NSString *currentTime = [formatter stringFromDate:[NSDate date]]; - NSMutableAttributedString *timeString = [self dateDiffrenceBetweenTwoDates:currentTime endDate:self.dueTime]; - NSMutableAttributedString *dueString = [[NSMutableAttributedString alloc] initWithString:@"Deposit Due: "]; - [dueString appendAttributedString:timeString]; - self.lblDepositDue.attributedText = dueString; - } - else { - self.lblDepositDue.text = @"Deposit Due: time expired"; - [self stopTimer]; - } -} - -- (NSMutableAttributedString*)dateDiffrenceBetweenTwoDates:(NSString*)startDate endDate:(NSString*)endDate { - NSMutableAttributedString *timeLeft = [[NSMutableAttributedString alloc] init]; - - NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; - formatter.dateFormat = LOCAL_DATE_FORMAT; - - NSDate *startDateT = [formatter dateFromString:startDate]; - NSDate *endDateT = [formatter dateFromString:endDate]; - - NSDateComponents *components; - - NSInteger days; - NSInteger hours; - NSInteger minutes = 0; - NSInteger seconds = 0; - - components = [[NSCalendar currentCalendar] components:NSCalendarUnitDay fromDate:startDateT toDate:endDateT options:0]; - days = [components day]; - components = [[NSCalendar currentCalendar] components:NSCalendarUnitHour fromDate:startDateT toDate:endDateT options:0]; - hours = [components hour]; - components = [[NSCalendar currentCalendar] components:NSCalendarUnitMinute fromDate:startDateT toDate:endDateT options:0]; - minutes = [components minute]; - components = [[NSCalendar currentCalendar] components:NSCalendarUnitSecond fromDate:startDateT toDate:endDateT options:0]; - seconds = [components second]; - NSString *secondsInString = [NSString stringWithFormat:@"%ld ", (long)minutes]; - - self.minutes = [secondsInString intValue]; - - NSInteger daysN = (int) (floor(seconds / (3600 * 24))); - if(daysN) seconds -= daysN * 3600 * 24; - - NSInteger hoursN = (int) (floor(seconds / 3600)); - if(hoursN) seconds -= hoursN * 3600; - - NSInteger minutesN = (int) (floor(seconds / 60)); - if(minutesN) seconds -= minutesN * 60; - - if(daysN) { - [timeLeft appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%ld Days ", (long)daysN*1]]]; - } - - if(hoursN) { - [timeLeft appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat: @"%ld Hour ", (long)hoursN*1]]]; - } - - if(minutesN) { - [timeLeft appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat: @"%ld Minutes ",(long)minutesN*1]]]; - } - - return timeLeft; -} - -// MARK: - API - -- (void)createHold:(NSString*)offerId phoneNo:(NSString*)phone { - - dispatch_async(dispatch_get_main_queue(), ^{ - MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; - - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; - NSDictionary *params ; - - if (token != nil && (![token isEqualToString:@"(null)"])) { - params = @{ - WOCApiBodyOffer: [NSString stringWithFormat:@"%@==",offerId], - WOCApiBodyJsonParameter:@"YES" - }; - } - else { - params = @{ - WOCApiBodyOffer: [NSString stringWithFormat:@"%@==",offerId], - WOCApiBodyPhoneNumber: phone, - WOCApiBodyDeviceName: WOCApiBodyDeviceName_IOS, - WOCApiBodyDeviceCode: deviceCode, - WOCApiBodyJsonParameter:@"YES" - }; - } - - [[APIManager sharedInstance] createHold:params response:^(id responseDict, NSError *error) { - dispatch_async(dispatch_get_main_queue(), ^{ - [hud hideAnimated:YES]; - }); - - if (error == nil) { - NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; - if ([responseDictionary valueForKey:WOCApiResponseToken] != nil && (![[responseDictionary valueForKey:WOCApiResponseToken] isEqualToString:@"(null)"])) - { - [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiResponseToken]] forKey:WOCUserDefaultsAuthToken]; - [self.defaults setValue:phone forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - } - - NSString *holdId = [NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiResponseId]]; - self.holdId = holdId; - - NSString *purchaseCode = [NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiResponsePurchaseCde]]; - self.purchaseCode = purchaseCode; - - [self captureHold:purchaseCode holdId:holdId]; - } - else if (error.code == 403 ) { - [self getHold]; - } - else if (error.code == 500 ) { - [self pushToBuyingSummary]; - } - }]; - }); -} - -- (void)getHold { - [[APIManager sharedInstance] getHold:^(id responseDict, NSError *error) { - if (error == nil) { - APILog(@"Hold with Hold Id: %@.",responseDict); - - if ([responseDict isKindOfClass:[NSArray class]]) { - NSArray *holdArray = (NSArray*)responseDict; - if (holdArray.count > 0) { - NSUInteger count = holdArray.count; - NSUInteger activeHodCount = 0; - - for (int i = 0; i < holdArray.count; i++) { - count -= count; - - NSDictionary *holdDict = [holdArray objectAtIndex:i]; - NSString *holdId = [holdDict valueForKey:WOCApiResponseId]; - NSString *holdStatus = [holdDict valueForKey:WOCApiResponseHoldsStatus]; - if (holdStatus != nil) { - if ([holdStatus isEqualToString:@"AC"]) { - if (holdId) { - activeHodCount = activeHodCount + 1; - [self deleteHold:holdId count:count]; - } - } - } - else { - if (holdId) { - activeHodCount = activeHodCount + 1; - [self deleteHold:holdId count:count]; - } - } - } - - if (activeHodCount == 0 ) { - [self getOrderList]; - } - } - else { - [self getOrderList]; - } - } - else { - [self getOrderList]; - } - } - else { - [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; - } - }]; -} - -- (void)deleteHold:(NSString*)holdId count:(NSUInteger)count { - - NSDictionary *params = @{ - }; - - [[APIManager sharedInstance] deleteHold:holdId response:^(id responseDict, NSError *error) { - - if (error == nil) { - APILog(@"Hold deleted."); - - NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; - [self createHold:self.offerId phoneNo:phoneNo]; - } - else { - [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; - } - }]; -} - -- (void)captureHold:(NSString*)purchaseCode holdId:(NSString*)holdId { - MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; - - NSDictionary *params = @{ - WOCApiBodyVerificationCode: purchaseCode, - WOCApiBodyJsonParameter: @"YES" - }; - - [[APIManager sharedInstance] captureHold:params holdId:self.holdId response:^(id responseDict, NSError *error) { - dispatch_async(dispatch_get_main_queue(), ^{ - [hud hideAnimated:YES]; - }); - - if (error == nil) { - if ([responseDict isKindOfClass:[NSArray class]]) - { - NSArray *response = [[NSArray alloc] initWithArray:(NSArray*)responseDict]; - if (response.count > 0) { - if ([[response objectAtIndex:0] isKindOfClass:[NSDictionary class]]) { - [self updateData:[response objectAtIndex:0]]; - } - } - } - } - else { - [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; - [self.navigationController popViewControllerAnimated:YES]; - } - }]; -} - -- (void)confirmDeposit { - MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; - - if (self.orderId != nil) { - - [[APIManager sharedInstance] confirmDeposit:self.orderId response:^(id responseDict, NSError *error) { - dispatch_async(dispatch_get_main_queue(), ^{ - [hud hideAnimated:YES]; - }); - - if (error == nil) { - [self stopTimer]; - [self pushToBuyingSummary]; - } - else { - - dispatch_async(dispatch_get_main_queue(), ^{ - if (error.userInfo != nil) { - if (error.userInfo[@"detail"] != nil) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self.navigationController.visibleViewController]; - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; - } - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; - } - }); - } - }]; - } -} - -- (void)cancelOrder { - - MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; - - if (self.orderId != nil) { - - [[APIManager sharedInstance] cancelOrder:self.orderId response:^(id responseDict, NSError *error) { - dispatch_async(dispatch_get_main_queue(), ^{ - [hud hideAnimated:YES]; - }); - - if (error == nil) { - [self stopTimer]; - [self backToMainView]; - } - else { - dispatch_async(dispatch_get_main_queue(), ^{ - if (error.userInfo != nil) { - if (error.userInfo[@"detail"] != nil) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self.navigationController.visibleViewController]; - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; - } - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; - } - }); - } - }]; - } -} - -// MARK: - IBAction - -- (IBAction)showMapClicked:(id)sender { - if (self.locationUrl != nil) { - if (![self.locationUrl hasPrefix:@"http"]) { - self.locationUrl = [NSString stringWithFormat:@"https://%@",self.locationUrl]; - } - - if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:self.locationUrl]]) { - [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.locationUrl] options:@{} completionHandler:^(BOOL success) { - APILog(@"URL opened."); - }]; - } - } - else { - // Your location from latitude and longitude - double latitude = [[self.defaults valueForKey:WOCUserDefaultsLocalLocationLatitude] doubleValue]; - double longitude = [[self.defaults valueForKey:WOCUserDefaultsLocalLocationLongitude] doubleValue]; - - NSString* directionsURL = [NSString stringWithFormat:@"http://maps.apple.com/?saddr=%f,%f&daddr=%f,%f", latitude, longitude, latitude, longitude]; - if ([[UIApplication sharedApplication] respondsToSelector:@selector(openURL:options:completionHandler:)]) { - [[UIApplication sharedApplication] openURL:[NSURL URLWithString: directionsURL] options:@{} completionHandler:^(BOOL success) {}]; - } - } -} - -- (IBAction)depositFinishedClicked:(id)sender { - [self showDepositAlert]; -} - -- (IBAction)cancelOrderClicked:(id)sender { - [self showCancelOrderAlert]; -} - -- (IBAction)wallOfCoinsClicked:(id)sender { - [self openSite:[NSURL URLWithString:@"https://wallofcoins.com"]]; -} - -- (IBAction)onSignOutButtonClick:(id)sender { - [self signOutWOC]; -} - -// MARK: - UITextView Delegate - -- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange { - if ([[URL scheme] isEqualToString:@"https"]) { - [self openSite:URL]; - return NO; - } - return YES; -} - -@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingPasswordViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingPasswordViewController.h deleted file mode 100644 index ae68f8ec..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingPasswordViewController.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// WOCPasswordViewController.h -// Wallofcoins -// -// Created by Genitrust on 27/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import -#import "WOCBaseViewController.h" -@interface WOCSellingPasswordViewController : WOCBaseViewController - -@property (strong, nonatomic) NSString *offerId; -@property (strong, nonatomic) NSString *phoneNo; - -@property (weak, nonatomic) IBOutlet UIView *mainView; -@property (weak, nonatomic) IBOutlet UILabel *WOCLinkLabel; -@property (weak, nonatomic) IBOutlet UIButton *WOCLinkButton; -@property (weak, nonatomic) IBOutlet UITextField *passwordTextField; -@property (weak, nonatomic) IBOutlet UIButton *loginButton; -@property (weak, nonatomic) IBOutlet UIButton *forgotPasswordButton; - -- (IBAction)onLinkButtonClick:(id)sender; -- (IBAction)onLoginButtonClick:(id)sender; -- (IBAction)onForgotPasswordButtonClick:(id)sender; -- (IBAction)onCloseButtonClick:(id)sender; - -@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingPasswordViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingPasswordViewController.m deleted file mode 100644 index cb5aa4ff..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingPasswordViewController.m +++ /dev/null @@ -1,218 +0,0 @@ -// -// WOCPasswordViewController.m -// Wallofcoins -// -// Created by Genitrust on 27/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import "WOCSellingPasswordViewController.h" -#import "WOCSellingWizardConfirmCodeViewController.h" -#import "APIManager.h" -#import "WOCConstants.h" -#import "WOCAlertController.h" -#import "MBProgressHUD.h" - -@interface WOCSellingPasswordViewController () - -@end - -@implementation WOCSellingPasswordViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - - self.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7]; - - self.mainView.layer.cornerRadius = 3.0; - self.mainView.layer.masksToBounds = YES; - - [self setShadowOnButton:self.loginButton]; - [self setShadowOnButton:self.forgotPasswordButton]; - - NSMutableAttributedString *titleString = [[NSMutableAttributedString alloc] initWithString:self.WOCLinkButton.titleLabel.text]; - [titleString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(29, 13)]; - [titleString addAttribute:NSForegroundColorAttributeName value:[UIColor darkGrayColor] range:NSMakeRange(29, 13)]; - [self.WOCLinkButton setAttributedTitle:titleString forState:UIControlStateNormal]; -} - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -// MARK: - API - -- (void)login:(NSString*)phoneNo password:(NSString*)password { - NSDictionary *params = @{ - WOCApiBodyPassword: password, - WOCApiBodyJsonParameter: @"YES" - }; - - [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDict, NSError *error) { - if (error == nil) { - NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; - [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults synchronize]; - [self storeDeviceInfoLocally]; - - [self getDeviceId:phoneNo]; - } - else { - dispatch_async(dispatch_get_main_queue(), ^{ - if (error.userInfo != nil) { - if (error.userInfo[@"detail"] != nil) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self]; - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self]; - } - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self]; - } - }); - } - }]; -} - -- (void)registerDevice:(NSString*)phoneNo { - MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; - - NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - - NSDictionary *params = @{ - WOCApiBodyName: WOCApiBodyDeviceName_IOS, - WOCApiBodyCode: deviceCode, - WOCApiBodyJsonParameter:@"YES" - }; - - [[APIManager sharedInstance] registerDevice:params response:^(id responseDict, NSError *error) { - dispatch_async(dispatch_get_main_queue(), ^(void) { - [hud hideAnimated:YES]; - }); - - if (error == nil) { - NSDictionary *response = (NSDictionary*)responseDict; - if (response.count > 0) { - NSString *deviceId = [NSString stringWithFormat:@"%@",[response valueForKey:WOCApiResponseId]]; - [self authorize:phoneNo deviceId:deviceId]; - } - } - else { - [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; - } - }]; -} - -- (void)getDeviceId:(NSString*)phoneNo { - dispatch_async(dispatch_get_main_queue(), ^(void){ - MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; - - [[APIManager sharedInstance] getDevice:^(id responseDict, NSError *error) { - dispatch_async(dispatch_get_main_queue(), ^(void){ - [hud hideAnimated:YES]; - }); - - if (error == nil) { - if ([responseDict isKindOfClass:[NSArray class]]) { - NSArray *response = (NSArray*)responseDict; - if (response.count > 0) { - NSDictionary *dictionary = [response lastObject]; - NSString *deviceId = [NSString stringWithFormat:@"%@",[dictionary valueForKey:@"id"]]; - - if (deviceId.length > 0 && (![deviceId isEqualToString:@"(null)"])) { - [self.defaults setValue:deviceId forKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - [self authorize:phoneNo deviceId:deviceId]; - } - } - else { - [self registerDevice:phoneNo]; - } - } - else { - [self registerDevice:phoneNo]; - } - } - else { - [self registerDevice:phoneNo]; - //[[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; - } - }]; - }); -} - -- (void)authorize:(NSString*)phoneNo deviceId:(NSString*)deviceId { - - MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; - - NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; - - NSDictionary *params = @{ - WOCApiBodyDeviceCode: deviceCode, - WOCApiBodyDeviceId: deviceId, - WOCApiBodyJsonParameter: @"YES" - }; - - [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDict, NSError *error) { - dispatch_async(dispatch_get_main_queue(), ^(void){ - [hud hideAnimated:YES]; - }); - - if (error == nil) { - NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; - [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiResponseDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - [self storeDeviceInfoLocally]; - - dispatch_async(dispatch_get_main_queue(), ^{ - [self dismissViewControllerAnimated:YES completion:nil]; - //move to step 8 - [[NSNotificationCenter defaultCenter] postNotificationName:WOCNotificationObserverNameBuyDashStep8 object:phoneNo]; - }); - } - else { - dispatch_async(dispatch_get_main_queue(), ^{ - - [self registerDevice:phoneNo]; - }); - } - }]; -} -// MARK: - IBAction - -- (IBAction)onLinkButtonClick:(id)sender { - NSURL *url = [NSURL URLWithString:@"https://wallofcoins.com/"]; - if ([[UIApplication sharedApplication] canOpenURL:url]) { - [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; - } -} - -- (IBAction)onLoginButtonClick:(id)sender { - NSString *password = [self.passwordTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; - if ([password length] > 0) { - [self login:self.phoneNo password:password]; - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter password." viewController:self.navigationController.visibleViewController]; - } -} - -- (IBAction)onForgotPasswordButtonClick:(id)sender { - NSURL *url = [NSURL URLWithString:@"https://wallofcoins.com/en/forgotPassword/"]; - if ([[UIApplication sharedApplication] canOpenURL:url]) { - [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; - } -} - -- (IBAction)onCloseButtonClick:(id)sender { - [self dismissViewControllerAnimated:YES completion:nil]; -} - -@end - diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSignInViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSignInViewController.h deleted file mode 100644 index 88465203..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSignInViewController.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// WOCSellingWizardOfferListViewController.h -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import -#import "WOCBaseViewController.h" -@interface WOCSellingSignInViewController : WOCBaseViewController - -@property (strong, nonatomic) NSString *discoveryId; -@property (strong, nonatomic) NSString *amount; -@property (weak, nonatomic) IBOutlet UIButton *signupButton; -@property (weak, nonatomic) IBOutlet UIButton *sighInButton; - -@property (weak, nonatomic) IBOutlet UILabel *instructionLabel; -@property (weak, nonatomic) IBOutlet UITableView *numberListTableView; - -- (IBAction)onExistingAccoutButtonClick:(id)sender; -- (IBAction)onSignUpButtonClick:(id)sender; - -@property (weak, nonatomic) IBOutlet NSLayoutConstraint *tableHeighConstrain; - -@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSignInViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSignInViewController.m deleted file mode 100644 index 07fe83b9..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSignInViewController.m +++ /dev/null @@ -1,260 +0,0 @@ -// -// WOCSellingWizardOfferListViewController.m -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import "WOCSellingSignInViewController.h" -#import "WOCSellingWizardInputPhoineNumberViewController.h" -#import "WOCSellingInstructionsViewController.h" -#import "WOCSellingSummaryViewController.h" -#import "BRRootViewController.h" -#import "BRAppDelegate.h" -#import "WOCOfferCell.h" -#import "APIManager.h" -#import "BRWalletManager.h" -#import "WOCAlertController.h" -#import "MBProgressHUD.h" -#import "WOCSellingWizardHomeViewController.h" -#import "WOCSellingSingUpViewController.h" - -@interface WOCSellingSignInViewController () - -@property (strong, nonatomic) NSArray *offers; -@property (assign, nonatomic) BOOL incremented; - -@end - -@implementation WOCSellingSignInViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - - self.instructionLabel.text = [NSString stringWithFormat:@"Below are offers for at least $%@. You must click the ORDER button before you receive instructions to pay at the Cash Payment center.",self.amount]; - [self setShadowOnButton:self.signupButton]; - [self setShadowOnButton:self.signupButton]; -} - -- (void)viewWillAppear:(BOOL)animated { - [self getLocalDevices]; - self.title = @"SignIN"; -} - -- (void)getLocalDevices { - - if ([self.defaults objectForKey:WOCUserDefaultsLocalDeviceInfo] != nil) { - if ([[self.defaults objectForKey:WOCUserDefaultsLocalDeviceInfo] isKindOfClass:[NSDictionary class]]) { - NSMutableDictionary *deviceInfoDict = [NSMutableDictionary dictionaryWithDictionary:[self.defaults objectForKey:WOCUserDefaultsLocalDeviceInfo]]; - if (deviceInfoDict != nil) { - self.offers = deviceInfoDict.allKeys; - [self.numberListTableView reloadData]; - } - } - } -} - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -- (void)pushToStep7:(NSInteger)sender { - NSIndexPath *indexPath = [NSIndexPath indexPathForRow:sender inSection:0]; - NSString *phoneNumber = self.offers[indexPath.row]; - APILog(@"phoneNumber = %@",phoneNumber); - - [self.defaults setObject:phoneNumber forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults synchronize]; - [self refereshToken]; - [self performSelector:@selector(backToMainView) withObject:nil afterDelay:2.0]; -} - -// MARK: - API -- (void)getOffers { - if (self.discoveryId != nil && [self.discoveryId length] > 0) { - [[APIManager sharedInstance] discoveryInputs:self.discoveryId response:^(id responseDict, NSError *error) { - if (error == nil) { - NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; - - if ([[responseDictionary valueForKey:@"singleDeposit"] isKindOfClass:[NSArray class]]) { - NSArray *offersArray = [[NSArray alloc] initWithArray:(NSArray*)[responseDictionary valueForKey:@"singleDeposit"]]; - self.offers = [[NSArray alloc] initWithArray:offersArray]; - - if ([[responseDictionary valueForKey:@"incremented"] boolValue]) { - self.incremented = true; - self.instructionLabel.text = [NSString stringWithFormat:@"Below are offers for at least $%@. You must click the ORDER button before you receive instructions to pay at the Cash Payment center.",self.amount]; - } - else { - self.incremented = false; - self.instructionLabel.text = [NSString stringWithFormat:@"Below are offers for $%@. You must click the ORDER button before you receive instructions to pay at the Cash Payment center.",self.amount]; - } - } - [self.numberListTableView reloadData]; - } - else { - dispatch_async(dispatch_get_main_queue(), ^{ - if (error.userInfo != nil) { - if (error.userInfo[@"detail"] != nil) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self.navigationController.visibleViewController]; - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; - } - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; - } - }); - } - }]; - } -} - -- (void)getOrders:(NSInteger)sender { - MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; - - NSDictionary *params = @{ - }; - - [[APIManager sharedInstance] getOrders:nil response:^(id responseDict, NSError *error) { - - dispatch_async(dispatch_get_main_queue(), ^(void){ - [hud hideAnimated:YES]; - }); - - if (error == nil) { - - if ([responseDict isKindOfClass:[NSArray class]]) { - - NSArray *orders = [[NSArray alloc] initWithArray:(NSArray*)responseDict]; - - if (orders.count > 0) { - NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; - NSPredicate *wdvPredicate = [NSPredicate predicateWithFormat:@"status == 'WD'"]; - NSArray *wdArray = [orders filteredArrayUsingPredicate:wdvPredicate]; - NSDictionary *orderDict = (NSDictionary*)[orders objectAtIndex:0]; - NSString *status = [NSString stringWithFormat:@"%@",[orderDict valueForKey:@"status"]]; - - if ([status isEqualToString:@"WD"]) { - WOCSellingInstructionsViewController *sellingInstructionsViewController = [self getViewController:@"WOCSellingInstructionsViewController"]; - sellingInstructionsViewController.phoneNo = phoneNo; - sellingInstructionsViewController.isFromSend = YES; - sellingInstructionsViewController.isFromOffer = NO; - sellingInstructionsViewController.orderDict = (NSDictionary*)[orders objectAtIndex:0]; - [self pushViewController:sellingInstructionsViewController animated:YES]; - } - else if (orders.count > 0) { - WOCSellingSummaryViewController *sellingSummaryViewController = [self getViewController:@"WOCSellingSummaryViewController"]; - sellingSummaryViewController.phoneNo = phoneNo; - sellingSummaryViewController.orders = orders; - sellingSummaryViewController.isFromSend = YES; - [self pushViewController:sellingSummaryViewController animated:YES]; - } - else { - [self backToMainView]; - } - } - else { - NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; - WOCSellingInstructionsViewController *sellingInstructionsViewController = [self getViewController:@"WOCSellingInstructionsViewController"]; - sellingInstructionsViewController.phoneNo = phoneNo; - sellingInstructionsViewController.isFromSend = NO; - sellingInstructionsViewController.isFromOffer = YES; - NSIndexPath *indexPath = [NSIndexPath indexPathForRow:sender inSection:0]; - NSDictionary *offerDict = self.offers[indexPath.row]; - sellingInstructionsViewController.offerId = [NSString stringWithFormat:@"%@",[offerDict valueForKey:WOCApiResponseId]]; - [self pushViewController:sellingInstructionsViewController animated:YES]; - } - } - else { - NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; - WOCSellingInstructionsViewController *sellingInstructionsViewController = [self getViewController:@"WOCSellingInstructionsViewController"]; - sellingInstructionsViewController.phoneNo = phoneNo; - sellingInstructionsViewController.isFromSend = NO; - sellingInstructionsViewController.isFromOffer = YES; - NSIndexPath *indexPath = [NSIndexPath indexPathForRow:sender inSection:0]; - NSDictionary *offerDict = self.offers[indexPath.row]; - sellingInstructionsViewController.offerId = [NSString stringWithFormat:@"%@",[offerDict valueForKey:WOCApiResponseId]]; - [self pushViewController:sellingInstructionsViewController animated:YES]; - } - } - else { - [self pushToStep1]; - dispatch_async(dispatch_get_main_queue(), ^{ - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Token expired." viewController:self]; - }); - } - }]; -} - -- (void)pushToStep1 { - [self backToMainView]; -} -// MARK: - IBAction -- (void)signInPhoneClicked:(UIButton *)sender { - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - if (token != nil && (![token isEqualToString:@"(null)"])) { - [self getOrderList]; - } - else { - [self pushToStep7:[sender tag]]; - } -} - -- (IBAction)onExistingAccoutButtonClick:(id)sender { - WOCSellingWizardInputPhoineNumberViewController *sellingWizardInputPhoneNumberViewController = [self getViewController:@"WOCSellingWizardInputPhoineNumberViewController"]; - sellingWizardInputPhoneNumberViewController.isForLoginOny = YES; - [self pushViewController:sellingWizardInputPhoneNumberViewController animated:YES]; -} -- (IBAction)onSignUpButtonClick:(id)sender { - - WOCSellingSingUpViewController *singUpViewController = [self getViewController:@"WOCSellingSingUpViewController"]; - [self pushViewController:singUpViewController animated:YES]; - - //NSURL *url = [NSURL URLWithString:@"https://wallofcoins.com/signup/"]; - //if ([[UIApplication sharedApplication] canOpenURL:url]) { - // [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; - //} -} - -- (IBAction)checkLocationClicked:(id)sender { - - NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[sender tag] inSection:0]; - NSDictionary *offerDict = self.offers[indexPath.row]; - if (![[offerDict valueForKey:@"bankLocationUrl"] isEqual:[NSNull null]]) { - NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",[offerDict valueForKey:@"bankLocationUrl"]]]; - if ([[UIApplication sharedApplication] canOpenURL:url]) { - [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) { - APILog(@"URL opened!"); - }]; - } - } -} - -// MARK: - UITableView DataSource - -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return self.offers.count; -} - -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - WOCOfferCell *cell = [tableView dequeueReusableCellWithIdentifier:@"offerCell"]; - cell.backgroundColor = [UIColor clearColor]; - NSString *phoneNumber = self.offers[indexPath.row]; - [cell.orderButton setTitle:[NSString stringWithFormat:@"SIGN IN: %@",phoneNumber] forState:UIControlStateNormal]; - [cell.orderButton setTitle:@"" forState:UIControlStateSelected]; - [cell.orderButton addTarget:self action:@selector(signInPhoneClicked:) forControlEvents:UIControlEventTouchUpInside]; - cell.orderButton.tag = indexPath.row; - - return cell; -} - -// MARK: - UITableView Delegate -- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - return 50.0; -} - -@end - diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSingUpViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSingUpViewController.h deleted file mode 100644 index 49456679..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSingUpViewController.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// WOCSellingSingUpViewController.h -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import -#import "WOCBaseViewController.h" - -// Enter Phone Number Screen -@interface WOCSellingSingUpViewController : WOCBaseViewController - -@property (strong, nonatomic) NSString *offerId; -@property (strong, nonatomic) NSString *emailId; -@property (assign, nonatomic) BOOL isActiveHoldChecked; -@property (assign, nonatomic) BOOL isForLoginOny; -@property (weak, nonatomic) IBOutlet UIButton *nextButton; -@property (weak, nonatomic) IBOutlet UITextField *countryCodeTextfield; -@property (weak, nonatomic) IBOutlet UITextField *phoneNumberTextfield; -@property (weak, nonatomic) IBOutlet UITextField *emailTextfield; -@property (weak, nonatomic) IBOutlet UITextField *confirmEmailTextfield; -@property (weak, nonatomic) IBOutlet UITextField *passwordTextfield; - -- (IBAction)onNextButtonClick:(id)sender; - -@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSingUpViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSingUpViewController.m deleted file mode 100644 index 14e3b282..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSingUpViewController.m +++ /dev/null @@ -1,741 +0,0 @@ -// -// WOCSellingWizardInputPhoineNumberViewController.m -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import "WOCSellingSingUpViewController.h" -#import "WOCSellingWizardConfirmCodeViewController.h" -#import "WOCSellingInstructionsViewController.h" -#import "WOCSellingSummaryViewController.h" -#import "WOCPasswordViewController.h" -#import "BRRootViewController.h" -#import "BRAppDelegate.h" -#import "APIManager.h" -#import "WOCConstants.h" -#import "WOCAlertController.h" -#import "MBProgressHUD.h" -#import "WOCHoldIssueViewController.h" -#import "WOCSellingWizardHomeViewController.h" -#import "WOCSellingCreatePasswordViewController.h" - -@interface WOCSellingSingUpViewController () - -@property (strong, nonatomic) NSArray *countries; -@property (strong, nonatomic) UIPickerView *pickerView; -@property (strong, nonatomic) NSString *countryCode; -@property (strong, nonatomic) NSString *purchaseCode; -@property (strong, nonatomic) NSString *holdId; -@property (strong, nonatomic) NSString *deviceName; -@end - -@implementation WOCSellingSingUpViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - - [self setShadowOnButton:self.nextButton]; - - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(openBuyDashStep8:) name:WOCNotificationObserverNameBuyDashStep8 object:nil]; - - self.pickerView = [[UIPickerView alloc] init]; - self.pickerView.delegate = self; - self.pickerView.dataSource = self; - self.countryCodeTextfield.inputView = self.pickerView; - - [self loadJSON]; -} - -- (void)loadJSON { - // Retrieve local JSON file called example.json - NSString *filePath = [[NSBundle mainBundle] pathForResource:@"countries" ofType:@"json"]; - - // Load the file into an NSData object called JSONData - NSError *error = nil; - NSData *JSONData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:&error]; - - // Create an Objective-C object from JSON Data - NSDictionary *countriesDict = [NSJSONSerialization JSONObjectWithData:JSONData options:NSJSONReadingMutableContainers error:nil]; - NSArray *countries = [countriesDict valueForKey:@"countries"]; - - self.countries = countries; - if (self.countries.count > 0) { - self.countryCodeTextfield.text = [NSString stringWithFormat:@"%@ (%@)",self.countries[0][@"name"],self.countries[0][@"code"]]; - self.countryCode = [NSString stringWithFormat:@"%@",self.countries[0][@"code"]]; - } - - [self.pickerView reloadAllComponents]; -} - -- (void)openBuyDashStep8:(NSNotification*)notification { - - NSString *phoneNo = [NSString stringWithFormat:@"%@",notification.object]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults synchronize]; - - [self createHoldAfterAuthorize:phoneNo]; -} - -// MARK: - API - -- (void)checkPhone:(NSString*)phone code:(NSString*)countryCode { - - NSDictionary *params = @{ - }; - - NSString *phoneNo = [NSString stringWithFormat:@"%@%@",countryCode,phone]; - [self.defaults setObject:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults synchronize]; - - [[APIManager sharedInstance] authorizeDevice:nil phone:phoneNo response:^(id responseDict, NSError *error) { - - if (error == nil) { - NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; - if ([responseDictionary valueForKey:@"recentDeviceName"] != nil) { - self.deviceName = [responseDictionary valueForKey:@"recentDeviceName"]; - } - - if ([[responseDictionary valueForKey:@"availableAuthSources"] isKindOfClass:[NSArray class]]) { - NSArray *availableAuthSource = (NSArray*)[responseDictionary valueForKey:@"availableAuthSources"]; - if (availableAuthSource.count > 0) { - if ([[availableAuthSource objectAtIndex:0] isEqualToString:@"password"]) { - [self login:phoneNo password:self.passwordTextfield.text]; - } - else if ([[availableAuthSource objectAtIndex:0] isEqualToString:@"device"]) { - //[self createHoldAfterAuthorize:phoneNo]; - [self resetPassword]; - } - } - } - else if ([responseDictionary valueForKey:@"response"] != nil) { - if ([[responseDictionary valueForKey:@"response"] isEqualToString:@"error"]) { - [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults synchronize]; - [self resetPassword]; - } - } - } - else { - if ([error code] == 404 || [error code] == 0) { - //new number - [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults synchronize]; - [self registerUser]; - //[self createHold:phoneNo]; - } - else { - dispatch_async(dispatch_get_main_queue(), ^{ - if (error.userInfo != nil) { - if (error.userInfo[@"detail"] != nil) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self.navigationController.visibleViewController]; - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; - } - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; - } - }); - } - } - }]; -} - -- (void)login:(NSString*)phoneNo { - - NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; - NSString *deviceId = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceId]; - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - - NSDictionary *params = @{ - WOCApiBodyDeviceCode: deviceCode - }; - - if (deviceId != nil) { - - params = @{ - WOCApiBodyDeviceCode: deviceCode, - WOCApiBodyDeviceId: deviceId, - WOCApiBodyJsonParameter: @"YES" - }; - - [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDict, NSError *error) { - - NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; - if (error == nil) { - if (responseDictionary != nil) { - [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - [self storeDeviceInfoLocally]; - [self backToMainView]; - } - } - else { - - [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - - BOOL isNewPhone = YES; - if (error.code == 400) { - if (error.userInfo != nil) { - NSString *errorDetail = error.userInfo[@"detail"]; - if (errorDetail != nil) { - if ([errorDetail isEqualToString:@"Unable to authorize your phone number. Password may be incorrect."]) { - isNewPhone = NO; - } - } - } - } - if (isNewPhone) { - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults synchronize]; - [self backToMainView]; - } - else { - [self openHoldIssueVC]; - } - } - }]; - } -} - -- (void)createHold:(NSString*)phoneNo { - - if (!self.isForLoginOny) { - MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; - - NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - - NSDictionary *params; - - if (token != nil && (![token isEqualToString:@"(null)"])) { - params = @{ - WOCApiBodyOffer: [NSString stringWithFormat:@"%@==",self.offerId], - WOCApiBodyJsonParameter:@"YES" - }; - } - else { - params = @{ - WOCApiBodyOffer: [NSString stringWithFormat:@"%@==",self.offerId], - WOCApiBodyPhoneNumber: phoneNo, - WOCApiBodyDeviceName: WOCApiBodyDeviceName_IOS, - WOCApiBodyDeviceCode: deviceCode, - WOCApiBodyJsonParameter:@"YES" - }; - - if (self.emailId != nil && self.emailId.length > 0) { - NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:params]; - [dict setObject:self.emailId forKey:WOCApiBodyEmail]; - params = (NSDictionary*)dict; - } - } - - [[APIManager sharedInstance] createHold:params response:^(id responseDict, NSError *error) { - dispatch_async(dispatch_get_main_queue(), ^(void) { - [hud hideAnimated:YES]; - }); - - if (error == nil) { - NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; - if ([responseDictionary valueForKey:WOCApiResponseToken] != nil && (![[responseDictionary valueForKey:WOCApiResponseToken] isEqualToString:@"(null)"])) { - [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiResponseToken]] forKey:WOCUserDefaultsAuthToken]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - [self storeDeviceInfoLocally]; - } - - NSString *holdId = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([responseDictionary valueForKey:WOCApiResponseId])]; - self.holdId = holdId; - - NSString *purchaseCode = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([responseDictionary valueForKey:WOCApiResponsePurchaseCde])]; - if (![purchaseCode isKindOfClass:[NSNull class]]) { - self.purchaseCode = purchaseCode; - } - else { - self.purchaseCode = @""; - } - WOCSellingWizardConfirmCodeViewController *confirmCodeViewController = [self getViewController:@"WOCSellingWizardConfirmCodeViewController"]; - confirmCodeViewController.phoneNo = phoneNo; - confirmCodeViewController.offerId = self.offerId; - confirmCodeViewController.purchaseCode = self.purchaseCode; - confirmCodeViewController.deviceCode = deviceCode; - confirmCodeViewController.emailId = self.emailId; - confirmCodeViewController.holdId = self.holdId; - [self pushViewController:confirmCodeViewController animated:YES]; - } - else if (error.code == 403 ) { - [self resolveActiveHoldIssue:phoneNo]; - } - else if (error.code == 401 ) { - [self registerDevice:phoneNo]; - } - }]; - } - else { - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - if (token != nil && (![token isEqualToString:@"(null)"])) { - [self getOrderList]; - } - else { - UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Error" message:@"Please select an offer and then try to register/login with app." preferredStyle:UIAlertControllerStyleAlert]; - - UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { - [self backToMainView]; - }]; - [alert addAction:okAction]; - [self presentViewController:alert animated:YES completion:nil]; - } - } -} - -- (void)resolveActiveHoldIssue:(NSString*)phoneNo { - - if (!self.isActiveHoldChecked) { - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - if (token != nil && (![token isEqualToString:@"(null)"])) { - /*you receive Status 403 from POST /api/v1/holds/ - IF YOU HAVE a token or the deviceId/deviceCode, login with that device -- you will use the token to get a list of holds so that you can cancel the holds. IF THERE ARE NO HOLDS, then you will bring the user to the Buy Summary, where they will see their latest WD orders. - */ - self.isActiveHoldChecked = YES; - [self getHold]; - } - else { - NSString *deviceID = [self getDeviceIDFromPhoneNumber:phoneNo]; - if (deviceID.length > 0 && (![deviceID isEqualToString:@"(null)"])) { - [self.defaults setObject:deviceID forKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - [self login:phoneNo]; - } - else { - [self openHoldIssueVC]; - } - } - } -} - -- (void)openHoldIssueVC { - /* - IF YOU DO NOT HAVE the token or deviceId/deviceCode in local storage, then you will need to show a new view that says, "You already have an open hold or a pending order with Wall of Coins. Before you can create a new order, you must finish these orders." and then show a yellow button w/ blue text (just like the "BUY MORE {Crypto Currency} WITH CASH" button), and when they press that button, you will bring them to this website link: - https://wallofcoins.com/signin/1-2397776832/ - https://wallofcoins.com/signin/{phone_country_code}-{local_phone_number}/ - */ - NSString *txtPhone = [self.phoneNumberTextfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; - NSString *txtcountryCode = [self.countryCode stringByReplacingOccurrencesOfString:@"+" withString:@""]; - WOCHoldIssueViewController *aViewController = [self getViewController:@"WOCHoldIssueViewController"]; - aViewController.phoneNo = [NSString stringWithFormat:@"%@-%@",txtcountryCode,txtPhone]; - [self pushViewController:aViewController animated:YES]; -} - -- (void)resolvePandingOrderIssue { - - [self getOrderList]; -} - -- (void)getHold { - - [[APIManager sharedInstance] getHold:^(id responseDict, NSError *error) { - if (error == nil) { - APILog(@"Hold with Hold Id: %@.",responseDict); - if ([responseDict isKindOfClass:[NSArray class]]) { - NSArray *holdArray = (NSArray*)responseDict; - if (holdArray.count > 0) { - NSUInteger count = holdArray.count; - NSUInteger activeHodCount = 0; - - for (int i = 0; i < holdArray.count; i++) { - count -= count; - - NSDictionary *holdDict = [holdArray objectAtIndex:i]; - NSString *holdId = [holdDict valueForKey:WOCApiResponseId]; - NSString *holdStatus = [holdDict valueForKey:WOCApiResponseHoldsStatus]; - - if (holdStatus != nil) { - if ([holdStatus isEqualToString:@"AC"]) { - if (holdId) { - activeHodCount = activeHodCount + 1; - [self deleteHold:holdId count:count]; - } - } - } - else { - if (holdId) { - activeHodCount = activeHodCount + 1; - [self deleteHold:holdId count:count]; - } - } - } - - if (activeHodCount == 0 ) { - [self resolvePandingOrderIssue]; - } - } - else { - [self resolvePandingOrderIssue]; - } - } - else { - [self resolvePandingOrderIssue]; - } - } - else { - [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; - } - }]; -} - -- (void)deleteHold:(NSString*)holdId count:(NSUInteger)count { - - NSDictionary *params = @{ - }; - - [[APIManager sharedInstance] deleteHold:holdId response:^(id responseDict, NSError *error) { - if (error == nil) { - APILog(@"Hold deleted."); - - NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; - [self createHoldAfterAuthorize:phoneNo]; - } - }]; -} - -- (void)registerDevice:(NSString*)phoneNo { - - MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; - - NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - - NSDictionary *params = @{ - WOCApiBodyName: WOCApiBodyDeviceName_IOS, - WOCApiBodyCode: deviceCode, - WOCApiBodyJsonParameter:@"YES" - }; - - [[APIManager sharedInstance] registerDevice:params response:^(id responseDict, NSError *error) { - dispatch_async(dispatch_get_main_queue(), ^(void) { - [hud hideAnimated:YES]; - }); - - if (error == nil) { - NSDictionary *response = (NSDictionary*)responseDict; - if (response.count > 0) { - NSString *deviceId = [NSString stringWithFormat:@"%@",[response valueForKey:WOCApiResponseId]]; - [self authorize:phoneNo deviceId:deviceId]; - } - } - else { - - [self pushToStep1]; - [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; - } - }]; -} - -- (void)authorize:(NSString*)phoneNo deviceId:(NSString*)deviceId { - - NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - - NSDictionary *params = @{ - WOCApiBodyDeviceCode: deviceCode, - WOCApiBodyJsonParameter: @"YES" - }; - - if (deviceId != nil && (![deviceId isEqualToString:@"(null)"])) { - params = @{ - WOCApiBodyDeviceCode: deviceCode, - WOCApiBodyDeviceId: deviceId, - WOCApiBodyJsonParameter: @"YES" - }; - } - - [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDict, NSError *error) { - if (error == nil) { - - NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; - [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - - [self storeDeviceInfoLocally]; - [self backToMainView]; - //[self createHoldAfterAuthorize:phoneNo]; - } - else { - - [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults synchronize]; - [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; - } - }]; -} - -- (void)createHoldAfterAuthorize:(NSString*)phoneNo { - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - - if (token != nil && (![token isEqualToString:@"(null)"])) { - [self createHold:phoneNo]; - } - else { - NSString *deviceID = [self getDeviceIDFromPhoneNumber:phoneNo]; - if (deviceID != nil) { - [self.defaults setObject:deviceID forKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - [self login:phoneNo]; - } - else { - [self createHold:phoneNo]; - } - } -} - -// MARK: - IBAction -- (IBAction)onNextButtonClick:(id)sender { - - NSString *txtPhone = [self.phoneNumberTextfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; - - if ([self.countryCode length] == 0) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Select country code." viewController:self.navigationController.visibleViewController]; - } - else if ([txtPhone length] == 0) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter phone number." viewController:self.navigationController.visibleViewController]; - } - else if ([self.emailTextfield.text length] == 0) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter email number." viewController:self.navigationController.visibleViewController]; - } - else if ([self isValidEmail:self.emailTextfield.text] == 0) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter valid email number." viewController:self.navigationController.visibleViewController]; - } - else if ([self.passwordTextfield.text length] == 0) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter password number." viewController:self.navigationController.visibleViewController]; - } - else if (![self.emailTextfield.text isEqualToString:self.confirmEmailTextfield.text]) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter email and confirm email does not metched." viewController:self.navigationController.visibleViewController]; - } - else if ([txtPhone length] == 10) { - self.isActiveHoldChecked = NO; - [self checkPhone:txtPhone code:self.countryCode]; - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter valid phone number." viewController:self.navigationController.visibleViewController]; - } -} - -// MARK: - UIPickerView Delegates - -- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView { - return 1; -} - -- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component { - return self.countries.count; -} - -- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { - return [NSString stringWithFormat:@"%@ (%@)",self.countries[row][@"name"],self.countries[row][@"code"]]; -} - -- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { - self.countryCodeTextfield.text = [NSString stringWithFormat:@"%@ (%@)",self.countries[row][@"name"],self.countries[row][@"code"]]; - self.countryCode = [NSString stringWithFormat:@"%@",self.countries[row][@"code"]]; -} - -- (void)pushToStep1 { - [self storeDeviceInfoLocally]; - [self backToMainView]; -} - -- (void)registerUser { - - NSString *phoneNumber = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; - NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - - NSDictionary *params = @{ - WOCApiBodyPhoneNumber: phoneNumber, - WOCApiBodyEmail: self.emailTextfield.text, - WOCApiBodyPassword: self.passwordTextfield.text, - WOCApiBodyJsonParameter: @"YES" - }; - - [[APIManager sharedInstance] registerUser:params response:^(id responseDict, NSError *error) { - - NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; - if (error == nil) { - BOOL isError = NO; - - if (responseDictionary != nil) { - if ([responseDictionary valueForKey:@"response"] != nil) { - if ([[responseDictionary valueForKey:@"response"] isEqualToString:@"error"]) { - // Error - isError = YES; - } - } - } - - if (isError) { - [self openHoldIssueVC]; - } - else { - [self login:phoneNumber password:self.passwordTextfield.text]; - } - } - else { - [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - - BOOL isNewPhone = YES; - if (error.code == 400) { - if (error.userInfo != nil) { - NSString *errorDetail = error.userInfo[@"detail"]; - if (errorDetail != nil) { - if ([errorDetail isEqualToString:@"Unable to authorize your phone number. Password may be incorrect."]) { - isNewPhone = NO; - } - } - } - } - - if (isNewPhone) { - [self.defaults setValue:phoneNumber forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults synchronize]; - - [self registrationCompleted]; - } - else { - [self openHoldIssueVC]; - } - } - }]; -} - -- (void)resetPassword { - - NSString *phoneNumber = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; - - NSDictionary *params = @{ - @"password1": self.passwordTextfield.text, - @"password2": self.passwordTextfield.text, - WOCApiBodyJsonParameter: @"YES" - }; - - [[APIManager sharedInstance] resetPassword:params phone:phoneNumber response:^(id responseDict, NSError *error) { - - NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; - if (error == nil) { - if (responseDictionary != nil) { - if ([[responseDictionary valueForKey:@"response"] isEqualToString:@"error"]) { - // Error - [self openHoldIssueVC]; - } - else { - [self registrationCompleted]; - } - //[self login:self.txtEmail.text password:self.txtPasword.text]; - //[self createHoldAfterAuthorize:phoneNumber]; - } - } - else { - [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - - BOOL isNewPhone = YES; - if (error.code == 400) { - if (error.userInfo != nil) { - NSString *errorDetail = error.userInfo[@"detail"]; - if (errorDetail != nil) { - if ([errorDetail isEqualToString:@"Unable to authorize your phone number. Password may be incorrect."]) { - isNewPhone = NO; - } - } - } - } - if (isNewPhone) { - [self.defaults setValue:phoneNumber forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults synchronize]; - //[self createHoldAfterAuthorize:phoneNumber]; - [self registrationCompleted]; - } - else { - [self openHoldIssueVC]; - } - } - }]; -} - -- (void)login:(NSString*)phoneNo password:(NSString*)password { - NSDictionary *params = @{ - WOCApiBodyPassword: password, - WOCApiBodyJsonParameter: @"YES" - }; - - [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDictionary, NSError *error) { - if (error == nil) { - if (responseDictionary != nil) { - [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - [self registerDevice:phoneNo]; - [self backToMainView]; - } - } - else { - dispatch_async(dispatch_get_main_queue(), ^{ - if (error.userInfo != nil) { - if (error.userInfo[@"detail"] != nil) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self]; - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self]; - } - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self]; - } - }); - } - }]; -} - -- (void)registrationCompleted { - - NSString *phoneNumber = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; - NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; - - WOCSellingCreatePasswordViewController *createPasswordViewController = [self getViewController:@"WOCSellingCreatePasswordViewController"]; - - if (self.deviceName != nil) { - createPasswordViewController.deviceName = self.deviceName; - } - createPasswordViewController.offerId = self.offerId; - createPasswordViewController.purchaseCode = self.purchaseCode; - createPasswordViewController.deviceCode = deviceCode; - createPasswordViewController.emailId = self.emailId; - createPasswordViewController.holdId = self.holdId; - [self pushViewController:createPasswordViewController animated:YES]; - //[self login:phoneNumber]; -} -@end - diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSummaryViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSummaryViewController.h deleted file mode 100644 index 5e8d2ef7..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSummaryViewController.h +++ /dev/null @@ -1,25 +0,0 @@ -// -// WOCSellingSummaryViewController.h -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import -#import "WOCBaseViewController.h" -@interface WOCSellingSummaryViewController : WOCBaseViewController - -@property (strong, nonatomic) NSString *phoneNo; -@property (strong, nonatomic) NSArray *orders; -@property (assign, nonatomic) BOOL isFromSend; -@property (assign, nonatomic) BOOL isHideSuccessAlert; -@property (weak, nonatomic) IBOutlet UITextView *instructionTextField; -@property (weak, nonatomic) IBOutlet UILabel *instructionLabel; -@property (weak, nonatomic) IBOutlet UITableView *sellingSummaryTableView; -@property (weak, nonatomic) IBOutlet UIButton *buyMoreDashButton; - -- (IBAction)onBuyMoreDashButtonClick:(id)sender; -- (void)displayAlert; - -@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSummaryViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSummaryViewController.m deleted file mode 100644 index 01313916..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingSummaryViewController.m +++ /dev/null @@ -1,476 +0,0 @@ -// -// WOCSellingSummaryViewController.m -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#define WD @"WD" -#define WDV @"WDV" -#define RERR @"RERR" -#define DERR @"DERR" -#define RSD @"RSD" -#define RMIT @"RMIT" -#define UCRV @"UCRV" -#define PAYP @"PAYP" -#define SENT @"SENT" - -#define STATUS_WD @"Waiting Deposit" -#define STATUS_WDV @"Waiting Deposit Verification" -#define STATUS_RERR @"Issue with Receipt" -#define STATUS_DERR @"Issue with Deposit" -#define STATUS_RSD @"Reserved for Deposit" -#define STATUS_RMIT @"Remit Address Missing" -#define STATUS_UCRV @"Under Review" -#define STATUS_PAYP @"Done - Pending Delivery" -#define STATUS_SENT @"Done - Units Delivered" - -#import "WOCSellingSummaryViewController.h" -#import "WOCSummaryCell.h" -#import "WOCSignOutCell.h" -#import "WOCSellingWizardHomeViewController.h" -#import "WOCSellingWizardInputAmountViewController.h" -#import "APIManager.h" -#import "BRRootViewController.h" -#import "BRAppDelegate.h" -#import -#import "WOCAlertController.h" -#import "MBProgressHUD.h" -#import "WOCAsyncImageView.h" - -@interface WOCSellingSummaryViewController () - -@property (strong, nonatomic) NSArray *wdOrders; -@property (strong, nonatomic) NSArray *otherOrders; - -@end - -@implementation WOCSellingSummaryViewController - -- (void)viewDidLoad { - - [super viewDidLoad]; - - self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"navigation_back"] style:UIBarButtonItemStylePlain target:self action:@selector(back:)]; - - [self setShadowOnButton:self.buyMoreDashButton]; - [self setAttributedString]; - - if (self.orders.count == 0) { - - [self reloadOrderTable]; - - [self getOrders]; - - if (!self.isHideSuccessAlert) { - [self displayAlert]; - } - } - else { - - NSPredicate *wdvPredicate = [NSPredicate predicateWithFormat:@"status == 'WD'"]; - NSArray *wdvArray = [self.orders filteredArrayUsingPredicate:wdvPredicate]; - self.wdOrders = [[NSArray alloc] initWithArray:wdvArray]; - - NSPredicate *otherPredicate = [NSPredicate predicateWithFormat:@"status == 'WDV' || status == 'RERR' || status == 'DERR' || status == 'RSD' || status == 'RMIT' || status == 'UCRV' || status == 'PAYP' || status == 'SENT' || status == 'ACAN'"]; - NSArray *otherArray = [self.orders filteredArrayUsingPredicate:otherPredicate]; - self.otherOrders = [[NSArray alloc] initWithArray:otherArray]; - - APILog(@"wdvArray count: %lu, otherArray count: %lu",(unsigned long)wdvArray.count,(unsigned long)otherArray.count); - - [self reloadOrderTable]; - } -} - -- (void)setAttributedString { - - NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"Wall of Coins will verify your payment. This usually takes up to 10 minutes. To expedite your order, take a picture of your receipt and click here to email your receipt to Wall of Coins." attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]}]; - - [attributedString addAttribute:NSLinkAttributeName - value:@"support@wallofcoins.com" - range:[[attributedString string] rangeOfString:@"click here"]]; - - - NSDictionary *linkAttributes = @{NSForegroundColorAttributeName: [UIColor blackColor], - NSUnderlineColorAttributeName: [UIColor blackColor], - NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle)}; - - self.instructionTextField.linkTextAttributes = linkAttributes; - self.instructionTextField.attributedText = attributedString; - self.instructionTextField.delegate = self; -} - -- (void)back:(id)sender { - - [self backToMainView]; -} - -- (NSString*)checkStatus:(NSString*)status { - - NSString *string = @""; - - if ([status isEqualToString:WD]) { - string = [NSString stringWithFormat:@"Status: %@",STATUS_WD]; - } - else if ([status isEqualToString:WDV]) { - string = [NSString stringWithFormat:@"Status: %@",STATUS_WDV]; - } - else if ([status isEqualToString:RERR]) { - string = [NSString stringWithFormat:@"Status: %@",STATUS_RERR]; - } - else if ([status isEqualToString:DERR]) { - string = [NSString stringWithFormat:@"Status: %@",STATUS_DERR]; - } - else if ([status isEqualToString:RMIT]) { - string = [NSString stringWithFormat:@"Status: %@",STATUS_RMIT]; - } - else if ([status isEqualToString:UCRV]) { - string = [NSString stringWithFormat:@"Status: %@",STATUS_UCRV]; - } - else if ([status isEqualToString:PAYP]) { - string = [NSString stringWithFormat:@"Status: %@",STATUS_PAYP]; - } - else if ([status isEqualToString:SENT]) { - string = [NSString stringWithFormat:@"Status: %@",STATUS_SENT]; - } - - return string; -} - -- (void)displayAlert { - - [[WOCAlertController sharedInstance] alertshowWithTitle:@"" message:[NSString stringWithFormat:@"Thank you for making the payment!\nOnce we verify your payment, we will send the %@ to your wallet!",WOCCurrency] viewController:self]; -} - -// MARK: - IBAction - -- (IBAction)onBuyMoreDashButtonClick:(id)sender { - [self backToMainView]; -} - -- (IBAction)onSignOutButtonClick:(id)sender { - [self signOutWOC]; -} - -- (IBAction)wallOfCoinsClicked:(id)sender { - - NSURL *url = [NSURL URLWithString:@"https://wallofcoins.com"]; - if ([[UIApplication sharedApplication] canOpenURL:url]) { - [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) { - APILog(@"URL opened..."); - }]; - } -} - -// MARK: - API -- (void)getOrders { - - MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; - - NSDictionary *params = @{ - }; - - [[APIManager sharedInstance] getIncomingOrders:nil response:^(id responseDict, NSError *error) { - dispatch_async(dispatch_get_main_queue(), ^{ - [hud hideAnimated:YES]; - }); - - if (error == nil) { - if ([responseDict isKindOfClass:[NSArray class]]) { - NSArray *response = [[NSArray alloc] initWithArray:(NSArray*)responseDict]; - self.orders = response; - - NSPredicate *wdvPredicate = [NSPredicate predicateWithFormat:@"status == 'WD'"]; - NSArray *wdvArray = [self.orders filteredArrayUsingPredicate:wdvPredicate]; - self.wdOrders = [[NSArray alloc] initWithArray:wdvArray]; - - NSPredicate *otherPredicate = [NSPredicate predicateWithFormat:@"status == 'WDV' || status == 'RERR' || status == 'DERR' || status == 'RSD' || status == 'RMIT' || status == 'UCRV' || status == 'PAYP' || status == 'SENT' || status == 'ACAN'"]; - NSArray *otherArray = [self.orders filteredArrayUsingPredicate:otherPredicate]; - self.otherOrders = [[NSArray alloc] initWithArray:otherArray]; - - APILog(@"wdvArray count: %lu, otherArray count: %lu",(unsigned long)wdvArray.count,(unsigned long)otherArray.count); - } - } - else { - [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; - } - - [self reloadOrderTable]; - - }]; -} - -- (void)reloadOrderTable{ - if (self.orders.count > 0) { - self.instructionTextField.text = @"Wall of Coins will verify your payment. This usually takes up to 10 minutes. To expedite your order, take a picture of your receipt and click here to email your receipt to Wall of Coins."; - } - else { - self.instructionTextField.text = [NSString stringWithFormat:@"You have no order history with %@ for iOS. To see your full order history across all devices, visit %@",WOCCryptoCurrency,BASE_URL_PRODUCTION]; - } - self.instructionLabel.hidden = YES; - self.instructionTextField.hidden = NO; - [self.sellingSummaryTableView reloadData]; -} - -#pragma mark - UITableView DataSource - -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return 4; -} - -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - - if (section == 0) { - return self.wdOrders.count; - } - else if (section == 1) { - return 1; - } - else if (section == 2) { - return 1; - } - else { - return self.otherOrders.count; - } -} - -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - - if (indexPath.section == 1) { - WOCSignOutCell *cell = [tableView dequeueReusableCellWithIdentifier:@"linkCell"]; - [cell.signOutButton addTarget:self action:@selector(wallOfCoinsClicked:) forControlEvents:UIControlEventTouchUpInside]; - return cell; - } - else if (indexPath.section == 2) { - WOCSignOutCell *cell = [tableView dequeueReusableCellWithIdentifier:@"signOutCell"]; - cell.descriptionLabel.text = [NSString stringWithFormat:@"Your wallet is signed into Wall of Coins using your mobile number %@",self.phoneNo]; - [cell.signOutButton addTarget:self action:@selector(onSignOutButtonClick:) forControlEvents:UIControlEventTouchUpInside]; - return cell; - } - else { - - static const NSInteger IMAGE_VIEW_TAG = 98; - NSString *cellIdentifier = @"offerCell"; - - WOCSummaryCell *cell = [tableView dequeueReusableCellWithIdentifier:@"summaryCell"]; - - NSDictionary *orderDict = [[NSDictionary alloc] init]; - /* - { - bankAccount = - { - bankBusiness = - { - country = us; - icon = "https://woc-staging-static.s3.amazonaws.com/logos/icon_us_Genitrust2x.png"; - id = 14; - logo = "https://woc-staging-static.s3.amazonaws.com/logos/logo_us_Genitrust2x.png"; - name = Genitrust; - payFields = 0; - url = "http://genitrust.com/"; - }; - id = 78; - name = "Sujal Bandhara"; - number = ABC1234567890; - }; - gross = "6.70454545"; - id = 397; - payment = "2.95"; - paymentDue = "2018-03-26T12:55:33.093147+05:30"; - status = DERR; - } - */ - NSMutableDictionary *sellingOrderDict = [NSMutableDictionary dictionaryWithCapacity:0]; - - if (indexPath.section == 0) { - orderDict = self.wdOrders[indexPath.row]; - if (orderDict[@"bankAccount"] != nil) { - if (orderDict[@"bankAccount"][@"bankBusiness"] != nil) { - sellingOrderDict = orderDict[@"bankAccount"][@"bankBusiness"]; - } - } - } - else { - orderDict = self.otherOrders[indexPath.row]; - if (orderDict[@"bankAccount"] != nil) { - if (orderDict[@"bankAccount"][@"bankBusiness"] != nil) { - sellingOrderDict = orderDict[@"bankAccount"][@"bankBusiness"]; - } - } - } - - if (![[sellingOrderDict valueForKey:@"number"] isEqual:[NSNull null]]) { - if ([[sellingOrderDict valueForKey:@"number"] length] > 16) { - cell = [tableView dequeueReusableCellWithIdentifier:@"summaryCell1"]; - - NSArray *accountArr = [NSJSONSerialization JSONObjectWithData:[[sellingOrderDict valueForKey:@"number"] dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:nil]; - NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"displaySort" ascending:YES comparator:^NSComparisonResult(id obj1, id obj2) { - float aObj1 = [(NSString *)obj1 floatValue]; - float aObj2 = [(NSString *)obj2 floatValue]; - return aObj1 > aObj2; - }]; - NSArray *accountArray = [accountArr sortedArrayUsingDescriptors:@[sort]]; - cell.phoneLabel.hidden = YES; - if (accountArray.count > 0) { - cell.firstNameLabel.text = [NSString stringWithFormat:@"First Name: %@",REMOVE_NULL_VALUE([[accountArray objectAtIndex:0] valueForKey:@"value"])]; - } - if (accountArray.count > 2) { - cell.lastNameLabel.text = [NSString stringWithFormat:@"Last Name: %@",REMOVE_NULL_VALUE([[accountArray objectAtIndex:2] valueForKey:@"value"])]; - } - if (accountArray.count > 3) { - cell.birthCountryLabel.text = [NSString stringWithFormat:@"Country of Birth: %@",REMOVE_NULL_VALUE([[accountArray objectAtIndex:3] valueForKey:@"value"])]; - } - if (accountArray.count > 1) { - cell.pickupStateLabel.text = [NSString stringWithFormat:@"Pick-up State: %@",REMOVE_NULL_VALUE([[accountArray objectAtIndex:1] valueForKey:@"value"])]; - } - } - } - else { - NSString *phoneNo = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([[orderDict valueForKey:@"bankAccount"] valueForKey:@"number"])]; - cell.phoneLabel.text = [NSString stringWithFormat:@"Acct: -%@",phoneNo]; - - } - NSString *bankLogo = REMOVE_NULL_VALUE([sellingOrderDict valueForKey:@"logo"]); - NSString *bankIcon = REMOVE_NULL_VALUE([sellingOrderDict valueForKey:@"icon"]); - NSString *bankName = REMOVE_NULL_VALUE([sellingOrderDict valueForKey:@"name"]); - - float depositAmount = [[orderDict valueForKey:@"payment"] floatValue]; - NSString *totalDash = REMOVE_NULL_VALUE([orderDict valueForKey:@"gross"]); - NSString *status = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([orderDict valueForKey:@"status"])]; - - UIView *cellView = cell.bankImageView.superview; - - WOCAsyncImageView *imageView = (WOCAsyncImageView *)[cellView viewWithTag:IMAGE_VIEW_TAG]; - - if (imageView == nil) { - imageView = [[WOCAsyncImageView alloc] initWithFrame:cell.bankImageView.frame]; - imageView.contentMode = UIViewContentModeScaleAspectFill; - imageView.clipsToBounds = YES; - imageView.image = [UIImage imageNamed:@"ic_account_balance_black"]; - imageView.tag = IMAGE_VIEW_TAG; - [cellView addSubview:imageView]; - } - - cell.bankImageView.hidden = YES; - imageView.hidden = NO; - - //get image view - //cancel loading previous image for cell - [[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:imageView]; - //bankLogo - if ([bankLogo length] > 0) { - - imageView.imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",bankLogo]]; - } - else if ([bankIcon length] > 0) { - - imageView.imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",bankIcon]]; - //cell.imgView.image = [UIImage imageNamed:@"ic_account_balance_black"]; - } - - cell.nameLabel.text = bankName; - if ([[[orderDict valueForKey:@"nearestBranch"] valueForKey:@"phone"] isEqual:[NSNull null]]) { - [cell.phoneLabel setHidden:YES]; - } - cell.cashDepositLabel.text = [NSString stringWithFormat:@"Verified Deposits: $%.02f",depositAmount]; - - NSNumber *num = [NSNumber numberWithDouble:([totalDash doubleValue] * 1000000)]; - NSNumberFormatter *numFormatter = [[NSNumberFormatter alloc] init]; - [numFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4]; - [numFormatter setNumberStyle:NSNumberFormatterDecimalStyle]; - //[numFormatter setAllowsFloats:YES]; - [numFormatter setAlwaysShowsDecimalSeparator:YES]; - //[numFormatter setDecimalSeparator:@"."]; - [numFormatter setUsesGroupingSeparator:YES]; - [numFormatter setGroupingSeparator:@","]; - [numFormatter setGroupingSize:3]; - NSString *stringNum = [numFormatter stringFromNumber:num]; - cell.totalDashLabel.text = [NSString stringWithFormat:@"Available %@: %@ (%@ %@)",WOCCurrencySpecial,totalDash,stringNum,WOCCurrencySymbolMinor]; - cell.statusLabel.text = [self checkStatus:status]; - - return cell; - } -} - -// MARK: - UITableView Delegate - -- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { - - if (section == 3) { - UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.sellingSummaryTableView.frame.size.width, 50)]; - headerView.backgroundColor = [UIColor colorWithRed:250.0/255.0 green:250.0/255.0 blue:250.0/255.0 alpha:1.0]; - UILabel *lblTitle = [[UILabel alloc] initWithFrame:CGRectMake(15, 5, headerView.frame.size.width - 30, headerView.frame.size.height - 15)]; - lblTitle.text = @"Incoming Order History"; - lblTitle.font = [UIFont systemFontOfSize:14.0 weight:UIFontWeightMedium]; - lblTitle.textAlignment = NSTextAlignmentCenter; - lblTitle.backgroundColor = [UIColor whiteColor]; - lblTitle.layer.cornerRadius = 10.0; - lblTitle.layer.masksToBounds = YES; - - [self setShadowOnView:lblTitle]; - [headerView addSubview:lblTitle]; - return headerView; - } - return nil; -} - -- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { - - if (section == 3) { - if (self.otherOrders.count > 0) { - return 50; - } - } - return 0; -} - -- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - - if (indexPath.section == 1 || indexPath.section == 2) { - return 110.0; - } - else { - NSDictionary *orderDict = [[NSDictionary alloc] init]; - if (indexPath.section == 0) { - orderDict = self.wdOrders[indexPath.row]; - if (![[orderDict valueForKey:@"account"] isEqual:[NSNull null]]) { - if ([[orderDict valueForKey:@"account"] length] > 16) { - return 250.0; - } - } - } - else { - orderDict = self.otherOrders[indexPath.row]; - } - return 185.0; - } -} - -#pragma mark - UITextView Delegate -- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange { - - if ([[URL absoluteString] hasPrefix:@"support"]) { - if([MFMailComposeViewController canSendMail]) { - MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init]; - mailController.mailComposeDelegate = self; - - NSDictionary *orderDict = [self.orders objectAtIndex:0]; - [mailController setSubject:[NSString stringWithFormat:@"Order #{%@} - {%@}",[orderDict valueForKey:@"id"],self.phoneNo]]; - [mailController setToRecipients:[NSArray arrayWithObject:@"support@wallofcoins.com"]]; - [mailController setMessageBody:@"" isHTML:NO]; - [self presentViewController:mailController animated:YES completion:nil]; - } - return NO; - } - return YES; -} - -#pragma mark - MFMailComposer Delegate -- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { - - [self dismissViewControllerAnimated:YES completion:nil]; -} - -@end - diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingVerifyDetailViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingVerifyDetailViewController.h deleted file mode 100644 index e6e9b922..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingVerifyDetailViewController.h +++ /dev/null @@ -1,30 +0,0 @@ -// -// WOCSellingVerifyDetailViewController.h -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import -#import "WOCBaseViewController.h" - -// Enter Phone Number Screen -@interface WOCSellingVerifyDetailViewController : WOCBaseViewController - -@property (strong, nonatomic) NSString *accountInformation; -@property (strong, nonatomic) NSString *currentPrice; -@property (weak, nonatomic) IBOutlet UITextField *accountCodeTextfield; -@property (weak, nonatomic) IBOutlet UITextField *phoneNumberTextfield; -@property (weak, nonatomic) IBOutlet UITextField *emailTextfield; -@property (weak, nonatomic) IBOutlet UITextField *currentPriceTextfield; -@property (weak, nonatomic) IBOutlet UIButton *nextButton; - -@property (strong, nonatomic) NSString *offerId; -@property (strong, nonatomic) NSString *emailId; -@property (assign, nonatomic) BOOL isActiveHoldChecked; -@property (assign, nonatomic) BOOL isForLoginOny; -@property (weak, nonatomic) IBOutlet UITextField *confirmEmailTextfield; - -- (IBAction)onNextButtonClick:(id)sender; -@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingVerifyDetailViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingVerifyDetailViewController.m deleted file mode 100644 index 1a472fc6..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingVerifyDetailViewController.m +++ /dev/null @@ -1,790 +0,0 @@ -// -// WOCSellingVerifyDetailViewController.m -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import "WOCSellingVerifyDetailViewController.h" -#import "WOCSellingWizardConfirmCodeViewController.h" -#import "WOCSellingInstructionsViewController.h" -#import "WOCSellingSummaryViewController.h" -#import "WOCPasswordViewController.h" -#import "BRRootViewController.h" -#import "BRAppDelegate.h" -#import "APIManager.h" -#import "WOCConstants.h" -#import "WOCAlertController.h" -#import "MBProgressHUD.h" -#import "WOCHoldIssueViewController.h" -#import "WOCSellingWizardHomeViewController.h" -#import "WOCSellingCreatePasswordViewController.h" - -@interface WOCSellingVerifyDetailViewController () - -@property (strong, nonatomic) NSArray *countries; -@property (strong, nonatomic) UIPickerView *pickerView; -@property (strong, nonatomic) NSString *countryCode; -@property (strong, nonatomic) NSString *purchaseCode; -@property (strong, nonatomic) NSString *holdId; -@property (strong, nonatomic) NSString *deviceName; -@end - -@implementation WOCSellingVerifyDetailViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - - [self setShadowOnButton:self.nextButton]; - - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(openBuyDashStep8:) name:WOCNotificationObserverNameBuyDashStep8 object:nil]; - - if (self.accountInformation != nil && self.accountInformation.length > 0) { - self.accountCodeTextfield.text = self.accountInformation; - } - if (self.currentPrice != nil && self.currentPrice.length > 0) { - self.currentPriceTextfield.text = [NSString stringWithFormat:@"$ %@",self.currentPrice]; - } - - NSString *phoneNumber = [self.defaults objectForKey:WOCUserDefaultsLocalPhoneNumber]; - if (phoneNumber != nil && phoneNumber.length > 0) { - self.phoneNumberTextfield.text = phoneNumber; - } - - NSString *emailAddress = [self.defaults objectForKey:WOCUserDefaultsLocalEmail]; - if (emailAddress != nil && emailAddress.length > 0) { - self.emailTextfield.text = emailAddress; - } - else { - self.emailTextfield.text = @""; - } - - NSString *bankInfo = [self.defaults objectForKey:WOCUserDefaultsLocalBankInfo]; - if (bankInfo != nil && bankInfo.length > 0) { - self.accountCodeTextfield.text = bankInfo; - } - else { - self.accountCodeTextfield.text = @""; - } - - NSString *txtCurrentPrice = [self.defaults objectForKey:WOCUserDefaultsLocalPrice]; - if (txtCurrentPrice != nil && txtCurrentPrice.length > 0) { - self.currentPriceTextfield.text = txtCurrentPrice; - } - else { - self.currentPriceTextfield.text = @"0"; - } - - self.accountCodeTextfield.userInteractionEnabled = NO; - self.phoneNumberTextfield.userInteractionEnabled = NO; - self.currentPriceTextfield.userInteractionEnabled = NO; - self.emailTextfield.userInteractionEnabled = NO; -} - -- (void)loadCountyData { - self.pickerView = [[UIPickerView alloc] init]; - self.pickerView.delegate = self; - self.pickerView.dataSource = self; - - [self loadJSON]; -} - -- (void)loadJSON { - // Retrieve local JSON file called example.json - NSString *filePath = [[NSBundle mainBundle] pathForResource:@"countries" ofType:@"json"]; - - // Load the file into an NSData object called JSONData - NSError *error = nil; - NSData *JSONData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:&error]; - - // Create an Objective-C object from JSON Data - NSDictionary *countriesDict = [NSJSONSerialization JSONObjectWithData:JSONData options:NSJSONReadingMutableContainers error:nil]; - NSArray *countries = [countriesDict valueForKey:@"countries"]; - - self.countries = countries; - if (self.countries.count > 0) { - self.accountCodeTextfield.text = [NSString stringWithFormat:@"%@ (%@)",self.countries[0][@"name"],self.countries[0][@"code"]]; - self.countryCode = [NSString stringWithFormat:@"%@",self.countries[0][@"code"]]; - } - - [self.pickerView reloadAllComponents]; -} - -- (void)openBuyDashStep8:(NSNotification*)notification { - - NSString *phoneNo = [NSString stringWithFormat:@"%@",notification.object]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults synchronize]; - - [self createHoldAfterAuthorize:phoneNo]; -} - -// MARK: - API - -- (void)checkPhone:(NSString*)phone code:(NSString*)countryCode { - - NSDictionary *params = @{ - }; - - NSString *phoneNo = [NSString stringWithFormat:@"%@%@",countryCode,phone]; - [self.defaults setObject:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults synchronize]; - - [[APIManager sharedInstance] authorizeDevice:nil phone:phoneNo response:^(id responseDict, NSError *error) { - - if (error == nil) { - NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; - - if ([responseDictionary valueForKey:@"recentDeviceName"] != nil) { - self.deviceName = [responseDictionary valueForKey:@"recentDeviceName"]; - } - - if ([[responseDictionary valueForKey:@"availableAuthSources"] isKindOfClass:[NSArray class]]) { - NSArray *availableAuthSource = (NSArray*)[responseDictionary valueForKey:@"availableAuthSources"]; - if (availableAuthSource.count > 0) { - if ([[availableAuthSource objectAtIndex:0] isEqualToString:@"password"]) { - [self login:phoneNo password:self.currentPriceTextfield.text]; - } - else if ([[availableAuthSource objectAtIndex:0] isEqualToString:@"device"]) { - //[self createHoldAfterAuthorize:phoneNo]; - [self resetPassword]; - } - } - } - else if ([responseDictionary valueForKey:@"response"] != nil) { - if ([[responseDictionary valueForKey:@"response"] isEqualToString:@"error"]) { - [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults synchronize]; - [self resetPassword]; - } - } - } - else { - - if ([error code] == 404 || [error code] == 0) { - //new number - [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults synchronize]; - [self registerUser]; - //[self createHold:phoneNo]; - } - else { - dispatch_async(dispatch_get_main_queue(), ^{ - if (error.userInfo != nil) { - if (error.userInfo[@"detail"] != nil) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self.navigationController.visibleViewController]; - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; - } - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; - } - }); - } - } - }]; -} - -- (void)login:(NSString*)phoneNo { - - NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; - NSString *deviceId = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceId]; - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - - NSDictionary *params = @{ - WOCApiBodyDeviceCode: deviceCode - }; - - if (deviceId != nil) { - params = @{ - WOCApiBodyDeviceCode: deviceCode, - WOCApiBodyDeviceId: deviceId, - WOCApiBodyJsonParameter: @"YES" - }; - [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDict, NSError *error) { - - NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; - if (error == nil) { - if (responseDictionary != nil) { - [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - [self storeDeviceInfoLocally]; - [self backToMainView]; - } - } - else { - - [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - - BOOL isNewPhone = YES; - if (error.code == 400) { - if (error.userInfo != nil) { - NSString *errorDetail = error.userInfo[@"detail"]; - if (errorDetail != nil) { - if ([errorDetail isEqualToString:@"Unable to authorize your phone number. Password may be incorrect."]) { - isNewPhone = NO; - } - } - } - } - if (isNewPhone) { - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults synchronize]; - [self backToMainView]; - } - else { - [self openHoldIssueVC]; - } - } - }]; - } -} - -- (void)createHold:(NSString*)phoneNo { - - if (!self.isForLoginOny) { - MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; - - NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - - NSDictionary *params; - - if (token != nil && (![token isEqualToString:@"(null)"])) { - params = @{ - WOCApiBodyOffer: [NSString stringWithFormat:@"%@==",self.offerId], - WOCApiBodyJsonParameter:@"YES" - }; - } - else { - params = @{ - WOCApiBodyOffer: [NSString stringWithFormat:@"%@==",self.offerId], - WOCApiBodyPhoneNumber: phoneNo, - WOCApiBodyDeviceName: WOCApiBodyDeviceName_IOS, - WOCApiBodyDeviceCode: deviceCode, - WOCApiBodyJsonParameter:@"YES" - }; - - if (self.emailId != nil && self.emailId.length > 0) { - NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:params]; - [dict setObject:self.emailId forKey:WOCApiBodyEmail]; - params = (NSDictionary*)dict; - } - } - - [[APIManager sharedInstance] createHold:params response:^(id responseDict, NSError *error) { - dispatch_async(dispatch_get_main_queue(), ^(void) { - [hud hideAnimated:YES]; - }); - - if (error == nil) { - NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; - if ([responseDictionary valueForKey:WOCApiResponseToken] != nil && (![[responseDictionary valueForKey:WOCApiResponseToken] isEqualToString:@"(null)"])) { - [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiResponseToken]] forKey:WOCUserDefaultsAuthToken]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - [self storeDeviceInfoLocally]; - } - - NSString *holdId = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([responseDictionary valueForKey:WOCApiResponseId])]; - self.holdId = holdId; - - NSString *purchaseCode = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([responseDictionary valueForKey:WOCApiResponsePurchaseCde])]; - if (![purchaseCode isKindOfClass:[NSNull class]]) { - self.purchaseCode = purchaseCode; - } - else { - self.purchaseCode = @""; - } - - WOCSellingWizardConfirmCodeViewController *sellingWizardConfirmCodeViewController = [self getViewController:@"WOCSellingWizardConfirmCodeViewController"]; - sellingWizardConfirmCodeViewController.phoneNo = phoneNo; - sellingWizardConfirmCodeViewController.offerId = self.offerId; - sellingWizardConfirmCodeViewController.purchaseCode = self.purchaseCode; - sellingWizardConfirmCodeViewController.deviceCode = deviceCode; - sellingWizardConfirmCodeViewController.emailId = self.emailId; - sellingWizardConfirmCodeViewController.holdId = self.holdId; - [self pushViewController:sellingWizardConfirmCodeViewController animated:YES]; - } - else if (error.code == 403) { - [self resolveActiveHoldIssue:phoneNo]; - } - else if (error.code == 401) { - [self registerDevice:phoneNo]; - } - }]; - } - else { - - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - if (token != nil && (![token isEqualToString:@"(null)"])) { - [self getOrderList]; - } - else { - - UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Error" message:@"Please select an offer and then try to register/login with app." preferredStyle:UIAlertControllerStyleAlert]; - - UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { - [self backToMainView]; - }]; - - [alert addAction:okAction]; - [self presentViewController:alert animated:YES completion:nil]; - - } - } -} - --(void)resolveActiveHoldIssue:(NSString*)phoneNo { - - if (!self.isActiveHoldChecked) { - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - - if (token != nil && (![token isEqualToString:@"(null)"])) { - /*you receive Status 403 from POST /api/v1/holds/ - IF YOU HAVE a token or the deviceId/deviceCode, login with that device -- you will use the token to get a list of holds so that you can cancel the holds. IF THERE ARE NO HOLDS, then you will bring the user to the Buy Summary, where they will see their latest WD orders. - */ - self.isActiveHoldChecked = YES; - [self getHold]; - } - else { - NSString *deviceID = [self getDeviceIDFromPhoneNumber:phoneNo]; - if (deviceID.length > 0 && (![deviceID isEqualToString:@"(null)"])) { - [self.defaults setObject:deviceID forKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - [self login:phoneNo]; - } - else { - [self openHoldIssueVC]; - } - } - } -} - -- (void)openHoldIssueVC { - /* - IF YOU DO NOT HAVE the token or deviceId/deviceCode in local storage, then you will need to show a new view that says, "You already have an open hold or a pending order with Wall of Coins. Before you can create a new order, you must finish these orders." and then show a yellow button w/ blue text (just like the "BUY MORE {Crypto Currency} WITH CASH" button), and when they press that button, you will bring them to this website link: - https://wallofcoins.com/signin/1-2397776832/ - https://wallofcoins.com/signin/{phone_country_code}-{local_phone_number}/ - */ - NSString *txtPhone = [self.phoneNumberTextfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; - NSString *txtAccountCode = [self.countryCode stringByReplacingOccurrencesOfString:@"+" withString:@""]; - WOCHoldIssueViewController *aViewController = [self getViewController:@"WOCHoldIssueViewController"]; - aViewController.phoneNo = [NSString stringWithFormat:@"%@-%@",txtAccountCode,txtPhone]; - [self pushViewController:aViewController animated:YES]; -} - -- (void)resolvePandingOrderIssue { - - [self getOrderList]; -} - -- (void)getHold { - - [[APIManager sharedInstance] getHold:^(id responseDict, NSError *error) { - if (error == nil) { - APILog(@"Hold with Hold Id: %@.",responseDict); - if ([responseDict isKindOfClass:[NSArray class]]) { - NSArray *holdArray = (NSArray*)responseDict; - if (holdArray.count > 0) { - NSUInteger count = holdArray.count; - NSUInteger activeHodCount = 0; - - for (int i = 0; i < holdArray.count; i++) { - count -= count; - - NSDictionary *holdDict = [holdArray objectAtIndex:i]; - NSString *holdId = [holdDict valueForKey:WOCApiResponseId]; - NSString *holdStatus = [holdDict valueForKey:WOCApiResponseHoldsStatus]; - - if (holdStatus != nil) { - if ([holdStatus isEqualToString:@"AC"]) { - if (holdId) { - activeHodCount = activeHodCount + 1; - [self deleteHold:holdId count:count]; - } - } - } - else { - if (holdId) { - activeHodCount = activeHodCount + 1; - [self deleteHold:holdId count:count]; - } - } - } - - if (activeHodCount == 0) { - [self resolvePandingOrderIssue]; - } - } - else { - [self resolvePandingOrderIssue]; - } - } - else { - [self resolvePandingOrderIssue]; - } - } - else { - [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; - } - }]; -} - -- (void)deleteHold:(NSString*)holdId count:(NSUInteger)count { - - NSDictionary *params = @{ - }; - - [[APIManager sharedInstance] deleteHold:holdId response:^(id responseDict, NSError *error) { - if (error == nil) { - APILog(@"Hold deleted."); - - NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; - [self createHoldAfterAuthorize:phoneNo]; - } - }]; -} - -- (void)registerDevice:(NSString*)phoneNo { - - MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; - - NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - - NSDictionary *params = @{ - WOCApiBodyName: WOCApiBodyDeviceName_IOS, - WOCApiBodyCode: deviceCode, - WOCApiBodyJsonParameter:@"YES" - }; - - [[APIManager sharedInstance] registerDevice:params response:^(id responseDict, NSError *error) { - dispatch_async(dispatch_get_main_queue(), ^(void) { - [hud hideAnimated:YES]; - }); - - if (error == nil) { - NSDictionary *response = (NSDictionary*)responseDict; - if (response.count > 0) { - NSString *deviceId = [NSString stringWithFormat:@"%@",[response valueForKey:WOCApiResponseId]]; - [self authorize:phoneNo deviceId:deviceId]; - } - } - else { - [self pushToStep1]; - [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; - } - }]; -} - -- (void)authorize:(NSString*)phoneNo deviceId:(NSString*)deviceId { - - NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - - NSDictionary *params = @{ - WOCApiBodyDeviceCode: deviceCode, - WOCApiBodyJsonParameter: @"YES" - }; - - if (deviceId != nil && (![deviceId isEqualToString:@"(null)"])) { - params = @{ - WOCApiBodyDeviceCode: deviceCode, - WOCApiBodyDeviceId: deviceId, - WOCApiBodyJsonParameter: @"YES" - }; - } - - [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDict, NSError *error) { - if (error == nil) { - NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; - [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - - [self storeDeviceInfoLocally]; - [self backToMainView]; - //[self createHoldAfterAuthorize:phoneNo]; - } - else { - [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults synchronize]; - [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; - } - }]; -} - -- (void)createHoldAfterAuthorize:(NSString*)phoneNo { - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - - if (token != nil && (![token isEqualToString:@"(null)"])) { - [self createHold:phoneNo]; - } - else { - NSString *deviceID = [self getDeviceIDFromPhoneNumber:phoneNo]; - if (deviceID != nil) { - [self.defaults setObject:deviceID forKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - [self login:phoneNo]; - } - else { - [self createHold:phoneNo]; - } - } -} - -// MARK: - IBAction -- (IBAction)onNextButtonClick:(id)sender { - - NSString *txtPhone = [self.phoneNumberTextfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; - - if ([txtPhone length] == 0) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter phone number." viewController:self.navigationController.visibleViewController]; - } - else if ([self.emailTextfield.text length] == 0) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter email number." viewController:self.navigationController.visibleViewController]; - } - else if ([self isValidEmail:self.emailTextfield.text] == 0) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter valid email number." viewController:self.navigationController.visibleViewController]; - } - else if ([self.currentPriceTextfield.text length] == 0) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter password number." viewController:self.navigationController.visibleViewController]; - } - else if ([txtPhone length] > 10) { - [self openVerificationCodeScreen]; - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter valid phone number." viewController:self.navigationController.visibleViewController]; - } -} - -// MARK: - UIPickerView Delegates - -- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView { - return 1; -} - -- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component { - return self.countries.count; -} - -- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { - return [NSString stringWithFormat:@"%@ (%@)",self.countries[row][@"name"],self.countries[row][@"code"]]; -} - -- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { - self.accountCodeTextfield.text = [NSString stringWithFormat:@"%@ (%@)",self.countries[row][@"name"],self.countries[row][@"code"]]; - self.countryCode = [NSString stringWithFormat:@"%@",self.countries[row][@"code"]]; -} - -- (void)pushToStep1 { - [self storeDeviceInfoLocally]; - [self backToMainView]; -} - -- (void)registerUser { - - NSString *phoneNumber = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; - NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - - NSDictionary *params = @{ - WOCApiBodyPhoneNumber: phoneNumber, - WOCApiBodyEmail: self.emailTextfield.text, - WOCApiBodyPassword: self.currentPriceTextfield.text, - WOCApiBodyJsonParameter: @"YES" - }; - - [[APIManager sharedInstance] registerUser:params response:^(id responseDict, NSError *error) { - - NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; - if (error == nil) { - BOOL isError = NO; - if (responseDictionary != nil) { - if ([responseDictionary valueForKey:@"response"] != nil) { - if ([[responseDictionary valueForKey:@"response"] isEqualToString:@"error"]) { - // Error - isError = YES; - } - } - } - - if (isError) { - [self openHoldIssueVC]; - } - else { - [self login:phoneNumber password:self.currentPriceTextfield.text]; - } - } - else { - - [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - - BOOL isNewPhone = YES; - if (error.code == 400) { - if (error.userInfo != nil) { - NSString *errorDetail = error.userInfo[@"detail"]; - if (errorDetail != nil) { - if ([errorDetail isEqualToString:@"Unable to authorize your phone number. Password may be incorrect."]) { - isNewPhone = NO; - } - } - } - } - - if (isNewPhone) { - [self.defaults setValue:phoneNumber forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults synchronize]; - - [self registrationCompleted]; - } - else { - [self openHoldIssueVC]; - } - } - }]; -} - -- (void)resetPassword { - - NSString *phoneNumber = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; - - NSDictionary *params = @{ - @"password1": self.currentPriceTextfield.text, - @"password2": self.currentPriceTextfield.text, - WOCApiBodyJsonParameter: @"YES" - }; - - [[APIManager sharedInstance] resetPassword:params phone:phoneNumber response:^(id responseDict, NSError *error) { - - NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; - if (error == nil) { - if (responseDictionary != nil) { - if ([[responseDictionary valueForKey:@"response"] isEqualToString:@"error"]) { - // Error - [self openHoldIssueVC]; - } - else { - [self registrationCompleted]; - } - } - } - else { - [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - - BOOL isNewPhone = YES; - if (error.code == 400) { - if (error.userInfo != nil) { - NSString *errorDetail = error.userInfo[@"detail"]; - if (errorDetail != nil) { - if ([errorDetail isEqualToString:@"Unable to authorize your phone number. Password may be incorrect."]) { - isNewPhone = NO; - } - } - } - } - - if (isNewPhone) { - [self.defaults setValue:phoneNumber forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults synchronize]; - //[self createHoldAfterAuthorize:phoneNumber]; - [self registrationCompleted]; - } - else { - [self openHoldIssueVC]; - } - } - }]; -} - -- (void)login:(NSString*)phoneNo password:(NSString*)password { - NSDictionary *params = @{ - WOCApiBodyPassword: password, - WOCApiBodyJsonParameter: @"YES" - }; - - [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDictionary, NSError *error) { - if (error == nil) { - if (responseDictionary != nil) { - [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - [self registerDevice:phoneNo]; - [self backToMainView]; - } - } - else { - dispatch_async(dispatch_get_main_queue(), ^{ - if (error.userInfo != nil) { - if (error.userInfo[@"detail"] != nil) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self]; - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self]; - } - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self]; - } - }); - } - }]; -} - -- (void)registrationCompleted { - - NSString *phoneNumber = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; - NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; - - WOCSellingCreatePasswordViewController *createPasswordViewController = [self getViewController:@"WOCSellingCreatePasswordViewController"]; - - if (self.deviceName != nil) { - createPasswordViewController.deviceName = self.deviceName; - } - createPasswordViewController.offerId = self.offerId; - createPasswordViewController.purchaseCode = self.purchaseCode; - createPasswordViewController.deviceCode = deviceCode; - createPasswordViewController.emailId = self.emailId; - createPasswordViewController.holdId = self.holdId; - [self pushViewController:createPasswordViewController animated:YES]; - //[self login:phoneNumber]; -} - -- (void)openVerificationCodeScreen { - - NSString *phoneNumber = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; - NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; - - WOCSellingWizardConfirmCodeViewController *confirmCodeViewController = [self getViewController:@"WOCSellingWizardConfirmCodeViewController"]; - confirmCodeViewController.emailId = self.emailId; - confirmCodeViewController.holdId = self.holdId; - [self pushViewController:confirmCodeViewController animated:YES]; - //[self login:phoneNumber]; -} -@end - diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardConfirmCodeViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardConfirmCodeViewController.h deleted file mode 100644 index 70e761b0..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardConfirmCodeViewController.h +++ /dev/null @@ -1,30 +0,0 @@ -// -// WOCSellingWizardConfirmCodeViewController.h -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import -#import "WOCBaseViewController.h" - -//WOCSellingWizardConfirmCodeViewController - -@interface WOCSellingWizardConfirmCodeViewController : WOCBaseViewController - -@property (strong, nonatomic) NSString *purchaseCode; -@property (strong, nonatomic) NSString *offerId; -@property (strong, nonatomic) NSString *holdId; -@property (strong, nonatomic) NSString *phoneNo; -@property (strong, nonatomic) NSString *emailId; -@property (strong, nonatomic) NSString *deviceCode; - -@property (weak, nonatomic) IBOutlet UILabel *descriptionLabel; -@property (weak, nonatomic) IBOutlet UITextField *confirmCodeTextfield; -@property (weak, nonatomic) IBOutlet UIButton *confirmVarificationCodeButton; - -- (IBAction)onConfirmVarificationCodeClicked:(id)sender; - - -@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardConfirmCodeViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardConfirmCodeViewController.m deleted file mode 100644 index 0c189542..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardConfirmCodeViewController.m +++ /dev/null @@ -1,116 +0,0 @@ -// -// WOCSellingWizardConfirmCodeViewController.m -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import "WOCSellingWizardConfirmCodeViewController.h" -#import "WOCSellingAdsInstructionsViewController.h" -#import "WOCSellingSummaryViewController.h" -#import "APIManager.h" -#import "WOCConstants.h" -#import "WOCAlertController.h" -#import "BRRootViewController.h" -#import "BRAppDelegate.h" -#import "MBProgressHUD.h" - -@interface WOCSellingWizardConfirmCodeViewController () - -@end - -@implementation WOCSellingWizardConfirmCodeViewController - -- (void)viewDidLoad { - - [super viewDidLoad]; - - [self setShadowOnButton:self.confirmVarificationCodeButton]; - - NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; - - self.descriptionLabel.text = [NSString stringWithFormat:@"The Mobile phone %@ will receive a verification code within 10 seconds.When you receive the code, input it below.",phoneNo]; - if (self.purchaseCode != nil) { - self.confirmCodeTextfield.text = REMOVE_NULL_VALUE(self.purchaseCode); - } else { - self.confirmCodeTextfield.text = @""; - } - self.confirmCodeTextfield.delegate = self; - [self.confirmCodeTextfield becomeFirstResponder] ; -} - -- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { - - if(textField.text.length == 4 && string.length == 1) - { - [self performSelector:@selector(onConfirmVarificationCodeClicked:) withObject:self afterDelay:1.0]; - } - return YES; -} - -// MARK: - IBAction - -- (IBAction)onConfirmVarificationCodeClicked:(id)sender { - - NSString *txtCode = [self.confirmCodeTextfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; - if ([txtCode length] == 5) { - - NSString *emailAddress = REMOVE_NULL_VALUE([self.defaults objectForKey:WOCUserDefaultsLocalEmail]); - NSString *bankAccountInfo = REMOVE_NULL_VALUE([self.defaults objectForKey:WOCUserDefaultsLocalBankInfo]); - NSString *bankAccountID = REMOVE_NULL_VALUE([self.defaults objectForKey:WOCUserDefaultsLocalBankAccount]); - NSString *bankAccount = REMOVE_NULL_VALUE([self.defaults objectForKey:WOCUserDefaultsLocalBankAccountNumber]); - NSString *bankName = REMOVE_NULL_VALUE([self.defaults objectForKey:WOCUserDefaultsLocalBankName]); - NSString *currentPrice = REMOVE_NULL_VALUE([self.defaults objectForKey:WOCUserDefaultsLocalPrice]); - NSString *deviceCode = REMOVE_NULL_VALUE([self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]); - NSString *deviceId = REMOVE_NULL_VALUE([self.defaults valueForKey:WOCUserDefaultsLocalDeviceId]); - NSString *token = REMOVE_NULL_VALUE([self.defaults valueForKey:WOCUserDefaultsAuthToken]); - NSString *phoneNumber = REMOVE_NULL_VALUE([self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]); - NSString *phoneCode = REMOVE_NULL_VALUE([self.defaults valueForKey:WOCUserDefaultsLocalCountryCode]); - phoneNumber = [phoneNumber stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%@",phoneCode] withString:@""]; - phoneCode = [phoneCode stringByReplacingOccurrencesOfString:@"+" withString:@""]; - - NSDictionary *params = @{ - WOCApiBodyDeviceCode: deviceCode - }; - - if (deviceId != nil) { - - params = @{ - WOCApiBodyPhoneNumber:phoneNumber, - WOCApiBodyEmail:emailAddress, - @"phoneCode": phoneCode, - @"bankBusiness": bankAccountID, - @"sellCrypto": WOCCryptoCurrency, - @"userEnabled": @"true", - @"dynamicPrice": @"false", - @"currentPrice": currentPrice, - @"name": bankName, - @"number": bankAccount, - @"number2": bankAccount, - WOCApiBodyDeviceCode: deviceCode, - WOCApiBodyDeviceId: deviceId, - WOCApiBodyJsonParameter: @"YES" - }; - [[APIManager sharedInstance] createAd:params response:^(id responseDict, NSError *error) { - - if (error == nil) { - - } - - WOCSellingAdsInstructionsViewController *adsInstructionsViewController = [self getViewController:@"WOCSellingAdsInstructionsViewController"]; - adsInstructionsViewController.AdvertiseId = @"90"; - [self pushViewController:adsInstructionsViewController animated:YES]; - }]; - } - } - else if ([txtCode length] == 0 ) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:@"Enter Purchase Code" viewController:self.navigationController.visibleViewController]; - } - else if ([txtCode length] != 5 ) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:@"Enter Valid Purchase Code" viewController:self.navigationController.visibleViewController]; - } -} - -@end - diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardHomeViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardHomeViewController.h deleted file mode 100644 index 05d58749..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardHomeViewController.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// WOCSellingWizardHomeViewController.h -// Wallofcoins -// -// Created by Genitrust on 23/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import -#import "WOCBaseViewController.h" - - -//WOCSellingWizardHomeViewController -// Find My Location Screen -@interface WOCSellingWizardHomeViewController : WOCBaseViewController - -@property (weak, nonatomic) IBOutlet UIView *signoutView; -@property (weak, nonatomic) IBOutlet UILabel *descriptionLabel; -@property (weak, nonatomic) IBOutlet UIButton *signOutButton; -@property (weak, nonatomic) IBOutlet UIButton *orderListButton; -@property (weak, nonatomic) IBOutlet UIButton *sellYourCryptoButton; -@property (assign, nonatomic) BOOL isFromSend; - -- (void)setLogoutButton; -- (IBAction)onBackButtonClick:(id)sender; -- (IBAction)onSignOutButtonClick:(id)sender; -- (IBAction)onSellYourCryptoButtonClick:(id)sender; - -@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardHomeViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardHomeViewController.m deleted file mode 100644 index 2473af00..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardHomeViewController.m +++ /dev/null @@ -1,136 +0,0 @@ -// -// WOCSellingWizardHomeViewController.m -// Wallofcoins -// -// Created by Genitrust on 23/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import "WOCSellingWizardHomeViewController.h" -#import "WOCLocationManager.h" -#import "WOCSellingWizardZipCodeViewController.h" -#import "WOCSellingWizardPaymentCenterViewController.h" -#import "WOCSellingWizardInputAmountViewController.h" -#import "WOCConstants.h" -#import "BRAppDelegate.h" -#import "BRRootViewController.h" -#import "MBProgressHUD.h" -#import "APIManager.h" -#import "WOCAlertController.h" -#import "WOCSellingWizardInputEmailViewController.h" -#import "WOCSellingWizardInputPhoineNumberViewController.h" - -@interface WOCSellingWizardHomeViewController () - -@property (strong, nonatomic) NSString *zipCode; - -@end - -@implementation WOCSellingWizardHomeViewController - -- (void)viewDidLoad { - - self.isBackButtonRequire = YES; - - [super viewDidLoad]; - - [self.defaults removeObjectForKey:WOCUserDefaultsLocalLocationLatitude]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalLocationLongitude]; - - [[NSNotificationCenter defaultCenter] removeObserver:WOCNotificationObserverNameBuyDashStep1]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setLogoutButton) name:WOCNotificationObserverNameBuyDashStep1 object:nil]; - - [self.sellYourCryptoButton setTitle:[NSString stringWithFormat:@"SELL YOUR %@",WOCCurrencySpecial] forState:UIControlStateNormal]; - [self setShadowOnButton:self.sellYourCryptoButton]; -} - -- (void)viewWillAppear:(BOOL)animated { - - [super viewWillAppear:animated]; - [self setLogoutButton]; -} - -- (void)viewWillDisappear:(BOOL)animated { - - [super viewWillDisappear:animated]; -} - -- (void)setLogoutButton { - - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - - if (token != nil && (![token isEqualToString:@"(null)"])) { - NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; - NSString *loginPhone = [NSString stringWithFormat:@"Your wallet is signed into Wall of Coins using your mobile number %@",phoneNo]; - self.descriptionLabel.text = loginPhone; - [self.signOutButton setTitle:@"SIGN OUT" forState:UIControlStateNormal]; - self.signoutView.hidden = NO; - self.orderListButton.hidden = NO; - } - else { - NSString *loginPhone = [NSString stringWithFormat:@"Do you already have an order?"]; - self.descriptionLabel.text = loginPhone; - [self.signOutButton setTitle:@"SIGN IN HERE" forState:UIControlStateNormal]; - self.signoutView.hidden = NO; - self.orderListButton.hidden = YES; - } - - [self setShadowOnButton:self.signOutButton]; - [self setShadowOnButton:self.orderListButton]; -} - -- (void)back:(id)sender { - - [self backToRoot]; -} - -// MARK: - API -- (void)signOut:(NSString*)phone { - - [self signOutWOC]; -} - -- (IBAction)onOrderListClick:(id)sender { - - [self getOrderList]; -} - -// MARK: - IBAction - -- (IBAction)onBackButtonClick:(id)sender { - APILog(@"onBackButtonClick"); - [self backToRoot]; -} - -- (IBAction)onSignOutButtonClick:(id)sender { - - UIButton * btn = (UIButton*) sender; - if (btn != nil) { - if ([btn.titleLabel.text isEqualToString:@"SIGN IN HERE"]) { - [self push:@"WOCSellingSignInViewController"]; - } - else { - [self signOutWOC]; - } - } - [self performSelector:@selector(setLogoutButton) withObject:nil afterDelay:1.0]; -} - -- (IBAction)onSellYourCryptoButtonClick:(id)sender { - - [self refereshToken]; - NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; - - if (phoneNo == nil || phoneNo.length == 0) - { - WOCSellingWizardInputPhoineNumberViewController *inputPhoneNumberViewController = [self getViewController:@"WOCSellingWizardInputPhoineNumberViewController"]; - inputPhoneNumberViewController.offerId = @""; - inputPhoneNumberViewController.emailId = @""; - [self pushViewController:inputPhoneNumberViewController animated:YES]; - } - else { - WOCSellingWizardInputEmailViewController *inputEmailViewController = [self getViewController:@"WOCSellingWizardInputEmailViewController"]; - [self pushViewController:inputEmailViewController animated:YES]; - } -} -@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputAmountViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputAmountViewController.h deleted file mode 100644 index a7e0bc36..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputAmountViewController.h +++ /dev/null @@ -1,30 +0,0 @@ -// -// WOCSellingWizardInputAmountViewController.h -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import -#import "WOCBaseViewController.h" -//WOCSellingWizardInputAmountViewController -// Get Offer with Amount -@interface WOCSellingWizardInputAmountViewController : WOCBaseViewController - -@property (strong, nonatomic) NSString *bankId; -@property (strong, nonatomic) NSString *zipCode; -@property (strong, nonatomic) NSDictionary *bankDict; - -@property (weak, nonatomic) IBOutlet UITextField *dashTextfield; -@property (weak, nonatomic) IBOutlet UITextField *dollarTextfield; -@property (weak, nonatomic) IBOutlet UIView *line1; -@property (weak, nonatomic) IBOutlet UIView *line2; -@property (weak, nonatomic) IBOutlet NSLayoutConstraint *line1Height; -@property (weak, nonatomic) IBOutlet NSLayoutConstraint *line2HeightConstant; -@property (weak, nonatomic) IBOutlet UIButton *getOffersButton; -@property (weak, nonatomic) IBOutlet UILabel *titleLabel; - -- (IBAction)getOffersButtonClick:(id)sender; - -@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputAmountViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputAmountViewController.m deleted file mode 100644 index a6020e37..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputAmountViewController.m +++ /dev/null @@ -1,186 +0,0 @@ -// -// WOCSellingWizardInputAmountViewController.m -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import "WOCSellingWizardInputAmountViewController.h" -#import "WOCSellingWizardOfferListViewController.h" -#import "WOCConstants.h" -#import "APIManager.h" -#import "WOCLocationManager.h" -#import -#import "BRWalletManager.h" -#import "WOCAlertController.h" -#import "BRAppDelegate.h" -#import "WOCSellingVerifyDetailViewController.h" -#import "WOCSellingAdvancedOptionsInstructionsViewController.h" - -static const int dashTextField = 101; -static const int dollarTextField = 102; - -//#define dashTextField 101 -//#define dollarTextField 102 - -@interface WOCSellingWizardInputAmountViewController () - -@end - -@implementation WOCSellingWizardInputAmountViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - - [self setShadowOnButton:self.getOffersButton]; - self.titleLabel.text = [NSString stringWithFormat:@"How much do you want per %@?",WOCCurrency]; - self.dashTextfield.text = @"Price Per Coin"; - self.dashTextfield.delegate = self; - self.dollarTextfield.delegate = self; - self.dashTextfield.userInteractionEnabled = NO; - self.line1Height.constant = 1; - self.line2HeightConstant.constant = 2; - [self.dollarTextfield becomeFirstResponder]; -} - -// MARK: - IBAction - -- (IBAction)getOffersButtonClick:(id)sender { - - NSString *dollarString = [self.dollarTextfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; - - if ([dollarString length] > 0 && [dollarString intValue] != 0) { - - if ([dollarString intValue] <10000000) { - - [self loadVarificationScreen]; - - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Amount must be less than $100000." viewController:self.navigationController.visibleViewController]; - } - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Enter amount." viewController:self.navigationController.visibleViewController]; - } -} - -// MARK: - API -- (void)sendUserData:(NSString*)amount zipCode:(NSString*)zipCode bankId:(NSString*)bankId { - - if (self.dashTextfield != nil) { - [self.dashTextfield resignFirstResponder]; - } - - if (self.dollarTextfield != nil) { - [self.dollarTextfield resignFirstResponder]; - } - - BRWalletManager *manager = [BRWalletManager sharedInstance]; - NSString *cryptoAddress = manager.wallet.receiveAddress; - APILog(@"cryptoAddress = %@",cryptoAddress); - - NSDictionary *params = @{ - WOCApiBodyCryptoAmount: @"0", - WOCApiBodyUsdAmount: amount, - WOCApiBodyCrypto: WOCCryptoCurrency, - WOCApiBodyCryptoAddress:cryptoAddress, - WOCApiBodyJsonParameter: @"YES" - }; - - //Receive Crypto Currency Address... - NSString *latitude = [self.defaults valueForKey:WOCUserDefaultsLocalLocationLatitude]; - NSString *longitude = [self.defaults valueForKey:WOCUserDefaultsLocalLocationLongitude]; - - if (latitude == nil && longitude == nil) { - latitude = @""; - longitude = @""; - } - - if (latitude.length > 0 && longitude.length > 0) { - NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:params]; - [dict setObject:@{WOCApiBodyLatitude:latitude , - WOCApiBodyLongitude:longitude } forKey:WOCApiBodyBrowserLocation]; - params = (NSDictionary*)dict; - } - - if (zipCode != nil && zipCode.length > 0) { - NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:params]; - [dict setObject:zipCode forKey:WOCApiBodyZipCode]; - params = (NSDictionary*)dict; - } - - if (bankId != nil && bankId.length > 0) { - NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:params]; - [dict setObject:bankId forKey:WOCApiBodyBank]; - params = (NSDictionary*)dict; - } - - NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:params]; - - if (bankId == nil || bankId.length == 0) { - NSString *countryCodeFromLatLong = [self.defaults objectForKey:WOCApiBodyCountryCode]; - - if (countryCodeFromLatLong == nil) { - NSString *countryCode = [[NSLocale currentLocale] objectForKey: NSLocaleCountryCode]; - [dict setObject:countryCode.lowercaseString forKey:WOCApiBodyCountry]; - } - else { - [dict setObject:countryCodeFromLatLong.lowercaseString forKey:WOCApiBodyCountry]; - } - } - //[dict setObject:@"us" forKey:WOCApiBodyCountry]; - - params = (NSDictionary*)dict; - - [[APIManager sharedInstance] discoverInfo:params response:^(id responseDict, NSError *error) { - if (error == nil) { - NSDictionary *dictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; - - if ([dictionary valueForKey:@"id"] != nil) { - WOCSellingWizardOfferListViewController *offerListViewController = (WOCSellingWizardOfferListViewController*)[self getViewController:@"WOCSellingWizardOfferListViewController"];; - offerListViewController.discoveryId = [NSString stringWithFormat:@"%@",[dictionary valueForKey:@"id"]]; - offerListViewController.amount = self.dollarTextfield.text; - [self pushViewController:offerListViewController animated:YES]; - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Error in getting offers. Please try after some time." viewController:self.navigationController.visibleViewController]; - } - } - else { - [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; - } - }]; -} - - -- (void)loadVarificationScreen { - - [self.defaults setObject:self.dollarTextfield.text forKey:WOCUserDefaultsLocalPrice]; - [self.defaults synchronize]; - - [self.defaults setBool:YES forKey:@"isBeforeCreateAd"]; - [self.defaults synchronize]; - - WOCSellingAdvancedOptionsInstructionsViewController *sellingAdvancedOptionsInstructionsViewController = [self getViewController:@"WOCSellingAdvancedOptionsInstructionsViewController"]; - [self pushViewController:sellingAdvancedOptionsInstructionsViewController animated:YES]; - [sellingAdvancedOptionsInstructionsViewController setupUI]; -} - -// MARK: - UITextField Delegates - -- (void)textFieldDidBeginEditing:(UITextField *)textField { - - if (textField.tag == dashTextField) { - self.line1Height.constant = 2; - self.line2HeightConstant.constant = 1; - } - else { - self.line1Height.constant = 1; - self.line2HeightConstant.constant = 2; - } -} - -@end - diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputEmailViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputEmailViewController.h deleted file mode 100644 index 56216914..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputEmailViewController.h +++ /dev/null @@ -1,24 +0,0 @@ -// -// WOCSellingWizardInputEmailViewController.h -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import -#import "WOCBaseViewController.h" -//WOCSellingWizardInputEmailViewController - -// Enter Email Address Screen -@interface WOCSellingWizardInputEmailViewController : WOCBaseViewController - -@property (strong, nonatomic) NSString *offerId; - -@property (weak, nonatomic) IBOutlet UIButton *nextButton; -@property (weak, nonatomic) IBOutlet UITextField *emailTextField; - -- (IBAction)onDoNotSendMeEmailButtonClick:(id)sender; -- (IBAction)onNextButtonClick:(id)sender; - -@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputEmailViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputEmailViewController.m deleted file mode 100644 index 65c5cf82..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputEmailViewController.m +++ /dev/null @@ -1,70 +0,0 @@ -// -// WOCBuyingWizardInputEmailViewController.m -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import "WOCSellingWizardInputEmailViewController.h" -#import "WOCSellingWizardInputPhoineNumberViewController.h" -#import "WOCAlertController.h" -#import "WOCConstants.h" -#import "WOCSellingWizardPaymentCenterViewController.h" - -@interface WOCSellingWizardInputEmailViewController () - -@end - -@implementation WOCSellingWizardInputEmailViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - - [self setShadowOnButton:self.nextButton]; - - if ([self.defaults objectForKey:WOCUserDefaultsLocalEmail] != nil) { - NSString *emailStr = [self.defaults objectForKey:WOCUserDefaultsLocalEmail]; - self.emailTextField.text = emailStr; - } -} - -- (BOOL)validateEmailWithString:(NSString*)checkString { - - BOOL stricterFilter = NO; // Discussion http://blog.logichigh.com/2010/09/02/validating-an-e-mail-address/ - NSString *stricterFilterString = @"[A-Z0-9a-z\\._%+-]+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2,4}"; - NSString *laxString = @".+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2}[A-Za-z]*"; - NSString *emailRegex = stricterFilter ? stricterFilterString : laxString; - NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex]; - return [emailTest evaluateWithObject:checkString]; -} - -// MARK: - IBAction - -- (IBAction)onDoNotSendMeEmailButtonClick:(id)sender { - - [self.defaults removeObjectForKey:WOCUserDefaultsLocalEmail]; - - WOCSellingWizardPaymentCenterViewController *paymentCenterViewController = [self getViewController:@"WOCSellingWizardPaymentCenterViewController"]; - [self pushViewController:paymentCenterViewController animated:YES]; -} - -- (IBAction)onNextButtonClick:(id)sender { - - NSString *emailStr = [self.emailTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; - - if ([emailStr length] == 0) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter email." viewController:self.navigationController.visibleViewController]; - } - else if (![self validateEmailWithString:emailStr]) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter valid email." viewController:self.navigationController.visibleViewController]; - } - else { - - [self.defaults setObject:emailStr forKey:WOCUserDefaultsLocalEmail]; - WOCSellingWizardPaymentCenterViewController *paymentCenterViewController = [self getViewController:@"WOCSellingWizardPaymentCenterViewController"]; - [self pushViewController:paymentCenterViewController animated:YES]; - } -} -@end - diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputPhoineNumberViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputPhoineNumberViewController.h deleted file mode 100644 index 2260b86f..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputPhoineNumberViewController.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// WOCSellingWizardInputPhoineNumberViewController.h -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import -#import "WOCBaseViewController.h" -//WOCSellingWizardInputPhoineNumberViewController - -// Enter Phone Number Screen -@interface WOCSellingWizardInputPhoineNumberViewController : WOCBaseViewController - -@property (strong, nonatomic) NSString *offerId; -@property (strong, nonatomic) NSString *emailId; -@property (assign, nonatomic) BOOL isActiveHoldChecked; -@property (assign, nonatomic) BOOL isForLoginOny; -@property (weak, nonatomic) IBOutlet UIButton *nextButton; -@property (weak, nonatomic) IBOutlet UITextField *countryCodeTextfield; -@property (weak, nonatomic) IBOutlet UITextField *phoneNumberTextfield; - -- (IBAction)onNextButtonClicked:(id)sender; - -@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputPhoineNumberViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputPhoineNumberViewController.m deleted file mode 100644 index 826efa71..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardInputPhoineNumberViewController.m +++ /dev/null @@ -1,490 +0,0 @@ -// -// WOCSellingWizardInputPhoineNumberViewController.m -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import "WOCSellingWizardInputPhoineNumberViewController.h" -#import "WOCSellingWizardConfirmCodeViewController.h" -#import "WOCSellingInstructionsViewController.h" -#import "WOCSellingSummaryViewController.h" -#import "WOCPasswordViewController.h" -#import "BRRootViewController.h" -#import "BRAppDelegate.h" -#import "APIManager.h" -#import "WOCConstants.h" -#import "WOCAlertController.h" -#import "MBProgressHUD.h" -#import "WOCHoldIssueViewController.h" -#import "WOCSellingWizardHomeViewController.h" -#import "WOCSellingCreatePasswordViewController.h" -#import "WOCSellingSingUpViewController.h" - -@interface WOCSellingWizardInputPhoineNumberViewController () - -@property (strong, nonatomic) NSArray *countries; -@property (strong, nonatomic) UIPickerView *pickerView; -@property (strong, nonatomic) NSString *countryCode; -@property (strong, nonatomic) NSString *purchaseCode; -@property (strong, nonatomic) NSString *holdId; - -@end - -@implementation WOCSellingWizardInputPhoineNumberViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - - [self setShadowOnButton:self.nextButton]; - - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(openBuyDashStep8:) name:WOCNotificationObserverNameBuyDashStep8 object:nil]; - - self.pickerView = [[UIPickerView alloc] init]; - self.pickerView.delegate = self; - self.pickerView.dataSource = self; - self.countryCodeTextfield.inputView = self.pickerView; - - [self loadJSON]; -} - -- (void)loadJSON { - // Retrieve local JSON file called example.json - NSString *filePath = [[NSBundle mainBundle] pathForResource:@"countries" ofType:@"json"]; - - // Load the file into an NSData object called JSONData - NSError *error = nil; - NSData *JSONData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:&error]; - - // Create an Objective-C object from JSON Data - NSDictionary *countriesDict = [NSJSONSerialization JSONObjectWithData:JSONData options:NSJSONReadingMutableContainers error:nil]; - NSArray *countries = [countriesDict valueForKey:@"countries"]; - - self.countries = countries; - if (self.countries.count > 0) { - self.countryCodeTextfield.text = [NSString stringWithFormat:@"%@ (%@)",self.countries[0][@"name"],self.countries[0][@"code"]]; - self.countryCode = [NSString stringWithFormat:@"%@",self.countries[0][@"code"]]; - } - - [self.pickerView reloadAllComponents]; -} - -- (void)openBuyDashStep8:(NSNotification*)notification { - - NSString *phoneNo = [NSString stringWithFormat:@"%@",notification.object]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults synchronize]; - - [self push:@"WOCSellingWizardInputEmailViewController"]; -} - -// MARK: - API - -- (void)checkPhone:(NSString*)phone code:(NSString*)countryCode { - - NSDictionary *params = @{ - }; - - NSString *phoneNo = [NSString stringWithFormat:@"%@%@",countryCode,phone]; - - - [[APIManager sharedInstance] authorizeDevice:nil phone:phoneNo response:^(id responseDict, NSError *error) { - - if (error == nil) { - - [self.defaults setObject:countryCode forKey:WOCUserDefaultsLocalCountryCode]; - [self.defaults synchronize]; - - NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; - - if ([[responseDictionary valueForKey:@"availableAuthSources"] isKindOfClass:[NSArray class]]) { - NSArray *availableAuthSource = (NSArray*)[responseDictionary valueForKey:@"availableAuthSources"]; - if (availableAuthSource.count > 0) { - if ([[availableAuthSource objectAtIndex:0] isEqualToString:@"password"]) { - UIStoryboard *storyboard = [UIStoryboard storyboardWithName:WOCBuyingStoryboard bundle:nil]; - - WOCPasswordViewController *passwordViewController = [storyboard instantiateViewControllerWithIdentifier:@"WOCPasswordViewController"]; - passwordViewController.phoneNo = phoneNo; - passwordViewController.modalTransitionStyle = UIModalPresentationOverCurrentContext; - [self.navigationController presentViewController:passwordViewController animated:YES completion:nil]; - } - else if ([[availableAuthSource objectAtIndex:0] isEqualToString:@"device"]) { - [self createHoldAfterAuthorize:phoneNo]; - } - } - } - } - else { - - if ([error code] == 404) { - //new number - [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults synchronize]; - - [self createHold:phoneNo]; - } - else { - dispatch_async(dispatch_get_main_queue(), ^{ - if (error.userInfo != nil) { - if (error.userInfo[@"detail"] != nil) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self.navigationController.visibleViewController]; - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; - } - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; - } - }); - } - } - }]; -} - -- (void)login:(NSString*)phoneNo { - - NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; - NSString *deviceId = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceId]; - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - - NSDictionary *params = @{ - WOCApiBodyDeviceCode: deviceCode - }; - - if (deviceId != nil) { - - params = @{ - WOCApiBodyDeviceCode: deviceCode, - WOCApiBodyDeviceId: deviceId, - WOCApiBodyJsonParameter: @"YES" - }; - - [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDict, NSError *error) { - - NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; - if (error == nil) { - - if (responseDictionary != nil) { - [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - [self storeDeviceInfoLocally]; - [self createHoldAfterAuthorize:phoneNo]; - } - } - else { - - [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - - BOOL isNewPhone = YES; - - if (error.code == 400) { - if (error.userInfo != nil) { - NSString *errorDetail = error.userInfo[@"detail"]; - if (errorDetail != nil) { - if ([errorDetail isEqualToString:@"Unable to authorize your phone number. Password may be incorrect."]) { - isNewPhone = FALSE; - } - } - } - } - if (isNewPhone) { - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults synchronize]; - [self createHoldAfterAuthorize:phoneNo]; - } - else { - [self openHoldIssueVC]; - } - } - }]; - } -} - -- (void)createHold:(NSString*)phoneNo { - - if (!self.isForLoginOny) { - WOCSellingSingUpViewController *sellingSingUpViewController = [self getViewController:@"WOCSellingSingUpViewController"]; - [self pushViewController:sellingSingUpViewController animated:YES]; - } - else { - - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - if (token != nil && (![token isEqualToString:@"(null)"])) { - [self getOrderList]; - } - else { - - UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Error" message:@"Please select an offer and then try to register/login with app." preferredStyle:UIAlertControllerStyleAlert]; - - UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { - [self backToMainView]; - }]; - - [alert addAction:okAction]; - [self presentViewController:alert animated:YES completion:nil]; - - } - } -} - -- (void)resolveActiveHoldIssue:(NSString*)phoneNo { - - if (!self.isActiveHoldChecked) { - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - if (token != nil && (![token isEqualToString:@"(null)"])) { - /*you receive Status 403 from POST /api/v1/holds/ - IF YOU HAVE a token or the deviceId/deviceCode, login with that device -- you will use the token to get a list of holds so that you can cancel the holds. IF THERE ARE NO HOLDS, then you will bring the user to the Buy Summary, where they will see their latest WD orders. - */ - self.isActiveHoldChecked = YES; - [self getHold]; - } - else { - - - NSString *deviceID = [self getDeviceIDFromPhoneNumber:phoneNo]; - if (deviceID.length > 0 && (![deviceID isEqualToString:@"(null)"])) { - [self.defaults setObject:deviceID forKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - [self login:phoneNo]; - } - else { - [self openHoldIssueVC]; - } - } - } -} - -- (void)openHoldIssueVC { - /* - IF YOU DO NOT HAVE the token or deviceId/deviceCode in local storage, then you will need to show a new view that says, "You already have an open hold or a pending order with Wall of Coins. Before you can create a new order, you must finish these orders." and then show a yellow button w/ blue text (just like the "BUY MORE {Crypto Currency} WITH CASH" button), and when they press that button, you will bring them to this website link: - https://wallofcoins.com/signin/1-2397776832/ - https://wallofcoins.com/signin/{phone_country_code}-{local_phone_number}/ - */ - NSString *txtPhone = [self.phoneNumberTextfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; - NSString *txtcountryCode = [self.countryCode stringByReplacingOccurrencesOfString:@"+" withString:@""]; - WOCHoldIssueViewController *aViewController = [self getViewController:@"WOCHoldIssueViewController"]; - aViewController.phoneNo = [NSString stringWithFormat:@"%@-%@",txtcountryCode,txtPhone]; - [self pushViewController:aViewController animated:YES]; -} - -- (void)resolvePandingOrderIssue { - - [self getOrderList]; -} - -- (void)getHold { - - [[APIManager sharedInstance] getHold:^(id responseDict, NSError *error) { - if (error == nil) { - APILog(@"Hold with Hold Id: %@.",responseDict); - if ([responseDict isKindOfClass:[NSArray class]]) { - NSArray *holdArray = (NSArray*)responseDict; - if (holdArray.count > 0) { - NSUInteger count = holdArray.count; - NSUInteger activeHodCount = 0; - - for (int i = 0; i < holdArray.count; i++) { - count -= count; - - NSDictionary *holdDict = [holdArray objectAtIndex:i]; - NSString *holdId = [holdDict valueForKey:WOCApiResponseId]; - NSString *holdStatus = [holdDict valueForKey:WOCApiResponseHoldsStatus]; - - if (holdStatus != nil) { - if ([holdStatus isEqualToString:@"AC"]) { - if (holdId) { - activeHodCount = activeHodCount + 1; - [self deleteHold:holdId count:count]; - } - } - } - else { - if (holdId) { - activeHodCount = activeHodCount + 1; - [self deleteHold:holdId count:count]; - } - } - } - - if (activeHodCount == 0 ) { - [self resolvePandingOrderIssue]; - } - } - else { - [self resolvePandingOrderIssue]; - } - } - else { - [self resolvePandingOrderIssue]; - } - } - else { - [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; - } - }]; -} - -- (void)deleteHold:(NSString*)holdId count:(NSUInteger)count { - - NSDictionary *params = @{ - }; - - [[APIManager sharedInstance] deleteHold:holdId response:^(id responseDict, NSError *error) { - if (error == nil) { - APILog(@"Hold deleted."); - - NSString *phoneNo = [self.defaults valueForKey:WOCUserDefaultsLocalPhoneNumber]; - [self createHoldAfterAuthorize:phoneNo]; - } - }]; -} - -- (void)registerDevice:(NSString*)phoneNo { - - MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; - - NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - - NSDictionary *params = @{ - WOCApiBodyName: WOCApiBodyDeviceName_IOS, - WOCApiBodyCode: deviceCode, - WOCApiBodyJsonParameter:@"YES" - }; - - [[APIManager sharedInstance] registerDevice:params response:^(id responseDict, NSError *error) { - dispatch_async(dispatch_get_main_queue(), ^(void) { - [hud hideAnimated:YES]; - }); - - if (error == nil) { - NSDictionary *response = (NSDictionary*)responseDict; - if (response.count > 0) { - NSString *deviceId = [NSString stringWithFormat:@"%@",[response valueForKey:WOCApiResponseId]]; - [self authorize:phoneNo deviceId:deviceId]; - } - } - else { - - [self pushToStep1]; - [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; - } - }]; -} - -- (void)authorize:(NSString*)phoneNo deviceId:(NSString*)deviceId { - - NSString *deviceCode = [self.defaults valueForKey:WOCUserDefaultsLocalDeviceCode]; - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - - NSDictionary *params = @{ - WOCApiBodyDeviceCode: deviceCode, - WOCApiBodyJsonParameter: @"YES" - }; - - if (deviceId != nil && (![deviceId isEqualToString:@"(null)"])) { - params = @{ - WOCApiBodyDeviceCode: deviceCode, - WOCApiBodyDeviceId: deviceId, - WOCApiBodyJsonParameter: @"YES" - }; - } - - [[APIManager sharedInstance] login:params phone:phoneNo response:^(id responseDict, NSError *error) { - if (error == nil) { - - NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; - [self.defaults setValue:[responseDictionary valueForKey:WOCApiResponseToken] forKey:WOCUserDefaultsAuthToken]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults setValue:[NSString stringWithFormat:@"%@",[responseDictionary valueForKey:WOCApiBodyDeviceId]] forKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - - [self storeDeviceInfoLocally]; - [self createHoldAfterAuthorize:phoneNo]; - } - else { - - [self.defaults removeObjectForKey:WOCUserDefaultsAuthToken]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults removeObjectForKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults setValue:phoneNo forKey:WOCUserDefaultsLocalPhoneNumber]; - [self.defaults synchronize]; - [[WOCAlertController sharedInstance] alertshowWithError:error viewController:self.navigationController.visibleViewController]; - } - }]; -} - -- (void)createHoldAfterAuthorize:(NSString*)phoneNo { - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - - if (token != nil && (![token isEqualToString:@"(null)"])) { - [self push:@"WOCSellingWizardInputEmailViewController"]; - } - else { - NSString *deviceID = [self getDeviceIDFromPhoneNumber:phoneNo]; - if (deviceID != nil) { - [self.defaults setObject:deviceID forKey:WOCUserDefaultsLocalDeviceId]; - [self.defaults synchronize]; - [self login:phoneNo]; - } - else { - [self createHold:phoneNo]; - } - } -} - -// MARK: - IBAction -- (IBAction)onNextButtonClicked:(id)sender { - - NSString *txtPhone = [self.phoneNumberTextfield.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; - - if ([self.countryCode length] == 0) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Select country code." viewController:self.navigationController.visibleViewController]; - } - else if ([txtPhone length] == 0) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter phone number." viewController:self.navigationController.visibleViewController]; - } - else if ([txtPhone length] == 10) { - self.isActiveHoldChecked = NO; - [self checkPhone:txtPhone code:self.countryCode]; - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Alert" message:@"Enter valid phone number." viewController:self.navigationController.visibleViewController]; - } -} - -// MARK: - UIPickerView Delegates - -- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView { - return 1; -} - -- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component { - return self.countries.count; -} - -- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { - return [NSString stringWithFormat:@"%@ (%@)",self.countries[row][@"name"],self.countries[row][@"code"]]; -} - -- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { - self.countryCodeTextfield.text = [NSString stringWithFormat:@"%@ (%@)",self.countries[row][@"name"],self.countries[row][@"code"]]; - self.countryCode = [NSString stringWithFormat:@"%@",self.countries[row][@"code"]]; -} - -- (void)pushToStep1 { - [self storeDeviceInfoLocally]; - [self backToMainView]; -} - -@end - diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardOfferListViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardOfferListViewController.h deleted file mode 100644 index 27ddc51e..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardOfferListViewController.h +++ /dev/null @@ -1,25 +0,0 @@ -// -// WOCSellingWizardOfferListViewController.h -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import -#import "WOCBaseViewController.h" - -//WOCSellingWizardOfferListViewController - -// Offer List ViewController -@interface WOCSellingWizardOfferListViewController : WOCBaseViewController - -@property (strong, nonatomic) NSString *discoveryId; -@property (strong, nonatomic) NSString *amount; - -@property (weak, nonatomic) IBOutlet UILabel *instructionLabel; -@property (weak, nonatomic) IBOutlet UITableView *offerListtTableView; - -- (IBAction)orderClicked:(id)sender; -- (NSIndexPath*)getIndexPathfromTag:(NSInteger)tag; -@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardOfferListViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardOfferListViewController.m deleted file mode 100644 index 0a8bcbf0..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardOfferListViewController.m +++ /dev/null @@ -1,496 +0,0 @@ -// -// WOCSellingWizardOfferListViewController.m -// Wallofcoins -// -// Created by Genitrust on 24/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import "WOCSellingWizardOfferListViewController.h" -#import "WOCSellingWizardInputEmailViewController.h" -#import "WOCSellingInstructionsViewController.h" -#import "WOCSellingSummaryViewController.h" -#import "BRRootViewController.h" -#import "BRAppDelegate.h" -#import "WOCOfferCell.h" -#import "APIManager.h" -#import "BRWalletManager.h" -#import "WOCAlertController.h" -#import "MBProgressHUD.h" -#import "WOCSellingWizardHomeViewController.h" -#import "WOCAsyncImageView.h" - -@interface WOCSellingWizardOfferListViewController () - -@property (strong, nonatomic) NSArray *offers; -@property (strong, nonatomic) NSMutableDictionary *offersDict; - -@property (assign, nonatomic) BOOL incremented; -@property (assign, nonatomic) BOOL isExtendedSearch; -@end - -@implementation WOCSellingWizardOfferListViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - - self.instructionLabel.text = [NSString stringWithFormat:@"Below are offers for at least $%@. You must click the ORDER button before you receive instructions to pay at the Cash Payment center.",self.amount]; - [self getOffers]; -} - -- (void)pushToStep6:(NSInteger)sender { - - NSIndexPath *indexPath = [self getIndexPathfromTag:sender]; - NSString *key = self.offersDict.allKeys[indexPath.section]; - NSArray *offerArray = self.offersDict[key]; - NSDictionary *offerDict = offerArray[indexPath.row]; - WOCSellingWizardInputEmailViewController *inputEmailViewController = (WOCSellingWizardInputEmailViewController*)[self getViewController:@"WOCSellingWizardInputEmailViewController"]; - inputEmailViewController.offerId = [NSString stringWithFormat:@"%@",[offerDict valueForKey:@"id"]]; - [self pushViewController:inputEmailViewController animated:YES]; -} - -// MARK: - API - -- (void)getOffers { - - self.offersDict = [NSMutableDictionary dictionaryWithCapacity:0]; - if (self.discoveryId != nil && [self.discoveryId length] > 0) { - - MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; - - [[APIManager sharedInstance] discoveryInputs:self.discoveryId response:^(id responseDict, NSError *error) { - - dispatch_async(dispatch_get_main_queue(), ^{ - [hud hideAnimated:YES]; - }); - - if (error == nil) { - - NSDictionary *responseDictionary = [[NSDictionary alloc] initWithDictionary:(NSDictionary*)responseDict]; - - if ([[responseDictionary valueForKey:@"isExtendedSearch"] boolValue]) { - self.isExtendedSearch = YES; - - self.instructionLabel.text = [NSString stringWithFormat:@"Most Convenient Options While $%@ is not available, we gathered the closest options.You must click the ORDER button before you receive instructions to pay at the Cash Payment center.",self.amount]; - } - else { - self.isExtendedSearch = NO; - - if ([[responseDictionary valueForKey:@"incremented"] boolValue]) { - self.incremented = YES; - self.instructionLabel.text = [NSString stringWithFormat:@"Below are offers for at least $%@. You must click the ORDER button before you receive instructions to pay at the Cash Payment center.",self.amount]; - } - else { - self.incremented = NO; - self.instructionLabel.text = [NSString stringWithFormat:@"Below are offers for $%@. You must click the ORDER button before you receive instructions to pay at the Cash Payment center.",self.amount]; - } - } - - if ([responseDictionary valueForKey:@"singleDeposit"] != nil) { - - if ([[responseDictionary valueForKey:@"singleDeposit"] isKindOfClass:[NSArray class]] ) { - - NSArray *offersArray = [[NSArray alloc] initWithArray:(NSArray*)[responseDictionary valueForKey:@"singleDeposit"]]; - self.offers = [[NSArray alloc] initWithArray:offersArray]; - if (offersArray.count > 0) { - self.offersDict[@""] = offersArray; - } - } - } - - if ([responseDictionary valueForKey:@"doubleDeposit"] != nil) { - - if ([[responseDictionary valueForKey:@"doubleDeposit"] isKindOfClass:[NSArray class]] ) { - - NSArray *offersArray = [[NSArray alloc] initWithArray:(NSArray*)[responseDictionary valueForKey:@"doubleDeposit"]]; - NSArray *doubleOffer = [self getOffersFromDoubleDeposit:offersArray]; - if (doubleOffer.count > 0) { - if (self.isExtendedSearch) { - NSString *key = [NSString stringWithFormat:@"Best Value options: more %@ for under $%@ cash.",WOCCurrency,self.amount]; - self.offersDict[key] = doubleOffer; - } - else { - NSString *key = [NSString stringWithFormat:@"Best Value options: more %@ for $%@ cash.",WOCCurrency,self.amount]; - self.offersDict[key] = doubleOffer; - } - } - } - } - - if ([responseDictionary valueForKey:@"multipleBanks"] != nil) { - - if ([[responseDictionary valueForKey:@"multipleBanks"] isKindOfClass:[NSArray class]] ) { - - NSArray *offersArray = [[NSArray alloc] initWithArray:(NSArray*)[responseDictionary valueForKey:@"multipleBanks"]]; - NSArray *multipleBankOffer = [self getOffersFromDoubleDeposit:offersArray]; NSArray *doubleOffer = [self getOffersFromDoubleDeposit:offersArray]; - if (multipleBankOffer.count > 0) { - if (self.isExtendedSearch) { - NSString *key = [NSString stringWithFormat:@"Best Value options: more %@ for under $%@ cash from multiple banks.",WOCCurrency,self.amount]; - self.offersDict[key] = multipleBankOffer; - } - else { - NSString *key = [NSString stringWithFormat:@"Best Value options: more %@ for $%@ cash from multiple banks.",WOCCurrency,self.amount]; - self.offersDict[key] = multipleBankOffer; - } - } - } - } - - dispatch_async(dispatch_get_main_queue(), ^{ - [self.offerListtTableView reloadData]; - }); - - } - else { - dispatch_async(dispatch_get_main_queue(), ^{ - if (error.userInfo != nil) { - if (error.userInfo[@"detail"] != nil) { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.userInfo[@"detail"] viewController:self.navigationController.visibleViewController]; - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; - } - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:@"Error" message:error.localizedDescription viewController:self.navigationController.visibleViewController]; - } - }); - } - }]; - } -} - -- (NSArray*)getOffersFromDoubleDeposit:(NSArray*)doubleDepositOffers -{ - NSMutableArray *signleDepositOfferArray = [NSMutableArray arrayWithCapacity:0]; - for (NSDictionary *offerDictionary in doubleDepositOffers) - { - NSMutableDictionary *reviceOfferDict = [[NSMutableDictionary alloc] initWithCapacity:0]; - reviceOfferDict[@"deposit"] = @{ - @"currency": REMOVE_NULL_VALUE(offerDictionary[@"totalDeposit"][@"currency"]), - @"amount": REMOVE_NULL_VALUE(offerDictionary[@"totalDeposit"][@"amount"]) - }; - reviceOfferDict[@"id"] = offerDictionary[@"id"]; - - if (offerDictionary[@"firstOffer"] != nil) { - NSDictionary *firstOfferDict = offerDictionary[@"firstOffer"]; - - reviceOfferDict[@"crypto"] = firstOfferDict[@"crypto"]; - reviceOfferDict[@"amount"] = @{ - @"DASH" : REMOVE_NULL_VALUE(firstOfferDict[@"amount"][@"DASH"]), - @"dots" : REMOVE_NULL_VALUE(firstOfferDict[@"amount"][@"dots"]), - @"bits" : REMOVE_NULL_VALUE(firstOfferDict[@"amount"][@"bits"]), - @"BTC" : REMOVE_NULL_VALUE(firstOfferDict[@"amount"][@"BTC"]) - }; - reviceOfferDict[@"discoveryId"] = REMOVE_NULL_VALUE(firstOfferDict[@"discoveryId"]); - reviceOfferDict[@"distance"] = REMOVE_NULL_VALUE(firstOfferDict[@"distance"]); - reviceOfferDict[@"address"] = REMOVE_NULL_VALUE(firstOfferDict[@"address"] ); - reviceOfferDict[@"state"] = REMOVE_NULL_VALUE(firstOfferDict[@"state"]) ; - reviceOfferDict[@"bankName"] = REMOVE_NULL_VALUE(firstOfferDict[@"bankName"]) ; - reviceOfferDict[@"bankLogo"] = REMOVE_NULL_VALUE(firstOfferDict[@"bankLogo"]) ; - reviceOfferDict[@"bankIcon"] = REMOVE_NULL_VALUE(firstOfferDict[@"bankIcon"]) ; - reviceOfferDict[@"bankLocationUrl"] = REMOVE_NULL_VALUE(firstOfferDict[@"bankLocationUrl"]); - reviceOfferDict[@"city"] = REMOVE_NULL_VALUE(firstOfferDict[@"city"]); - - - if (offerDictionary[@"secondOffer"] != nil) { - NSDictionary *secondOffer = offerDictionary[@"secondOffer"]; - if (![REMOVE_NULL_VALUE(firstOfferDict[@"bankName"]) isEqualToString:REMOVE_NULL_VALUE(secondOffer[@"bankName"])]) { - reviceOfferDict[@"isMultipleBank"] = @YES; - reviceOfferDict[@"otherBankName"] = REMOVE_NULL_VALUE(secondOffer[@"bankName"]); - reviceOfferDict[@"otherBankLogo"] = REMOVE_NULL_VALUE(secondOffer[@"bankLogo"]); - } - - NSDictionary *amountDict = firstOfferDict[@"amount"]; - NSDictionary *secondAmountDict = offerDictionary[@"secondOffer"]; - - NSNumber *firstOfferMinorNumber = [NSNumber numberWithFloat:[NSString stringWithFormat:@"%@",[REMOVE_NULL_VALUE(firstOfferDict[@"amount"][WOCCryptoCurrencySmall]) stringByReplacingOccurrencesOfString:@"," withString:@""]].floatValue]; - - NSNumber *secondOfferMinorNumber = [NSNumber numberWithFloat:[NSString stringWithFormat:@"%@",[REMOVE_NULL_VALUE(secondOffer[@"amount"][WOCCryptoCurrencySmall]) stringByReplacingOccurrencesOfString:@"," withString:@""]].floatValue]; - - NSNumber *totoalMinorNumber = [NSNumber numberWithFloat:(firstOfferMinorNumber.longLongValue + secondOfferMinorNumber.floatValue)] ; - - NSString *totalMinorStr = [self getCryptoPrice:totoalMinorNumber]; - APILog(@"totalMinorStr = %@",totalMinorStr); - - NSNumber *firstOfferMajorNumber = [NSNumber numberWithFloat:[NSString stringWithFormat:@"%@",[REMOVE_NULL_VALUE(firstOfferDict[@"amount"][WOCCryptoCurrency]) stringByReplacingOccurrencesOfString:@"," withString:@""]].floatValue]; - - NSNumber *secondOfferMajorNumber = [NSNumber numberWithFloat:[NSString stringWithFormat:@"%@",[REMOVE_NULL_VALUE(secondOffer[@"amount"][WOCCryptoCurrency]) stringByReplacingOccurrencesOfString:@"," withString:@""]].floatValue]; - - NSNumber *totoalMajorNumber = [NSNumber numberWithFloat:(firstOfferMajorNumber.longLongValue + secondOfferMajorNumber.floatValue)] ; - - NSString *totalMajorStr = [self getCryptoPrice:totoalMajorNumber]; - APILog(@"totalMajorStr = %@",totalMajorStr); - - reviceOfferDict[@"amount"] = @{ - WOCCryptoCurrency : totalMajorStr, - WOCCryptoCurrencySmall : totalMinorStr, - @"bits" : [NSNumber numberWithFloat:([amountDict[@"bits"] floatValue] + [secondAmountDict[@"bits"] floatValue])], - @"BTC" : [NSNumber numberWithFloat:([amountDict[@"BTC"] floatValue] + [secondAmountDict[@"BTC"] floatValue])] - }; - } - - [signleDepositOfferArray addObject:reviceOfferDict]; - } - } - return (NSArray*)signleDepositOfferArray; -} - -- (void)getOrders:(NSInteger)sender { - - MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.topViewController.view animated:YES]; - - NSDictionary *params = @{ - }; - - [[APIManager sharedInstance] getOrders:nil response:^(id responseDict, NSError *error) { - - dispatch_async(dispatch_get_main_queue(), ^(void){ - [hud hideAnimated:YES]; - }); - - NSString *phoneNo = [[NSUserDefaults standardUserDefaults] valueForKey:WOCUserDefaultsLocalPhoneNumber]; - - if (error == nil) { - if ([responseDict isKindOfClass:[NSArray class]]) { - NSArray *orders = [[NSArray alloc] initWithArray:(NSArray*)responseDict]; - if (orders.count > 0) { - NSPredicate *wdvPredicate = [NSPredicate predicateWithFormat:@"status == 'WD'"]; - NSArray *wdArray = [orders filteredArrayUsingPredicate:wdvPredicate]; - if (wdArray.count > 0) { - NSDictionary *orderDict = (NSDictionary*)[wdArray objectAtIndex:0]; - NSString *status = [NSString stringWithFormat:@"%@",[orderDict valueForKey:@"status"]]; - if ([status isEqualToString:@"WD"]) { - WOCSellingInstructionsViewController *instructionsViewController = [self getViewController:@"WOCSellingInstructionsViewController"]; - instructionsViewController.phoneNo = phoneNo; - instructionsViewController.isFromSend = YES; - instructionsViewController.isFromOffer = NO; - instructionsViewController.orderDict = orderDict; - [self pushViewController:instructionsViewController animated:YES]; - return ; - } - } - } - } - - WOCSellingInstructionsViewController *instructionsViewController = [self getViewController:@"WOCSellingInstructionsViewController"]; - instructionsViewController.phoneNo = phoneNo; - instructionsViewController.isFromSend = NO; - instructionsViewController.isFromOffer = YES; - - NSIndexPath *indexPath = [self getIndexPathfromTag:sender]; - NSString *key = self.offersDict.allKeys[indexPath.section]; - NSArray *offerArray = self.offersDict[key]; - NSDictionary *offerDict = offerArray[indexPath.row]; - - instructionsViewController.offerId = [NSString stringWithFormat:@"%@",[offerDict valueForKey:WOCApiResponseId]]; - [self pushViewController:instructionsViewController animated:YES]; - } - else { - [self refereshToken]; - } - }]; -} - -// MARK: - IBAction - -- (IBAction)orderClicked:(id)sender { - - NSString *token = [self.defaults valueForKey:WOCUserDefaultsAuthToken]; - if (token != nil && (![token isEqualToString:@"(null)"])) { - [self getOrders:[sender tag]]; - } - else { - [self pushToStep6:[sender tag]]; - } -} - -- (IBAction)checkLocationClicked:(id)sender { - - NSIndexPath *indexPath = [self getIndexPathfromTag:[sender tag]]; - NSString *key = self.offersDict.allKeys[indexPath.section]; - NSArray *offerArray = self.offersDict[key]; - NSDictionary *offerDict = offerArray[indexPath.row]; - - if (![[offerDict valueForKey:@"bankLocationUrl"] isEqual:[NSNull null]]) { - NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",[offerDict valueForKey:@"bankLocationUrl"]]]; - if ([[UIApplication sharedApplication] canOpenURL:url]) { - [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) { - APILog(@"URL opened!"); - }]; - } - } -} - -// MARK: - UITableView DataSource -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - - return self.offersDict.allKeys.count; -} - -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - - NSString *key = self.offersDict.allKeys[section]; - NSArray *offerArray = self.offersDict[key]; - return offerArray.count; -} - -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - - static const NSInteger IMAGE_VIEW_TAG = 98; - static const NSInteger OTHER_IMAGE_VIEW_TAG = 99; - NSString *cellIdentifier = @"offerCell"; - WOCOfferCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; - UIView *cellView = cell.bankImageView.superview; - - WOCAsyncImageView *imageView = (WOCAsyncImageView *)[cellView viewWithTag:IMAGE_VIEW_TAG]; - WOCAsyncImageView *otherImageView = (WOCAsyncImageView *)[cellView viewWithTag:OTHER_IMAGE_VIEW_TAG]; - - if (imageView == nil) { - imageView = [[WOCAsyncImageView alloc] initWithFrame:cell.bankImageView.frame]; - imageView.contentMode = UIViewContentModeScaleAspectFill; - imageView.clipsToBounds = YES; - imageView.image = [UIImage imageNamed:@"ic_account_balance_black"]; - imageView.tag = IMAGE_VIEW_TAG; - [cellView addSubview:imageView]; - } - - if (otherImageView == nil) { - - otherImageView = [[WOCAsyncImageView alloc] initWithFrame:cell.otherBankImageView.frame]; - otherImageView.contentMode = UIViewContentModeScaleAspectFill; - otherImageView.clipsToBounds = YES; - otherImageView.image = [UIImage imageNamed:@"ic_account_balance_black"]; - otherImageView.tag = OTHER_IMAGE_VIEW_TAG; - [cellView addSubview:otherImageView]; - otherImageView.hidden = YES; - } - - cell.bankImageView.hidden = YES; - cell.otherBankImageView.hidden = YES; - otherImageView.hidden = YES; - imageView.hidden = NO; - - //get image view - //cancel loading previous image for cell - [[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:imageView]; - [[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:otherImageView]; - - NSString *key = self.offersDict.allKeys[indexPath.section]; - NSArray *offerArray = self.offersDict[key]; - - NSDictionary *offerDict = offerArray[indexPath.row]; - if (self.incremented || self.isExtendedSearch) { - cell.dollarLabel.hidden = NO; - } - else { - cell.dollarLabel.hidden = NO; - } - - NSString *dashAmount = [NSString stringWithFormat:@"%@ %@",WOCCurrencySymbol,REMOVE_NULL_VALUE([[offerDict valueForKey:@"amount"] valueForKey:WOCCryptoCurrency])]; - NSString *bits = [NSString stringWithFormat:@"(%@ %@)",WOCCurrencySymbolMinor,REMOVE_NULL_VALUE([[offerDict valueForKey:@"amount"] valueForKey:WOCCryptoCurrencySmall])]; - NSString *dollarAmount = [NSString stringWithFormat:@"Pay $%@",REMOVE_NULL_VALUE([[offerDict valueForKey:@"deposit"] valueForKey:@"amount"])]; - NSString *bankName = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([offerDict valueForKey:@"bankName"])]; - NSString *bankAddress = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([offerDict valueForKey:@"address"])]; - NSString *bankLocationUrl = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([offerDict valueForKey:@"bankLocationUrl"])]; - NSString *bankLogo = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([offerDict valueForKey:@"bankLogo"])]; - NSString *bankIcon = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([offerDict valueForKey:@"bankIcon"])]; - NSString *otherbankLogo = [NSString stringWithFormat:@"%@",REMOVE_NULL_VALUE([offerDict valueForKey:@"otherBankLogo"])]; - - cell.locationLabel.font = [UIFont systemFontOfSize:12]; - cell.dashTitleLabel.text = dashAmount; - cell.dashSubTitleLabel.text = bits; - cell.dollarLabel.text = dollarAmount; - cell.bankNameLabel.text = bankName; - cell.locationLabel.text = bankAddress; - - if (bankLocationUrl.length > 0) { - cell.locationButton.hidden = NO; - cell.locationButton.tag = indexPath.section * 100000 + indexPath.row; - [cell.locationButton addTarget:self action:@selector(checkLocationClicked:) forControlEvents:UIControlEventTouchUpInside]; - } - - if (offerDict[@"isMultipleBank"] != nil) { - - BOOL isMultipleBank = [offerDict valueForKey:@"isMultipleBank"]; - - if (isMultipleBank) { - bankAddress = [offerDict valueForKey:@"otherBankName"]; - cell.locationLabel.font = cell.bankNameLabel.font; - } - - - if ([otherbankLogo length] > 0) { - otherImageView.hidden = NO; - //load the image - otherImageView.imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",otherbankLogo]]; - } - } - - - //bankLogo - if ([bankLogo length] > 0) { - - imageView.imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",bankLogo]]; - } - else if ([bankIcon length] > 0) { - - imageView.imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",bankIcon]]; - - cell.bankImageView.image = [UIImage imageNamed:@"ic_account_balance_black"]; - } - - cell.orderButton.tag = indexPath.section * 100000 + indexPath.row; - [cell.orderButton addTarget:self action:@selector(orderClicked:) forControlEvents:UIControlEventTouchUpInside]; - - return cell; -} - -// MARK: - UITableView Delegate - -- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - - NSString *key = self.offersDict.allKeys[indexPath.section]; - NSArray *offerArray = self.offersDict[key]; - NSDictionary *offerDict = offerArray[indexPath.row]; - if (offerDict[@"isMultipleBank"] != nil) { - BOOL isMultipleBank = [offerDict valueForKey:@"isMultipleBank"]; - if (isMultipleBank) { - return 150.0; - } - } - return 125.0; -} - -- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { - float height = 20.0; - if (section > 0) { - height = 50.0; - } - NSString *key = self.offersDict.allKeys[section]; - UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, tableView.frame.size.width, height)]; - UILabel *lblHeader = [[UILabel alloc] initWithFrame:CGRectMake(10.0, 0.0, headerView.frame.size.width-20.0, height)]; - lblHeader.text = key; - lblHeader.numberOfLines = 2.0; - lblHeader.backgroundColor = [UIColor colorWithRed:250.0/255.0 green:250.0/255.0 blue:250.0/255.0 alpha:1.0]; - lblHeader.textAlignment = NSTextAlignmentCenter; - [headerView addSubview:lblHeader]; - return headerView; -} - -- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { - if (section > 0){ - return 50.0; - } - return 20.0; -} - -- (NSIndexPath*)getIndexPathfromTag:(NSInteger)tag { - - int row = tag % 100000; - int section = tag / 100000; - NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section]; - return indexPath; -} -@end - diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardPaymentCenterViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardPaymentCenterViewController.h deleted file mode 100644 index 5d824438..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardPaymentCenterViewController.h +++ /dev/null @@ -1,22 +0,0 @@ -// -// WOCSellingWizardPaymentCenterViewController.h -// Wallofcoins -// -// Created by Genitrust on 23/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import -#import "WOCBaseViewController.h" - -//WOCSellingWizardPaymentCenterViewController - -@interface WOCSellingWizardPaymentCenterViewController : WOCBaseViewController - -@property (weak, nonatomic) IBOutlet UITextField *paymentCenterTextfield; -@property (weak, nonatomic) IBOutlet UIButton *nextButton; - -- (IBAction)onNextButtonClick:(id)sender; -- (IBAction)onUseNewAccountButtonClick:(id)sender; - -@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardPaymentCenterViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardPaymentCenterViewController.m deleted file mode 100644 index f6726c3b..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardPaymentCenterViewController.m +++ /dev/null @@ -1,104 +0,0 @@ -// -// WOCSellingWizardPaymentCenterViewController.m -// Wallofcoins -// -// Created by Genitrust on 23/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import "WOCSellingWizardPaymentCenterViewController.h" -#import "WOCSellingWizardInputAmountViewController.h" -#import "APIManager.h" -#import "WOCAlertController.h" -#import "WOCSellingAddNewBankViewController.h" -@interface WOCSellingWizardPaymentCenterViewController () - -@property (strong, nonatomic) NSArray *paymentCenters; -@property (strong, nonatomic) UIPickerView *pickerView; -@property (strong, nonatomic) NSString *bankId; - -@end - -@implementation WOCSellingWizardPaymentCenterViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - - [self setShadowOnButton:self.nextButton]; - - self.pickerView = [[UIPickerView alloc] init]; - self.pickerView.delegate = self; - self.pickerView.dataSource = self; - self.paymentCenterTextfield.inputView = self.pickerView; - - [self getPaymentCenters]; -} - -// MARK: - API - -- (void)getPaymentCenters { - - [[APIManager sharedInstance] getAvailablePaymentCenters:^(id responseDict, NSError *error) { - if (error == nil) { - if ([responseDict isKindOfClass:[NSArray class]]) { - NSArray *responseArray = [[NSArray alloc] initWithArray:(NSArray *)responseDict]; - NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]; - self.paymentCenters = [responseArray sortedArrayUsingDescriptors:@[sort]]; - [self.pickerView reloadAllComponents]; - } - } - }]; -} - -// MARK: - IBAction - -- (IBAction)onNextButtonClick:(id)sender { - - if ([self.bankId length] > 0) { - WOCSellingWizardInputAmountViewController *inputAmountViewController = (WOCSellingWizardInputAmountViewController*)[self getViewController:@"WOCSellingWizardInputAmountViewController"];; - inputAmountViewController.bankId = self.bankId; - NSString *bankInfo = [NSString stringWithFormat:@"%@ (-%@)",self.paymentCenterTextfield.text,self.bankId]; - [self.defaults setObject:bankInfo forKey:WOCUserDefaultsLocalBankInfo]; - [self.defaults synchronize]; - - [self.defaults setObject:self.paymentCenterTextfield.text forKey:WOCUserDefaultsLocalBankName]; - [self.defaults synchronize]; - - [self.defaults setObject:self.bankId forKey:WOCUserDefaultsLocalBankAccount]; - [self.defaults synchronize]; - - [self pushViewController:inputAmountViewController animated:YES]; - return; - } - else { - [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Select payment center." viewController:self.navigationController.visibleViewController]; - } -} - -- (IBAction)onUseNewAccountButtonClick:(id)sender { - - WOCSellingAddNewBankViewController *addNewBankViewController = (WOCSellingAddNewBankViewController*)[self getViewController:@"WOCSellingAddNewBankViewController"]; - [self pushViewController:addNewBankViewController animated:YES]; -} - -// MARK: UIPickerView Delegates - -- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView { - return 1; -} - -- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component { - return self.paymentCenters.count; -} - -- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { - return self.paymentCenters[row][@"name"]; -} - -- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { - self.paymentCenterTextfield.text = self.paymentCenters[row][@"name"]; - self.bankId = [NSString stringWithFormat:@"%@",self.paymentCenters[row][@"id"]]; -} - -@end - diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardZipCodeViewController.h b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardZipCodeViewController.h deleted file mode 100644 index e96916d9..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardZipCodeViewController.h +++ /dev/null @@ -1,23 +0,0 @@ -// -// WOCSellingWizardZipCodeViewController.h -// Wallofcoins -// -// Created by Genitrust on 23/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import -#import "WOCBaseViewController.h" - -////WOCSellingWizardZipCodeViewController - -// Enter ZipCode -@interface WOCSellingWizardZipCodeViewController : WOCBaseViewController - -@property (weak, nonatomic) IBOutlet UITextField *txtZipCode; -@property (weak, nonatomic) IBOutlet UIButton *btnNext; -@property (assign, nonatomic) BOOL isZipCodeBlank; - -- (IBAction)nextClicked:(id)sender; - -@end diff --git a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardZipCodeViewController.m b/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardZipCodeViewController.m deleted file mode 100644 index acf8e826..00000000 --- a/PivxWallet/Wallofcoins/WOCSellng/WOCSellingWizardZipCodeViewController.m +++ /dev/null @@ -1,102 +0,0 @@ -// -// WOCSellingWizardZipCodeViewController.m -// Wallofcoins -// -// Created by Genitrust on 23/01/18. -// Copyright (c) 2018 Wallofcoins. All rights reserved. -// - -#import "WOCSellingWizardZipCodeViewController.h" -#import "WOCSellingWizardPaymentCenterViewController.h" -#import "WOCSellingWizardInputAmountViewController.h" -#import "APIManager.h" -#import "WOCLocationManager.h" -#import -#import -#import -@interface WOCSellingWizardZipCodeViewController () - -@end - - -@implementation WOCSellingWizardZipCodeViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - - self.navigationItem.backBarButtonItem.title = @""; - [self setShadowOnButton:self.btnNext]; -} - -// MARK: - IBAction - -- (IBAction)nextClicked:(id)sender { - - [self.defaults removeObjectForKey:WOCApiBodyCountryCode]; - - [self.defaults synchronize]; - - NSString *zipCode = [self.txtZipCode.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; - - if ([zipCode length] == 0) { - [self push:@"WOCSellingWizardPaymentCenterViewController"]; - } - else if ([zipCode length] < 5 || [zipCode length] > 6 ) { - [[WOCAlertController sharedInstance] alertshowWithTitle:ALERT_TITLE message:@"Enter valid zipcode" viewController:self.navigationController.visibleViewController]; - } - else { - [self setCountryWithZipCode:zipCode]; - - WOCSellingWizardInputAmountViewController *inputAmountViewController = (WOCSellingWizardInputAmountViewController*)[self getViewController:@"WOCSellingWizardInputAmountViewController"];; - inputAmountViewController.zipCode = zipCode; - [self pushViewController:inputAmountViewController animated:YES]; - } -} - -- (void)setCountryWithZipCode:(NSString*)zipCode { - - CLGeocoder* geoCoder = [[CLGeocoder alloc] init]; - CNMutablePostalAddress *postalAddress = [[CNMutablePostalAddress alloc] init]; - postalAddress.postalCode = zipCode; - postalAddress.country = @"us"; - postalAddress.state = @""; - if (@available(iOS 11.0, *)) { - [geoCoder geocodePostalAddress:postalAddress completionHandler:^(NSArray *placemarks, NSError *error) { - if ([placemarks count] > 0) { - CLPlacemark* placemark = [placemarks objectAtIndex:0]; - [self.defaults setObject:[placemark ISOcountryCode].lowercaseString forKey:WOCApiBodyCountryCode]; - [self.defaults synchronize]; - APILog(@"%@",[placemark description]); - APILog(@"======> country code is %@",[placemark ISOcountryCode]); - } - else { - APILog(@"Error in featching Country ="); - } - }]; - } - else { - // Fallback on earlier versions - [geoCoder geocodeAddressDictionary:@{(NSString*)kABPersonAddressZIPKey : zipCode,(NSString*)kABPersonAddressCountryCodeKey : @"us"} - completionHandler:^(NSArray *placemarks, NSError *error) { - if ([placemarks count] > 0) { - CLPlacemark* placemark = [placemarks objectAtIndex:0]; - - NSString* city = placemark.addressDictionary[(NSString*)kABPersonAddressCityKey]; - NSString* state = placemark.addressDictionary[(NSString*)kABPersonAddressStateKey]; - NSString* country = placemark.addressDictionary[(NSString*)kABPersonAddressCountryCodeKey]; - - [self.defaults setObject:country.lowercaseString forKey:WOCApiBodyCountryCode]; - [self.defaults synchronize]; - APILog(@"%@",[placemark description]); - APILog(@"======> country code is city [%@] state [%@] country [%@]",city,state,country); - - } else { - // Lookup Failed - APILog(@"Error in featching Country ="); - } - }]; - } -} - -@end - From 1bee41693596a6e4dfa71264031613dc1c58d38c Mon Sep 17 00:00:00 2001 From: Sujal Bandhara Date: Fri, 25 May 2018 18:59:08 +0530 Subject: [PATCH 3/3] Code refactoring --- PivxWallet/BRRootViewController.m | 75 ++++++++++--------- PivxWallet/BRTxHistoryViewController.m | 1 + .../PivxControllers/MenuController.swift | 6 +- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/PivxWallet/BRRootViewController.m b/PivxWallet/BRRootViewController.m index d7686289..b9954bbc 100644 --- a/PivxWallet/BRRootViewController.m +++ b/PivxWallet/BRRootViewController.m @@ -89,14 +89,16 @@ -(BOOL)prefersStatusBarHidden { } - (void)addErrorView{ - if (self.errorBar != nil && self.errorBar.hidden == FALSE) { - if (!self.errorBar.superview) { - [self.navigationController.navigationBar addSubview:self.errorBar]; - [self.navigationController.navigationBar addConstraint:[NSLayoutConstraint constraintWithItem:self.errorBar attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.navigationController.navigationBar attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0]]; - [self.navigationController.navigationBar addConstraint:[NSLayoutConstraint constraintWithItem:self.errorBar attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.navigationController.navigationBar attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.0]]; - [self.navigationController.navigationBar addConstraint:[NSLayoutConstraint constraintWithItem:self.errorBar attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.navigationController.navigationBar attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-48.0]]; - } + + if (self.errorBar != nil && self.errorBar.hidden == FALSE) + { + if (!self.errorBar.superview) { + [self.navigationController.navigationBar addSubview:self.errorBar]; + [self.navigationController.navigationBar addConstraint:[NSLayoutConstraint constraintWithItem:self.errorBar attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.navigationController.navigationBar attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0]]; + [self.navigationController.navigationBar addConstraint:[NSLayoutConstraint constraintWithItem:self.errorBar attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.navigationController.navigationBar attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.0]]; + [self.navigationController.navigationBar addConstraint:[NSLayoutConstraint constraintWithItem:self.errorBar attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.navigationController.navigationBar attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-48.0]]; } + } } - (void)viewDidLoad @@ -179,37 +181,36 @@ - (void)viewDidLoad if (self.urlObserver == nil ) { self.urlObserver = [[NSNotificationCenter defaultCenter] addObserverForName:BRURLNotification object:nil queue:nil - usingBlock:^(NSNotification *note) { - if (! manager.noWallet) { - if (self.navigationController.topViewController != self) { - [self.navigationController popToRootViewControllerAnimated:YES]; - } - - if (self.navigationController.presentedViewController) { - [self.navigationController dismissViewControllerAnimated:YES completion:nil]; - } - - NSURL * url = note.userInfo[@"url"]; - - - - - BRSendViewController *c = self.sendViewController; - - [self.pageViewController setViewControllers:(c ? @[c] : @[]) - direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:^(BOOL finished) { - _url = note.userInfo[@"url"]; - - if (self.didAppear && [UIApplication sharedApplication].protectedDataAvailable) { - _url = nil; - [c performSelector:@selector(handleURL:) withObject:note.userInfo[@"url"] afterDelay:0.0]; - } - }]; - + usingBlock:^(NSNotification *note) { + if (! manager.noWallet) { + if (self.navigationController.topViewController != self) { + [self.navigationController popToRootViewControllerAnimated:YES]; } - }]; + + if (self.navigationController.presentedViewController) { + [self.navigationController dismissViewControllerAnimated:YES completion:nil]; + } + + NSURL * url = note.userInfo[@"url"]; + + + + + BRSendViewController *c = self.sendViewController; + + [self.pageViewController setViewControllers:(c ? @[c] : @[]) + direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:^(BOOL finished) { + _url = note.userInfo[@"url"]; + + if (self.didAppear && [UIApplication sharedApplication].protectedDataAvailable) { + _url = nil; + [c performSelector:@selector(handleURL:) withObject:note.userInfo[@"url"] afterDelay:0.0]; + } + }]; + + } + }]; } - if (self.fileObserver == nil) { self.fileObserver = [[NSNotificationCenter defaultCenter] addObserverForName:BRFileNotification object:nil queue:nil @@ -237,7 +238,6 @@ - (void)viewDidLoad } }]; } - if (self.foregroundObserver == nil) { self.foregroundObserver = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillEnterForegroundNotification object:nil @@ -842,6 +842,7 @@ - (void)protectedViewDidAppear } } + - (void)viewWillDisappear:(BOOL)animated { if (self.navBarTap) [self.navigationController.navigationBar removeGestureRecognizer:self.navBarTap]; diff --git a/PivxWallet/BRTxHistoryViewController.m b/PivxWallet/BRTxHistoryViewController.m index 04e7f49c..d2a0d1e7 100644 --- a/PivxWallet/BRTxHistoryViewController.m +++ b/PivxWallet/BRTxHistoryViewController.m @@ -754,6 +754,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath [self performSelector:@selector(more:) withObject:tableView afterDelay:0.0]; } else if (self.transactions.count > 0) [self showTx:self.transactions[indexPath.row]]; // transaction details + NSLog(@"Open WOC module Here"); [self loadWOCModule]; diff --git a/PivxWallet/PivxControllers/MenuController.swift b/PivxWallet/PivxControllers/MenuController.swift index b1bc33e0..5f6feed8 100644 --- a/PivxWallet/PivxControllers/MenuController.swift +++ b/PivxWallet/PivxControllers/MenuController.swift @@ -95,7 +95,6 @@ class MenuController: BaseController { slideMenuController()?.closeLeft() return } - let controller = DonationController(nibName:"Donation", bundle:nil) let navigation = UINavigationController(rootViewController: controller) slideMenuController()?.changeMainViewController(navigation, close: true) @@ -116,12 +115,10 @@ class MenuController: BaseController { self.slideMenuController()?.changeMainViewController(navController!, close: true) }) -// let controller = DonationController(nibName:"Donation", bundle:nil) -// let navigation = UINavigationController(rootViewController: controller) -// slideMenuController()?.changeMainViewController(navigation, close: true) optionSelected = 5 selectTitle() } + func selectTitle(){ titleLabel1.textColor = K.color.gray_r155g155b155 titleLabel2.textColor = K.color.gray_r155g155b155 @@ -182,4 +179,5 @@ class MenuController: BaseController { syncLabel.text = "Not connection"; } + }