Skip to content

Commit

Permalink
Add ScanOID4VPQR view to navController which launches when scan to sh…
Browse files Browse the repository at this point in the history
…are button is pressed
  • Loading branch information
joeyschmoe committed Oct 2, 2024
1 parent 67ca763 commit fe68da5
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 3 deletions.
27 changes: 27 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.spruceid.mobilesdkexample.verifiersettings.VerifierSettingsHomeView
import com.spruceid.mobilesdkexample.viewmodels.IRawCredentialsViewModel
import com.spruceid.mobilesdkexample.wallet.AddToWalletView
import com.spruceid.mobilesdkexample.walletsettings.WalletSettingsHomeView
import com.spruceid.mobilesdkexample.wallet.ScanOID4VPQR

@Composable
fun SetupNavGraph(
Expand Down Expand Up @@ -73,8 +74,7 @@ fun SetupNavGraph(
}
)
) {
// val params = backStackEntry.arguments?.getString("params")!!
Text(text = "@TODO: OID4VP flow")
ScanOID4VPQR(navController)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.spruceid.mobilesdkexample.wallet

import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.navigation.NavController
import com.spruceid.mobilesdkexample.ScanningComponent
import com.spruceid.mobilesdkexample.ScanningType
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.spruceid.mobile.sdk.rs.verifyJwtVp
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch

@OptIn(ExperimentalMaterial3Api::class, ExperimentalPermissionsApi::class)
@Composable
fun ScanOID4VPQR(
navController: NavController
) {
var success by remember {
mutableStateOf<Boolean?>(null)
}

fun onRead(url: String) {
GlobalScope.launch {
// TODO: Add other checks as necessary for validating OID4VP url
// and handle OID4VP flow

// success = url.startsWith("oid4vp://")

// if (success == false) {
// error("Not a valid OID4VP url.")
// }
}
}

ScanningComponent(
navController = navController,
scanningType = ScanningType.QRCODE,
onRead = ::onRead
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fun WalletHomeBody(

val rawCredentials by rawCredentialsViewModel.rawCredentials.collectAsState()

if(rawCredentials.isNotEmpty()) {
if(!rawCredentials.isNotEmpty()) {
Column {
LazyColumn(
Modifier
Expand Down

0 comments on commit fe68da5

Please sign in to comment.