UI modifier configuration method and device, electronic equipment and medium

By creating template classes and generating hybrid modifier chains within a declarative UI framework, issues of code redundancy, style consistency, and integration are resolved, resulting in an efficient and maintainable UI development solution.

CN121597210APending Publication Date: 2026-03-03BEIJING CHENGSHI WANGLIN INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511580237.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-31
Publication Date
2026-03-03

AI Technical Summary

Technical Problem

Existing declarative UI frameworks suffer from issues such as code duplication and redundancy, difficulty in maintaining style consistency, poor reusability, lack of dynamic responsiveness, insufficient type safety, and poor integration.

Method used

By using the template configuration interface based on the basic properties of the UI modifiers, a template class is created and the modifier chain construction logic is encapsulated. The template instance is instantiated and external configuration parameters are received to generate the basic modifier chain, which is then combined with the native modifier chain to form a hybrid modifier chain.

Benefits of technology

It achieves centralized encapsulation and efficient reuse of style logic, ensures global consistency control of style attributes, improves the maintainability, flexibility and development efficiency of UI development, and solves problems of code redundancy, style inconsistency and integration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121597210A_ABST
    Figure CN121597210A_ABST
Patent Text Reader

Abstract

The invention provides a UI modifier configuration method and device, electronic equipment and a medium. The method comprises the steps that a template class is created based on a template configuration interface declaring a UI modifier basic attribute, the template class provides a default parameter value for the basic attribute, and modifier chain construction logic for generating a modifier chain defining a UI style based on the parameter value of the basic attribute is packaged; instantiating the template class to obtain a template instance; receiving external configuration parameters based on the configuration interface, updating state information of the template instance according to the external configuration parameters, and calling a modifier chain construction logic of the template instance to generate a basic modifier chain based on the updated state information; and combining the basic modifier chain with at least one native modifier chain determined according to the functional requirements of the UI component to generate a mixed modifier chain applied to the UI component. According to the method and the device, centralized management and global consistency control of the style attributes are realized, and natural fusion of the template style and the native characteristics is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of computer technology, and specifically relates to a UI modifier configuration method, device, electronic device, and medium. Background Technology

