@jimrising/easymerchantsdk-react-native 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/caches/deviceStreaming.xml +340 -0
- package/.idea/em-MobileCheckoutSDK-ReactNative.iml +9 -0
- package/.idea/misc.xml +5 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +230 -0
- package/android/build/.transforms/27d3a0c22098810ca42038b1b8102417/results.bin +1 -0
- package/android/build/.transforms/27d3a0c22098810ca42038b1b8102417/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/BuildConfig.dex +0 -0
- package/android/build/.transforms/27d3a0c22098810ca42038b1b8102417/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule$1.dex +0 -0
- package/android/build/.transforms/27d3a0c22098810ca42038b1b8102417/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule.dex +0 -0
- package/android/build/.transforms/27d3a0c22098810ca42038b1b8102417/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkPackage.dex +0 -0
- package/android/build/.transforms/27d3a0c22098810ca42038b1b8102417/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
- package/android/build/.transforms/41cd2635778c1bb5c18af2c46eb9196e/results.bin +1 -0
- package/android/build/.transforms/41cd2635778c1bb5c18af2c46eb9196e/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/.transforms/6b36622787f586c4b6e3df98c5efa11c/results.bin +1 -0
- package/android/build/.transforms/6b36622787f586c4b6e3df98c5efa11c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/BuildConfig.dex +0 -0
- package/android/build/.transforms/6b36622787f586c4b6e3df98c5efa11c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule$1.dex +0 -0
- package/android/build/.transforms/6b36622787f586c4b6e3df98c5efa11c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule.dex +0 -0
- package/android/build/.transforms/6b36622787f586c4b6e3df98c5efa11c/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkPackage.dex +0 -0
- package/android/build/.transforms/6b36622787f586c4b6e3df98c5efa11c/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
- package/android/build/.transforms/7eb7ceaa43c9e8323ac65b4f785987b6/results.bin +1 -0
- package/android/build/.transforms/7eb7ceaa43c9e8323ac65b4f785987b6/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/.transforms/a8b93af4be449a0e2cca4bd6ddb6685e/results.bin +1 -0
- package/android/build/.transforms/a8b93af4be449a0e2cca4bd6ddb6685e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/BuildConfig.dex +0 -0
- package/android/build/.transforms/a8b93af4be449a0e2cca4bd6ddb6685e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule$1.dex +0 -0
- package/android/build/.transforms/a8b93af4be449a0e2cca4bd6ddb6685e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkModule.dex +0 -0
- package/android/build/.transforms/a8b93af4be449a0e2cca4bd6ddb6685e/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/reactlibrary/RNEasymerchantsdkPackage.dex +0 -0
- package/android/build/.transforms/a8b93af4be449a0e2cca4bd6ddb6685e/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
- package/android/build/.transforms/f1a160720415bc76d8d6c6734c5acf3e/results.bin +1 -0
- package/android/build/.transforms/f1a160720415bc76d8d6c6734c5acf3e/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/generated/source/buildConfig/debug/com/reactlibrary/BuildConfig.java +10 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +7 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/output-metadata.json +18 -0
- package/android/build/intermediates/aar_metadata/debug/writeDebugAarMetadata/aar-metadata.properties +6 -0
- package/android/build/intermediates/annotation_processor_list/debug/javaPreCompileDebug/annotationProcessors.json +1 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
- package/android/build/intermediates/compile_r_class_jar/debug/generateDebugRFile/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/generateDebugRFile/R.txt +0 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +2 -0
- package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +2 -0
- package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +2 -0
- package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +2 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactlibrary/BuildConfig.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkModule$1.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkModule.class +0 -0
- package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactlibrary/RNEasymerchantsdkPackage.class +0 -0
- package/android/build/intermediates/local_only_symbol_list/debug/parseDebugLocalResources/R-def.txt +2 -0
- package/android/build/intermediates/manifest_merge_blame_file/debug/processDebugManifest/manifest-merger-blame-debug-report.txt +7 -0
- package/android/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml +7 -0
- package/android/build/intermediates/navigation_json/debug/extractDeepLinksDebug/navigation.json +1 -0
- package/android/build/intermediates/nested_resources_validation_report/debug/generateDebugResources/nestedResourcesValidationReport.txt +1 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/reactlibrary/BuildConfig.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/reactlibrary/RNEasymerchantsdkModule$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/reactlibrary/RNEasymerchantsdkModule.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/reactlibrary/RNEasymerchantsdkPackage.class +0 -0
- package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
- package/android/build/intermediates/symbol_list_with_package_name/debug/generateDebugRFile/package-aware-r.txt +1 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +17 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNEasymerchantsdkModule$1.class.uniqueId2 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNEasymerchantsdkModule.class.uniqueId1 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/RNEasymerchantsdkPackage.class.uniqueId0 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build.gradle +55 -0
- package/android/src/main/AndroidManifest.xml +5 -0
- package/android/src/main/java/com/reactlibrary/RNEasymerchantsdkModule.java +72 -0
- package/android/src/main/java/com/reactlibrary/RNEasymerchantsdkPackage.java +28 -0
- package/index.js +5 -0
- package/ios/Bundle/EasyPayBundle.swift +22 -0
- package/ios/Classes/EasyMerchantSdk.h +4 -0
- package/ios/Classes/EasyMerchantSdk.m +43 -0
- package/ios/Classes/EasyMerchantSdk.swift +124 -0
- package/ios/Classes/EasyPayViewController.swift +90 -0
- package/ios/CustomComponents/CheckboxButton.swift +20 -0
- package/ios/CustomComponents/FilledButton.swift +17 -0
- package/ios/CustomComponents/OutlineButton.swift +26 -0
- package/ios/CustomComponents/TextFieldStackView.swift +96 -0
- package/ios/EnvironmentConfig.swift +63 -0
- package/ios/Example/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
- package/ios/Example/Assets.xcassets/AppIcon.appiconset/Contents.json +13 -0
- package/ios/Example/Assets.xcassets/Contents.json +6 -0
- package/ios/Example/Base.lproj/LaunchScreen.storyboard +25 -0
- package/ios/Example/Base.lproj/Main.storyboard +65 -0
- package/ios/Example/SceneDelegate.swift +52 -0
- package/ios/Example/ViewController.swift +84 -0
- package/ios/Extensions/UIColor.swift +22 -0
- package/ios/Extensions/UIFont.swift +80 -0
- package/ios/Extensions/UIViewController+Extension.swift +42 -0
- package/ios/Models/AdditionalInfo.swift +16 -0
- package/ios/Models/BankAccountModel.swift +23 -0
- package/ios/Models/BillingInfo.swift +16 -0
- package/ios/Models/CardModel.swift +19 -0
- package/ios/Models/Country.swift +19 -0
- package/ios/Models/PaymentInfo.swift +46 -0
- package/ios/Models/Request.swift +245 -0
- package/ios/Models/Result.swift +69 -0
- package/ios/Pods/UserDefaults/UserStoreSingleton.swift +200 -0
- package/ios/Pods/ViewControllers/AdditionalInfoVC.swift +1073 -0
- package/ios/Pods/ViewControllers/BaseVC.swift +117 -0
- package/ios/Pods/ViewControllers/BillingInfoVC/BillingInfoVC.swift +616 -0
- package/ios/Pods/ViewControllers/BillingInfoVC/Cells/CityListTVC.swift +19 -0
- package/ios/Pods/ViewControllers/BillingInfoVC/Cells/CountryListTVC.swift +19 -0
- package/ios/Pods/ViewControllers/BillingInfoVC/Cells/StateListTVC.swift +19 -0
- package/ios/Pods/ViewControllers/CountryListVC.swift +367 -0
- package/ios/Pods/ViewControllers/EmailVerificationVC.swift +192 -0
- package/ios/Pods/ViewControllers/OTPVerificationVC.swift +1009 -0
- package/ios/Pods/ViewControllers/PaymentDoneVC.swift +94 -0
- package/ios/Pods/ViewControllers/PaymentErrorVC.swift +43 -0
- package/ios/Pods/ViewControllers/PaymentInformation/AccountTypeTVC.swift +19 -0
- package/ios/Pods/ViewControllers/PaymentInformation/PaymentInfoVC.swift +4269 -0
- package/ios/Pods/ViewControllers/PaymentInformation/PaymentInformationCVC.swift +20 -0
- package/ios/Pods/ViewControllers/PaymentInformation/SavedAccountsTVC/SavedAccountTVC.swift +37 -0
- package/ios/Pods/ViewControllers/PaymentInformation/SavedAccountsTVC/SavedAccountTVC.xib +163 -0
- package/ios/Pods/ViewControllers/PaymentInformation/SavedCardsTVC/SavedCardsTVC.swift +40 -0
- package/ios/Pods/ViewControllers/PaymentInformation/SavedCardsTVC/SavedCardsTVC.xib +184 -0
- package/ios/Pods/ViewControllers/TermAndConditionsVC.swift +21 -0
- package/ios/Resources/Assets.xcassets/Card/Amex.imageset/206682_american_express_method_card_payment_icon.svg +1 -0
- package/ios/Resources/Assets.xcassets/Card/Amex.imageset/Contents.json +12 -0
- package/ios/Resources/Assets.xcassets/Card/Contents.json +6 -0
- package/ios/Resources/Assets.xcassets/Card/DinersClub.imageset/472318_card_club_diners_dinner_payment_icon.svg +1 -0
- package/ios/Resources/Assets.xcassets/Card/DinersClub.imageset/Contents.json +12 -0
- package/ios/Resources/Assets.xcassets/Card/Discover.imageset/206686_network_payment_discover_card_method_icon.svg +1 -0
- package/ios/Resources/Assets.xcassets/Card/Discover.imageset/Contents.json +12 -0
- package/ios/Resources/Assets.xcassets/Card/JCB.imageset/358102_card_jcb_payment_icon.svg +1 -0
- package/ios/Resources/Assets.xcassets/Card/JCB.imageset/Contents.json +12 -0
- package/ios/Resources/Assets.xcassets/Card/MasterCard.imageset/206680_master_method_card_payment_icon.svg +1 -0
- package/ios/Resources/Assets.xcassets/Card/MasterCard.imageset/Contents.json +12 -0
- package/ios/Resources/Assets.xcassets/Card/UnionPay.imageset/1468976_card_payment_unionpay_icon.svg +1 -0
- package/ios/Resources/Assets.xcassets/Card/UnionPay.imageset/Contents.json +12 -0
- package/ios/Resources/Assets.xcassets/Card/Visa.imageset/206684_visa_method_card_payment_icon.svg +1 -0
- package/ios/Resources/Assets.xcassets/Card/Visa.imageset/Contents.json +12 -0
- package/ios/Resources/Assets.xcassets/Card/maestro.imageset/Contents.json +12 -0
- package/ios/Resources/Assets.xcassets/Card/maestro.imageset/maestro.svg +1 -0
- package/ios/Resources/Assets.xcassets/Card/paypal.imageset/206675_paypal_method_payment_icon.svg +1 -0
- package/ios/Resources/Assets.xcassets/Card/paypal.imageset/Contents.json +12 -0
- package/ios/Resources/Assets.xcassets/Card/rupay.imageset/Contents.json +12 -0
- package/ios/Resources/Assets.xcassets/Card/rupay.imageset/rupay.svg +1 -0
- package/ios/Resources/Assets.xcassets/Card/unknown_card.imageset/4635000_card_credit_digital_money_icon.svg +1 -0
- package/ios/Resources/Assets.xcassets/Card/unknown_card.imageset/Contents.json +12 -0
- package/ios/Resources/Assets.xcassets/Card/worldpay.imageset/Contents.json +12 -0
- package/ios/Resources/Assets.xcassets/Card/worldpay.imageset/worldpay.svg +1 -0
- package/ios/Resources/Assets.xcassets/Contents.json +6 -0
- package/ios/Resources/Assets.xcassets/Ellipsis.imageset/Contents.json +23 -0
- package/ios/Resources/Assets.xcassets/Ellipsis.imageset/icons8-menu-30.png +0 -0
- package/ios/Resources/Assets.xcassets/Ellipsis.imageset/icons8-menu-60.png +0 -0
- package/ios/Resources/Assets.xcassets/Ellipsis.imageset/icons8-menu-90.png +0 -0
- package/ios/Resources/Assets.xcassets/Rotate.imageset/Contents.json +23 -0
- package/ios/Resources/Assets.xcassets/Rotate.imageset/refresh-cw-2.png +0 -0
- package/ios/Resources/Assets.xcassets/Rotate.imageset/refresh-cw-3.png +0 -0
- package/ios/Resources/Assets.xcassets/Rotate.imageset/refresh-cw.png +0 -0
- package/ios/Resources/Assets.xcassets/amexCvc.imageset/Contents.json +22 -0
- package/ios/Resources/Assets.xcassets/amexCvc.imageset/Group-1.png +0 -0
- package/ios/Resources/Assets.xcassets/amexCvc.imageset/Group.png +0 -0
- package/ios/Resources/Assets.xcassets/check.imageset/Contents.json +23 -0
- package/ios/Resources/Assets.xcassets/check.imageset/check-circle-4.png +0 -0
- package/ios/Resources/Assets.xcassets/check.imageset/check-circle-5.png +0 -0
- package/ios/Resources/Assets.xcassets/check.imageset/check-circle-6.png +0 -0
- package/ios/Resources/Assets.xcassets/chip.imageset/Contents.json +21 -0
- package/ios/Resources/Assets.xcassets/chip.imageset/chip.png +0 -0
- package/ios/Resources/Assets.xcassets/loaderImage.imageset/Contents.json +23 -0
- package/ios/Resources/Assets.xcassets/loaderImage.imageset/check-circle-2.png +0 -0
- package/ios/Resources/Assets.xcassets/loaderImage.imageset/check-circle-3.png +0 -0
- package/ios/Resources/Assets.xcassets/loaderImage.imageset/check-circle.png +0 -0
- package/ios/Resources/Assets.xcassets/payment_done_icon.imageset/Contents.json +23 -0
- package/ios/Resources/Assets.xcassets/payment_done_icon.imageset/payment_done_icon 1.png +0 -0
- package/ios/Resources/Assets.xcassets/payment_done_icon.imageset/payment_done_icon 2.png +0 -0
- package/ios/Resources/Assets.xcassets/payment_done_icon.imageset/payment_done_icon.png +0 -0
- package/ios/Resources/Assets.xcassets/payment_error_icon.imageset/Contents.json +23 -0
- package/ios/Resources/Assets.xcassets/payment_error_icon.imageset/payment_error_icon 1.png +0 -0
- package/ios/Resources/Assets.xcassets/payment_error_icon.imageset/payment_error_icon 2.png +0 -0
- package/ios/Resources/Assets.xcassets/payment_error_icon.imageset/payment_error_icon.png +0 -0
- package/ios/Resources/Assets.xcassets/wallet.imageset/Contents.json +23 -0
- package/ios/Resources/Assets.xcassets/wallet.imageset/icons8-wallet-24(@1/303/227).png +0 -0
- package/ios/Resources/Assets.xcassets/wallet.imageset/icons8-wallet-48(@2/303/227).png +0 -0
- package/ios/Resources/Assets.xcassets/wallet.imageset/icons8-wallet-72(@3/303/227).png +0 -0
- package/ios/Resources/Colors.xcassets/00000008.colorset/Contents.json +20 -0
- package/ios/Resources/Colors.xcassets/00000016.colorset/Contents.json +20 -0
- package/ios/Resources/Colors.xcassets/00000038.colorset/Contents.json +20 -0
- package/ios/Resources/Colors.xcassets/00000060.colorset/Contents.json +20 -0
- package/ios/Resources/Colors.xcassets/1757D9.colorset/Contents.json +20 -0
- package/ios/Resources/Colors.xcassets/Contents.json +6 -0
- package/ios/Resources/Colors.xcassets/E93939.colorset/Contents.json +20 -0
- package/ios/Resources/PrivacyInfo.xcprivacy +10 -0
- package/ios/ThirdParty/Keyboad Handling/KeyboardObserver.swift +74 -0
- package/ios/easymerchantsdk.podspec +80 -0
- package/ios/easymerchantsdk.storyboard +5885 -0
- package/package.json +27 -0
- package/src/index.js +44 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
//
|
|
2
|
+
// BaseVC.swift
|
|
3
|
+
// EasyPay
|
|
4
|
+
//
|
|
5
|
+
// Created by Mony's Mac on 12/08/24.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import UIKit
|
|
9
|
+
|
|
10
|
+
class BaseVC: UIViewController {
|
|
11
|
+
|
|
12
|
+
private let activityIndicator: UIActivityIndicatorView? = nil
|
|
13
|
+
private var overlayView: UIView?
|
|
14
|
+
|
|
15
|
+
override func viewDidLoad() {
|
|
16
|
+
super.viewDidLoad()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
func addOverlayView() {
|
|
20
|
+
guard let keyWindowScene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene,
|
|
21
|
+
let keyWindow = keyWindowScene.windows.first(where: { $0.isKeyWindow }) else {
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
DispatchQueue.main.async {
|
|
25
|
+
let overlayView = UIView(frame: keyWindow.bounds)
|
|
26
|
+
overlayView.backgroundColor = UIColor.black.withAlphaComponent(0.3)
|
|
27
|
+
keyWindow.addSubview(overlayView)
|
|
28
|
+
self.overlayView = overlayView
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
func removeOverlayView() {
|
|
33
|
+
DispatchQueue.main.async {
|
|
34
|
+
self.overlayView?.removeFromSuperview()
|
|
35
|
+
self.overlayView = nil
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
func showLoadingIndicator() {
|
|
40
|
+
DispatchQueue.main.async {
|
|
41
|
+
let activityIndicator = UIActivityIndicatorView(style: .large)
|
|
42
|
+
activityIndicator.center = self.view.center
|
|
43
|
+
activityIndicator.hidesWhenStopped = true
|
|
44
|
+
activityIndicator.startAnimating()
|
|
45
|
+
|
|
46
|
+
self.addOverlayView()
|
|
47
|
+
self.view.addSubview(activityIndicator)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
func hideLoadingIndicator() {
|
|
52
|
+
DispatchQueue.main.async {
|
|
53
|
+
// Find and remove the activity indicator from its superview
|
|
54
|
+
for subview in self.view.subviews {
|
|
55
|
+
if let activityIndicator = subview as? UIActivityIndicatorView {
|
|
56
|
+
activityIndicator.stopAnimating()
|
|
57
|
+
self.removeOverlayView()
|
|
58
|
+
activityIndicator.removeFromSuperview()
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// MARK: - Toast Method
|
|
65
|
+
func showToast(message: String, duration: Double = 3.0) {
|
|
66
|
+
DispatchQueue.main.async { [weak self] in
|
|
67
|
+
guard let self = self else { return }
|
|
68
|
+
|
|
69
|
+
let toastLabel = UILabel()
|
|
70
|
+
toastLabel.text = message
|
|
71
|
+
toastLabel.textColor = UIColor.white
|
|
72
|
+
toastLabel.backgroundColor = UIColor.black.withAlphaComponent(0.7)
|
|
73
|
+
toastLabel.textAlignment = .center
|
|
74
|
+
toastLabel.font = UIFont.systemFont(ofSize: 14)
|
|
75
|
+
toastLabel.numberOfLines = 0
|
|
76
|
+
toastLabel.alpha = 0.0
|
|
77
|
+
toastLabel.layer.cornerRadius = 10
|
|
78
|
+
toastLabel.clipsToBounds = true
|
|
79
|
+
|
|
80
|
+
// Set the position of the toast
|
|
81
|
+
let toastWidth: CGFloat = min(self.view.frame.width - 40, 250)
|
|
82
|
+
let toastHeight: CGFloat = 50
|
|
83
|
+
toastLabel.frame = CGRect(x: (self.view.frame.width - toastWidth) / 2,
|
|
84
|
+
y: self.view.frame.height - 100,
|
|
85
|
+
width: toastWidth,
|
|
86
|
+
height: toastHeight)
|
|
87
|
+
|
|
88
|
+
self.view.addSubview(toastLabel)
|
|
89
|
+
|
|
90
|
+
UIView.animate(withDuration: 0.5, animations: {
|
|
91
|
+
toastLabel.alpha = 1.0
|
|
92
|
+
}) { _ in
|
|
93
|
+
UIView.animate(withDuration: 0.5, delay: duration, options: .curveEaseOut, animations: {
|
|
94
|
+
toastLabel.alpha = 0.0
|
|
95
|
+
}) { _ in
|
|
96
|
+
toastLabel.removeFromSuperview()
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
func showAlert(title: String = "Alert", message: String, actionTitle: String = "OK", handler: ((UIAlertAction) -> Void)? = nil) {
|
|
103
|
+
DispatchQueue.main.async {
|
|
104
|
+
let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
|
|
105
|
+
let action = UIAlertAction(title: actionTitle, style: .default, handler: handler)
|
|
106
|
+
alert.addAction(action)
|
|
107
|
+
self.present(alert, animated: true, completion: nil)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Helper function to validate email format using regex
|
|
112
|
+
func isValidEmail(_ email: String) -> Bool {
|
|
113
|
+
let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
|
|
114
|
+
let emailPred = NSPredicate(format: "SELF MATCHES %@", emailRegEx)
|
|
115
|
+
return emailPred.evaluate(with: email)
|
|
116
|
+
}
|
|
117
|
+
}
|