Tuesday, August 2, 2022
HomeMobiletime to construct wearable apps with Compose!

time to construct wearable apps with Compose!



Posted by Kseniia Shumelchyk, Android Developer Relations Engineer

At present we’re launching model 1.0 of Compose for Put on OS, the primary steady launch of our trendy declarative UI toolkit designed to assist builders create stunning, responsive apps for Google’s smartwatch platform.

Compose for Put on OS was constructed from the underside up in Kotlin with assumptions of contemporary app structure. It makes constructing apps for Put on OS simpler, quicker, and extra intuitive by following the declarative method and providing highly effective Kotlin syntax.

The toolkit not solely simplifies UI growth, but in addition supplies a wealthy set of UI elements optimized for the watch expertise with built-in assist of Materials design for Put on OS, and it’s accompanied by many highly effective instruments in Android Studio to streamline UI iteration.

What this implies

The Compose for Put on OS 1.0 launch implies that the API is steady and has what you’ll want to construct production-ready apps. Shifting ahead, Compose for Put on OS is our really helpful method for constructing consumer interfaces for Put on OS apps.

Your suggestions has helped form the event of Compose for Put on OS; our developer group has been with us every step of the best way, participating with us on Slack and offering suggestions on the APIs, elements, and tooling. As we’re engaged on bringing new options to future variations of Compose for Put on OS, we’ll proceed to welcome developer suggestions and strategies.

We’re additionally excited to share how builders have already adopted Compose of their Put on OS apps and what they like about it.

What builders are saying

Todoist helps individuals set up, plan and collaborate on initiatives. They’re one of many first firms to fully rebuild their Put on OS app utilizing Compose and redesign all screens and interactions:

“When the brand new Put on design language and Compose for Put on OS have been introduced, we have been thrilled. It gave us new motivation and alternative to speculate into the platform.

Todoist utility

Counting on Compose for Put on OS has improved each developer and consumer expertise for Todoist:

“Compose for Put on OS helped us tremendously each on the event aspect and the design aspect. The guides and documentation made it simple for our product designers to arrange mockups matching the brand new design language of the platform. And the libraries made it very simple for us to implement these, offering all the required widgets and customizations. Swipe to dismiss, TimeText, ScalingLazyList have been all elements that labored very effectively out-of-the-box for us, whereas nonetheless permitting us to make a recognizable and distinct app.”

Outdooractive helps individuals plan routes for mountaineering, biking, operating, and different out of doors adventures. As wearables are a key facet of their product technique, they’ve been fast to replace their providing with an app for the consumer’s wrist.

Outdooractive utility

Outdooractive has already embraced Put on OS 3, and by migrating to Compose for Put on OS they aimed for developer-side advantages akin to having a contemporary code base and elevated growth productiveness:

Large enchancment is how lists are created. Because of ScalingLazyColumn it’s simpler (in comparison with RecyclerView) to create scrolling screens with out losing sources. Availability of normal elements like Chip helps saving time by with the ability to use pre-fabricated design-/view-components. What would have taken us days now takes us hours.

The Outdooractive group additionally highlighted that Compose for Put on OS utilization assist them to try for higher app high quality:

Improved animations have been a pleasant shock, permitting easily hiding/revealing elements by simply wrapping elements in “AnimatedVisibility” for instance, which we utilized in locations the place we’d usually not have invested any time in implementing animations.


One other developer we’ve been working with, Interval Tracker helps maintain monitor of interval cycles, ovulation, and the possibility of conception.

     
Interval Tracker utility

They’ve taken benefit of our UI toolkit to considerably enhance consumer interface and shortly develop new options out there completely on Put on OS:

“Compose for Put on OS supplied us with many kits to assist us deliver our designs to life. For instance, we used Chips to design the principle buttons for interval recording, water ingesting, and taking medicine, and it additionally helped us create a novel search for the most recent model of Kegel exercise.