[0002] In the mobile application and web development field, declarative UI (User Interface) frameworks (such as Google's Jetpack Compose) have become the mainstream choice for building applications. These frameworks describe the UI through composable functions and configure the layout, appearance, and interaction behavior of components through the core concept of modifiers. Developers can flexibly combine the required component styles by chaining multiple modifiers.

[0003] However, as applications grow in scale and UI complexity increases, the basic modifier usage patterns have gradually revealed the following shortcomings in practice: 1. Code duplication and redundancy: The same combination of modifiers often needs to be written repeatedly in multiple different UI components. This copy-paste development pattern leads to code redundancy.

[0004] 2. Difficulty in maintaining style consistency: When it is necessary to adjust the global style, it is necessary to find and modify all places that use a certain style combination. This process is not only tedious and inefficient, but also easy to miss, which ultimately leads to inconsistent UI performance within the application and affects the user experience.

[0005] 3. Poor reusability: Existing frameworks lack an effective encapsulation mechanism for complex modifier combinations. Developers find it difficult to reuse a fixed set of modifier combinations as a configurable, independent unit, resulting in poor maintainability.

[0006] 4. Lack of dynamic configuration and responsiveness: Existing modifier combinations are usually static. When it is necessary to dynamically switch the entire style according to the runtime state, there is a lack of efficient mechanisms to respond to changes in conditions and update the modifier combination, which limits the construction of responsive UI.

[0007] 5. Insufficient type safety: Common reuse schemes (such as ordinary function encapsulation) cannot provide type-safe configuration interfaces. Parameter errors can only be exposed at runtime, which increases debugging costs and maintenance risks.

[0008] 6. Poor integration: Encapsulated modifier combinations are often difficult to integrate naturally and smoothly with the native modifier chains of frameworks such as Jetpack Compose, limiting the flexible expansion of styles.

[0009] In summary, while modifiers in existing declarative UI frameworks offer great flexibility, they also have significant shortcomings in terms of reusability, maintainability, dynamic responsiveness, type safety, and integration. Summary of the Invention

[0010] In view of the above problems, embodiments of this application provide a UI modifier configuration method, apparatus, electronic device, and medium that overcomes or at least partially solves the above problems.

[0011] In a first aspect, embodiments of this application provide a UI modifier configuration method, including: Based on the template configuration interface that declares UI modifier basic properties, a template class is created. The template class provides default parameter values ​​for the basic properties and encapsulates modifier chain construction logic. The modifier chain construction logic is used to generate a modifier chain that defines the UI style based on the parameter values ​​of the basic properties. Instantiate the template class to obtain a template instance. The template instance is initialized with the default parameter value and carries UI style state information for a specific business scenario. The template instance receives external configuration parameters through a configuration interface, updates its status information based on the external configuration parameters, and, based on the updated status information, calls the modifier chain construction logic of the template instance to generate a basic modifier chain. The basic modifier chain is combined with at least one native modifier chain determined according to the functional requirements of the UI component to generate a hybrid modifier chain applied to the UI component.

[0012] Secondly, embodiments of this application provide a UI modifier configuration device, including: Create a module for creating a template class based on the template configuration interface that declares the basic properties of UI modifiers. The template class provides default parameter values ​​for the basic properties and encapsulates the modifier chain construction logic. The modifier chain construction logic is used to generate a modifier chain that defines the UI style based on the parameter values ​​of the basic properties. The first processing module is used to instantiate the template class to obtain a template instance. The template instance is initialized with the default parameter value and carries UI style state information for a specific business scenario. The second processing module is used to receive external configuration parameters based on the configuration interface, update the status information of the template instance according to the external configuration parameters, and, based on the updated status information, call the modifier chain construction logic of the template instance to generate a basic modifier chain. The combination generation module is used to combine the basic modifier chain with at least one native modifier chain determined according to the functional requirements of the UI component to generate a hybrid modifier chain applied to the UI component.

[0013] Thirdly, embodiments of this application provide an electronic device including a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps of the method described in the first aspect.

[0014] Fourthly, embodiments of this application provide a readable storage medium on which a program or instructions are stored, which, when executed by a processor, implement the steps of the method described in the first aspect.

[0015] In this embodiment, a template class encapsulating modifier chain construction logic is created based on the template configuration interface that declares the basic attributes of UI modifiers. This achieves centralized encapsulation and efficient reuse of style logic. Furthermore, the template configuration interface unifies the basic attributes, enabling centralized management and global consistency control of style attributes. After updating the state information of the template instance based on external configuration parameters, the modifier chain construction logic of the template instance is called to generate a basic modifier chain. The basic modifier chain is then combined with at least one native modifier chain to effectively integrate basic style features and extended functional characteristics, generating a hybrid modifier chain that is applied to UI components. This achieves a natural fusion of templated styles and native features. Attached Figure Description

[0016] Figure 1 A schematic diagram illustrating the UI modifier configuration method provided in an embodiment of this application is shown. Figure 2 This application illustrates the overall implementation flowchart of the UI modifier configuration method provided in its embodiments. Figure 3 The system architecture diagram of the UI modifier templated configuration system provided in the embodiments of this application is shown; Figure 4 A schematic diagram of a UI modifier configuration device provided in an embodiment of this application is shown; Figure 5 A schematic diagram of the electronic device structure provided in an embodiment of this application is shown. Detailed Implementation

[0017] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0018] The UI modifier configuration method provided in this application will be described in detail below with reference to the accompanying drawings, through specific embodiments and application scenarios.

[0019] The UI modifier configuration method provided in this application is applied to a computing device. This method is executed within the operating system or application of the computing device. The computing device is an electronic device containing a processor and memory and capable of executing computer programs, including but not limited to smartphones, tablets, wearable devices, personal computers, and servers running operating systems. Figure 1 As shown, the method includes the following steps: Step 101: Based on the template configuration interface that declares the basic properties of UI modifiers, create a template class. The template class provides default parameter values ​​for the basic properties and encapsulates the modifier chain construction logic. The modifier chain construction logic is used to generate a modifier chain that defines the UI style based on the parameter values ​​of the basic properties.

[0020] The template configuration interface is used to declare one or more basic properties, which are attributes of UI modifiers and are used to characterize the general visual and / or layout features of UI components. For example, multiple basic properties include visual attributes such as padding, background color, border thickness, corner radius, and shadow size, as well as layout attributes such as size constraints and margins.

[0021] This involves creating one or more template classes based on a template configuration interface that declares UI modifier base properties. Each template class provides default parameter values ​​for the base properties; different template classes may provide the same or different default parameter values ​​for the base properties. Each template class encapsulates its own modifier chain construction logic, used to generate a modifier chain that defines UI styles based on the parameter values ​​of the base properties. Specifically, the encapsulated modifier chain construction logic takes the values ​​of the base properties as parameters to generate the corresponding modifier chain (i.e., modifier sequence), thereby concretizing the characteristics defined by the base properties into the visual representation of UI components.

