-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from smileidentity/feature/reactcompose
React Native Products Integration
- Loading branch information
Showing
55 changed files
with
3,505 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
SmileId_kotlinVersion=1.9.0 | ||
SmileId_kotlinVersion=1.9.10 | ||
SmileId_minSdkVersion=21 | ||
SmileId_targetSdkVersion=34 | ||
SmileId_compileSdkVersion=34 | ||
SmileId_ndkversion=21.4.7075529 | ||
SmileId_androidVersion=10.0.0-beta05 | ||
SmileId_androidVersion=10.0.0-beta09 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 18 additions & 4 deletions
22
android/src/main/java/com/smileidentity/react/SmileIdPackage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
android/src/main/java/com/smileidentity/react/utils/ReactUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package com.smileidentity.react.utils | ||
|
||
import com.facebook.react.bridge.ReadableMap | ||
import com.facebook.react.bridge.ReadableType | ||
import com.smileidentity.models.IdInfo | ||
import com.smileidentity.models.JobType | ||
import com.smileidentity.models.PartnerParams | ||
import com.smileidentity.util.randomUserId | ||
import timber.log.Timber | ||
|
||
fun ReadableMap.toMap(): Map<String, String> { | ||
val map = mutableMapOf<String, String>() | ||
val iterator = keySetIterator() | ||
while (iterator.hasNextKey()) { | ||
val key = iterator.nextKey() | ||
val value: String = when (getType(key)) { | ||
ReadableType.Null -> null.toString() | ||
ReadableType.Boolean -> getBoolean(key).toString() | ||
ReadableType.Number -> getDouble(key).toString() | ||
ReadableType.String -> getString(key)!! | ||
ReadableType.Map -> getMap(key)?.toMap().toString() | ||
ReadableType.Array -> getArray(key).toString() | ||
} | ||
map[key] = value | ||
} | ||
return map | ||
} | ||
|
||
fun ReadableMap.idInfo(): IdInfo? { | ||
val idInfoMap = getMapOrDefault("idInfo", null) | ||
val country = idInfoMap?.getStringOrDefault("country", null) ?: run { | ||
Timber.e("idInfo.country is required") | ||
return null | ||
} | ||
return IdInfo( | ||
country = country, | ||
idType = idInfoMap.getStringOrDefault("idType", null), | ||
idNumber = idInfoMap.getStringOrDefault("idNumber", null), | ||
firstName = idInfoMap.getStringOrDefault("firstName", null), | ||
middleName = idInfoMap.getStringOrDefault("middleName", null), | ||
lastName = idInfoMap.getStringOrDefault("lastName", null), | ||
dob = idInfoMap.getStringOrDefault("dob", null), | ||
bankCode = idInfoMap.getStringOrDefault("bankCode", null), | ||
entered = idInfoMap.getBoolOrDefault("entered", false), | ||
) | ||
} | ||
|
||
|
||
fun ReadableMap.partnerParams(): PartnerParams? { | ||
val partnerParams = getMapOrDefault("partnerParams", null) ?: run { | ||
Timber.w("partnerParams is required") | ||
return null | ||
} | ||
val jobTypeValue = partnerParams.getIntOrDefault("jobType", null) | ||
val jobType = if (jobTypeValue != null) JobType.fromValue(jobTypeValue) else null | ||
return PartnerParams( | ||
jobType = jobType, | ||
userId = partnerParams.getStringOrDefault("userId", null) ?: run { randomUserId() }, | ||
jobId = partnerParams.getStringOrDefault("jobId", null) ?: run { randomUserId() }, | ||
extras = partnerParams.getMapOrDefault("extras", null)?.toMap() ?: run { emptyMap() }, | ||
) | ||
} | ||
|
||
|
||
fun ReadableMap.getBoolOrDefault(key: String, defaultValue: Boolean): Boolean { | ||
if (hasKey(key)) { | ||
return getBoolean(key) | ||
} | ||
return defaultValue | ||
} | ||
|
||
fun ReadableMap.getStringOrDefault(key: String, defaultValue: String?): String? { | ||
if (hasKey(key)) { | ||
return getString(key) | ||
} | ||
return defaultValue | ||
} | ||
|
||
fun ReadableMap.getIntOrDefault(key: String, defaultValue: Int?): Int? { | ||
if (hasKey(key)) { | ||
return getInt(key) | ||
} | ||
return defaultValue | ||
} | ||
|
||
fun ReadableMap.getMapOrDefault(key: String, defaultValue: ReadableMap?): ReadableMap? { | ||
if (hasKey(key)) { | ||
return getMap(key) | ||
} | ||
return defaultValue | ||
} |
42 changes: 42 additions & 0 deletions
42
android/src/main/java/com/smileidentity/react/viewmanagers/SmileIDBVNConsentViewManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.smileidentity.react.viewmanagers | ||
|
||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.bridge.ReadableMap | ||
import com.facebook.react.module.annotations.ReactModule | ||
import com.facebook.react.uimanager.SimpleViewManager | ||
import com.facebook.react.uimanager.ThemedReactContext | ||
import com.facebook.react.uimanager.annotations.ReactProp | ||
import com.smileidentity.react.views.SmileIDBVNConsentScreen | ||
|
||
|
||
@ReactModule(name = SmileIDBVNConsentViewManager.NAME) | ||
class SmileIDBVNConsentViewManager(private val reactApplicationContext: ReactApplicationContext) : | ||
SimpleViewManager<SmileIDBVNConsentScreen>() { | ||
override fun getName(): String { | ||
return NAME | ||
} | ||
|
||
override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> { | ||
return mapOf( | ||
"onSmileResult" to mapOf( | ||
"phasedRegistrationNames" to mapOf( | ||
"bubbled" to "onResult" | ||
) | ||
) | ||
) | ||
} | ||
|
||
@ReactProp(name = "product") | ||
fun setProduct(view: SmileIDBVNConsentScreen, product: ReadableMap) { | ||
view.product = product | ||
} | ||
|
||
override fun createViewInstance(p0: ThemedReactContext): SmileIDBVNConsentScreen { | ||
return SmileIDBVNConsentScreen(reactApplicationContext) | ||
} | ||
|
||
companion object { | ||
const val NAME = "SmileIDBVNConsentScreenView" | ||
} | ||
|
||
} |
Oops, something went wrong.