-
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.
setting up enhanced biometric screens
- Loading branch information
Showing
10 changed files
with
395 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
SmileId_kotlinVersion=2.0.0 | ||
SmileId_minSdkVersion=21 | ||
SmileId_targetSdkVersion=34 | ||
SmileId_compileSdkVersion=34 | ||
SmileId_targetSdkVersion=35 | ||
SmileId_compileSdkVersion=35 | ||
SmileId_ndkversion=21.4.7075529 | ||
SmileId_androidVersion=10.3.7 | ||
SmileId_kotlinCompilerExtensionVersion=1.5.11 | ||
SmileId_androidVersion=10.4.0 | ||
#SmileId_kotlinCompilerExtensionVersion=1.5.11 |
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
64 changes: 64 additions & 0 deletions
64
...m/smileidentity/react/viewmanagers/SmileIDSmartSelfieAuthenticationEnhancedViewManager.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,64 @@ | ||
package com.smileidentity.react.viewmanagers | ||
|
||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.bridge.ReadableArray | ||
import com.facebook.react.module.annotations.ReactModule | ||
import com.facebook.react.uimanager.SimpleViewManager | ||
import com.facebook.react.uimanager.ThemedReactContext | ||
import com.smileidentity.react.utils.getBoolOrDefault | ||
import com.smileidentity.react.utils.getImmutableMapOrDefault | ||
import com.smileidentity.react.utils.getStringOrDefault | ||
import com.smileidentity.react.views.SmileIDSmartSelfieAuthenticationEnhancedView | ||
|
||
@ReactModule(name = SmileIDSmartSelfieAuthenticationEnhancedViewManager.NAME) | ||
class SmileIDSmartSelfieAuthenticationEnhancedViewManager( | ||
private val reactApplicationContext: ReactApplicationContext | ||
) : SimpleViewManager<SmileIDSmartSelfieAuthenticationEnhancedView>() { | ||
|
||
override fun getName(): String = NAME | ||
|
||
override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> { | ||
return mapOf( | ||
"onSmileResult" to mapOf( | ||
"phasedRegistrationNames" to mapOf( | ||
"bubbled" to "onResult" | ||
) | ||
) | ||
) | ||
} | ||
|
||
override fun getCommandsMap(): Map<String, Int> { | ||
return mapOf("setParams" to COMMAND_SET_PARAMS) | ||
} | ||
|
||
override fun receiveCommand( | ||
view: SmileIDSmartSelfieAuthenticationEnhancedView, | ||
commandId: String?, | ||
args: ReadableArray? | ||
) { | ||
super.receiveCommand(view, commandId, args) | ||
when (commandId?.toInt()) { | ||
COMMAND_SET_PARAMS -> { | ||
// Extract params from args and apply to view | ||
val params = args?.getMap(0) | ||
params?.let { | ||
view.extraPartnerParams = params.getImmutableMapOrDefault("extraPartnerParams") | ||
view.userId = params.getStringOrDefault("userId") | ||
view.showAttribution = params.getBoolOrDefault("showAttribution", true) | ||
view.showInstructions = params.getBoolOrDefault("showInstructions", true) | ||
view.allowNewEnroll = params.getBoolOrDefault("allowNewEnroll", false) | ||
view.renderContent() | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun createViewInstance(p0: ThemedReactContext): SmileIDSmartSelfieAuthenticationEnhancedView { | ||
return SmileIDSmartSelfieAuthenticationEnhancedView(reactApplicationContext) | ||
} | ||
|
||
companion object { | ||
const val NAME = "SmileIDSmartSelfieAuthenticationEnhancedView" | ||
const val COMMAND_SET_PARAMS = 2 | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...a/com/smileidentity/react/viewmanagers/SmileIDSmartSelfieEnrollmentEnhancedViewManager.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,64 @@ | ||
package com.smileidentity.react.viewmanagers | ||
|
||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.bridge.ReadableArray | ||
import com.facebook.react.module.annotations.ReactModule | ||
import com.facebook.react.uimanager.SimpleViewManager | ||
import com.facebook.react.uimanager.ThemedReactContext | ||
import com.smileidentity.react.utils.getBoolOrDefault | ||
import com.smileidentity.react.utils.getImmutableMapOrDefault | ||
import com.smileidentity.react.utils.getStringOrDefault | ||
import com.smileidentity.react.views.SmileIDSmartSelfieEnrollmentEnhancedView | ||
|
||
@ReactModule(name = SmileIDSmartSelfieEnrollmentEnhancedViewManager.NAME) | ||
class SmileIDSmartSelfieEnrollmentEnhancedViewManager( | ||
private val reactApplicationContext: ReactApplicationContext | ||
) : SimpleViewManager<SmileIDSmartSelfieEnrollmentEnhancedView>() { | ||
|
||
override fun getName(): String = NAME | ||
|
||
override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> { | ||
return mapOf( | ||
"onSmileResult" to mapOf( | ||
"phasedRegistrationNames" to mapOf( | ||
"bubbled" to "onResult" | ||
) | ||
) | ||
) | ||
} | ||
|
||
override fun getCommandsMap(): Map<String, Int> { | ||
return mapOf("setParams" to COMMAND_SET_PARAMS) | ||
} | ||
|
||
override fun receiveCommand( | ||
view: SmileIDSmartSelfieEnrollmentEnhancedView, | ||
commandId: String?, | ||
args: ReadableArray? | ||
) { | ||
super.receiveCommand(view, commandId, args) | ||
when (commandId?.toInt()) { | ||
COMMAND_SET_PARAMS -> { | ||
// Extract params from args and apply to view | ||
val params = args?.getMap(0) | ||
params?.let { | ||
view.extraPartnerParams = params.getImmutableMapOrDefault("extraPartnerParams") | ||
view.userId = params.getStringOrDefault("userId") | ||
view.showAttribution = params.getBoolOrDefault("showAttribution", true) | ||
view.showInstructions = params.getBoolOrDefault("showInstructions", true) | ||
view.allowNewEnroll = params.getBoolOrDefault("allowNewEnroll", false) | ||
view.renderContent() | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun createViewInstance(p0: ThemedReactContext): SmileIDSmartSelfieEnrollmentEnhancedView { | ||
return SmileIDSmartSelfieEnrollmentEnhancedView(reactApplicationContext) | ||
} | ||
|
||
companion object { | ||
const val NAME = "SmileIDSmartSelfieEnrollmentEnhancedView" | ||
const val COMMAND_SET_PARAMS = 1 | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...c/main/java/com/smileidentity/react/views/SmileIDSmartSelfieAuthenticationEnhancedView.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,64 @@ | ||
package com.smileidentity.react.views | ||
|
||
import androidx.compose.runtime.CompositionLocalProvider | ||
import androidx.compose.runtime.saveable.rememberSaveable | ||
import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner | ||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.smileidentity.SmileID | ||
import com.smileidentity.compose.SmartSelfieAuthenticationEnhanced | ||
import com.smileidentity.react.results.SmartSelfieCaptureResult | ||
import com.smileidentity.react.utils.SelfieCaptureResultAdapter | ||
import com.smileidentity.results.SmileIDResult | ||
import com.smileidentity.util.randomUserId | ||
import kotlinx.collections.immutable.toImmutableMap | ||
|
||
class SmileIDSmartSelfieAuthenticationEnhancedView(context: ReactApplicationContext) : | ||
SmileIDView(context) { | ||
|
||
override fun renderContent() { | ||
composeView.apply { | ||
val customViewModelStoreOwner = CustomViewModelStoreOwner() | ||
setContent { | ||
CompositionLocalProvider(LocalViewModelStoreOwner provides customViewModelStoreOwner) { | ||
SmileID.SmartSelfieAuthenticationEnhanced( | ||
userId = userId ?: rememberSaveable { randomUserId() }, | ||
allowNewEnroll = allowNewEnroll ?: false, | ||
showAttribution = showAttribution, | ||
showInstructions = showInstructions, | ||
extraPartnerParams = extraPartnerParams, | ||
) { res -> | ||
when (res) { | ||
is SmileIDResult.Success -> { | ||
// val result = | ||
// SmartSelfieCaptureResult( | ||
// selfieFile = res.data.selfieFile, | ||
// livenessFiles = res.data.livenessFiles, | ||
// apiResponse = res.data.apiResponse, | ||
// ) | ||
// val newMoshi = | ||
// SmileID.moshi | ||
// .newBuilder() | ||
// .add(SelfieCaptureResultAdapter.FACTORY) | ||
// .build() | ||
// val json = | ||
// try { | ||
// newMoshi | ||
// .adapter(SmartSelfieCaptureResult::class.java) | ||
// .toJson(result) | ||
// } catch (e: Exception) { | ||
// emitFailure(e) | ||
// return@SmartSelfieAuthentication | ||
// } | ||
// json?.let { js -> | ||
// emitSuccess(js) | ||
// } | ||
} | ||
|
||
is SmileIDResult.Error -> emitFailure(res.throwable) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
...d/src/main/java/com/smileidentity/react/views/SmileIDSmartSelfieEnrollmentEnhancedView.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,63 @@ | ||
package com.smileidentity.react.views | ||
|
||
import androidx.compose.runtime.CompositionLocalProvider | ||
import androidx.compose.runtime.saveable.rememberSaveable | ||
import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner | ||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.smileidentity.SmileID | ||
import com.smileidentity.compose.SmartSelfieEnrollmentEnhanced | ||
import com.smileidentity.react.results.SmartSelfieCaptureResult | ||
import com.smileidentity.react.utils.SelfieCaptureResultAdapter | ||
import com.smileidentity.results.SmileIDResult | ||
import com.smileidentity.util.randomUserId | ||
import kotlinx.collections.immutable.toImmutableMap | ||
|
||
class SmileIDSmartSelfieEnrollmentEnhancedView(context: ReactApplicationContext) : SmileIDView(context) { | ||
|
||
override fun renderContent() { | ||
composeView.apply { | ||
setContent { | ||
val customViewModelStoreOwner = CustomViewModelStoreOwner() | ||
CompositionLocalProvider(LocalViewModelStoreOwner provides customViewModelStoreOwner) { | ||
SmileID.SmartSelfieEnrollmentEnhanced( | ||
userId = userId ?: rememberSaveable { randomUserId() }, | ||
allowNewEnroll = allowNewEnroll ?: false, | ||
showAttribution = showAttribution, | ||
showInstructions = showInstructions, | ||
extraPartnerParams = extraPartnerParams, | ||
) { res -> | ||
when (res) { | ||
is SmileIDResult.Success -> { | ||
// val result = | ||
// SmartSelfieCaptureResult( | ||
// selfieFile = res.data.selfieFile, | ||
// livenessFiles = res.data.livenessFiles, | ||
// apiResponse = res.data.apiResponse, | ||
// ) | ||
// val newMoshi = | ||
// SmileID.moshi | ||
// .newBuilder() | ||
// .add(SelfieCaptureResultAdapter.FACTORY) | ||
// .build() | ||
// val json = | ||
// try { | ||
// newMoshi | ||
// .adapter(SmartSelfieCaptureResult::class.java) | ||
// .toJson(result) | ||
// } catch (e: Exception) { | ||
// emitFailure(e) | ||
// return@SmartSelfieEnrollment | ||
// } | ||
// json?.let { js -> | ||
// emitSuccess(js) | ||
// } | ||
} | ||
|
||
is SmileIDResult.Error -> emitFailure(res.throwable) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.