[0022] By creating multiple template classes based on the template configuration interface, different template classes with the same template configuration interface can provide different default parameter values ​​and modifier chain construction logic according to specific business needs, thereby achieving diversified style performance under unified basic attribute constraints.

[0023] Step 102: Instantiate the template class to obtain a template instance. The template instance is initialized with default parameter values ​​and carries UI style state information for specific business scenarios.

[0024] After creating a template class based on the template configuration interface, a template instance is obtained by instantiating the template class. The template instance obtained by instantiation is an operable object with an initial state, initialized with the default parameter values ​​defined in the template class. It carries UI style state information for specific business scenarios, such as the current values ​​of basic attributes and possible dynamic states.

[0025] A single template class can correspond to one or more template instances. Multiple template instances can correspond to the same basic attribute values, or they can be configured with different basic attribute values ​​to distinguish them based on their respective business scenario requirements. For example, a template class provides an initial default value for each basic attribute. Multiple template instances created based on the same template class have the same default value during initialization, but each template instance can independently modify some or all of the basic attribute values ​​according to actual needs, thus distinguishing the basic attribute values ​​between different template instances. Different template instances corresponding to the same template class are independent of each other, each maintaining its own UI style state information, thereby achieving style differentiation between template instances.

[0026] Step 103: Receive external configuration parameters based on the configuration interface, update the status information of the template instance according to the external configuration parameters, and, based on the updated status information, call the modifier chain construction logic of the template instance to generate the basic modifier chain.

[0027] After obtaining a template instance by instantiating the template class, if external configuration parameters are received based on the configuration interface, the state information of the template instance is updated based on the external configuration parameters. If the received external configuration parameters include attribute configuration parameters for updating basic attribute values, the template instance can modify the values ​​of some or all basic attributes based on external conditions; if the received external configuration parameters include instruction parameters for controlling dynamic behavior, the template instance can achieve reactive behavior control.

[0028] After updating the state information of the template instance based on external configuration parameters, the modifier chain construction logic corresponding to the template instance, which is used to convert the parameter values ​​of basic attributes into UI styles, is called based on the updated state information to generate a basic modifier chain corresponding to the current state of the template instance.

[0029] Step 104: Combine the basic modifier chain with at least one native modifier chain determined according to the functional requirements of the UI component to generate a hybrid modifier chain applied to the UI component.

[0030] In response to generating a base modifier chain corresponding to the current state of a template instance, this base modifier chain is combined with at least one native modifier chain determined based on the functional requirements of the UI component. At least one native modifier chain provides extended functionality to the UI component independent of base properties; the UI component is the basic unit for building user interfaces in a declarative UI framework, and the template instance, as an independent unit for style configuration, provides basic style support to the UI component through the generated base modifier chain.

[0031] By combining a basic modifier chain with at least one native modifier chain, basic style features and extended functions can be integrated to generate a hybrid modifier chain that can be applied to UI components, thereby achieving a unified application of basic style features and extended functions.

[0032] The above implementation scheme of this application, based on the template configuration interface that declares the basic attributes of UI modifiers, creates a template class that encapsulates the modifier chain construction logic, realizing centralized encapsulation and efficient reuse of style logic. Moreover, the template configuration interface unifies the basic attributes, realizing centralized management and global consistency control of style attributes. After updating the state information of the template instance based on external configuration parameters, the modifier chain construction logic of the template instance is called to generate a basic modifier chain. The basic modifier chain is combined with at least one native modifier chain to effectively integrate basic style features and extended functional features, generating a hybrid modifier chain that is applied to UI components, realizing the natural integration of templated styles and native features.

[0033] Based on this, the embodiments of this application construct a complete system from style definition to UI rendering. While maintaining the flexibility of the declarative UI framework, it solves problems such as poor code reusability, difficulty in maintaining style consistency, and difficulty in integration, providing a maintainable, scalable, and efficient style management solution for UI development.

[0034] In an optional embodiment of this application, the template configuration interface provides unified basic attributes for M template classes, where M is an integer greater than or equal to 1; the M template classes jointly serve multiple business scenarios, and each template class serves at least one business scenario; multiple business scenarios share unified basic attributes, and each business scenario maintains UI style status information through a dedicated template instance.

