Custom Extension Capability Overview

The ArkUI framework offers a range of custom extension capabilities that enable the enhancement and customization of UI components in a way that is decoupled from the UI. With these capabilities, known as modifiers, you can quickly adjust the appearance and behavior of UI components without changing the underlying implementation of UI components. The available modifiers include AttributeModifier, GestureModifier, and DrawModifier. AttributeModifier and AttributeUpdater, in particular, enable you to set attributes through custom classes, thereby expanding the ways in which attribute settings can be implemented and allowing them to be mixed with native attribute setting methods. For example, you can use the custom extension capabilities to process intricate logic or complex interactions, and rely on native setting methods for simpler, static attributes.

AttributeModifier

AttributeModifier allows dynamic attribute modification through Modifier objects, overcoming the limited use cases of the @Styles and @Extend decorators in declarative syntax. When compared to @Styles and @Extend, AttributeModifier provides superior capabilities and flexibility. As it continues to evolve to encompass a full spectrum of attribute and event settings, AttributeModifier is the preferred choice for implementation.

AttributeUpdater

As a special type of AttributeModifier, AttributeUpdater not only inherits all the functionality of AttributeModifier but also extends its capabilities by allowing access to the attribute object. By using the attribute object, you can update specific attributes without relying on state variables. With AttributeUpdater, you can implement custom update strategies, further improving the performance of attribute updates.