source
stringlengths
14
113
code
stringlengths
10
21.3k
application-dev\ui\arkts-routing.md
import { router } from '@kit.ArkUI'; import { BusinessError } from '@kit.BasicServicesKit'; // Define a click event processing function for the back button. function onBackClick(): void { // Invoke the router.showAlertBeforeBackPage() API to set the information about the confirmation dialog box. try { router.s...
application-dev\ui\arkts-routing.md
import { router } from '@kit.ArkUI';
application-dev\ui\arkts-routing.md
import { promptAction, router } from '@kit.ArkUI'; import { BusinessError } from '@kit.BasicServicesKit'; function onBackClick() { // Display a custom confirmation dialog box. promptAction.showDialog({ message:'Payment not completed yet. Are you sure you want to return?', buttons: [ { text: '...
application-dev\ui\arkts-routing.md
import { router } from '@kit.ArkUI';
application-dev\ui\arkts-routing.md
// library/src/main/ets/pages/Index.ets // library is the custom name of the new shared package. @Entry({ routeName: 'myPage' }) @Component export struct MyComponent { build() { Row() { Column() { Text('Library Page') .fontSize(50) .fontWeight(FontWeight.Bold) } .widt...
application-dev\ui\arkts-routing.md
import { BusinessError } from '@kit.BasicServicesKit'; import '@ohos/library/src/main/ets/pages/Index'; // Import the named route page from the library of the shared package. @Entry @Component struct Index { build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign...
application-dev\ui\arkts-routing.md
>"dependencies": { > "@ohos/library": "file:../library", > ... > } >
application-dev\ui\arkts-shadow-effect.md
@Entry @Component struct ShadowOptionDemo { build() { Row() { Column() { Column() { Text('shadowOption').fontSize(12) } .width(100) .aspectRatio(1) .margin(10) .justifyContent(FlexAlign.Center) .backgroundColor(Color.White) .borderRad...
application-dev\ui\arkts-shared-element-transition.md
class PostData { avatar: Resource = $r('app.media.flower'); name: string = ''; message: string = ''; images: Resource[] = []; } @Entry @Component struct Index { @State isExpand: boolean = false; @State @Watch('onItemClicked') selectedIndex: number = -1; private allPostData: PostData[] = [ { avatar: ...
application-dev\ui\arkts-shared-element-transition.md
// Index.ets import { createPostNode, getPostNode, PostNode } from "../PostNode" import { componentUtils, curves } from '@kit.ArkUI'; @Entry @Component struct Index { // Create an animation class. @State AnimationProperties: AnimationProperties = new AnimationProperties(); private listArray: Array<number> = [1, ...
application-dev\ui\arkts-shared-element-transition.md
// PostNode.ets // Cross-container migration import { UIContext } from '@ohos.arkui.UIContext'; import { NodeController, BuilderNode, FrameNode } from '@ohos.arkui.node'; import { curves } from '@kit.ArkUI'; class Data { item: string | null = null isExpand: Boolean | false = false } @Builder function PostBuilder(...
application-dev\ui\arkts-shared-element-transition.md
// Index.ets import { AnimateCallback, CustomTransition } from '../CustomTransition/CustomNavigationUtils'; const TAG: string = 'Index'; @Entry @Component struct Index { private pageInfos: NavPathStack = new NavPathStack(); // Allow custom transition for specific pages by name. private allowedCustomTransitionFr...
application-dev\ui\arkts-shared-element-transition.md
// PageOne.ets import { CustomTransition } from '../CustomTransition/CustomNavigationUtils'; import { MyNodeController, createMyNode, getMyNode } from '../NodeContainer/CustomComponent'; import { ComponentAttrUtils, RectInfoInPx } from '../utils/ComponentAttrUtils'; import { WindowUtils } from '../utils/WindowUtils'; ...
application-dev\ui\arkts-shared-element-transition.md
// PageTwo.ets import { CustomTransition } from '../CustomTransition/CustomNavigationUtils'; import { AnimationProperties } from '../CustomTransition/AnimationProperties'; import { RectInfoInPx } from '../utils/ComponentAttrUtils'; import { getMyNode, MyNodeController } from '../NodeContainer/CustomComponent'; @Builde...
application-dev\ui\arkts-shared-element-transition.md
// CustomNavigationUtils.ets // Configure custom transition animations for Navigation. export interface AnimateCallback { animation: ((isPush: boolean, isExit: boolean, transitionProxy: NavigationTransitionProxy) => void | undefined) | undefined; timeout: (number | undefined) | undefined; } const customTransit...
application-dev\ui\arkts-shared-element-transition.md
// Add the {"routerMap": "$profile:route_map"} configuration to the project configuration file module.json5. // route_map.json { "routerMap": [ { "name": "PageOne", "pageSourceFile": "src/main/ets/pages/PageOne.ets", "buildFunction": "PageOneBuilder" }, { "name": "PageTwo", "...
application-dev\ui\arkts-shared-element-transition.md
// AnimationProperties.ets // Encapsulation of shared element transition animation import { curves } from '@kit.ArkUI'; import { RectInfoInPx } from '../utils/ComponentAttrUtils'; import { WindowUtils } from '../utils/WindowUtils'; import { MyNodeController } from '../NodeContainer/CustomComponent'; const TAG: string ...
application-dev\ui\arkts-shared-element-transition.md
// ComponentAttrUtils.ets // Obtain the position of the component relative to the window. import { componentUtils, UIContext } from '@kit.ArkUI'; import { JSON } from '@kit.ArkTS'; export class ComponentAttrUtils { // Obtain the position information of the component based on its ID. public static getRectInfoById(c...
application-dev\ui\arkts-shared-element-transition.md
// WindowUtils.ets // Window information import { window } from '@kit.ArkUI'; export class WindowUtils { public static window: window.Window; public static windowWidth_px: number; public static windowHeight_px: number; public static topAvoidAreaHeight_px: number; public static navigationIndicatorHeight_px: n...
application-dev\ui\arkts-shared-element-transition.md
// EntryAbility.ets // Add capture of window width and height in onWindowStageCreate at the application entry. import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { display, window } from '@kit.ArkUI'; import { WindowUtils } from '../utils/Win...
application-dev\ui\arkts-shared-element-transition.md
// CustomComponent.ets // Custom placeholder node with cross-container migration capability import { BuilderNode, FrameNode, NodeController } from '@kit.ArkUI'; @Builder function CardBuilder() { Image($r("app.media.card")) .width('100%') .id('card') } export class MyNodeController extends NodeController { ...
application-dev\ui\arkts-shared-element-transition.md
// index.ets import { MyNodeController, createMyNode, getMyNode } from '../NodeContainer/CustomComponent'; import { ComponentAttrUtils, RectInfoInPx } from '../utils/ComponentAttrUtils'; import { WindowUtils } from '../utils/WindowUtils'; import { inspector } from '@kit.ArkUI' class AnimationInfo { scale: number = 0...
application-dev\ui\arkts-shared-element-transition.md
// CustomComponent.ets // Custom placeholder node with cross-container migration capability import { BuilderNode, FrameNode, NodeController } from '@kit.ArkUI'; @Builder function CardBuilder() { Image($r("app.media.flower")) // Prevent flickering of the image during the first load. .syncLoad(true) } export ...
application-dev\ui\arkts-shared-element-transition.md
// ComponentAttrUtils.ets // Obtain the position of the component relative to the window. import { componentUtils, UIContext } from '@kit.ArkUI'; import { JSON } from '@kit.ArkTS'; export class ComponentAttrUtils { // Obtain the position information of the component based on its ID. public static getRectInfoById(c...
application-dev\ui\arkts-shared-element-transition.md
// WindowUtils.ets // Window information import { window } from '@kit.ArkUI'; export class WindowUtils { public static window: window.Window; public static windowWidth_px: number; public static windowHeight_px: number; public static topAvoidAreaHeight_px: number; public static navigationIndicatorHeight_px: n...
application-dev\ui\arkts-shared-element-transition.md
// EntryAbility.ets // Add capture of window width and height in onWindowStageCreate at the application entry. import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { display, window } from '@kit.ArkUI'; import { WindowUtils } from '../utils/Win...
application-dev\ui\arkts-shared-element-transition.md
import { curves } from '@kit.ArkUI'; @Entry @Component struct IfElseGeometryTransition { @State isShow: boolean = false; build() { Stack({ alignContent: Alignment.Center }) { if (this.isShow) { Image($r('app.media.spring')) .autoResize(false) .clip(true) .width(200)...
application-dev\ui\arkts-shared-element-transition.md
class PostData { avatar: Resource = $r('app.media.flower'); name: string = ''; message: string = ''; images: Resource[] = []; } @Entry @Component struct Index { @State isPersonalPageShow: boolean = false; @State selectedIndex: number = 0; @State alphaValue: number = 1; private allPostData: PostData[] ...
application-dev\ui\arkts-sheet-page.md
.nestedScroll({ // Nested scrolling options for the scrollable component when it scrolls towards the end, with the gesture upwards. scrollForward: NestedScrollMode.PARENT_FIRST, // Nested scrolling options for the scrollable component when it scrolls towards the start, with the gesture downwards. scroll...
application-dev\ui\arkts-sheet-page.md
@Entry @Component struct SheetDemo { @State isShowSheet: boolean = false private items: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] @Builder SheetBuilder() { Column() { // Step 1: Customize a scrollable container. List({ space: '10vp' }) { ForEach(this.items, (item: number) => { ...
application-dev\ui\arkts-sheet-page.md
// Step 1: Declare the onWillDismiss callback. onWillDismiss: ((DismissSheetAction: DismissSheetAction) => { // Step 2: Implement the secondary confirmation interaction, using an AlertDialog component to prompt the user for confirmation. AlertDialog.show( { message: 'Do you want to close the semi-modal?', ...
application-dev\ui\arkts-sheet-page.md
onWillDismiss: ((DismissSheetAction: DismissSheetAction) => { if (DismissSheetAction.reason == DismissReason.SLIDE_DOWN) { DismissSheetAction.dismiss() // Register the dismiss behavior. } }),
application-dev\ui\arkts-sheet-page.md
onWillDismiss: ((DismissSheetAction: DismissSheetAction) => { if (DismissSheetAction.reason == DismissReason.SLIDE_DOWN) { DismissSheetAction.dismiss() // Register the dismiss behavior. } }), onWillSpringBackWhenDismiss: ((SpringBackAction: SpringBackAction) => { // Do not call SpringBackAction.springBack(), ...
application-dev\ui\arkts-spring-curve.md
function springMotion(response?: number, dampingFraction?: number, overlapDuration?: number): ICurve;
application-dev\ui\arkts-spring-curve.md
function responsiveSpringMotion(response?: number, dampingFraction?: number, overlapDuration?: number): ICurve;
application-dev\ui\arkts-spring-curve.md
function interpolatingSpring(velocity: number, mass: number, stiffness: number, damping: number): ICurve;
application-dev\ui\arkts-spring-curve.md
function springCurve(velocity: number, mass: number, stiffness: number, damping: number): ICurve;
application-dev\ui\arkts-spring-curve.md
import { curves } from '@kit.ArkUI'; class Spring { public title: string; public subTitle: string; public iCurve: ICurve; constructor(title: string, subTitle: string, iCurve: ICurve) { this.title = title; this.iCurve = iCurve; this.subTitle = subTitle; } } // Spring component @Component struct ...
application-dev\ui\arkts-styled-string.md
@Entry @Component struct styled_string_demo1 { styledString1: StyledString = new StyledString("45-minute workout"); mutableStyledString1: MutableStyledString = new MutableStyledString("35-minute workout"); controller1: TextController = new TextController(); controller2: TextController = new TextCont...
application-dev\ui\arkts-styled-string.md
import { LengthMetrics } from '@kit.ArkUI'; @Entry @Component struct styled_string_demo2 { textStyleAttrs: TextStyle = new TextStyle({ fontWeight: FontWeight.Bolder, fontSize: LengthMetrics.vp(24), fontStyle: FontStyle.Italic }); mutableStyledString: MutableStyledString = new MutableStyledString("3...
application-dev\ui\arkts-styled-string.md
// xxx.ets @Entry @Component struct styled_string_demo3 { mutableStyledString: MutableStyledString = new MutableStyledString("35-minute workout", [ { start: 0, length: 3, styledKey: StyledStringKey.TEXT_SHADOW, styledValue: new TextShadowStyle({ radius: 5, ...
application-dev\ui\arkts-styled-string.md
// xxx.ets @Entry @Component struct styled_string_demo4 { mutableStyledString: MutableStyledString = new MutableStyledString("35-minute workout", [ { start: 0, length: 3, styledKey: StyledStringKey.DECORATION, styledValue: new DecorationStyle({ type: TextDecorationType.Li...
application-dev\ui\arkts-styled-string.md
import { LengthMetrics } from '@kit.ArkUI'; // xxx.ets @Entry @Component struct styled_string_demo5 { mutableStyledString: MutableStyledString = new MutableStyledString("35-minute workout", [ { start: 0, length: 3, styledKey: StyledStringKey.BASELINE_OFFSET, styledValu...
application-dev\ui\arkts-styled-string.md
import { LengthMetrics } from '@kit.ArkUI'; // xxx.ets @Entry @Component struct styled_string_demo6 { mutableStyledString: MutableStyledString = new MutableStyledString("35-minute workout\nFighting\nAchieved", [ { start: 8, length: 3, styledKey: StyledStringKey.LINE_HEIGHT, ...
application-dev\ui\arkts-styled-string.md
import { LengthMetrics, LengthUnit } from '@kit.ArkUI'; // xxx.ets @Entry @Component struct styled_string_demo7 { mutableStyledString: MutableStyledString = new MutableStyledString("35-minute workout", [ { start: 0, length: 2, styledKey: StyledStringKey.LETTER_SPACING, ...
application-dev\ui\arkts-styled-string.md
import { LengthMetrics } from '@kit.ArkUI'; titleParagraphStyleAttr: ParagraphStyle = new ParagraphStyle({ textAlign: TextAlign.Center }); // Create a paragraph style for a 15 vp first-line text indent. paragraphStyleAttr1: ParagraphStyle = new ParagraphStyle({ textIndent: LengthMetrics.vp(15) }); // Line heigh...
application-dev\ui\arkts-styled-string.md
import { LengthMetrics } from '@kit.ArkUI'; // Set the maximum number of lines and text overflow mode for the paragraph, without setting the indent. paragraphStyleAttr3: ParagraphStyle = new ParagraphStyle({ textAlign: TextAlign.End, maxLines: 1, wordBreak: WordBreak.BREAK_ALL, overflow: TextOverflow.Ellipsis}); ...
application-dev\ui\arkts-styled-string.md
// xxx.ets import { image } from '@kit.ImageKit'; import { LengthMetrics } from '@kit.ArkUI'; @Entry @Component struct styled_string_demo4 { @State message: string = 'Hello World'; imagePixelMap: image.PixelMap | undefined = undefined; @State imagePixelMap3: image.PixelMap | undefined = undefined...
application-dev\ui\arkts-styled-string.md
import { drawing } from '@kit.ArkGraphics2D'; class MyCustomSpan extends CustomSpan { constructor(word: string, width: number, height: number, fontSize: number) { super(); this.word = word; this.width = width; this.height = height; this.fontSize = fontSize; } onMeasure(meas...
application-dev\ui\arkts-styled-string.md
import { LengthMetrics } from '@kit.ArkUI'; @Entry @Component struct Index { alignCenterParagraphStyleAttr: ParagraphStyle = new ParagraphStyle({ textAlign: TextAlign.Center }); // Line height style object lineHeightStyle1: LineHeightStyle = new LineHeightStyle(LengthMetrics.vp(24)); //Bold style boldTextSty...
application-dev\ui\arkts-traditional-curve.md
class MyCurve { public title: string; public curve: Curve; public color: Color | string; constructor(title: string, curve: Curve, color: Color | string = '') { this.title = title; this.curve = curve; this.color = color; } } const myCurves: MyCurve[] = [ new MyCurve(' Linear', Curve.Linear, '#3...
application-dev\ui\arkts-uicontext-custom-dialog.md
private contentNode: ComponentContent<Object> = new ComponentContent(this.ctx, wrapBuilder(buildText), new Params(this.message));
application-dev\ui\arkts-uicontext-custom-dialog.md
PromptActionClass.ctx.getPromptAction().openCustomDialog(PromptActionClass.contentNode, PromptActionClass.options) .then(() => { console.info('OpenCustomDialog complete.') }) .catch((error: BusinessError) => { let message = (error as BusinessError).message; let code = (error as Busin...
application-dev\ui\arkts-uicontext-custom-dialog.md
PromptActionClass.ctx.getPromptAction().closeCustomDialog(PromptActionClass.contentNode) .then(() => { console.info('CloseCustomDialog complete.') if (this.contentNode !== null) { this.contentNode.dispose(); // Dispose of contentNode. } }) .catch((error: BusinessError)...
application-dev\ui\arkts-uicontext-custom-dialog.md
this.contentNode.update(new Params('update'))
application-dev\ui\arkts-uicontext-custom-dialog.md
PromptActionClass.ctx.getPromptAction().updateCustomDialog(PromptActionClass.contentNode, options) .then(() => { console.info('UpdateCustomDialog complete.') }) .catch((error: BusinessError) => { let message = (error as BusinessError).message; let code = (error as BusinessError).code; console.erro...
application-dev\ui\arkts-uicontext-custom-dialog.md
// PromptActionClass.ets import { BusinessError } from '@kit.BasicServicesKit'; import { ComponentContent, promptAction } from '@kit.ArkUI'; import { UIContext } from '@ohos.arkui.UIContext'; export class PromptActionClass { static ctx: UIContext; static contentNode: ComponentContent<Object>; static options: pro...
application-dev\ui\arkts-uicontext-custom-dialog.md
// Index.ets import { ComponentContent } from '@kit.ArkUI'; import { PromptActionClass } from './PromptActionClass'; class Params { text: string = "" constructor(text: string) { this.text = text; } } @Builder function buildText(params: Params) { Column() { Text(params.text) .fontSize(50) ...
application-dev\ui\arkts-user-defined-arktsNode-builderNode.md
import { BuilderNode, FrameNode, NodeController, UIContext } from '@kit.ArkUI'; class Params { text: string = ""; constructor(text: string) { this.text = text; } } @Builder function buildText(params: Params) { Column() { Text(params.text) .fontSize(50) .fontWeight(FontWeight.Bold) ....
application-dev\ui\arkts-user-defined-arktsNode-builderNode.md
import { NodeController, BuilderNode, FrameNode, UIContext, RenderNode } from "@kit.ArkUI"; class Params { text: string = ""; constructor(text: string) { this.text = text; } } @Builder function buildText(params: Params) { Column() { Text(params.text) .fontSize(50) .fontWeight(FontWeight.B...
application-dev\ui\arkts-user-defined-arktsNode-builderNode.md
import { NodeController, BuilderNode, FrameNode, UIContext } from "@kit.ArkUI"; class Params { text: string = ""; constructor(text: string) { this.text = text; } } // Custom component @Component struct TextBuilder { // The @Prop decorated attribute is the attribute to be updated in the custom component. I...
application-dev\ui\arkts-user-defined-arktsNode-builderNode.md
import { NodeController, BuilderNode, FrameNode, UIContext } from '@kit.ArkUI'; class Params { text: string = "this is a text"; } @Builder function ButtonBuilder(params: Params) { Column() { Button(`button ` + params.text) .borderWidth(2) .backgroundColor(Color.Orange) .width("100%") ....
application-dev\ui\arkts-user-defined-arktsNode-builderNode.md
import { FrameNode, NodeController, BuilderNode, UIContext } from "@kit.ArkUI"; const TEST_TAG: string = "Reuse+Recycle"; class MyDataSource { private dataArray: string[] = []; private listener: DataChangeListener | null = null public totalCount(): number { return this.dataArray.length; } public getDa...
application-dev\ui\arkts-user-defined-arktsNode-builderNode.md
import { NodeController, BuilderNode, FrameNode, UIContext } from "@kit.ArkUI"; import { AbilityConstant, Configuration, EnvironmentCallback } from '@kit.AbilityKit'; class Params { text: string = "" constructor(text: string) { this.text = text; } } // Custom component @Component struct TextBuilder { // ...
application-dev\ui\arkts-user-defined-arktsNode-builderNode.md
// ets/pages/Index.ets import { NodeController, BuilderNode, FrameNode, UIContext } from "@kit.ArkUI"; import "ets/pages/PageTwo" @Builder function buildText() { // Use syntax nodes to generate a BuilderProxyNode within @Builder. if (true) { MyComponent() } } @Component struct MyComponent { @StorageLink("...
application-dev\ui\arkts-user-defined-arktsNode-builderNode.md
// ets/pages/PageTwo.ets // This page contains a button to navigate back to the home page, where the original text disappears. import "ets/pages/Index" @Entry({ routeName: "pageTwo" }) @Component struct PageTwo { build() { Column() { Button('Router replace to index') .onClick(() => { this...
application-dev\ui\arkts-user-defined-arktsNode-builderNode.md
// ets/pages/Index.ets import { NodeController, BuilderNode, FrameNode, UIContext } from "@kit.ArkUI"; import "ets/pages/PageTwo" @Builder function buildText() { // Use syntax nodes to generate a BuilderProxyNode within @Builder. if (true) { MyComponent() } } @Component struct MyComponent { @StorageLink("...
application-dev\ui\arkts-user-defined-arktsNode-builderNode.md
import { BuilderNode, NodeController, UIContext } from '@kit.ArkUI'; let localStorage1: LocalStorage = new LocalStorage(); localStorage1.setOrCreate('PropA', 'PropA'); let localStorage2: LocalStorage = new LocalStorage(); localStorage2.setOrCreate('PropB', 'PropB'); @Entry(localStorage1) @Component struct Index { ...
application-dev\ui\arkts-user-defined-arktsNode-frameNode.md
import { BuilderNode, FrameNode, NodeController, UIContext } from '@kit.ArkUI'; import { BusinessError } from '@kit.BasicServicesKit'; const TEST_TAG: string = "FrameNode" class Params { text: string = "this is a text" } @Builder function buttonBuilder(params: Params) { Column({ space: 10 }) { Button(params....
application-dev\ui\arkts-user-defined-arktsNode-frameNode.md
import { BuilderNode, FrameNode, NodeController, UIContext } from '@kit.ArkUI' class Params { text: string = "this is a text" } @Builder function buttonBuilder(params: Params) { Button(params.text) .fontSize(12) .borderRadius(8) .borderWidth(2) .backgroundColor(Color.Orange) .onClick((event: C...
application-dev\ui\arkts-user-defined-arktsNode-frameNode.md
import { DrawContext, FrameNode, NodeController, Position, Size, UIContext, LayoutConstraint } from '@kit.ArkUI'; import { drawing } from '@kit.ArkGraphics2D'; function GetChildLayoutConstraint(constraint: LayoutConstraint, child: FrameNode): LayoutConstraint { const size = child.getUserConfigSize(); const width =...
application-dev\ui\arkts-user-defined-arktsNode-frameNode.md
import { NodeController, FrameNode, UIContext } from '@kit.ArkUI'; const TEST_TAG: string = "FrameNode" class MyNodeController extends NodeController { public frameNode: FrameNode | null = null; private rootNode: FrameNode | null = null; makeNode(uiContext: UIContext): FrameNode | null { this.rootNode = ne...
application-dev\ui\arkts-user-defined-arktsNode-frameNode.md
import { NodeController, FrameNode, UIContext, BuilderNode, typeNode } from '@kit.ArkUI'; class Params { text: string = ""; constructor(text: string) { this.text = text; } } @Builder function buildText(params: Params) { Column() { Text(params.text) .id("buildText") .border({ width: 1 }) ...
application-dev\ui\arkts-user-defined-arktsNode-frameNode.md
import { NodeController, FrameNode, BuilderNode } from '@kit.ArkUI'; const TEST_TAG: string = "FrameNode"; @Component struct TestComponent { build() { Column() { Text('This is a BuilderNode.') .fontSize(16) .fontWeight(FontWeight.Bold) } .width('100%') .backgroundColor(Color.Gr...
application-dev\ui\arkts-user-defined-arktsNode-frameNode.md
import { FrameNode, NodeController, NodeAdapter, typeNode } from '@kit.ArkUI'; const TEST_TAG: string = "FrameNode"; class MyNodeAdapter extends NodeAdapter { uiContext: UIContext cachePool: Array<FrameNode> = new Array(); changed: boolean = false reloadTimes: number = 0; data: Array<string> = new Array(); ...
application-dev\ui\arkts-user-defined-arktsNode-renderNode.md
import { FrameNode, NodeController, RenderNode } from '@kit.ArkUI'; const TEST_TAG: string = "RenderNode"; const renderNode = new RenderNode(); renderNode.frame = { x: 0, y: 0, width: 200, height: 350 }; renderNode.backgroundColor = 0xffff0000; for (let i = 0; i < 5; i++) { const node = new RenderNode(); /...
application-dev\ui\arkts-user-defined-arktsNode-renderNode.md
import { RenderNode, FrameNode, NodeController, ShapeMask, ShapeClip } from '@kit.ArkUI'; const TEST_TAG: string = "RenderNode"; const mask = new ShapeMask(); mask.setRectShape({ left: 0, right: 150, top: 0, bottom: 150 }); mask.fillColor = 0X55FF0000; mask.strokeColor = 0XFFFF0000; mask.strokeWidth = 24; con...
application-dev\ui\arkts-user-defined-arktsNode-renderNode.md
import { FrameNode, NodeController, RenderNode } from '@kit.ArkUI'; import { drawing } from '@kit.ArkGraphics2D'; class MyRenderNode extends RenderNode { width: number = 200; draw(context: DrawContext) { // Obtain the canvas object. const canvas = context.canvas; // Create a brush. const brush = n...
application-dev\ui\arkts-user-defined-arktsNode-renderNode.md
import { DrawContext } from '@kit.ArkUI' export const nativeOnDraw: (id: number, context: DrawContext, width: number, height: number) => number;
application-dev\ui\arkts-user-defined-arktsNode-renderNode.md
// Index.ets import bridge from "libentry.so" // This .so file is written and generated by Node-API. import { DrawContext, FrameNode, NodeController, RenderNode } from '@kit.ArkUI' class MyRenderNode extends RenderNode { draw(context: DrawContext) { // The width and height in the context need to be converted fro...
application-dev\ui\arkts-user-defined-arktsNode-renderNode.md
import { RenderNode, FrameNode, NodeController, UIContext } from '@kit.ArkUI'; class MyNodeController extends NodeController { private rootNode: FrameNode | null = null; makeNode(uiContext: UIContext): FrameNode | null { this.rootNode = new FrameNode(uiContext); const renderNode: RenderNode | null = this...
application-dev\ui\arkts-user-defined-extension-attributeModifier.md
declare interface AttributeModifier<T> { applyNormalAttribute?(instance: T): void; applyPressedAttribute?(instance: T): void; applyFocusedAttribute?(instance: T): void; applyDisabledAttribute?(instance: T): void; applySelectedAttribute?(instance: T): void; }
application-dev\ui\arkts-user-defined-extension-attributeModifier.md
declare class CommonMethod<T> { attributeModifier(modifier: AttributeModifier<T>): T; }
application-dev\ui\arkts-user-defined-extension-attributeModifier.md
// button_modifier.ets export class MyButtonModifier implements AttributeModifier<ButtonAttribute> { // A private member variable that can be dynamically modified externally isDark: boolean = false // The constructor allows for parameter passing when creating an instance. constructor(dark?: boolean) ...
application-dev\ui\arkts-user-defined-extension-attributeModifier.md
// demo.ets import { MyButtonModifier } from './button_modifier' @Entry @Component struct attributeDemo { // The modifier is decorated with @State, with behavior consistent with that of a regular object. @State modifier: MyButtonModifier = new MyButtonModifier(true); build() { Row() { ...
application-dev\ui\arkts-user-defined-extension-attributeModifier.md
// button_modifier.ets export class MyButtonModifier implements AttributeModifier<ButtonAttribute> { isDark: boolean = false constructor(dark?: boolean) { this.isDark = dark ? dark : false } applyNormalAttribute(instance: ButtonAttribute): void { if (this.isDark) { instance.backg...
application-dev\ui\arkts-user-defined-extension-attributeModifier.md
// demo.ets import { MyButtonModifier } from './button_modifier'; @Entry @Component struct attributeDemo { @State modifier: MyButtonModifier = new MyButtonModifier(true); build() { Row() { Column() { // As the attribute is set before the modifier, the button's color changes in ...
application-dev\ui\arkts-user-defined-extension-attributeModifier.md
// button_modifier.ets export class MyButtonModifier implements AttributeModifier<ButtonAttribute> { isDark: boolean = false constructor(dark?: boolean) { this.isDark = dark ? dark : false } applyNormalAttribute(instance: ButtonAttribute): void { if (this.isDark) { instance.backg...
application-dev\ui\arkts-user-defined-extension-attributeModifier.md
// button_modifier2.ets export class MyButtonModifier2 implements AttributeModifier<ButtonAttribute> { isDark2: boolean = false constructor(dark?: boolean) { this.isDark2 = dark ? dark : false } applyNormalAttribute(instance: ButtonAttribute): void { if (this.isDark2) { instance....
application-dev\ui\arkts-user-defined-extension-attributeModifier.md
// demo.ets import { MyButtonModifier } from './button_modifier'; import { MyButtonModifier2 } from './button_modifier2'; @Entry @Component struct attributeDemo { @State modifier: MyButtonModifier = new MyButtonModifier(true); @State modifier2: MyButtonModifier2 = new MyButtonModifier2(true); bu...
application-dev\ui\arkts-user-defined-extension-attributeModifier.md
// button_modifier.ets export class MyButtonModifier implements AttributeModifier<ButtonAttribute> { applyNormalAttribute(instance: ButtonAttribute): void { // instance is the attribute object for the Button, used to set attributes for the normal state. instance.backgroundColor('#17A98D') .bor...
application-dev\ui\arkts-user-defined-extension-attributeModifier.md
// demo.ets import { MyButtonModifier } from './button_modifier' @Entry @Component struct attributeDemo { @State modifier: MyButtonModifier = new MyButtonModifier(); build() { Row() { Column() { Button("Button") .attributeModifier(this.modifier) } .w...
application-dev\ui\arkts-user-defined-extension-attributeUpdater.md
export declare class AttributeUpdater<T, C = Initializer<T>> implements AttributeModifier<T> { applyNormalAttribute?(instance: T): void; initializeModifier(instance: T): void; get attribute(): T | undefined; updateConstructorParams: C; }
application-dev\ui\arkts-user-defined-extension-attributeUpdater.md
import { AttributeUpdater } from '@ohos.arkui.modifier' class MyButtonModifier extends AttributeUpdater<ButtonAttribute> { // The initializeModifier method is triggered upon the first binding, initializing the attributes. initializeModifier(instance: ButtonAttribute): void { instance.backgroundColor('#2787D9')...
application-dev\ui\arkts-user-defined-extension-attributeUpdater.md
import { AttributeUpdater } from '@ohos.arkui.modifier' class MyTextModifier extends AttributeUpdater<TextAttribute, TextInterface> { initializeModifier(instance: TextAttribute): void { } } @Entry @Component struct updaterDemo { modifier: MyTextModifier = new MyTextModifier() build() { Row() { Colu...
application-dev\ui\arkts-user-defined-place-holder.md
// common.ets import { BuilderNode, UIContext } from '@kit.ArkUI' class Params { text: string = "this is a text" } let buttonNode: BuilderNode<[Params]> | null = null; @Builder function buttonBuilder(params: Params) { Column() { Button(params.text) .fontSize(12) .borderRadius(8) .borderWidt...
application-dev\ui\arkts-user-defined-place-holder.md
// Index.ets import { FrameNode, NodeController, Size, UIContext } from '@kit.ArkUI' import { getOrCreateNode } from "./common" const TEST_TAG: string = "NodeContainer"; class MyNodeController extends NodeController { private isShow: boolean = false; constructor(isShow: boolean) { super(); this.isShow = ...
application-dev\ui\arkts-user-defined-place-holder.md
import { FrameNode, NodeContent, NodeController, typeNode, UIContext } from '@kit.ArkUI'; class NodeContentCtrl { content: NodeContent textNode: Array<typeNode.Text> = new Array(); uiContext: UIContext width: number constructor(uiContext: UIContext) { this.content = new NodeContent() this.uiContext ...
application-dev\ui\arkui-support-for-aging-adaptation.md
import { abilityManager, Configuration } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; @Entry @Component struct SideBarContainerExample { @State currentFontSizeScale: number = 1 normalIcon: Resource = $r("app.media.icon") selectedIcon: Resource = $r("app.media.icon") @State arr...
application-dev\ui\arkui-support-for-aging-adaptation.md
import { abilityManager, Configuration } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; @Entry @Component struct TextPickerExample { private select: number | number[] = 0; private cascade: TextCascadePickerRangeContent[] = [ { text: 'Category 1', children: [{ text: '...