[0035] In this embodiment, the template configuration interface provides unified basic attributes for at least one template class. When the template configuration interface provides unified basic attributes for multiple template classes, the default parameter values ​​provided by different template classes for the basic attributes may be the same or different. The modifier chain construction logic of different template classes may be the same or different. If the modifier chain construction logic of different template classes is different, it is possible to support diverse UI style implementations while maintaining the provision of unified basic attributes.

[0036] A single template class serves at least one business scenario, with each business scenario corresponding to a template instance. UI style state information is maintained through a dedicated template instance. M template classes collectively serve multiple business scenarios, with each template class serving one or more business scenarios (corresponding to one or more template instances) together constituting multiple business scenarios. Based on this, multiple business scenarios (corresponding to multiple template instances) share unified basic attributes provided by the template configuration interface. This ensures that all related business scenarios share the same set of basic attributes in the architecture, and that multiple template instances share unified basic attributes, guaranteeing the consistency of the global basic style system.

[0037] Different template classes provide the same or different default parameter values ​​for basic attributes. A single template class can configure the same or different attribute values ​​for template instances in different business scenarios. Multiple template instances can achieve customized style performance while adhering to unified basic attribute constraints, thus solving the problem of balancing the maintenance of global style consistency with the flexibility of local scenarios.

[0038] The process of receiving external configuration parameters and updating the template instance based on these parameters is described below. In an optional embodiment, the method further includes: Construct a template container that encapsulates the template instance and the modifier chain construction logic of the template instance. The template container provides a configuration interface through an apply method and receives external configuration parameters in a type-safe manner. The template container is a generic class, and the type parameter of the template container is limited to the type that implements the template configuration interface.

[0039] After instantiating the template class and generating the template instance, a template container is constructed to encapsulate the template instance and the corresponding modifier chain construction logic. By constructing the template container, the template instance and the modifier chain construction logic are uniformly encapsulated, providing a centralized management entry point for style configuration.

[0040] The template container provides an apply method, which serves as a type-safe configuration interface. It receives a configuration block for updating the template instance's state information (parameter state). This configuration block contains external configuration parameters, enabling the apply method to receive external configuration parameters in a declarative and type-safe manner.

[0041] In this context, the template container is a generic class. Generic classes are a programming feature that uses type parameters when defining a class. They allow the creation of reusable components that can handle multiple data types without sacrificing type safety. The type parameters of the template container are determined at compile time and are limited to types that implement the Template Configuration interface. This ensures that the template container can only encapsulate template instances that conform to the constraints of the Template Configuration interface, thus guaranteeing type safety during the compile phase.

[0042] After the template container provides a type-safe configuration interface through the apply method, it receives external configuration parameters in a type-safe manner, updates the state information of the template instance based on the external configuration parameters, and calls the modifier chain construction logic of the template instance based on the updated state information to generate the basic modifier chain.

[0043] By constructing a template container and providing an apply method, type checking of configuration parameters can be performed during the compilation phase, thereby effectively solving the deficiency of insufficient type safety in the traditional modifier usage pattern. At the same time, the template container encapsulates the template instance and its modifier chain construction logic in a unified manner, providing a consistent and standard configuration entry point, improving the encapsulation and maintainability of style configuration, and simplifying the style configuration calling process.

[0044] In another alternative embodiment, the configuration interface is implemented through an extension function defined for the modifier object. The extension function receives a configuration code block including external configuration parameters and performs the following operations internally: updates the state information of the template instance based on the configuration code block, calls the modifier chain construction logic of the template instance based on the updated state information to generate a basic modifier chain, and returns a new modifier object that integrates the basic modifier chain; wherein the name of the extension function is determined based on the semantic type of the corresponding template class.

[0045] The configuration interface for receiving external configuration parameters is implemented through extension functions defined for modifier objects. That is, by declaring extension functions (such as Kotlin extension functions) for modifier objects, a declarative DSL (Domain-Specific Language) interface is provided as the configuration interface.

[0046] The name of the extension function is determined based on the semantic type of the corresponding template class. The semantic type of the template class refers to the business meaning or UI component type represented by the template class. The name of the extension function is determined based on this, so the function name can directly reflect its semantics, thereby providing an intuitive and semantically clear declarative interface, which significantly reduces the cost of understanding and use.

[0047] Extension functions can receive and process external configuration parameters in a type-safe manner. For example, extension functions use the compiler's type checking mechanism to ensure that all external configuration parameters conform to the data specifications defined by the template configuration interface; this mechanism can identify and intercept type errors during the development phase, thereby effectively preventing related problems from occurring at runtime.

