diff --git a/example/src/main/java/com/spruceid/mobilesdkexample/HomeView.kt b/example/src/main/java/com/spruceid/mobilesdkexample/HomeView.kt index 6a049db..d872ba6 100644 --- a/example/src/main/java/com/spruceid/mobilesdkexample/HomeView.kt +++ b/example/src/main/java/com/spruceid/mobilesdkexample/HomeView.kt @@ -1,13 +1,18 @@ package com.spruceid.mobilesdkexample import android.annotation.SuppressLint +import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.navigationBarsPadding import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.BottomAppBar import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Scaffold @@ -17,14 +22,22 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.ColorFilter +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.navigation.NavController import com.spruceid.mobilesdkexample.ui.theme.Bg -import com.spruceid.mobilesdkexample.ui.theme.Inter +import com.spruceid.mobilesdkexample.ui.theme.ColorBlue300 +import com.spruceid.mobilesdkexample.ui.theme.ColorBlue500 +import com.spruceid.mobilesdkexample.ui.theme.ColorBlue900 +import com.spruceid.mobilesdkexample.ui.theme.Switzer import com.spruceid.mobilesdkexample.verifier.VerifierHomeView import com.spruceid.mobilesdkexample.viewmodels.CredentialPacksViewModel import com.spruceid.mobilesdkexample.viewmodels.VerificationMethodsViewModel @@ -38,57 +51,28 @@ enum class HomeTabs { @Composable fun HomeView( navController: NavController, + initialTab: String, verificationMethodsViewModel: VerificationMethodsViewModel, credentialPacksViewModel: CredentialPacksViewModel ) { var tab by remember { - mutableStateOf(HomeTabs.WALLET) + if (initialTab == "verifier") { + mutableStateOf(HomeTabs.VERIFIER) + } else { + mutableStateOf(HomeTabs.WALLET) + } } Scaffold( containerColor = Color.Transparent, bottomBar = { - Row( - modifier = Modifier - .fillMaxWidth() - .background(Bg), horizontalArrangement = Arrangement.SpaceEvenly - ) { - Button( - onClick = { tab = HomeTabs.WALLET }, - modifier = Modifier.weight(1f), - colors = ButtonDefaults.buttonColors( - containerColor = Color.Transparent, - contentColor = if (tab == HomeTabs.WALLET) Color.Blue else Color.Gray, - ) - ) { - Text( - text = "Wallet", - fontFamily = Inter, - fontWeight = FontWeight.Normal, - fontSize = 10.sp, - ) - } - - Button( - onClick = { tab = HomeTabs.VERIFIER }, - modifier = Modifier.weight(1f), - colors = ButtonDefaults.buttonColors( - containerColor = Color.Transparent, - contentColor = if (tab == HomeTabs.VERIFIER) Color.Blue else Color.Gray, - ) - ) { - Text( - text = "Verifier", - fontFamily = Inter, - fontWeight = FontWeight.Normal, - fontSize = 10.sp, - ) - } + HomeBottomTabs(tab) { newTab -> + tab = newTab } }, modifier = Modifier.navigationBarsPadding() ) { - Box(modifier = Modifier.padding(bottom = 30.dp)) { + Box(modifier = Modifier.padding(bottom = 60.dp)) { if (tab == HomeTabs.WALLET) { WalletHomeView( navController, @@ -103,3 +87,82 @@ fun HomeView( } } } + +@Composable +fun HomeBottomTabs( + tab: HomeTabs, + changeTabs: (HomeTabs) -> Unit +) { + BottomAppBar(containerColor = Bg) { + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.Center + ) { + Row( + modifier = Modifier + .clip(shape = RoundedCornerShape(14.dp)) + .background(ColorBlue900) + .padding(horizontal = 4.dp) + ) { + Button( + onClick = { changeTabs(HomeTabs.WALLET) }, + colors = ButtonDefaults.buttonColors( + containerColor = if (tab == HomeTabs.WALLET) ColorBlue500 else Color.Transparent, + contentColor = if (tab == HomeTabs.WALLET) Color.White else ColorBlue300, + ), + shape = RoundedCornerShape(10.dp) + ) { + Row(verticalAlignment = Alignment.CenterVertically) { + Image( + painter = painterResource(id = R.drawable.wallet), + contentDescription = stringResource(id = R.string.wallet), + colorFilter = ColorFilter.tint( + if (tab == HomeTabs.WALLET) Color.White else ColorBlue300, + ), + modifier = Modifier + .width(20.dp) + .height(20.dp) + .padding(end = 3.dp) + ) + Text( + text = "Wallet", + fontFamily = Switzer, + fontWeight = FontWeight.Normal, + fontSize = 14.sp, + ) + } + } + + Button( + onClick = { changeTabs(HomeTabs.VERIFIER) }, + colors = ButtonDefaults.buttonColors( + containerColor = if (tab == HomeTabs.VERIFIER) ColorBlue500 else Color.Transparent, + contentColor = if (tab == HomeTabs.VERIFIER) Color.White else ColorBlue300, + ), + shape = RoundedCornerShape(10.dp) + ) { + Row(verticalAlignment = Alignment.CenterVertically) { + Image( + painter = painterResource(id = R.drawable.qrcode_scanner), + contentDescription = stringResource(id = R.string.verifier), + colorFilter = ColorFilter.tint( + if (tab == HomeTabs.VERIFIER) Color.White else ColorBlue300, + ), + modifier = Modifier + .width(20.dp) + .height(20.dp) + .padding(end = 3.dp) + ) + Text( + text = "Verifier", + fontFamily = Switzer, + fontWeight = FontWeight.Normal, + fontSize = 14.sp, + ) + } + } + } + } + } + +} diff --git a/example/src/main/java/com/spruceid/mobilesdkexample/verifier/Loader.kt b/example/src/main/java/com/spruceid/mobilesdkexample/Loader.kt similarity index 98% rename from example/src/main/java/com/spruceid/mobilesdkexample/verifier/Loader.kt rename to example/src/main/java/com/spruceid/mobilesdkexample/Loader.kt index 1b4e03f..4756f97 100644 --- a/example/src/main/java/com/spruceid/mobilesdkexample/verifier/Loader.kt +++ b/example/src/main/java/com/spruceid/mobilesdkexample/Loader.kt @@ -1,4 +1,4 @@ -package com.spruceid.mobilesdkexample.verifier +package com.spruceid.mobilesdkexample import androidx.compose.animation.core.LinearEasing import androidx.compose.animation.core.VectorConverter diff --git a/example/src/main/java/com/spruceid/mobilesdkexample/ScanningComponent.kt b/example/src/main/java/com/spruceid/mobilesdkexample/ScanningComponent.kt index 52edb8e..9557e5f 100644 --- a/example/src/main/java/com/spruceid/mobilesdkexample/ScanningComponent.kt +++ b/example/src/main/java/com/spruceid/mobilesdkexample/ScanningComponent.kt @@ -25,7 +25,6 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleEventObserver -import androidx.navigation.NavController import com.google.accompanist.permissions.ExperimentalPermissionsApi import com.google.accompanist.permissions.isGranted import com.google.accompanist.permissions.rememberMultiplePermissionsState @@ -43,13 +42,12 @@ enum class ScanningType { @ExperimentalPermissionsApi @Composable fun ScanningComponent( - navController: NavController, scanningType: ScanningType, title: String = "Scan QR Code", subtitle: String = "Please align within the guides", onRead: (content: String) -> Unit, isMatch: (content: String) -> Boolean = { _ -> true }, - onCancel: (() -> Unit)? = null + onCancel: () -> Unit ) { val context = LocalContext.current @@ -79,18 +77,6 @@ fun ScanningComponent( }, ) - fun backHome() { - navController.popBackStack() - } - - fun internalOnCancel() { - if (onCancel != null) { - onCancel() - } else { - backHome() - } - } - Column( modifier = Modifier.fillMaxSize(), ) { @@ -104,7 +90,7 @@ fun ScanningComponent( cancelButtonLabel = "Cancel", onRead = onRead, isMatch = isMatch, - onCancel = ::internalOnCancel, + onCancel = onCancel, fontFamily = Inter, readerColor = Color.White, guidesColor = Color.White, @@ -118,7 +104,7 @@ fun ScanningComponent( cancelButtonLabel = "Cancel", onRead = onRead, isMatch = isMatch, - onCancel = ::internalOnCancel, + onCancel = onCancel, fontFamily = Inter, readerColor = Color.White, guidesColor = Color.White, @@ -132,7 +118,7 @@ fun ScanningComponent( cancelButtonLabel = "Cancel", onRead = onRead, isMatch = isMatch, - onCancel = ::internalOnCancel, + onCancel = onCancel, fontFamily = Inter, readerColor = Color.White, guidesColor = Color.White, @@ -144,9 +130,7 @@ fun ScanningComponent( AlertDialog( containerColor = Color.White, shape = RoundedCornerShape(8.dp), - onDismissRequest = { - backHome() - }, + onDismissRequest = onCancel, title = { Text( "Camera permission denied", @@ -189,9 +173,7 @@ fun ScanningComponent( }, dismissButton = { Button( - onClick = { - backHome() - }, + onClick = onCancel, colors = ButtonDefaults.buttonColors( containerColor = Color.Transparent, diff --git a/example/src/main/java/com/spruceid/mobilesdkexample/navigation/Screen.kt b/example/src/main/java/com/spruceid/mobilesdkexample/navigation/Screen.kt index 986dcbe..19eb22a 100644 --- a/example/src/main/java/com/spruceid/mobilesdkexample/navigation/Screen.kt +++ b/example/src/main/java/com/spruceid/mobilesdkexample/navigation/Screen.kt @@ -1,6 +1,6 @@ package com.spruceid.mobilesdkexample.navigation -const val HOME_SCREEN_PATH = "home" +const val HOME_SCREEN_PATH = "home/{tab}" const val VERIFY_DL_PATH = "verify_dl" const val VERIFY_EA_PATH = "verify_ea" const val VERIFY_VC_PATH = "verify_vc" diff --git a/example/src/main/java/com/spruceid/mobilesdkexample/navigation/SetupNavGraph.kt b/example/src/main/java/com/spruceid/mobilesdkexample/navigation/SetupNavGraph.kt index 69249d5..aabc737 100644 --- a/example/src/main/java/com/spruceid/mobilesdkexample/navigation/SetupNavGraph.kt +++ b/example/src/main/java/com/spruceid/mobilesdkexample/navigation/SetupNavGraph.kt @@ -2,8 +2,10 @@ package com.spruceid.mobilesdkexample.navigation import androidx.compose.runtime.Composable import androidx.navigation.NavHostController +import androidx.navigation.NavType import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable +import androidx.navigation.navArgument import androidx.navigation.navDeepLink import com.spruceid.mobilesdkexample.HomeView import com.spruceid.mobilesdkexample.credentials.AddToWalletView @@ -30,9 +32,16 @@ fun SetupNavGraph( NavHost(navController = navController, startDestination = Screen.HomeScreen.route) { composable( route = Screen.HomeScreen.route, - ) { + arguments = listOf( + navArgument("tab") { + type = NavType.StringType; defaultValue = "wallet" + } + ), + ) { backStackEntry -> + val tab = backStackEntry.arguments?.getString("tab")!! HomeView( navController, + initialTab = tab, verificationMethodsViewModel = verificationMethodsViewModel, credentialPacksViewModel = credentialPacksViewModel ) diff --git a/example/src/main/java/com/spruceid/mobilesdkexample/ui/theme/Color.kt b/example/src/main/java/com/spruceid/mobilesdkexample/ui/theme/Color.kt index 0f6ecbd..6456e76 100644 --- a/example/src/main/java/com/spruceid/mobilesdkexample/ui/theme/Color.kt +++ b/example/src/main/java/com/spruceid/mobilesdkexample/ui/theme/Color.kt @@ -21,7 +21,10 @@ val VerifierCloseButton = Color(0xFF44403C) val ColorBase300 = Color(0xFFE6E1D6) val ColorBase800 = Color(0xFF75675C) val ColorBase900 = Color(0xFF584C43) +val ColorBlue300 = Color(0xFF98C7F8) +val ColorBlue500 = Color(0xFF4389F2) val ColorBlue600 = Color(0xFF2F6AE1) +val ColorBlue900 = Color(0xFF243F84) val ColorStone50 = Color(0xFFFAFAF9) val ColorStone200 = Color(0xFFE7E5E4) val ColorStone300 = Color(0xFFD6D3D1) diff --git a/example/src/main/java/com/spruceid/mobilesdkexample/verifier/AddVerificationMethodView.kt b/example/src/main/java/com/spruceid/mobilesdkexample/verifier/AddVerificationMethodView.kt index 89c9db6..dd7ad09 100644 --- a/example/src/main/java/com/spruceid/mobilesdkexample/verifier/AddVerificationMethodView.kt +++ b/example/src/main/java/com/spruceid/mobilesdkexample/verifier/AddVerificationMethodView.kt @@ -30,7 +30,9 @@ fun AddVerificationMethodView( var qrcode by remember { mutableStateOf(null) } fun back() { - navController.navigate(Screen.HomeScreen.route) { + navController.navigate( + Screen.HomeScreen.route.replace("{tab}", "verifier") + ) { popUpTo(0) } } @@ -68,9 +70,9 @@ fun AddVerificationMethodView( } else if (qrcode == null) { ScanningComponent( subtitle = "Scan Verification QR Code", - navController = navController, scanningType = ScanningType.QRCODE, - onRead = ::onRead + onRead = ::onRead, + onCancel = ::back ) } else { LoadingView( diff --git a/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifierBinarySuccessView.kt b/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifierBinarySuccessView.kt index a3f311e..8636c9e 100644 --- a/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifierBinarySuccessView.kt +++ b/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifierBinarySuccessView.kt @@ -26,9 +26,6 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import androidx.navigation.NavController -import androidx.navigation.NavHostController -import androidx.navigation.compose.rememberNavController import com.spruceid.mobilesdkexample.R import com.spruceid.mobilesdkexample.ui.theme.Inter import com.spruceid.mobilesdkexample.ui.theme.MobileSdkTheme @@ -39,9 +36,9 @@ import com.spruceid.mobilesdkexample.ui.theme.VerifierCloseButton @Composable fun VerifierBinarySuccessView( - navController: NavController, success: Boolean, - description: String + description: String, + onClose: () -> Unit ) { Column( modifier = Modifier @@ -124,9 +121,7 @@ fun VerifierBinarySuccessView( Spacer(modifier = Modifier.weight(1f)) Button( - onClick = { - navController.popBackStack() - }, + onClick = onClose, shape = RoundedCornerShape(5.dp), colors = ButtonDefaults.buttonColors( containerColor = VerifierCloseButton, @@ -148,12 +143,10 @@ fun VerifierBinarySuccessView( @Preview(showBackground = true) @Composable fun VerifierBinarySuccessViewPreview() { - val navController: NavHostController = rememberNavController() MobileSdkTheme { VerifierBinarySuccessView( - navController = navController, success = true, description = "Valid" - ) + ) {} } } \ No newline at end of file diff --git a/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifierHomeView.kt b/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifierHomeView.kt index a637266..f2af070 100644 --- a/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifierHomeView.kt +++ b/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifierHomeView.kt @@ -84,8 +84,8 @@ fun VerifierHomeHeader( } ) { Image( - painter = painterResource(id = R.drawable.user), - contentDescription = stringResource(id = R.string.user), + painter = painterResource(id = R.drawable.cog), + contentDescription = stringResource(id = R.string.cog), modifier = Modifier .width(20.dp) .height(20.dp) diff --git a/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifierMDocResultView.kt b/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifierMDocResultView.kt index 4e31866..aa6f2f6 100644 --- a/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifierMDocResultView.kt +++ b/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifierMDocResultView.kt @@ -31,11 +31,8 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import androidx.navigation.NavController -import androidx.navigation.compose.rememberNavController import com.spruceid.mobile.sdk.rs.MDocItem import com.spruceid.mobilesdkexample.R -import com.spruceid.mobilesdkexample.navigation.Screen import com.spruceid.mobilesdkexample.ui.theme.BgSurfacePrimaryContrast import com.spruceid.mobilesdkexample.ui.theme.BgSurfacePureWhite import com.spruceid.mobilesdkexample.ui.theme.BorderSecondary @@ -77,8 +74,8 @@ fun mDocArrayToByteArray(repr: MDocItem.Array): ByteArray = @Composable fun VerifierMDocResultView( - navController: NavController, - result: Map> + result: Map>, + onClose: () -> Unit ) { val givenName = getDiscriminant(result["org.iso.18013.5.1"]?.get("given_name")!!) val familyName = getDiscriminant(result["org.iso.18013.5.1"]?.get("family_name")!!) @@ -262,7 +259,7 @@ fun VerifierMDocResultView( modifier = Modifier .fillMaxWidth(), shape = RoundedCornerShape(8.dp), - onClick = { navController.popBackStack() }, + onClick = onClose, colors = ButtonColors( containerColor = BgSurfacePrimaryContrast, contentColor = TextBase, disabledContainerColor = Color.Black, @@ -292,11 +289,7 @@ fun VerifierMDocResultView( .fillMaxWidth() .border(width = 1.dp, color = BorderSecondary), shape = RoundedCornerShape(8.dp), - onClick = { - navController.navigate(Screen.HomeScreen.route) { - popUpTo(0) - } - }, + onClick = onClose, colors = ButtonColors( containerColor = BgSurfacePureWhite, contentColor = TextPrimary, disabledContainerColor = BgSurfacePureWhite, @@ -344,5 +337,5 @@ fun MDocVerifyPreview() { "veteran" to MDocItem.Integer(1) ) ) - VerifierMDocResultView(rememberNavController(), example) + VerifierMDocResultView(example) {} } \ No newline at end of file diff --git a/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifyDLView.kt b/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifyDLView.kt index 5359408..0646abd 100644 --- a/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifyDLView.kt +++ b/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifyDLView.kt @@ -11,6 +11,7 @@ import com.google.accompanist.permissions.ExperimentalPermissionsApi import com.spruceid.mobile.sdk.rs.verifyPdf417Barcode import com.spruceid.mobilesdkexample.ScanningComponent import com.spruceid.mobilesdkexample.ScanningType +import com.spruceid.mobilesdkexample.navigation.Screen import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch @@ -35,18 +36,26 @@ fun VerifyDLView( } } + fun back() { + navController.navigate( + Screen.HomeScreen.route.replace("{tab}", "verifier") + ) { + popUpTo(0) + } + } + if (success == null) { ScanningComponent( subtitle = "Scan the\nback of your driver's license", - navController = navController, scanningType = ScanningType.PDF417, - onRead = ::onRead + onRead = ::onRead, + onCancel = ::back ) } else { VerifierBinarySuccessView( - navController = navController, success = success!!, - description = if (success!!) "Valid Driver's License" else "Invalid Driver's License" + description = if (success!!) "Valid Driver's License" else "Invalid Driver's License", + onClose = ::back ) } } \ No newline at end of file diff --git a/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifyDelegatedOid4vpView.kt b/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifyDelegatedOid4vpView.kt index 84e8e7e..d6cda9a 100644 --- a/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifyDelegatedOid4vpView.kt +++ b/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifyDelegatedOid4vpView.kt @@ -104,7 +104,11 @@ fun VerifyDelegatedOid4vpView( } fun back() { - navController.navigate(Screen.HomeScreen.route) { popUpTo(0) } + navController.navigate( + Screen.HomeScreen.route.replace("{tab}", "verifier") + ) { + popUpTo(0) + } } LaunchedEffect(Unit) { diff --git a/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifyEAView.kt b/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifyEAView.kt index 6ab9b72..da35ae7 100644 --- a/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifyEAView.kt +++ b/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifyEAView.kt @@ -13,6 +13,7 @@ import com.spruceid.mobile.sdk.rs.verifyVcbQrcodeAgainstMrz import com.spruceid.mobilesdkexample.LoadingView import com.spruceid.mobilesdkexample.ScanningComponent import com.spruceid.mobilesdkexample.ScanningType +import com.spruceid.mobilesdkexample.navigation.Screen import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch @@ -59,13 +60,21 @@ fun VerifyEAView( } } + fun back() { + navController.navigate( + Screen.HomeScreen.route.replace("{tab}", "verifier") + ) { + popUpTo(0) + } + } + when (step) { VerifyEASteps.STEP_ONE -> { ScanningComponent( subtitle = "Scan the front of your\nemployment authorization", - navController = navController, scanningType = ScanningType.QRCODE, - onRead = ::onReadStepOne + onRead = ::onReadStepOne, + onCancel = ::back ) } @@ -79,17 +88,17 @@ fun VerifyEAView( ScanningComponent( title = "Scan MRZ", subtitle = "Scan the back of your document", - navController = navController, scanningType = ScanningType.MRZ, - onRead = ::onReadStepTwo + onRead = ::onReadStepTwo, + onCancel = ::back ) } VerifyEASteps.SUCCESS -> { VerifierBinarySuccessView( - navController = navController, success = success!!, - description = if (success!!) "Valid Employment Authorization" else "Invalid Employment Authorization" + description = if (success!!) "Valid Employment Authorization" else "Invalid Employment Authorization", + onClose = ::back ) } } diff --git a/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifyMDocView.kt b/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifyMDocView.kt index 0fb1f2c..ead3dcf 100644 --- a/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifyMDocView.kt +++ b/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifyMDocView.kt @@ -7,34 +7,30 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ExperimentalLayoutApi import androidx.compose.foundation.layout.FlowColumn -import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.navigation.NavController -import androidx.navigation.compose.rememberNavController import com.google.accompanist.permissions.ExperimentalPermissionsApi import com.spruceid.mobile.sdk.BLESessionStateDelegate import com.spruceid.mobile.sdk.IsoMdlReader import com.spruceid.mobile.sdk.getBluetoothManager import com.spruceid.mobile.sdk.getPermissions import com.spruceid.mobile.sdk.rs.MDocItem -import com.spruceid.mobile.sdk.ui.QRCodeScanner import com.spruceid.mobilesdkexample.LoadingView import com.spruceid.mobilesdkexample.ScanningComponent import com.spruceid.mobilesdkexample.ScanningType +import com.spruceid.mobilesdkexample.navigation.Screen import com.spruceid.mobilesdkexample.utils.checkAndRequestBluetoothPermissions import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch @@ -154,8 +150,12 @@ fun VerifyMDocView(navController: NavController) { } } - fun onCancel() { - navController.popBackStack() + fun back() { + navController.navigate( + Screen.HomeScreen.route.replace("{tab}", "verifier") + ) { + popUpTo(0) + } } val elementsList = elementMapToList(defaultElements) @@ -163,12 +163,11 @@ fun VerifyMDocView(navController: NavController) { when (scanProcessState) { State.SCANNING -> Column { ScanningComponent( - navController, ScanningType.QRCODE, title = "", subtitle = "", onRead = ::onRead, - onCancel = ::onCancel + onCancel = ::back ) HorizontalDivider(thickness = 1.dp) Text("Requesting the following:") @@ -187,10 +186,10 @@ fun VerifyMDocView(navController: NavController) { } } - State.TRANSMITTING -> LoadingView("Verifying...", "Cancel", ::onCancel) + State.TRANSMITTING -> LoadingView("Verifying...", "Cancel", ::back) State.DONE -> VerifierMDocResultView( - navController = navController, result = result!!, + onClose = ::back ) } } \ No newline at end of file diff --git a/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifyVCView.kt b/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifyVCView.kt index acb2afd..90b1700 100644 --- a/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifyVCView.kt +++ b/example/src/main/java/com/spruceid/mobilesdkexample/verifier/VerifyVCView.kt @@ -11,6 +11,7 @@ import com.google.accompanist.permissions.ExperimentalPermissionsApi import com.spruceid.mobile.sdk.rs.verifyJwtVp import com.spruceid.mobilesdkexample.ScanningComponent import com.spruceid.mobilesdkexample.ScanningType +import com.spruceid.mobilesdkexample.navigation.Screen import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch @@ -35,17 +36,25 @@ fun VerifyVCView( } } + fun back() { + navController.navigate( + Screen.HomeScreen.route.replace("{tab}", "verifier") + ) { + popUpTo(0) + } + } + if (success == null) { ScanningComponent( - navController = navController, scanningType = ScanningType.QRCODE, - onRead = ::onRead + onRead = ::onRead, + onCancel = ::back ) } else { VerifierBinarySuccessView( - navController = navController, success = success!!, - description = if (success!!) "Valid Verifiable Credential" else "Invalid Verifiable Credential" + description = if (success!!) "Valid Verifiable Credential" else "Invalid Verifiable Credential", + onClose = ::back ) } } \ No newline at end of file diff --git a/example/src/main/java/com/spruceid/mobilesdkexample/verifiersettings/VerifierSettingsHomeView.kt b/example/src/main/java/com/spruceid/mobilesdkexample/verifiersettings/VerifierSettingsHomeView.kt index 8d3a442..0702f8c 100644 --- a/example/src/main/java/com/spruceid/mobilesdkexample/verifiersettings/VerifierSettingsHomeView.kt +++ b/example/src/main/java/com/spruceid/mobilesdkexample/verifiersettings/VerifierSettingsHomeView.kt @@ -1,6 +1,5 @@ package com.spruceid.mobilesdkexample.verifiersettings -import android.widget.Space import androidx.compose.foundation.Image import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement @@ -34,6 +33,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.navigation.NavController import com.spruceid.mobilesdkexample.R +import com.spruceid.mobilesdkexample.navigation.Screen import com.spruceid.mobilesdkexample.ui.theme.Inter import com.spruceid.mobilesdkexample.ui.theme.TextBody import com.spruceid.mobilesdkexample.ui.theme.TextHeader @@ -66,7 +66,11 @@ fun VerifierSettingsHomeView( if (subpage != null) { subpage = null } else { - navController.popBackStack() + navController.navigate( + Screen.HomeScreen.route.replace("{tab}", "verifier") + ) { + popUpTo(0) + } } } ) diff --git a/example/src/main/java/com/spruceid/mobilesdkexample/wallet/DispatchQRView.kt b/example/src/main/java/com/spruceid/mobilesdkexample/wallet/DispatchQRView.kt index 9c9bb6c..94205b1 100644 --- a/example/src/main/java/com/spruceid/mobilesdkexample/wallet/DispatchQRView.kt +++ b/example/src/main/java/com/spruceid/mobilesdkexample/wallet/DispatchQRView.kt @@ -39,7 +39,9 @@ fun DispatchQRView( var loading by remember { mutableStateOf(false) } fun back() { - navController.navigate(Screen.HomeScreen.route) { + navController.navigate( + Screen.HomeScreen.route.replace("{tab}", "wallet") + ) { popUpTo(0) } } @@ -84,7 +86,6 @@ fun DispatchQRView( LoadingView(loadingText = "Loading...") } else { ScanningComponent( - navController = navController, scanningType = ScanningType.QRCODE, onRead = ::onRead, onCancel = ::back diff --git a/example/src/main/java/com/spruceid/mobilesdkexample/wallet/WalletHomeView.kt b/example/src/main/java/com/spruceid/mobilesdkexample/wallet/WalletHomeView.kt index 6c9084f..f593672 100644 --- a/example/src/main/java/com/spruceid/mobilesdkexample/wallet/WalletHomeView.kt +++ b/example/src/main/java/com/spruceid/mobilesdkexample/wallet/WalletHomeView.kt @@ -139,12 +139,6 @@ fun WalletHomeBody(credentialPacksViewModel: CredentialPacksViewModel) { } } else { Box(Modifier.fillMaxSize()) { - Column(horizontalAlignment = Alignment.CenterHorizontally) { - Image( - painter = painterResource(id = R.drawable.add_first_credential), - contentDescription = stringResource(id = R.string.add_first_credential), - ) - } Column( Modifier.fillMaxSize(), verticalArrangement = Arrangement.Center, diff --git a/example/src/main/java/com/spruceid/mobilesdkexample/walletsettings/WalletSettingsHomeView.kt b/example/src/main/java/com/spruceid/mobilesdkexample/walletsettings/WalletSettingsHomeView.kt index 5f10f98..caf84f0 100644 --- a/example/src/main/java/com/spruceid/mobilesdkexample/walletsettings/WalletSettingsHomeView.kt +++ b/example/src/main/java/com/spruceid/mobilesdkexample/walletsettings/WalletSettingsHomeView.kt @@ -24,6 +24,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.navigation.NavController import com.spruceid.mobilesdkexample.R +import com.spruceid.mobilesdkexample.navigation.Screen import com.spruceid.mobilesdkexample.ui.theme.Inter import com.spruceid.mobilesdkexample.ui.theme.TextHeader import com.spruceid.mobilesdkexample.ui.theme.VerifiedRedInvalid @@ -34,16 +35,20 @@ fun WalletSettingsHomeView( navController: NavController, credentialPacksViewModel: CredentialPacksViewModel ) { + fun back() { + navController.navigate( + Screen.HomeScreen.route.replace("{tab}", "wallet") + ) { + popUpTo(0) + } + } + Column( Modifier .padding(all = 20.dp) .padding(top = 20.dp) ) { - WalletSettingsHomeHeader( - onBack = { - navController.popBackStack() - } - ) + WalletSettingsHomeHeader(onBack = ::back) WalletSettingsHomeBody(credentialPacksViewModel) } } diff --git a/example/src/main/res/drawable-hdpi/scan_qr_code.png b/example/src/main/res/drawable-hdpi/scan_qr_code.png deleted file mode 100644 index 87c8546..0000000 Binary files a/example/src/main/res/drawable-hdpi/scan_qr_code.png and /dev/null differ diff --git a/example/src/main/res/drawable-hdpi/scan_qr_code_white.png b/example/src/main/res/drawable-hdpi/scan_qr_code_white.png deleted file mode 100644 index 7aaf653..0000000 Binary files a/example/src/main/res/drawable-hdpi/scan_qr_code_white.png and /dev/null differ diff --git a/example/src/main/res/drawable-mdpi/scan_qr_code.png b/example/src/main/res/drawable-mdpi/scan_qr_code.png deleted file mode 100644 index fd52f04..0000000 Binary files a/example/src/main/res/drawable-mdpi/scan_qr_code.png and /dev/null differ diff --git a/example/src/main/res/drawable-xhdpi/scan_qr_code.png b/example/src/main/res/drawable-xhdpi/scan_qr_code.png deleted file mode 100644 index c7df906..0000000 Binary files a/example/src/main/res/drawable-xhdpi/scan_qr_code.png and /dev/null differ diff --git a/example/src/main/res/drawable-xxhdpi/scan_qr_code.png b/example/src/main/res/drawable-xxhdpi/scan_qr_code.png deleted file mode 100644 index 6828db4..0000000 Binary files a/example/src/main/res/drawable-xxhdpi/scan_qr_code.png and /dev/null differ diff --git a/example/src/main/res/drawable-xxxhdpi/scan_qr_code.png b/example/src/main/res/drawable-xxxhdpi/scan_qr_code.png deleted file mode 100644 index 4d1d27b..0000000 Binary files a/example/src/main/res/drawable-xxxhdpi/scan_qr_code.png and /dev/null differ diff --git a/example/src/main/res/drawable/add_first_credential.xml b/example/src/main/res/drawable/add_first_credential.xml deleted file mode 100644 index 75bc3b1..0000000 --- a/example/src/main/res/drawable/add_first_credential.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - diff --git a/example/src/main/res/drawable/cog.xml b/example/src/main/res/drawable/cog.xml new file mode 100644 index 0000000..23de2c0 --- /dev/null +++ b/example/src/main/res/drawable/cog.xml @@ -0,0 +1,9 @@ + + + diff --git a/example/src/main/res/drawable/wallet.xml b/example/src/main/res/drawable/wallet.xml new file mode 100644 index 0000000..80850e4 --- /dev/null +++ b/example/src/main/res/drawable/wallet.xml @@ -0,0 +1,14 @@ + + + + + + diff --git a/example/src/main/res/values/colors.xml b/example/src/main/res/values/colors.xml index 04f3b48..0e593cc 100644 --- a/example/src/main/res/values/colors.xml +++ b/example/src/main/res/values/colors.xml @@ -24,7 +24,10 @@ #FFE6E1D6 #FF75675C + #FF98C7F8 + #FF4389F2 #FF2F6AE1 + #FF243F84 #FFFAFAF9 #FFD6D3D1 #FFA8A29E diff --git a/example/src/main/res/values/strings.xml b/example/src/main/res/values/strings.xml index f76199e..a73d65b 100644 --- a/example/src/main/res/values/strings.xml +++ b/example/src/main/res/values/strings.xml @@ -18,8 +18,8 @@ Click to expand Click to collapse Error - Click on the button to add your first credential Read this QR Code to start the verification Start flow Restart + Settings \ No newline at end of file