With Compose for Wear OS 1.0, Google has released the first stable variant of the UI toolkit for the smartwatch operating system. This makes Compose the recommended way to create user interfaces for Wear OS apps. At the same time, version 1.2 of Jetpack Compose for smartphones, tablets and foldables was released.
Google released Jetpack Compose in the stable version 1.0 at the end of July 2021. The UI toolkit for Android follows a declarative approach and relies on the Kotlin programming language and a reactive programming model. So-called Composable Functions define the individual control elements – or parts of them. With
@Composable Decorated functions can be nested in each other to ultimately create the interface. The code describes the basic look of the interface, and under the hood the toolkit takes care of the implementation in the UI tree structure and updating the content.
On the smart watch
According to the developer blog, there are already more components for the Wear OS variant at the start of version 1.0 than for view-based layouts. As with the regular Jetpack Compose, the elements rely on the guidelines of Material Design developed by Google. Besides that implement material themingto unify and customize the design of the interface.
androidx.wear.compose.foundation there are elements that are tailored to different shapes such as round or square smartwatches. The APIs bring with them
CurvedLayout a layout that arranges the elements in an arc and rotates them as needed. There are curved elements like
basicCurvedText. the Interoperability APIs are designed to work together seamlessly with view-based user interfaces. The composable elements can be integrated directly into existing surfaces.
Google has with Horologist some libraries with components for the smartwatch like a media player and a date picker as well as functions for audio control and effects like hiding the layout.
More details on WearOS 1.0 can be found on the Android Developer Blog. An article on the portal for developing with Android should help Optimize the performance of Compose UI applications on the smartwatch.
For smartphones and tablets
Jetpack Compose for smartphones, foldables and tablets has appeared in version 1.2 almost exactly a year after the 1.0 release. The innovations include the stabilized grid layout, which can be used both in a horizontal (
LazyHorizontalGrid) as well as in a vertical variant (
LazyVerticalGrid) exists. The lazy in the name means that the layout only creates the required, visible columns or rows.
Version 1.2 has additional functions for mouse control, including defining a hover icon that is displayed when the mouse moves over the element. The new feature
Modifier.nestedScroll defines how elements are included in a nested scroll hierarchy.
The integration of downloadable character sets is still marked as experimental from Google Fonts. There are also extensions for scrollable layouts with
LazyLayout. The APIs for testing also get new experimental functions such as
performKeyInput for a key input.
More new features and bug fixes can be found on the Android Developer Blog. Jetpack Compose 1.2 requires the latest Kotlin 1.7. In the Jetpack documentation there is a compatibility table for the appropriate Kotlin releases for Compose. Compose for Wear OS 1.0 requires the androidx.compose libraries in version 1.2 and thus also Kotlin 1.7.