[0048] The configuration interface provided by the extension function receives a configuration code block including external configuration parameters, updates the state information of the template instance according to the external configuration parameters, calls the modifier chain construction logic of the template instance based on the updated state information, generates the basic modifier chain, and returns a new modifier object that integrates the basic modifier chain.

[0049] By calling this extension function, declarative calls and automated construction of style configurations can be achieved. Developers only need to provide parameters in the configuration code block to trigger the entire process from state update to basic modifier chain generation, thereby simplifying the configuration complexity of UI styles and improving development efficiency and code maintainability.

[0050] The process of generating a hybrid modifier chain is described below. When combining a base modifier chain with at least one native modifier chain determined based on the functional requirements of the UI component to generate a hybrid modifier chain applied to the UI component, the process includes: The `then` combination operator concatenates the basic modifier chain with at least one native modifier chain to form a unified hybrid modifier chain. Among them, the native modifier chain is used to provide additional style features and / or interactive features for UI components, while the hybrid modifier chain is applied to UI components.

[0051] Native modifier chains are used to provide UI components with extended functionality independent of basic properties. This extended functionality includes additional style features and / or interactive features. The native `then` composition operator (defined in the `Modifier` interface) concatenates the basic modifier chain with at least one native modifier chain to form a unified hybrid modifier chain. The `then` composition operator joins two Modifier objects, returning a new Modifier object that combines all the effects of both. The basic modifier chain is a standard Modifier object, and the native modifier chain is also a Modifier object. By directly combining the basic and native modifier chains using the framework's native `then` composition operator, template-generated basic styles can be seamlessly embedded into the native modifier chain. Therefore, based on a unified Modifier type and a native composition mechanism, this solves the technical challenge of poor integration between traditional encapsulation schemes and declarative UI frameworks.

[0052] The resulting hybrid modifier chain is applied to UI components, allowing them to inherit the basic styles defined by the template while flexibly integrating extended functionalities provided by the native framework. Furthermore, through the `then` composition mechanism, the basic styles and the extended functionalities provided by the native framework are seamlessly integrated, creating a unified visual and interactive experience while maintaining their respective independence and maintainability.

[0053] In an optional embodiment of this application, at least two template classes generate a composite template class through a template combiner, and the at least two template classes correspond to the same or different template configuration interfaces; A composite template class inherits the basic properties corresponding to at least two template classes respectively. The modifier chain construction logic of the composite template class is used to coordinate and sequentially call the modifier chain construction logic corresponding to at least two template classes respectively. The template instance corresponding to the composite template class is used to generate a composite basic modifier chain, which is formed by integrating the basic style features of at least two template classes.

[0054] For at least two template classes corresponding to the same or different template configuration interfaces, a composite template class is generated based on the template combiner. The composite template class inherits the basic attributes corresponding to the at least two template classes. If the at least two template classes correspond to the same template configuration interface, the composite template class inherits the same set of basic attributes. Since different template classes may provide different default parameter values ​​for the same basic attributes, a predetermined conflict resolution strategy is needed to determine the default parameter values ​​of each basic attribute in the composite template class. Conflict resolution strategies include, for example, selecting the default parameter value of a specified template class (such as the first or last template class), selecting the default parameter value of a template class with a specific priority, or redefining new default parameter values ​​for the composite template class based on the default parameter values ​​corresponding to the at least two template classes.

[0055] The core function of the modifier chain construction logic is to generate a modifier chain defining UI styles based on the parameter values ​​of basic attributes. The modifier chain construction logic of the composite template class coordinates and sequentially calls the modifier chain construction logic of at least two template classes, forming a unified style construction process. This process executes the modifier chain construction logic of each template class in a predetermined order, sequentially stacking the generated basic modifier chains using the `then` combination operator to form a composite basic modifier chain that integrates the basic style features of each template class. The basic style features are UI styles transformed by the template class based on its basic attribute state through its modifier chain construction logic; the generated composite basic modifier chain is essentially a single modifier chain integrating multiple style effects.

[0056] A template instance is obtained by instantiating a composite template class. This template instance encapsulates the composite style state information and generates a composite basic modifier chain based on it. The composite basic modifier chain integrates the basic style features of at least two template classes to achieve the unified application of multi-level style features.

