Compose Screens
The vitallens-ui module provides pre-built Jetpack Compose screens to get you up and running quickly. These screens handle camera permissions, state management, user guidance, and data visualization.
Setup
Import the screens from the UI module:
import com.rouast.vitallens.ui.ScanScreen
import com.rouast.vitallens.ui.MonitorScreen
import com.rouast.vitallens.ui.FileScreen
1. ScanScreen
A guided flow that handles a full measurement cycle. It instructs the user to position their face, checks lighting conditions, performs a ~30-second scan, and displays the final results.
ScanScreen(
apiKey = "YOUR_KEY",
method = "vitallens",
mode = VitalLensMode.STANDARD,
onComplete = { result ->
result.heartRate?.value?.let { hr ->
println("Final Heart Rate: $hr bpm")
}
},
)
Parameters
| Parameter | Type | Description |
|---|---|---|
onComplete |
(VitalLensResult) -> Unit |
Callback triggered when the scan finishes successfully. |
apiKey |
String? |
Your API Key. Required if proxyUrl is not set. |
proxyUrl |
HttpUrl? |
URL to your backend proxy. |
method |
String |
Model version (e.g., "vitallens", "vitallens-2.0"). Default is "vitallens". |
mode |
VitalLensMode |
STANDARD (30 FPS, default) or ECO (15 FPS). Falls back to ECO once if the connection is too slow for STANDARD. |
baseUrl |
HttpUrl? |
Overrides the API host (e.g. for a staging/dev environment). Rarely needed — see Advanced Use. |
2. MonitorScreen
A dashboard that visualizes live signals continuously. It renders real-time PPG and respiratory charts, displaying numeric values as they update.
Parameters
| Parameter | Type | Description |
|---|---|---|
apiKey |
String? |
Your API Key. Required if proxyUrl is not set. |
proxyUrl |
HttpUrl? |
URL to your backend proxy. |
method |
String |
Model version. Default is "vitallens". |
showWaveforms |
Boolean |
Whether to render the real-time waveform charts. Default is true. |
initialMode |
VitalLensMode |
Initial FPS mode STANDARD or ECO. Default is STANDARD. Falls back to ECO once if the connection is too slow for STANDARD. |
bufferOffsetSeconds |
Double |
Delay in seconds for smooth chart rendering. Default is 0.15. |
windowSizeSeconds |
Double |
Duration of data to show in the waveform charts. Default is 8.0. |
minDisplayDurationSeconds |
Double |
Minimum data required before displaying values. Default is 6.0. |
baseUrl |
HttpUrl? |
Overrides the API host. Rarely needed — see Advanced Use. |
3. FileScreen
A complete UI for selecting and analyzing pre-recorded videos through the system file picker (gallery or files). It handles file selection, processing, and result visualization. No camera permission is needed.
Parameters
| Parameter | Type | Description |
|---|---|---|
apiKey |
String? |
Your API Key. Required if proxyUrl is not set. |
proxyUrl |
HttpUrl? |
URL to your backend proxy. |
method |
String |
Model version. Default is "vitallens". |
baseUrl |
HttpUrl? |
Overrides the API host. Rarely needed — see Advanced Use. |