@circle-fin/w3s-pw-react-native-sdk 0.0.175 → 1.0.1

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.
Files changed (62) hide show
  1. package/LICENSE.md +4 -17
  2. package/README.md +5 -5
  3. package/android/build.gradle +137 -0
  4. package/android/gradle.properties +19 -0
  5. package/android/src/main/AndroidManifest.xml +21 -0
  6. package/android/src/main/AndroidManifestNew.xml +20 -0
  7. package/android/src/main/java/com/circlefin/programmablewalletrnsdk/BridgeHelper.kt +388 -0
  8. package/android/src/main/java/com/circlefin/programmablewalletrnsdk/ProgrammablewalletRnSdkModule.kt +226 -0
  9. package/android/src/main/java/com/circlefin/programmablewalletrnsdk/ProgrammablewalletRnSdkPackage.kt +47 -0
  10. package/android/src/main/java/com/circlefin/programmablewalletrnsdk/PromiseCallback.kt +87 -0
  11. package/android/src/main/java/com/circlefin/programmablewalletrnsdk/TestHelper.kt +35 -0
  12. package/android/src/main/java/com/circlefin/programmablewalletrnsdk/pwcustom/RnImageSetter.kt +40 -0
  13. package/android/src/main/java/com/circlefin/programmablewalletrnsdk/pwcustom/RnLayoutProvider.kt +86 -0
  14. package/android/src/main/java/com/circlefin/programmablewalletrnsdk/pwcustom/RnViewSetterProvider.kt +75 -0
  15. package/android/src/newarch/ProgrammablewalletRnSdkSpec.kt +27 -0
  16. package/android/src/oldarch/ProgrammablewalletRnSdkSpec.kt +65 -0
  17. package/{circlefin-programmablewallet-rn-sdk.podspec → circlefin-w3s-pw-react-native-sdk.podspec} +3 -2
  18. package/ios/Array+Extension.swift +25 -0
  19. package/ios/BridgeHelper.swift +183 -0
  20. package/ios/EventEmitter.swift +47 -0
  21. package/ios/ProgrammablewalletRnSdk.h +27 -0
  22. package/ios/ProgrammablewalletRnSdk.mm +144 -0
  23. package/ios/ReactNativeEventEmitter.m +25 -0
  24. package/ios/ReactNativeEventEmitter.swift +34 -0
  25. package/ios/RnWalletSdk+CustomizeAdapter.swift +367 -0
  26. package/ios/RnWalletSdk.swift +330 -0
  27. package/ios/TextConfig.swift +26 -0
  28. package/ios/TextKey.swift +102 -0
  29. package/ios/UIApplication+Extension.swift +38 -0
  30. package/ios/UIColor+Extension.swift +97 -0
  31. package/ios/UIView+Extension.swift +59 -0
  32. package/ios/programmablewallet-rn-sdk-Bridging-Header.h +20 -0
  33. package/lib/commonjs/NativeProgrammablewalletRnSdk.js +13 -0
  34. package/lib/commonjs/NativeProgrammablewalletRnSdk.js.map +1 -1
  35. package/lib/commonjs/ProgrammablewalletRnSdkModule.js +14 -0
  36. package/lib/commonjs/ProgrammablewalletRnSdkModule.js.map +1 -1
  37. package/lib/commonjs/WalletSdk.js +14 -0
  38. package/lib/commonjs/WalletSdk.js.map +1 -1
  39. package/lib/commonjs/index.js.map +1 -1
  40. package/lib/commonjs/types.js +13 -0
  41. package/lib/commonjs/types.js.map +1 -1
  42. package/lib/module/NativeProgrammablewalletRnSdk.js +14 -0
  43. package/lib/module/NativeProgrammablewalletRnSdk.js.map +1 -1
  44. package/lib/module/ProgrammablewalletRnSdkModule.js +13 -0
  45. package/lib/module/ProgrammablewalletRnSdkModule.js.map +1 -1
  46. package/lib/module/WalletSdk.js +13 -0
  47. package/lib/module/WalletSdk.js.map +1 -1
  48. package/lib/module/index.js +13 -0
  49. package/lib/module/index.js.map +1 -1
  50. package/lib/module/types.js +14 -0
  51. package/lib/module/types.js.map +1 -1
  52. package/lib/typescript/src/NativeProgrammablewalletRnSdk.d.ts.map +1 -1
  53. package/lib/typescript/src/ProgrammablewalletRnSdkModule.d.ts.map +1 -1
  54. package/lib/typescript/src/WalletSdk.d.ts.map +1 -1
  55. package/lib/typescript/src/index.d.ts.map +1 -1
  56. package/lib/typescript/src/types.d.ts.map +1 -1
  57. package/package.json +18 -9
  58. package/src/NativeProgrammablewalletRnSdk.ts +13 -0
  59. package/src/ProgrammablewalletRnSdkModule.ts +13 -0
  60. package/src/WalletSdk.ts +13 -0
  61. package/src/index.tsx +13 -0
  62. package/src/types.ts +13 -0