[0057] In one optional embodiment of this application, the template class supports static properties and dynamic reactive properties; static properties are implemented through regular variables, initialized when the template is instantiated and remain unchanged during runtime; dynamic reactive properties are implemented through reactive state variables, which can be dynamically updated according to state changes during runtime and trigger UI style updates.

[0058] The template classes in this embodiment support both static and dynamic reactive properties. If a single template class contains both static and dynamic reactive properties, they are seamlessly integrated during the modifier chain construction process: when generating the modifier chain based on the modifier chain construction logic, the fixed value of the static property and the current state value of the dynamic reactive property are integrated synchronously; that is, the fixed value is used for the static property, and the real-time state value is used for the dynamic reactive property.

[0059] Static properties are implemented using regular variables, initialized with default parameter values ​​during template instantiation and remaining unchanged at runtime. Dynamic reactive properties are implemented using reactive state management mechanisms (such as the mutableStateOf mechanism). After template instantiation, their parameter states can be dynamically updated based on received external configuration parameters. When the parameter state of a dynamic reactive property changes, the modifier chain construction logic is automatically triggered to regenerate the basic modifier chain and update the UI style accordingly.

[0060] By introducing dynamic reactive properties and state management mechanisms, real-time dynamic response of UI styles is achieved. If the state changes during runtime, the modifier chain is automatically reconstructed and the UI is updated, which solves the problem that traditional static modifier combinations cannot dynamically respond to state changes, and enhances the ability to build responsive UIs and user experience.

[0061] The following describes the solution of the embodiments of this application through an overall implementation process, such as... Figure 2 As shown: Step 201: Define the template configuration interface for declaring the basic properties of UI modifiers.

[0062] Step 202: Create template classes based on the template configuration interface. These template classes provide default parameter values ​​for basic attributes and encapsulate the modifier chain construction logic for generating modifier chains that define UI styles based on the parameter values ​​of the basic attributes. At least two template classes are combined using a template comboer to generate a composite template class, which can be used normally like a regular template class.

[0063] Step 203: Instantiate the template class to obtain a template instance. The template instance is initialized with default parameter values ​​and carries UI style state information for specific business scenarios.

[0064] Step 204: Construct a template container that encapsulates the template instance and the modifier chain construction logic of the template instance. Provide a configuration interface based on the apply method of the template container, or implement the configuration interface through an extension function defined for the modifier object.

[0065] Step 205: Receive external configuration parameters based on the configuration interface, update the status information of the template instance according to the external configuration parameters, and, based on the updated status information, call the modifier chain construction logic of the template instance to generate the basic modifier chain.

[0066] Step 206: Use the then combination operator to concatenate the basic modifier chain with at least one native modifier chain to form a unified hybrid modifier chain applied to the UI group.

[0067] The above implementation process, from uniformly defining basic attributes and encapsulating construction logic to instantiating template classes to generate template instances, and then dynamically updating styles through configuration interfaces, ultimately achieves seamless integration with native functions. This solves problems such as code redundancy, inconsistent styles, poor reusability, and poor integration that exist in the traditional modifier usage pattern, and significantly improves the maintainability, flexibility, and development efficiency of UI development.

[0068] Figure 3 The system architecture diagram of the UI modifier templated configuration system provided in the embodiments of this application is shown. Figure 3 As shown, the system architecture includes a template configuration interface layer, a template implementation layer, a container management layer, a DSL extension layer, a build generation layer, a state management layer, a template combination layer, and an application integration layer.

[0069] The template configuration interface layer defines a unified set of basic UI modifier attributes, establishes constraints that template classes must adhere to, and provides standardized constraints for the template implementation layer. The template implementation layer creates concrete template classes based on the template configuration interface, encapsulates the modifier chain construction logic and default parameter values, and provides template instances. The template composition layer aggregates multiple template classes through a template combiner, handles attribute inheritance and construction logic integration, and the generated composite template class returns to the template implementation layer. Composite template classes can be used normally like ordinary template classes.

[0070] The container management layer encapsulates template instances and their modifier chains within a template container, providing a type-safe `apply` method as a configuration interface. The DSL extension layer provides a declarative DSL interface as its configuration interface through extension functions. Both the container management layer and the DSL extension layer provide configuration interfaces, receiving external configuration parameters. These parameters are used to update the state information of the template instances, and the updated state information is then provided to the build layer.

