AmbientAwareTime
An example of using AmbientAware: Provides the time, at the specified update frequency, whilst in interactive mode, or when ambient-generated updates occur (typically every 1 min).
Example usage:
AmbientAware { stateUpdate -> Box( contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize() ) { AmbientAwareTime(stateUpdate) { dateTime, isAmbient -> // Basic example of AmbientAwareTime usage val ambientFmt = remember { DateTimeFormatter.ofPattern("HH:mm") } val interactiveFmt = remember { DateTimeFormatter.ofPattern("HH:mm:ss") } val dateTimeStr = if (isAmbient) { ambientFmt.format(ZonedDateTime.now()) } else { interactiveFmt.format(ZonedDateTime.now()) } Text(dateTimeStr) } } }
Parameters
The state update from AmbientAware
The update period, whilst in interactive mode
The developer-supplied composable for rendering the date and time.