Skip to content

Commit

Permalink
Bugfix/docflow (#484)
Browse files Browse the repository at this point in the history
* fix: enhanced doc v and nav params

* feat: change log update

* feat: params observed correctly

* feat: add biometric kyc fragment
  • Loading branch information
JNdhlovu authored Nov 8, 2024
1 parent 76a8b0c commit 1d2592c
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 83 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## 10.3.5

* Fix the camera is closed bug on document capture flow
* Enhanced doc v submitted as doc v
* Correct flow for selfie when showInstructions is false

## 10.3.4

Expand Down
102 changes: 59 additions & 43 deletions lib/src/main/java/com/smileidentity/compose/SmileIDExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.smileidentity.compose.nav.OrchestratedSelfieCaptureParams
import com.smileidentity.compose.nav.ResultCallbacks
import com.smileidentity.compose.nav.Routes
import com.smileidentity.compose.nav.SelfieCaptureParams
import com.smileidentity.compose.nav.SerializableFile
import com.smileidentity.compose.nav.getDocumentCaptureRoute
import com.smileidentity.compose.nav.getSelfieCaptureRoute
import com.smileidentity.compose.theme.colorScheme
Expand Down Expand Up @@ -92,10 +93,14 @@ fun SmileID.SmartSelfieEnrollment(
true,
skipApiSubmission,
)
val screenDestination = getSelfieCaptureRoute(useStrictMode, commonParams)
val orchestratedDestination = Routes.Orchestrated.SelfieRoute(
params = OrchestratedSelfieCaptureParams(commonParams),
params = OrchestratedSelfieCaptureParams(
commonParams,
startRoute = screenDestination,
showStartRoute = true,
),
)
val screenDestination = getSelfieCaptureRoute(useStrictMode, commonParams)
BaseSmileIDScreen(
orchestratedDestination,
screenDestination,
Expand Down Expand Up @@ -159,10 +164,14 @@ fun SmileID.SmartSelfieAuthentication(
isEnroll = false,
skipApiSubmission,
)
val screenDestination = getSelfieCaptureRoute(useStrictMode, commonParams)
val orchestratedDestination = Routes.Orchestrated.SelfieRoute(
params = OrchestratedSelfieCaptureParams(commonParams),
params = OrchestratedSelfieCaptureParams(
commonParams,
startRoute = screenDestination,
showStartRoute = true,
),
)
val screenDestination = getSelfieCaptureRoute(useStrictMode, commonParams)
BaseSmileIDScreen(
orchestratedDestination,
screenDestination,
Expand Down Expand Up @@ -228,23 +237,22 @@ fun SmileID.DocumentVerification(
onResult: SmileIDCallback<DocumentVerificationResult> = {},
) {
val commonParams = DocumentCaptureParams(
userId,
jobId,
allowNewEnroll,
allowAgentMode,
showAttribution,
showInstructions,
extraPartnerParams,
userId = userId,
jobId = jobId,
showInstructions = showInstructions,
showAttribution = showAttribution,
allowAgentMode = allowAgentMode,
allowGallerySelection = allowGalleryUpload,
knownIdAspectRatio = idAspectRatio,
allowNewEnroll = allowNewEnroll,
countryCode = countryCode,
documentType = documentType,
captureBothSides = captureBothSides,
selfieFile = bypassSelfieCaptureWithFile?.let { SerializableFile.fromFile(it) },
extraPartnerParams = extraPartnerParams,
)
val screenDestination = getDocumentCaptureRoute(
countryCode,
commonParams,
documentType,
captureBothSides,
idAspectRatio,
bypassSelfieCaptureWithFile,
allowGalleryUpload,
)
val orchestratedDestination = Routes.Orchestrated.DocVRoute(
params = OrchestratedDocumentParams(commonParams),
Expand Down Expand Up @@ -315,23 +323,22 @@ fun SmileID.EnhancedDocumentVerificationScreen(
onResult: SmileIDCallback<EnhancedDocumentVerificationResult> = {},
) {
val commonParams = DocumentCaptureParams(
userId,
jobId,
allowNewEnroll,
allowAgentMode,
showAttribution,
showInstructions,
extraPartnerParams,
userId = userId,
jobId = jobId,
showInstructions = showInstructions,
showAttribution = showAttribution,
allowAgentMode = allowAgentMode,
allowGallerySelection = allowGalleryUpload,
knownIdAspectRatio = idAspectRatio,
allowNewEnroll = allowNewEnroll,
countryCode = countryCode,
documentType = documentType,
captureBothSides = captureBothSides,
selfieFile = bypassSelfieCaptureWithFile?.let { SerializableFile.fromFile(it) },
extraPartnerParams = extraPartnerParams,
)
val screenDestination = getDocumentCaptureRoute(
countryCode,
commonParams,
documentType,
captureBothSides,
idAspectRatio,
bypassSelfieCaptureWithFile,
allowGalleryUpload,
)
val orchestratedDestination = Routes.Orchestrated.EnhancedDocVRoute(
params = OrchestratedDocumentParams(commonParams),
Expand Down Expand Up @@ -385,6 +392,25 @@ fun SmileID.BiometricKYC(
typography: Typography = SmileID.typography,
onResult: SmileIDCallback<BiometricKycResult> = {},
) {
val commonParams = SelfieCaptureParams(
userId,
jobId,
allowNewEnroll,
allowAgentMode,
showAttribution,
showInstructions,
extraPartnerParams,
true,
skipApiSubmission = true,
)
val selfieDestination = getSelfieCaptureRoute(false, commonParams)
val screenDestination = Routes.Orchestrated.SelfieRoute(
params = OrchestratedSelfieCaptureParams(
commonParams,
startRoute = selfieDestination,
showStartRoute = true,
),
)
val orchestratedDestination = Routes.Orchestrated.BiometricKycRoute(
OrchestratedBiometricCaptureParams(
BiometricKYCParams(
Expand All @@ -397,23 +423,13 @@ fun SmileID.BiometricKYC(
allowNewEnroll = allowNewEnroll,
extraPartnerParams = extraPartnerParams,
),
startRoute = screenDestination,
showStartRoute = true,
),
)
val selfieCaptureParams = SelfieCaptureParams(
userId,
jobId,
allowNewEnroll,
allowAgentMode,
showAttribution,
showInstructions,
extraPartnerParams,
true,
skipApiSubmission = true,
)
val screenDestination = getSelfieCaptureRoute(false, selfieCaptureParams)
BaseSmileIDScreen(
orchestratedDestination,
screenDestination,
selfieDestination,
ResultCallbacks(onBiometricKYCResult = onResult),
modifier,
colorScheme,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@ import androidx.compose.foundation.layout.statusBars
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
import com.smileidentity.R
import com.smileidentity.compose.nav.NavigationBackHandler
import com.smileidentity.compose.nav.OrchestratedSelfieCaptureParams
import com.smileidentity.compose.nav.ProcessingScreenParams
import com.smileidentity.compose.nav.ResultCallbacks
import com.smileidentity.compose.nav.Routes
import com.smileidentity.compose.nav.SelfieCaptureParams
import com.smileidentity.compose.nav.localNavigationState
import com.smileidentity.models.IdInfo
import com.smileidentity.results.BiometricKycResult
Expand All @@ -43,9 +44,8 @@ internal fun OrchestratedBiometricKYCScreen(
userId: String = rememberSaveable { randomUserId() },
jobId: String = rememberSaveable { randomJobId() },
allowNewEnroll: Boolean = false,
allowAgentMode: Boolean = false,
showAttribution: Boolean = true,
showInstructions: Boolean = true,
showStartRoute: Boolean = false,
startRoute: Routes? = null,
extraPartnerParams: ImmutableMap<String, String> = persistentMapOf(),
viewModel: BiometricKycViewModel = viewModel(
factory = viewModelFactory {
Expand All @@ -70,6 +70,7 @@ internal fun OrchestratedBiometricKYCScreen(
content()
}
val uiState = viewModel.uiState.collectAsStateWithLifecycle().value
var startRouteShown by rememberSaveable { mutableStateOf(false) }
resultCallbacks.onProcessingContinue = { viewModel.onFinished(onResult) }
resultCallbacks.onProcessingClose = { viewModel.onFinished(onResult) }
resultCallbacks.onSmartSelfieResult = {
Expand Down Expand Up @@ -106,20 +107,10 @@ internal fun OrchestratedBiometricKYCScreen(
),
),
)
} else -> {
} showStartRoute && startRoute != null && !startRouteShown -> {
startRouteShown = true
localNavigationState.orchestratedNavigation.navigateTo(
Routes.Orchestrated.SelfieRoute(
OrchestratedSelfieCaptureParams(
SelfieCaptureParams(
userId = userId,
jobId = jobId,
showInstructions = showInstructions,
showAttribution = showAttribution,
allowAgentMode = allowAgentMode,
skipApiSubmission = true,
),
),
),
startRoute,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ data class OrchestratedBiometricCaptureParams(
),
),
),
val showStartRoute: Boolean = false,
) : Parcelable

@Serializable
Expand Down
26 changes: 8 additions & 18 deletions lib/src/main/java/com/smileidentity/compose/nav/NavUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import androidx.compose.ui.res.stringResource
import androidx.navigation.NavDestination
import androidx.navigation.NavType
import com.smileidentity.R
import java.io.File
import java.net.URLDecoder
import java.net.URLEncoder
import java.nio.charset.StandardCharsets
Expand Down Expand Up @@ -40,24 +39,15 @@ class CustomNavType<T : Parcelable>(
}

@Composable
internal fun getDocumentCaptureRoute(
countryCode: String,
params: DocumentCaptureParams,
documentType: String?,
captureBothSides: Boolean,
idAspectRatio: Float?,
bypassSelfieCaptureWithFile: File?,
allowGalleryUpload: Boolean,
): Routes {
val serializableFile = bypassSelfieCaptureWithFile?.let { SerializableFile.fromFile(it) }
internal fun getDocumentCaptureRoute(params: DocumentCaptureParams): Routes {
return if (params.showInstructions) {
Routes.Document.InstructionScreen(
params = DocumentInstructionParams(
R.drawable.si_doc_v_front_hero,
stringResource(R.string.si_doc_v_instruction_title),
stringResource(R.string.si_verify_identity_instruction_subtitle),
params.showAttribution,
allowGalleryUpload,
params.allowGallerySelection,
showSkipButton = false,
),
)
Expand All @@ -69,18 +59,18 @@ internal fun getDocumentCaptureRoute(
showInstructions = true,
showAttribution = params.showAttribution,
allowAgentMode = params.allowAgentMode,
allowGallerySelection = allowGalleryUpload,
allowGallerySelection = params.allowGallerySelection,
showSkipButton = params.showSkipButton,
instructionsHeroImage = params.instructionsHeroImage,
instructionsTitleText = params.instructionsTitleText,
instructionsSubtitleText = params.instructionsSubtitleText,
captureTitleText = params.captureTitleText,
knownIdAspectRatio = idAspectRatio,
knownIdAspectRatio = params.knownIdAspectRatio,
allowNewEnroll = params.allowNewEnroll,
countryCode = countryCode,
documentType = documentType,
captureBothSides = captureBothSides,
selfieFile = serializableFile,
countryCode = params.countryCode,
documentType = params.documentType,
captureBothSides = params.captureBothSides,
selfieFile = params.selfieFile,
extraPartnerParams = params.extraPartnerParams,
),
)
Expand Down
7 changes: 3 additions & 4 deletions lib/src/main/java/com/smileidentity/compose/nav/SmileIDNav.kt
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,9 @@ internal fun NavGraphBuilder.orchestratedNavGraph(
idInfo = params.captureParams.idInfo,
userId = params.captureParams.userId,
jobId = params.captureParams.jobId,
startRoute = params.startRoute,
showStartRoute = params.showStartRoute,
allowNewEnroll = params.captureParams.allowNewEnroll,
allowAgentMode = params.captureParams.allowAgentMode,
showAttribution = params.captureParams.showAttribution,
showInstructions = params.captureParams.showInstructions,
extraPartnerParams = params.captureParams.extraPartnerParams,
onResult = { resultCallbacks.onBiometricKYCResult?.invoke(it) },
)
Expand Down Expand Up @@ -224,7 +223,7 @@ internal fun NavGraphBuilder.orchestratedNavGraph(
viewModel = viewModel(
factory = viewModelFactory {
EnhancedDocumentVerificationViewModel(
jobType = JobType.DocumentVerification,
jobType = JobType.EnhancedDocumentVerification,
userId = params.captureParams.userId,
jobId = params.captureParams.jobId,
allowNewEnroll = params.captureParams.allowNewEnroll,
Expand Down
Loading

0 comments on commit 1d2592c

Please sign in to comment.