Equally to different builders, Interval Tracker famous that Compose for Put on OS helped them to realize higher developer expertise and improved collaboration with design and growth groups:

“For instance, earlier than Chips elements have been out there, we had to make use of a customized option to load pictures on buttons which brought on plenty of adaptation work. Sure, Compose for Put on OS improved our productiveness and made our designers extra prepared to design a greater consumer expertise on wearables.

Try the in-depth case research to be taught extra about how different builders are utilizing Jetpack Compose.

1.0 launch

Let’s look into the important thing options out there with 1.0 launch:

  • Materials: The Compose Materials catalog for Put on OS already affords extra elements than can be found with View-based layouts. The elements observe materials styling and likewise implement materials theming, which lets you customise the design on your model.
  • Declarative: Compose for Put on OS leverages Trendy Android Improvement and works seamlessly with different Jetpack libraries. Compose-based UIs typically end in much less code and speed up the event course of as a complete, learn extra.
  • Interoperable: When you’ve got an current Put on OS app with a big View-based codebase, it is potential to steadily undertake Compose for Put on OS by utilizing the Compose Interoperability APIs fairly than having to rewrite the entire codebase.
  • Handles completely different watch shapes: Compose for Put on OS extends the muse of Compose, including a DSL for all curved components to make it simple to develop for all Put on OS system shapes: spherical, sq., or rectangular with minimal code.
  • Efficiency: Every Compose for Put on OS library ships with its personal baseline profiles which are robotically merged and distributed together with your app’s APK and are compiled forward of time on system. Typically, this achieves app efficiency for manufacturing builds that’s on-par with View-based apps. Nonetheless, it’s vital to know the way to configure, develop, and take a look at your app’s efficiency for the most effective outcomes. Study extra.

Word that utilizing model 1.0 of Compose for Put on OS requires utilizing the model 1.2 of androidx.compose libraries and due to this fact Kotlin 1.7.0. Learn extra about Jetpack Compose 1.2 launch right here.

Instruments and libraries

Android Studio

The declarative paradigm shift additionally alters the event workflow. The Compose tooling out there in Android Studio will enable you to construct apps extra productively.

Android Studio Dolphin features a new mission template with Compose for Put on OS that can assist you get began.

The Composable Preview annotation means that you can immediately confirm how your app’s format behaves on completely different watch sizes and shapes. You’ll be able to configure the system preview to indicate completely different Put on OS system sorts (spherical, rectangle, and so forth):

import androidx.compose.ui.tooling.preview


@Preview(

    system = Units.WEAR_OS_LARGE_ROUND,

    showSystemUi = true,

    backgroundColor = 0xff000000,

    showBackground = true

)

@Composable

enjoyable PreviewCustomComposable() {

    CustomComposable(…)

}

Beginning with Android Studio Electrical Eel, Stay Edit helps iterative code growth for Put on OS, offering fast suggestions as you make modifications within the editor and instantly reflecting UI within the Preview or operating app on the system.

Horologist

Horologist is a gaggle of open-source libraries from Google that complement Put on OS growth, which we introduced with the beta launch of Compose for Put on OS. Horologist has graduated quite a lot of experimental APIs to steady together with TimeText fadeAway modifiers, WearNavScaffold, the Date and Time pickers.

      

Date and Time pickers from Horologist library     

Studying Compose

If you’re unfamiliar with utilizing Jetpack Compose, we suggest beginning with the tutorial. Lots of the growth rules there additionally apply to Compose for Put on OS.

To be taught extra about Compose for Put on OS try:

Now that Compose for Put on OS has reached its first steady launch, it’s time to create stunning apps constructed for the wrist with Compose!

Be part of the group

Be part of the dialogue within the Kotlin Slack #compose-wear channel to attach with the group and different builders and share what you’re constructing.

Present suggestions

Please maintain offering us suggestions on the challenge tracker and tell us your expertise!

For extra details about constructing apps for Put on OS, try the developer website.



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular