Skip to main content
Version: v3+

API_LEVEL 4.0 New Features

API_LEVEL 4.0 brings several important updates and new features, providing developers with more powerful tools and a more flexible development experience. This article will introduce the main new features and improvements.

Widget Layout Properties for Flex Layout​

For more details, refer to Widget Layout Properties for Flex Layout.

API_LEVEL 4.0 introduces support for Flex layout, allowing developers to build smartwatch application interfaces in a way similar to Web development, greatly improving layout flexibility and development efficiency.

Widget Property Read/Write​

For more details, refer to Widget Getter/Setter Feature.

Starting from API_LEVEL 4.0, widget properties can be directly accessed and set through the getter/setter feature, making property reading and writing more concise and intuitive.

The widget documentation will indicate property access support status.

import { createWidget, widget, prop } from '@zos/ui'

Page({
build() {
// Create TEXT widget
const textWidget = createWidget(widget.TEXT, {
// ...
})

// Using getter to read properties
console.log('Text content:', textWidget.text)
console.log('Text color:', textWidget.color)
console.log('Text position:', textWidget.x, textWidget.y)

// Using setter to set properties
textWidget.text = 'Updated Text'
textWidget.color = 0xff0000
textWidget.x = 120
}
})

Comparison with getProperty and setProperty methods

// Reading properties
const oldText = textWidget.getProperty(prop.TEXT)
console.log('Old way - Text content:', oldText)

// Setting properties
textWidget.setProperty(prop.TEXT, 'Set by old method')
textWidget.setProperty(prop.MORE, {
color: 0x00ff00,
x: 150
})

New UI Widgets/Methods​

Sensor Module​

  • Compass supports setting sensor reporting frequency
  • Geolocation can retrieve the user's privacy location permission protection status

@zos/app Module​

Get mini app performance statistics, including memory usage and loading performance metrics.

@zos/util Module​

Added new utility methods that support conversion between ArrayBuffer and String types, making data processing easier