package/LICENSE.md CHANGED
@@ -1,20 +1,7 @@
1
- MIT License
1
+ # Copyright (c) 2024, Circle Technologies, LLC. All rights reserved
2
2
 
3
- Copyright (c) 2024 Circle
4
- Permission is hereby granted, free of charge, to any person obtaining a copy
5
- of this software and associated documentation files (the "Software"), to deal
6
- in the Software without restriction, including without limitation the rights
7
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- copies of the Software, and to permit persons to whom the Software is
9
- furnished to do so, subject to the following conditions:
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
10
4
 
11
- The above copyright notice and this permission notice shall be included in all
12
- copies or substantial portions of the Software.
5
+ [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0)
13
6
 
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- SOFTWARE.
7
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package/README.md CHANGED
@@ -81,11 +81,13 @@ Add below links at tne top of `ios/Podfile`:
81
81
  ```ruby
82
82
  source 'https://github.com/circlefin/w3s-ios-sdk.git'
83
83
  source 'https://cdn.cocoapods.org/'
84
+
85
+ platform :ios, '13.4'
84
86
  ```
85
- Declare static link as below:
87
+ Declare dynamic link as below:
86
88
  ```ruby
87
89
  target 'W3sSampleWallet' do
88
- use_frameworks! :linkage => :static
90
+ use_frameworks!
89
91
  end
90
92
  ```
91
93
  And add the following `post_install` hook:
@@ -95,9 +97,7 @@ post_install do |installer|
95
97
  target.build_configurations.each do |config|
96
98
  config.build_settings["ONLY_ACTIVE_ARCH"] = "NO"
97
99
  config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
98
- end
99
- installer.pods_project.build_configurations.each do |config|
100
- config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
100
+ config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
101
101
  end
102
102
  end
103
103
  end
