fun AlwaysOnScreen()

in AlwaysOnKotlin/compose/src/main/java/com/example/android/wearable/wear/alwayson/AlwaysOnScreen.kt [59:134]


fun AlwaysOnScreen(
    ambientState: AmbientState,
    ambientUpdateTimestamp: Instant,
    drawCount: Int,
    currentInstant: Instant,
    currentTime: LocalTime
) {
    val dateFormat = remember { DateTimeFormatter.ofPattern("HH:mm:ss", Locale.US) }

    val stateColor = when (ambientState) {
        AmbientState.Interactive -> Color.Green
        is AmbientState.Ambient -> Color.White
    }

    // TODO: Compose doesn't support disabling antialiasing on Text
    //       https://issuetracker.google.com/issues/206701013
    // val isAntiAlias = when (ambientState) {
    //     AmbientState.Interactive -> true
    //     is AmbientState.Ambient -> false
    // }

    Column(
        verticalArrangement = Arrangement.Center,
        horizontalAlignment = Alignment.CenterHorizontally,
        modifier = Modifier
            .verticalScroll(rememberScrollState())
            .fillMaxRectangle()
            .padding(with(LocalDensity.current) { BURN_IN_OFFSET_PX.toDp() })
            .burnInTranslation(ambientState, ambientUpdateTimestamp)
    ) {
        Text(
            modifier = Modifier.testTag("time"),
            text = dateFormat.format(currentTime),
            style = MaterialTheme.typography.title1,
            textAlign = TextAlign.Center
        )
        Text(
            modifier = Modifier.testTag("timestamp"),
            text = stringResource(id = R.string.timestamp_label, currentInstant.toEpochMilli()),
            style = MaterialTheme.typography.body2,
            textAlign = TextAlign.Center
        )
        Text(
            modifier = Modifier.testTag("mode"),
            text = stringResource(
                id = when (ambientState) {
                    AmbientState.Interactive -> R.string.mode_active_label
                    is AmbientState.Ambient -> R.string.mode_ambient_label
                }
            ),
            style = MaterialTheme.typography.body2,
            color = stateColor,
            textAlign = TextAlign.Center
        )
        Text(
            modifier = Modifier.testTag("rate"),
            text = stringResource(
                id = R.string.update_rate_label,
                when (ambientState) {
                    AmbientState.Interactive -> ACTIVE_INTERVAL.seconds
                    is AmbientState.Ambient -> AMBIENT_INTERVAL.seconds
                }
            ),
            style = MaterialTheme.typography.body2,
            color = stateColor,
            textAlign = TextAlign.Center
        )
        Text(
            modifier = Modifier.testTag("drawCount"),
            text = stringResource(id = R.string.draw_count_label, drawCount),
            style = MaterialTheme.typography.body2,
            color = stateColor,
            textAlign = TextAlign.Center
        )
    }
}