[0071] The state management layer monitors changes in the template instance's state. When a dynamically reactive property changes, it sends a rebuild trigger signal to the build generation layer. The build generation layer receives state update signals from the container management layer and the DSL extension layer, the rebuild trigger signal from the state management layer, the build logic from the template implementation layer, and the current state information of the template instance. It executes the modifier chain build logic, generates a basic modifier chain, and concatenates the basic modifier chain with the native modifier chain using the `then` combination operator to generate a hybrid modifier chain. The application integration layer applies the hybrid modifier chain to UI components, achieving a unified presentation of styles and functions.

[0072] Figure 3 The system architecture shown implements the entire process of style configuration from definition to rendering. While ensuring the independence of each layer, it also ensures the overall consistency and maintainability of the system, providing a complete solution for style management of complex UIs.

[0073] Figure 4 This application illustrates a UI modifier configuration apparatus provided in an embodiment, the apparatus comprising: Create module 401, which is used to create a template class based on the template configuration interface that declares the basic properties of UI modifiers. The template class provides default parameter values ​​for the basic properties and encapsulates the modifier chain construction logic. The modifier chain construction logic is used to generate a modifier chain that defines the UI style based on the parameter values ​​of the basic properties. The first processing module 402 is used to instantiate the template class to obtain a template instance. The template instance is initialized with the default parameter value and carries UI style status information for a specific business scenario. The second processing module 403 is used to receive external configuration parameters based on the configuration interface, update the status information of the template instance according to the external configuration parameters, and, based on the updated status information, call the modifier chain construction logic of the template instance to generate a basic modifier chain. The combination generation module 404 is used to combine the basic modifier chain with at least one native modifier chain determined according to the functional requirements of the UI component to generate a hybrid modifier chain applied to the UI component.

[0074] Optionally, the template configuration interface provides unified basic attributes for M template classes, where M is an integer greater than or equal to 1; The M template classes collectively serve multiple business scenarios, and each template class serves at least one business scenario; The multiple business scenarios share the unified basic attributes, and each business scenario maintains UI style status information through a dedicated template instance.

[0075] Optionally, the device further includes: A constructor module is used to construct a template container that encapsulates the template instance and the modifier chain construction logic of the template instance. The template container provides the configuration interface through an apply method and receives the external configuration parameters in a type-safe manner. The template container is a generic class, and the type parameter of the template container is limited to the type that implements the template configuration interface.

[0076] Optionally, the configuration interface is implemented through extension functions defined for modifier objects; The extension function receives a configuration code block including the external configuration parameters and performs the following operations within it: updates the state information of the template instance based on the configuration code block, calls the modifier chain construction logic of the template instance based on the updated state information to generate the basic modifier chain, and returns a new modifier object that integrates the basic modifier chain.

[0077] Optionally, the combination generation module is further configured to: The basic modifier chain is concatenated with at least one native modifier chain using the then combination operator to form a unified hybrid modifier chain; The native modifier chain is used to provide additional style features and / or interactive features for the UI component, while the hybrid modifier chain is applied to the UI component.

[0078] Optionally, at least two template classes are used to generate a composite template class through a template comboer, wherein the at least two template classes correspond to the same or different template configuration interfaces; The composite template class inherits the basic attributes corresponding to the at least two template classes respectively, and the modifier chain construction logic of the composite template class is used to coordinate and sequentially call the modifier chain construction logic corresponding to the at least two template classes respectively. The template instance corresponding to the composite template class is used to generate a composite basic modifier chain, wherein the composite basic modifier chain is formed by integrating the basic style features of the at least two template classes.

[0079] Optionally, the template class supports static properties and dynamic reactive properties; The static properties are implemented through regular variables, initialized when the template is instantiated and remain unchanged during runtime; the dynamic reactive properties are implemented through reactive state variables, which can be dynamically updated according to state changes during runtime and trigger UI style updates.

[0080] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0081] This application also provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, it implements the various processes of the above-described UI modifier configuration method embodiments and achieves the same technical effect. To avoid repetition, it will not be described again here.

[0082] For example, Figure 5 A schematic diagram of the physical structure of an electronic device is shown. (For example...) Figure 5 As shown, the electronic device may include a processor 510, a communications interface 520, a memory 530, and a communication bus 540. The processor 510, communications interface 520, and memory 530 communicate with each other via the communication bus 540. The processor 510 can call logical instructions stored in the memory 530. The processor 510 is used to execute various processes of the UI modifier configuration method according to the embodiments of this application, which will not be described in detail here.

[0083] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.

