Skip to content

Fit it into your screens

The wallet is one piece between your bars: your title bar above, your tab bar below, the SDK’s cards in between. It draws no heading, takes your page colour, and leaves the pill and Back to you. This is CityNow’s Documents screen; the sample is the same screen with generic names.

My Documents: the wallet's cards under CityNow's title bar and above its tab bar
The wallet between CityNow’s bars. The pill sits just above the tab bar.
A card opened inside CityNow's My Documents screen
A card opened. The pill is hidden; the bars stay.
HostAppTile.kt
package samples
import android.os.Bundle
import androidx.activity.compose.BackHandler
import androidx.activity.compose.setContent
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawingPadding
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Card
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import androidx.fragment.app.FragmentActivity
import com.wallet.ScannedCode
import com.wallet.WalletSdk
import com.wallet.ui.CredentialOfferSheet
import com.wallet.ui.WalletActionPill
import com.wallet.ui.WalletBranding
import com.wallet.ui.WalletLinkPresentment
import com.wallet.ui.WalletPresentScreen
import com.wallet.ui.WalletPromptDialogs
import com.wallet.ui.WalletScanScreen
import com.wallet.ui.WalletScreen
/** Your app stays the app: your home screen, your tiles. One tile, "Documents", opens the wallet. */
class HostActivity : FragmentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
var documents by rememberSaveable { mutableStateOf(false) }
WalletBranding.theme { // the SDK's theme in your colours and typeface (see Branding.kt)
if (documents) DocumentsScreen(App.sdk, onBack = { documents = false })
else HomeScreen(onDocuments = { documents = true })
}
}
}
}
@Composable
private fun HomeScreen(onDocuments: () -> Unit) {
Column(Modifier.fillMaxSize().safeDrawingPadding().padding(24.dp)) {
Text("My Hub", style = MaterialTheme.typography.titleLarge)
// One of your tiles.
Card(onClick = onDocuments, modifier = Modifier.padding(top = 16.dp).fillMaxWidth()) {
Text("Documents", Modifier.padding(20.dp))
}
}
}
/** "← My Documents" over the SDK's wallet (cards, details), with your tab bar below it. */
@Composable
fun DocumentsScreen(sdk: WalletSdk, onBack: () -> Unit) {
var scanning by remember { mutableStateOf(false) }
var presenting by remember { mutableStateOf(false) }
var cardOpen by remember { mutableStateOf(false) }
var offerUri by remember { mutableStateOf<String?>(null) }
var scanProblem by remember { mutableStateOf<String?>(null) }
val context = LocalContext.current
// Back closes the scanner or the Present screen first, then returns to your home.
BackHandler { if (scanning || presenting) { scanning = false; presenting = false } else onBack() }
when {
// The SDK's full-screen flows: they bring their own close button.
scanning -> WalletScanScreen(
onScanned = { code ->
scanning = false
when (val scanned = ScannedCode.classify(code)) {
is ScannedCode.CredentialOffer -> offerUri = scanned.uri // an issuer's offer: the sheet below
is ScannedCode.PresentationRequest -> WalletLinkPresentment.start(context, sdk, scanned.uri) // a website's request: the SDK's screen
is ScannedCode.Unrecognized -> scanProblem = "This QR code isn't a request for your documents or a new document to add."
}
},
onClose = { scanning = false },
)
presenting -> WalletPresentScreen(sdk, onClose = { presenting = false })
else -> Box(Modifier.fillMaxSize().background(MaterialTheme.colorScheme.background).safeDrawingPadding()) {
Column(Modifier.fillMaxSize()) {
// Your title bar.
Row(Modifier.fillMaxWidth().height(56.dp), verticalAlignment = Alignment.CenterVertically) {
IconButton(onClick = onBack) { Text("‹", style = MaterialTheme.typography.headlineMedium) }
Text("My Documents", style = MaterialTheme.typography.titleLarge)
}
// The wallet, without its own heading: your bar above is the title.
WalletScreen(sdk, Modifier.weight(1f), onCardOpen = { cardOpen = it }, title = null)
// Your tab bar.
NavigationBar {
NavigationBarItem(selected = true, onClick = onBack, icon = { Text("⌂") }, label = { Text("Home") })
NavigationBarItem(selected = false, onClick = {}, icon = { Text("☰") }, label = { Text("Services") })
}
}
// The SDK's Scan | Present pill, just above your tab bar. No shadow, so the two don't stack.
if (!cardOpen) {
WalletActionPill(
onScan = { scanning = true }, onPresent = { presenting = true }, shadow = false,
modifier = Modifier.align(Alignment.BottomCenter).padding(bottom = 96.dp),
)
}
}
}
offerUri?.let { CredentialOfferSheet(sdk, it, onDone = { offerUri = null }) }
// Anything else that was scanned: say so, instead of silently doing nothing.
scanProblem?.let { message ->
AlertDialog(
onDismissRequest = { scanProblem = null },
confirmButton = { TextButton(onClick = { scanProblem = null }) { Text("OK") } },
title = { Text("Not a document request") },
text = { Text(message) },
)
}
WalletPromptDialogs() // the consent sheet and the permission prompts, over everything
}

