From 33f9b9b3a3e78f9050f96314c1c8f3ccdb4485fc Mon Sep 17 00:00:00 2001 From: niulihua Date: Thu, 21 Jul 2022 17:11:45 +0800 Subject: [PATCH 1/2] add list_item_group api Signed-off-by: niulihua Change-Id: Ie104aae3e9ac9d4a947b8406e078ac0bef31ffe2 --- BUILD.gn | 1 + api/@internal/component/ets/list.d.ts | 30 ++++++++ .../component/ets/list_item_group.d.ts | 76 +++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 api/@internal/component/ets/list_item_group.d.ts diff --git a/BUILD.gn b/BUILD.gn index aee10d9f6c..312e85d520 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -72,6 +72,7 @@ ohos_copy("ets_component") { "api/@internal/component/ets/line.d.ts", "api/@internal/component/ets/list.d.ts", "api/@internal/component/ets/list_item.d.ts", + "api/@internal/component/ets/list_item_group.d.ts", "api/@internal/component/ets/loading_progress.d.ts", "api/@internal/component/ets/marquee.d.ts", "api/@internal/component/ets/navigation.d.ts", diff --git a/api/@internal/component/ets/list.d.ts b/api/@internal/component/ets/list.d.ts index 9d12aef340..61c3328277 100644 --- a/api/@internal/component/ets/list.d.ts +++ b/api/@internal/component/ets/list.d.ts @@ -61,6 +61,30 @@ declare enum ListItemAlign { End, } +/** + * Declare item group sticky style. + * @since 9 + */ + declare enum StickyStyle { + /** + * The header and footer of each item group will not be pinned. + * @since 9 + */ + None = 0, + + /** + * The header of each item group will be pinned. + * @since 9 + */ + Header = 1, + + /** + * The footer of each item group will be pinned. + * @since 9 + */ + Footer = 2, +} + /** * The list interface is extended. * @since 7 @@ -144,6 +168,12 @@ declare class ListAttribute extends CommonMethod { */ chainAnimation(value: boolean): ListAttribute; + /** + * Called when header or footer of item group will be pinned. + * @since 9 + */ + sticky(value: StickyStyle): ListAttribute; + /** * Called when the offset and status callback of the slide are set. * @since 7 diff --git a/api/@internal/component/ets/list_item_group.d.ts b/api/@internal/component/ets/list_item_group.d.ts new file mode 100644 index 0000000000..e86ba62c8d --- /dev/null +++ b/api/@internal/component/ets/list_item_group.d.ts @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Defines thd list item group options. + * @since 9 + */ +declare interface ListItemGroupOptions { + /** + * Describes the ListItemGroup header. + * @since 9 + */ + header?: CustomBuilder; + + /** + * Describes the ListItemGroup footer. + * @since 9 + */ + footer?: CustomBuilder; + + /** + * Describes the ListItemGroup space. + * @since 9 + */ + space?: number | string; +} + +/** + * Defines the ListItemGroup component + * @since 9 + */ +interface ListItemGroupInterface { + /** + * Called when interface is called. + * @since 9 + */ + (options?: ListItemGroupOptions): ListItemGroupAttribute; +} + +/** + * Defines the item group attibute functions. + * @since 9 + */ +declare class ListItemGroupAttribute extends CommonMethod { + /** + * Called when the ListItemGroup split line style is set. + * @since 9 + */ + divider( + value: { + strokeWidth: Length; + color?: ResourceColor; + startMargin?: Length; + endMargin?: Length; + } | null, + ): ListItemGroupAttribute; +} + +/** + * @since 9 + */ +declare const ListItemGroupInstance: ListItemGroupAttribute; +declare const ListItemGroup: ListItemGroupInterface; + \ No newline at end of file -- Gitee From b7825dfacf52aabd0e6879614e145d1b89f8e123 Mon Sep 17 00:00:00 2001 From: niulihua Date: Sat, 30 Jul 2022 19:46:50 +0800 Subject: [PATCH 2/2] add api for custom layout Signed-off-by: niulihua Change-Id: I3402b2f3900b3a5d67151472cad7aa157f9fb7bd --- BUILD.gn | 1 + api/@internal/component/ets/common.d.ts | 5 ++ api/@internal/component/ets/custom.d.ts | 81 +++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 api/@internal/component/ets/custom.d.ts diff --git a/BUILD.gn b/BUILD.gn index 312e85d520..53eda6fb16 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -73,6 +73,7 @@ ohos_copy("ets_component") { "api/@internal/component/ets/list.d.ts", "api/@internal/component/ets/list_item.d.ts", "api/@internal/component/ets/list_item_group.d.ts", + "api/@internal/component/ets/custom.d.ts", "api/@internal/component/ets/loading_progress.d.ts", "api/@internal/component/ets/marquee.d.ts", "api/@internal/component/ets/navigation.d.ts", diff --git a/api/@internal/component/ets/common.d.ts b/api/@internal/component/ets/common.d.ts index 70402c47b1..b1acaa8b26 100644 --- a/api/@internal/component/ets/common.d.ts +++ b/api/@internal/component/ets/common.d.ts @@ -133,6 +133,11 @@ declare const LocalStorageLink: (value: string) => PropertyDecorator; */ declare const LocalStorageProp: (value: string) => PropertyDecorator; +/** + * Defining Layout ClassDecorator * @since 9 + */ +declare const Layout: ClassDecorator; + /** * Get context. * @StageModelOnly diff --git a/api/@internal/component/ets/custom.d.ts b/api/@internal/component/ets/custom.d.ts new file mode 100644 index 0000000000..37063ce82a --- /dev/null +++ b/api/@internal/component/ets/custom.d.ts @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/** + * Defines the options of CustomController. + * @since 9 + */ +declare interface CustomControllerOptions { + /** + * Custom builder function. + * @since 9 + */ + builder: any; + + /** + * Defines horizontal space. + * @since 9 + */ + horizontalSpace?: number; + + /** + * Defines vertical space. + * @since 9 + */ + verticalSpace?: number; + + /** + * Defines the children. + * @since 9 + */ + children: () => void; +} + +/** + * Use the CustomController class to display the custom view. + * @since 9 + */ +declare class CustomController { + /** + * The constructor transfers parameter settings. + * @since 9 + */ + constructor(value: CustomControllerOptions); + + /** + * Custom Draw callback. + * @since 9 + */ + onDraw(value: CanvasAttribute); + + /** + * Custom Animation callback. + * @since 9 + */ + onAnimation(); + + /** + * Custom Mesure callback. + * @since 9 + */ + onMeasure(width: number, height: number); + + /** + * Custom Layout callback. + * @since 9 + */ + onLayout(width: number, height: number); +} \ No newline at end of file -- Gitee