@@ -0,0 +1,137 @@
1
+ // Copyright (c) 2024, Circle Technologies, LLC. All rights reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ buildscript {
16
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
17
+ def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["ProgrammablewalletRnSdk_kotlinVersion"]
18
+
19
+ repositories {
20
+ google()
21
+ mavenCentral()
22
+ }
23
+
24
+ dependencies {
25
+ classpath "com.android.tools.build:gradle:7.2.1"
26
+ // noinspection DifferentKotlinGradleVersion
27
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
28
+ }
29
+ }
30
+
31
+ def isNewArchitectureEnabled() {
32
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
33
+ }
34
+
35
+ apply plugin: "com.android.library"
36
+ apply plugin: "kotlin-android"
37
+
38
+ if (isNewArchitectureEnabled()) {
39
+ apply plugin: "com.facebook.react"
40
+ }
41
+
42
+ def getExtOrDefault(name) {
43
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["ProgrammablewalletRnSdk_" + name]
44
+ }
45
+
46
+ def getExtOrIntegerDefault(name) {
47
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ProgrammablewalletRnSdk_" + name]).toInteger()
48
+ }
49
+
50
+ def supportsNamespace() {
51
+ def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
52
+ def major = parsed[0].toInteger()
53
+ def minor = parsed[1].toInteger()
54
+
55
+ // Namespace support was added in 7.3.0
56
+ return (major == 7 && minor >= 3) || major >= 8
57
+ }
58
+
59
+ android {
60
+ if (supportsNamespace()) {
61
+ namespace "com.circlefin.programmablewalletrnsdk"
62
+
63
+ sourceSets {
64
+ main {
65
+ manifest.srcFile "src/main/AndroidManifestNew.xml"
66
+ }
67
+ }
68
+ }
69
+
70
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
71
+
72
+ defaultConfig {
73
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
74
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
75
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
76
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
77
+ }
78
+
79
+ buildFeatures {
80
+ buildConfig true
81
+ }
82
+
83
+ buildTypes {
84
+ release {
85
+ minifyEnabled false
86
+ }
87
+ debug {
88
+ testCoverageEnabled false
89
+ }
90
+ }
91
+
92
+ lintOptions {
93
+ disable "GradleCompatible"
94
+ }
95
+
96
+ compileOptions {
97
+ sourceCompatibility JavaVersion.VERSION_11
98
+ targetCompatibility JavaVersion.VERSION_11
99
+ }
100
+ sourceSets {
101
+ main {
102
+ if (isNewArchitectureEnabled()) {
103
+ java.srcDirs += [
104
+ "src/newarch",
105
+ // This is needed to build Kotlin project with NewArch enabled
106
+ "${project.buildDir}/generated/source/codegen/java"
107
+ ]
108
+ } else {
109
+ java.srcDirs += ["src/oldarch"]
110
+ }
111
+ }
112
+ }
113
+ }
114
+ repositories {
115
+ mavenCentral()
116
+ google()
117
+ }
118
+
119
+ def kotlin_version = getExtOrDefault("kotlinVersion")
120
+
121
+ dependencies {
122
+ // For < 0.71, this will be from the local maven repo
123
+ // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
124
+ //noinspection GradleDynamicVersion
125
+ implementation "com.facebook.react:react-native:+"
126
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
127
+ implementation "circle.programmablewallet:sdk:1.0.+"
128
+ implementation 'com.github.bumptech.glide:glide:4.14.2'
129
+ }
130
+
131
+ if (isNewArchitectureEnabled()) {
132
+ react {
133
+ jsRootDir = file("../src/")
134
+ libraryName = "ProgrammablewalletRnSdk"
135
+ codegenJavaPackageName = "com.circlefin.programmablewalletrnsdk"
136
+ }
137
+ }
@@ -0,0 +1,19 @@
1
+ # Copyright (c) 2024, Circle Technologies, LLC. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ ProgrammablewalletRnSdk_kotlinVersion=1.7.0
16
+ ProgrammablewalletRnSdk_minSdkVersion=21
17
+ ProgrammablewalletRnSdk_targetSdkVersion=31
18
+ ProgrammablewalletRnSdk_compileSdkVersion=31
19
+ ProgrammablewalletRnSdk_ndkversion=21.4.7075529
@@ -0,0 +1,21 @@
1
+ <!--
2
+ Copyright (c) 2024, Circle Technologies, LLC. All rights reserved.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ -->
16
+
17
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
18
+ package="com.circlefin.programmablewalletrnsdk">
19
+
20
+ <uses-permission android:name="android.permission.REORDER_TASKS" />
21
+ </manifest>
@@ -0,0 +1,20 @@
1
+ <!--
2
+ Copyright (c) 2024, Circle Technologies, LLC. All rights reserved.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ -->
16
+
17
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
18
+
19
+ <uses-permission android:name="android.permission.REORDER_TASKS" />
20
+ </manifest>
@@ -0,0 +1,388 @@
1
+ // Copyright (c) 2024, Circle Technologies, LLC. All rights reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ package com.circlefin.programmablewalletrnsdk
15
+
16
+ import android.content.Context
17
+ import android.graphics.Color
18
+ import android.graphics.Typeface
19
+ import android.text.TextUtils
20
+ import android.util.Log
21
+ import circle.programmablewallet.sdk.api.ApiError
22
+ import circle.programmablewallet.sdk.api.ExecuteWarning
23
+ import circle.programmablewallet.sdk.presentation.IconTextConfig
24
+ import circle.programmablewallet.sdk.presentation.Resource
25
+ import circle.programmablewallet.sdk.presentation.SecurityQuestion
26
+ import circle.programmablewallet.sdk.presentation.SettingsManagement
27
+ import circle.programmablewallet.sdk.presentation.TextConfig
28
+ import com.circlefin.programmablewalletrnsdk.pwcustom.RnImageSetter
29
+ import com.facebook.react.bridge.Arguments
30
+ import com.facebook.react.bridge.ReadableArray
31
+ import com.facebook.react.bridge.ReadableMap
32
+ import com.facebook.react.bridge.WritableArray
33
+ import com.facebook.react.bridge.WritableMap
34
+ import java.lang.reflect.Modifier
35
+
36
+ object BridgeHelper {
37
+ private val TAG = BridgeHelper::class.java.simpleName
38
+ val typefaceMap: MutableMap<String?, Typeface?> = HashMap()
39
+ var questionsForTest: Array<SecurityQuestion?>? = null
40
+ var dismissOnCallbackForTest: MutableMap<Int, Boolean>? = null
41
+
42
+ fun objectToMap(obj: ExecuteWarning?): WritableMap {
43
+ val map = Arguments.createMap()
44
+ obj ?: return map
45
+ map.putString("warningString", obj.warningString)
46
+ map.putString("warningType", obj.warningType.toString())
47
+ return map
48
+ }
49
+
50
+ fun objectToMap(obj: ApiError?): WritableMap {
51
+ val map = Arguments.createMap()
52
+ obj ?: return map
53
+ map.putString("code", obj.code.value.toString())
54
+ map.putString("message", obj.message)
55
+ return map
56
+ }
57
+
58
+ @JvmStatic
59
+ fun objectToMap(obj: Any?): WritableMap {
60
+ val map = Arguments.createMap()
61
+ obj ?: return map
62
+ for (field in obj.javaClass.fields) {
63
+ try {
64
+ val name = field.name
65
+ val value = field[obj]
66
+ if (Modifier.isStatic(field.modifiers)) { // skip static field
67
+ continue
68
+ }
69
+ if (!Modifier.isPublic(field.modifiers)) { // skip non-public field
70
+ continue
71
+ }
72
+ if (value == null) {
73
+ map.putNull(name)
74
+ } else if (value is Int) {
75
+ map.putInt(name, value)
76
+ } else if (value is Long) {
77
+ map.putDouble(name, value.toDouble())
78
+ } else if (value is Float) {
79
+ map.putDouble(name, value.toDouble())
80
+ } else if (value is Double) {
81
+ map.putDouble(name, value)
82
+ } else if (value is Boolean) {
83
+ map.putBoolean(name, value)
84
+ } else if (value is String) {
85
+ map.putString(name, value)
86
+ } else if (value.javaClass.isArray) {
87
+ map.putArray(name, objectToArray(value))
88
+ } else if (value.javaClass.isEnum) {
89
+ map.putString(name, (value as Enum<*>).name)
90
+ } else if (!value.javaClass.isPrimitive) {
91
+ map.putMap(name, objectToMap(value))
92
+ } else {
93
+ throw UnsupportedOperationException("Not implemented: $value")
94
+ }
95
+ } catch (e: Exception) {
96
+ Log.w(TAG, "Read field failed", e)
97
+ }
98
+ }
99
+ return map
100
+ }
101
+
102
+ private fun objectToArray(array: Any?): WritableArray {
103
+ val arr = Arguments.createArray()
104
+ array ?: return arr
105
+ val n = java.lang.reflect.Array.getLength(array)
106
+ for (i in 0 until n) {
107
+ try {
108
+ val elem = java.lang.reflect.Array.get(array, i)
109
+ if (elem == null) {
110
+ arr.pushNull()
111
+ } else if (elem is Int) {
112
+ arr.pushInt(elem)
113
+ } else if (elem is Long) {
114
+ arr.pushDouble(elem.toDouble())
115
+ } else if (elem is Float) {
116
+ arr.pushDouble(elem.toDouble())
117
+ } else if (elem is Double) {
118
+ arr.pushDouble(elem)
119
+ } else if (elem is Boolean) {
120
+ arr.pushBoolean(elem)
121
+ } else if (elem is String) {
122
+ arr.pushString(elem)
123
+ } else if (elem.javaClass.isArray) {
124
+ arr.pushArray(objectToArray(elem))
125
+ } else if (!elem.javaClass.isPrimitive) {
126
+ arr.pushMap(objectToMap(elem))
127
+ } else {
128
+ throw UnsupportedOperationException("Not implemented: $elem")
129
+ }
130
+ } catch (e: Exception) {
131
+ Log.w(TAG, "Read element failed", e)
132
+ }
133
+ }
134
+ return arr
135
+ }
136
+
137
+ fun getColor(colorStr: String?): Int {
138
+ return try {
139
+ if (TextUtils.isEmpty(colorStr)) {
140
+ 0
141
+ } else Color.parseColor(colorStr)
142
+ } catch (e: Exception) {
143
+ e.printStackTrace()
144
+ 0
145
+ }
146
+ }
147
+
148
+ // ReactFontManager.java
149
+ private fun getTypeface(context: Context, fontFamilyName: String?): Typeface? {
150
+ if (TextUtils.isEmpty(fontFamilyName)) {
151
+ return null
152
+ }
153
+ if (typefaceMap[fontFamilyName] != null) {
154
+ return typefaceMap[fontFamilyName]
155
+ }
156
+ val FILE_EXTENSIONS = arrayOf(".ttf", ".otf")
157
+ val FONTS_ASSET_PATH = "fonts/"
158
+ for (fileExtension in FILE_EXTENSIONS) {
159
+ return try {
160
+ val fileName = FONTS_ASSET_PATH +
161
+ fontFamilyName +
162
+ fileExtension
163
+ val typeface = Typeface.createFromAsset(context.assets, fileName)
164
+ typefaceMap[fontFamilyName] = typeface
165
+ typeface
166
+ } catch (e: Exception) {
167
+ // If the typeface asset does not exist, try another extension.
168
+ continue
169
+ }
170
+ }
171
+ return null
172
+ }
173
+
174
+ private fun getColors(readableArray: ReadableArray?): IntArray? {
175
+ if (readableArray == null || readableArray.size() == 0) {
176
+ return null
177
+ }
178
+ val array = IntArray(readableArray.size())
179
+ for (i in 0 until readableArray.size()) {
180
+ array[i] = getColor(readableArray.getString(i))
181
+ }
182
+ return array
183
+ }
184
+
185
+ private fun getTextConfig(context: Context, rnMap: ReadableMap?): TextConfig? {
186
+ rnMap ?: return null
187
+ val textConfig = TextConfig(
188
+ safeGetString(rnMap, "text"),
189
+ getColors(safeGetArray(rnMap, "gradientColors")),
190
+ getTypeface(context, safeGetString(rnMap, "font"))
191
+ )
192
+ textConfig.textColor = getColor(safeGetString(rnMap, "textColor"))
193
+ return textConfig
194
+ }
195
+
196
+ private fun getIconTextConfig(context: Context, rnMap: ReadableMap?): IconTextConfig? {
197
+ rnMap ?: return null
198
+ val v = safeGetString(rnMap, "image")
199
+ return IconTextConfig(RnImageSetter(v), getTextConfig(context, safeGetMap(rnMap, "textConfig")))
200
+ }
201
+
202
+ fun getSettingsManagement(rnMap: ReadableMap?): SettingsManagement? {
203
+ rnMap ?: return null
204
+ val settingsMap = safeGetMap(rnMap, "settingsManagement") ?: return null
205
+ return SettingsManagement(safeGetBoolean(settingsMap, "enableBiometricsPin"), safeGetBoolean(settingsMap, "disableConfirmationUI"))
206
+ }
207
+
208
+ private fun safeGetBoolean(map: ReadableMap, key: String): Boolean{
209
+ if (map.hasKey(key)){
210
+ return map.getBoolean(key)
211
+ }
212
+ return false
213
+ }
214
+ private fun safeGetString(map: ReadableMap, key: String): String?{
215
+ if (map.hasKey(key)){
216
+ return map.getString(key)
217
+ }
218
+ return null
219
+ }
220
+ private fun safeGetArray(map: ReadableMap, key: String): ReadableArray?{
221
+ if (map.hasKey(key)){
222
+ return map.getArray(key)
223
+ }
224
+ return null
225
+ }
226
+ private fun safeGetMap(map: ReadableMap, key: String): ReadableMap?{
227
+ if (map.hasKey(key)){
228
+ return map.getMap(key)
229
+ }
230
+ return null
231
+ }
232
+
233
+ private fun getTextConfigArray(context: Context, rnArray: ReadableArray?): Array<TextConfig?> {
234
+ rnArray ?: return arrayOfNulls(0)
235
+ val array = arrayOfNulls<TextConfig>(rnArray.size())
236
+ for (i in 0 until rnArray.size()) {
237
+ try {
238
+ array[i] = getTextConfig(context, rnArray.getMap(i))
239
+ } catch (e: Exception) {
240
+ e.printStackTrace()
241
+ }
242
+ }
243
+ return array
244
+ }
245
+
246
+ private fun getIconTextConfigArray(
247
+ context: Context,
248
+ rnArray: ReadableArray?
249
+ ): Array<IconTextConfig?> {
250
+ rnArray ?: return arrayOfNulls(0)
251
+ val array = arrayOfNulls<IconTextConfig>(rnArray.size())
252
+ for (i in 0 until rnArray.size()) {
253
+ try {
254
+ array[i] = getIconTextConfig(context, rnArray.getMap(i))
255
+ } catch (e: Exception) {
256
+ e.printStackTrace()
257
+ }
258
+ }
259
+ return array
260
+ }
261
+
262
+ fun getTextConfigsMap(context: Context, rnMap: ReadableMap?): Map<String, Array<TextConfig?>> {
263
+ val map: MutableMap<String, Array<TextConfig?>> = HashMap()
264
+ rnMap ?: return map
265
+ val itor = rnMap.keySetIterator()
266
+ while (itor.hasNextKey()) {
267
+ val key = itor.nextKey()
268
+ try {
269
+ map[key] = getTextConfigArray(context, rnMap.getArray(key))
270
+ } catch (e: Exception) {
271
+ e.printStackTrace()
272
+ }
273
+ }
274
+ return map
275
+ }
276
+
277
+ fun getTextConfigMap(context: Context, rnMap: ReadableMap?): Map<String, TextConfig> {
278
+ val map: MutableMap<String, TextConfig> = HashMap()
279
+ rnMap ?: return map
280
+ val itor = rnMap.keySetIterator()
281
+ while (itor.hasNextKey()) {
282
+ val key = itor.nextKey()
283
+ try {
284
+ getTextConfig(context, rnMap.getMap(key))?.let {
285
+ map[key] = it
286
+ }
287
+ } catch (e: Exception) {
288
+ e.printStackTrace()
289
+ }
290
+ }
291
+ return map
292
+ }
293
+
294
+ fun getIconTextConfigsMap(
295
+ context: Context,
296
+ rnMap: ReadableMap?
297
+ ): Map<Resource.IconTextsKey, Array<IconTextConfig?>> {
298
+ val map: MutableMap<Resource.IconTextsKey, Array<IconTextConfig?>> =
299
+ HashMap()
300
+ rnMap ?: return map
301
+ val itor = rnMap.keySetIterator()
302
+ while (itor.hasNextKey()) {
303
+ val key = itor.nextKey()
304
+ try {
305
+ val enumKey: Resource.IconTextsKey = Resource.IconTextsKey.valueOf(key)
306
+ map[enumKey] = getIconTextConfigArray(context, rnMap.getArray(key))
307
+ } catch (e: Exception) {
308
+ e.printStackTrace()
309
+ }
310
+ }
311
+ return map
312
+ }
313
+
314
+ fun getDismissOnCallbackMap(rnMap: ReadableMap?): Map<Int, Boolean> {
315
+ val map: MutableMap<Int, Boolean> = HashMap()
316
+ rnMap ?: return map
317
+ val itor = rnMap.keySetIterator()
318
+ while (itor.hasNextKey()) {
319
+ val key = itor.nextKey()
320
+ try {
321
+ map[Integer.valueOf(key)] = rnMap.getBoolean(key)
322
+ } catch (e: Exception) {
323
+ e.printStackTrace()
324
+ }
325
+ }
326
+ if (BuildConfig.DEBUG) {
327
+ dismissOnCallbackForTest = map
328
+ }
329
+ return map
330
+ }
331
+
332
+ fun getErrorStringMap(rnMap: ReadableMap?): Map<Int, String> {
333
+ val map: MutableMap<Int, String> = HashMap()
334
+ rnMap ?: return map
335
+ val itor = rnMap.keySetIterator()
336
+ while (itor.hasNextKey()) {
337
+ val key = itor.nextKey()
338
+ try {
339
+ rnMap.getString(key)?.let {
340
+ map[Integer.valueOf(key)] = it
341
+ }
342
+ } catch (e: Exception) {
343
+ e.printStackTrace()
344
+ }
345
+ }
346
+ return map
347
+ }
348
+
349
+ fun reactNativeMapToStringMap(rnMap: ReadableMap?): Map<String, String> {
350
+ val map: MutableMap<String, String> = HashMap()
351
+ rnMap ?: return map
352
+ val itor = rnMap.keySetIterator()
353
+ while (itor.hasNextKey()) {
354
+ val key = itor.nextKey()
355
+ try {
356
+ rnMap.getString(key)?.let {
357
+ map[key] = it
358
+ }
359
+ } catch (e: Exception) {
360
+ e.printStackTrace()
361
+ }
362
+ }
363
+ return map
364
+ }
365
+
366
+ fun getSecurityQuestions(rnArray: ReadableArray?): Array<SecurityQuestion?> {
367
+ rnArray ?: return arrayOfNulls(0)
368
+ val array = arrayOfNulls<SecurityQuestion>(rnArray.size())
369
+ for (i in 0 until rnArray.size()) {
370
+ val readableMap = rnArray.getMap(i)
371
+ val inputType = safeGetString(readableMap, "inputType")
372
+ val title = safeGetString(readableMap, "title") ?: ""
373
+ if (SecurityQuestion.InputType.datePicker.name != inputType) {
374
+ array[i] = SecurityQuestion(title)
375
+ } else {
376
+ array[i] = SecurityQuestion(
377
+ title,
378
+ SecurityQuestion.InputType.datePicker
379
+ )
380
+ }
381
+ }
382
+ if (BuildConfig.DEBUG) {
383
+ questionsForTest = array
384
+ }
385
+ return array
386
+ }
387
+
388
+ }