[0084] This application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the various processes of the UI modifier configuration method embodiments described above and achieves the same technical effects. To avoid repetition, it will not be described again here. The computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc.

[0085] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0086] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0087] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

Claims

1. A method for configuring UI modifiers, characterized in that, include: Based on the template configuration interface that declares UI modifier basic properties, a template class is created. The template class provides default parameter values ​​for the basic properties and encapsulates modifier chain construction logic. The modifier chain construction logic is used to generate a modifier chain that defines the UI style based on the parameter values ​​of the basic properties. Instantiate the template class to obtain a template instance. The template instance is initialized with the default parameter value and carries UI style state information for a specific business scenario. The template instance receives external configuration parameters through a configuration interface, updates its status information based on the external configuration parameters, and, based on the updated status information, calls the modifier chain construction logic of the template instance to generate a basic modifier chain. The basic modifier chain is combined with at least one native modifier chain determined according to the functional requirements of the UI component to generate a hybrid modifier chain applied to the UI component.

2. The method according to claim 1, characterized in that, The template configuration interface provides unified basic attributes for M template classes, where M is an integer greater than or equal to 1; The M template classes collectively serve multiple business scenarios, and each template class serves at least one business scenario; The multiple business scenarios share the unified basic attributes, and each business scenario maintains UI style status information through a dedicated template instance.

3. The method according to claim 1, characterized in that, Also includes: Construct a template container that encapsulates the template instance and the modifier chain construction logic of the template instance. The template container provides the configuration interface through an apply method and receives the external configuration parameters in a type-safe manner. The template container is a generic class, and the type parameter of the template container is limited to the type that implements the template configuration interface.

4. The method according to claim 1, characterized in that, The configuration interface is implemented through extension functions defined for modifier objects; The extension function receives a configuration code block including the external configuration parameters and performs the following operations within it: updates the state information of the template instance based on the configuration code block, calls the modifier chain construction logic of the template instance based on the updated state information to generate the basic modifier chain, and returns a new modifier object that integrates the basic modifier chain.

5. The method according to claim 1, characterized in that, The step of combining the basic modifier chain with at least one native modifier chain determined according to the functional requirements of the UI component to generate a hybrid modifier chain applied to the UI component includes: The basic modifier chain is concatenated with at least one native modifier chain using the then combination operator to form a unified hybrid modifier chain; The native modifier chain is used to provide additional style features and / or interactive features for the UI component, while the hybrid modifier chain is applied to the UI component.

6. The method according to claim 2, characterized in that, At least two template classes are used to generate a composite template class through a template comboer, wherein the at least two template classes correspond to the same or different template configuration interfaces; The composite template class inherits the basic attributes corresponding to the at least two template classes respectively, and the modifier chain construction logic of the composite template class is used to coordinate and sequentially call the modifier chain construction logic corresponding to the at least two template classes respectively. The template instance corresponding to the composite template class is used to generate a composite basic modifier chain, wherein the composite basic modifier chain is formed by integrating the basic style features of the at least two template classes.

7. The method according to claim 1, 2 or 6, characterized in that, The template class supports static properties and dynamic reactive properties; The static properties are implemented through regular variables, initialized when the template is instantiated and remain unchanged during runtime; the dynamic reactive properties are implemented through reactive state variables, which can be dynamically updated according to state changes during runtime and trigger UI style updates.

8. A UI modifier configuration device, characterized in that, include: Create a module for creating a template class based on the template configuration interface that declares the basic properties of UI modifiers. The template class provides default parameter values ​​for the basic properties and encapsulates the modifier chain construction logic. The modifier chain construction logic is used to generate a modifier chain that defines the UI style based on the parameter values ​​of the basic properties. The first processing module is used to instantiate the template class to obtain a template instance. The template instance is initialized with the default parameter value and carries UI style state information for a specific business scenario. The second processing module is used to receive external configuration parameters based on the configuration interface, update the status information of the template instance according to the external configuration parameters, and, based on the updated status information, call the modifier chain construction logic of the template instance to generate a basic modifier chain. The combination generation module is used to combine the basic modifier chain with at least one native modifier chain determined according to the functional requirements of the UI component to generate a hybrid modifier chain applied to the UI component.

9. An electronic device, characterized in that, It includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps of the UI modifier configuration method as described in any one of claims 1 to 7.

10. A readable storage medium, characterized in that, The program or instructions are stored on the readable storage medium, and when the program or instructions are executed by a processor, they implement the steps of the UI modifier configuration method as described in any one of claims 1 to 7.