The wallet screen draws a large heading above the cards, Wallet by default. Give it your own, or none when your bar above it is the title:

Android iOS
Your heading WalletScreen(sdk, title = "Documents") WalletViewController(sdk: sdk, title: "Documents", pillShadow: true)
No heading WalletScreen(sdk, title = null) WalletViewController(sdk: sdk, title: nil, pillShadow: false)

Set WalletBranding.backgroundColor (Swift: setBackgroundColor(argb:)) to the colour of your own screens, and the wallet, your bars and the space between them are one surface. On iOS, give the SwiftUI container the same colour, as the sample does. The rest of the branding is in Make it look like your app.

The Scan | Present pill is the SDK’s, but you place it. On Android you draw it, WalletActionPill(onScan, onPresent), over the wallet and just above your tab bar; on iOS the controller draws it at the bottom of its view. Pass shadow = false (iOS: pillShadow: false) so its shadow and your tab bar’s don’t stack. onCardOpen tells you when a card is open, so you can hide the pill, as the sample does.

The wallet shows its cards as soon as your screen opens, from a copy it keeps of the last card list, while the wallet loads behind them. The pill appears together with the cards, never before them, and hides while a consent sheet is up: draw it on the same screen as WalletScreen.

Back means your home screen. The scanner and the Present screen are full-screen flows with their own close button; on Android the sample’s BackHandler closes them first, then returns to your home. Your bar’s arrow and your Home tab do the same. The SDK’s consent sheet and permission prompts draw over everything through WalletPromptDialogs(); on iOS the controller hosts them itself. The consent sheet closes only with its Cancel, its ✕ or Back, never with a swipe (The consent sheet).

The pill’s Scan button opens the SDK’s scanner. A code it reads is one of three things; on Android you decide what happens with each, with ScannedCode.classify:

The code is What to do
a website’s request (a QR on a laptop screen) WalletLinkPresentment.start(context, sdk, uri): the SDK’s screen fetches the request, shows the consent sheet, runs the face check and answers
an issuer’s credential offer CredentialOfferSheet(sdk, uri): the holder previews and accepts the new card
anything else say so. CityNow shows “Not a document request” with one line, as the sample does

On iOS the controller scans itself and does the first two; a code that is neither is ignored.

A website’s request reaches a phone in two ways. Your app only needs the scan; the tap opens the wallet registered with the hosted service for its link domain (Wallet links).

Another screen: a scan Same phone: a tap
What the holder does opens your tile, taps Scan, scans the QR on the laptop taps the QR in the browser on this phone
Who opens the wallet your app’s scanner the service, through the link registered for the domain
After sharing the site’s tab turns green; nothing to return to the holder is sent back to the site

CityNow scans only. A tap in a browser keeps opening the wallet registered for the domain, never CityNow. If your app should answer browser links itself, add the intent filters and the Associated Domain (Present) and register it with us: one wallet per link domain.

Next: Make it look like your app.