From 3ef2c6d1f7a6173c0a19a23b9fb21c49ddaa5a98 Mon Sep 17 00:00:00 2001 From: yangzk Date: Wed, 18 May 2022 10:24:15 +0800 Subject: [PATCH] add api for dynamic forms Signed-off-by: yangzk Change-Id: I9e9489d314e74261ab43d6f69d4227cb419bedd7 --- api/@ohos.application.formInfo.d.ts | 158 +++++++++++++++++++++--- api/@ohos.application.formProvider.d.ts | 42 +++++++ 2 files changed, 181 insertions(+), 19 deletions(-) diff --git a/api/@ohos.application.formInfo.d.ts b/api/@ohos.application.formInfo.d.ts index b7b33bb4a2..666d61795c 100644 --- a/api/@ohos.application.formInfo.d.ts +++ b/api/@ohos.application.formInfo.d.ts @@ -32,7 +32,7 @@ declare namespace formInfo { */ interface FormInfo { /** - * Obtains the bundle name of the application to which this form belongs. + * Indicates the bundle name of the application to which this form belongs. * * @since 8 * @syscap SystemCapability.Ability.Form @@ -40,7 +40,15 @@ declare namespace formInfo { bundleName: string; /** - * Obtains the name of the application module to which this form belongs. + * Indicates the bundle name of the application to which this form belongs. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + */ + bundleName?: string; + + /** + * Indicates the name of the application module to which this form belongs. * * @since 8 * @syscap SystemCapability.Ability.Form @@ -48,7 +56,7 @@ declare namespace formInfo { moduleName: string; /** - * Obtains the class name of the ability to which this form belongs. + * Indicates the class name of the ability to which this form belongs. * * @since 8 * @syscap SystemCapability.Ability.Form @@ -56,7 +64,7 @@ declare namespace formInfo { abilityName: string; /** - * Obtains the name of this form. + * Indicates the name of this form. * * @since 8 * @syscap SystemCapability.Ability.Form @@ -64,7 +72,7 @@ declare namespace formInfo { name: string; /** - * Obtains the name of this form. + * Indicates the description of this form. * * @since 8 * @syscap SystemCapability.Ability.Form @@ -72,7 +80,15 @@ declare namespace formInfo { description: string; /** - * Obtains the type of this form. Currently, JS forms are supported. + * Indicates the description of this form. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + */ + description?: string; + + /** + * Indicates the type of this form. Currently, JS forms are supported. * * @since 8 * @syscap SystemCapability.Ability.Form @@ -80,7 +96,7 @@ declare namespace formInfo { type: FormType; /** - * Obtains the JS component name of this JS form. + * Indicates the JS component name of this JS form. * * @since 8 * @syscap SystemCapability.Ability.Form @@ -88,7 +104,15 @@ declare namespace formInfo { jsComponentName: string; /** - * Obtains the color mode of this form. + * Indicates the JS component name of this JS form. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + */ + jsComponentName?: string; + + /** + * Indicates the color mode of this form. * * @since 8 * @syscap SystemCapability.Ability.Form @@ -96,7 +120,15 @@ declare namespace formInfo { colorMode: ColorMode; /** - * Checks whether this form is a default form. + * Indicates the color mode of this form. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + */ + colorMode?: ColorMode; + + /** + * Indicates whether this form is default. * * @since 8 * @syscap SystemCapability.Ability.Form @@ -104,7 +136,7 @@ declare namespace formInfo { isDefault: boolean; /** - * Obtains the updateEnabled. + * Indicates whether this form supports scheduled refresh. * * @since 8 * @syscap SystemCapability.Ability.Form @@ -112,7 +144,7 @@ declare namespace formInfo { updateEnabled: boolean; /** - * Obtains whether notify visible of this form. + * Indicates whether this form is allowed to use visibility notifications. * * @since 8 * @syscap SystemCapability.Ability.Form @@ -120,7 +152,15 @@ declare namespace formInfo { formVisibleNotify: boolean; /** - * Obtains the bundle relatedBundleName of the application to which this form belongs. + * Indicates whether this form is allowed to use visibility notifications. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + */ + formVisibleNotify?: boolean; + + /** + * Indicates the bundle relatedBundleName of the application to which this form belongs. * * @since 8 * @syscap SystemCapability.Ability.Form @@ -128,7 +168,15 @@ declare namespace formInfo { relatedBundleName: string; /** - * Obtains the scheduledUpdateTime. + * Indicates the bundle relatedBundleName of the application to which this form belongs. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + */ + relatedBundleName?: string; + + /** + * Indicates the time when this form is refreshed at a fixed time. * * @since 8 * @syscap SystemCapability.Ability.Form @@ -136,7 +184,15 @@ declare namespace formInfo { scheduledUpdateTime: string; /** - * Obtains the form config ability about this form. + * Indicates the time when this form is refreshed at a fixed time. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + */ + scheduledUpdateTime?: string; + + /** + * Indicates the name of the ability for form adjustment. * * @since 8 * @syscap SystemCapability.Ability.Form @@ -144,7 +200,15 @@ declare namespace formInfo { formConfigAbility: string; /** - * Obtains the updateDuration. + * Indicates the name of the ability for form adjustment. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + */ + formConfigAbility?: string; + + /** + * Indicates the update frequency of this form. * * @since 8 * @syscap SystemCapability.Ability.Form @@ -152,7 +216,15 @@ declare namespace formInfo { updateDuration: number; /** - * Obtains the default grid style of this form. + * Indicates the update frequency of this form. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + */ + updateDuration?: number; + + /** + * Indicates the default grid style of this form. * * @since 8 * @syscap SystemCapability.Ability.Form @@ -160,7 +232,7 @@ declare namespace formInfo { defaultDimension: number; /** - * Obtains the grid styles supported by this form. + * Indicates the grid styles supported by this form. * * @since 8 * @syscap SystemCapability.Ability.Form @@ -168,12 +240,36 @@ declare namespace formInfo { supportDimensions: Array; /** - * Obtains the custom data defined in this form. + * Indicates the custom data defined in this form. * * @since 8 * @syscap SystemCapability.Ability.Form */ customizeData: {[key: string]: [value: string]}; + + /** + * Indicates the custom data defined in this form. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + */ + customizeData?: {[key: string]: [value: string]}; + + /** + * Indicates the window-related configurations for this form. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + */ + window?: Window; + + /** + * Indicates whether this form is static. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + */ + isStatic?: boolean; } /** @@ -182,7 +278,7 @@ declare namespace formInfo { * @name FormType * @since 8 * @syscap SystemCapability.Ability.Form - */ + */ enum FormType { /** * JS form. @@ -226,6 +322,30 @@ declare namespace formInfo { MODE_LIGHT = 1 } + /** + * Window-related configurations. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + */ + interface Window { + /** + * Indicates the baseline width for form design, in pixels. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + */ + designWidth?: number; + + /** + * Whether to automatically calculate the baseline width for form design. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + */ + autoDesignWidth?: boolean; + } + /** * Provides state information about a form. * diff --git a/api/@ohos.application.formProvider.d.ts b/api/@ohos.application.formProvider.d.ts index 22390cf910..cf5dc7ffdd 100644 --- a/api/@ohos.application.formProvider.d.ts +++ b/api/@ohos.application.formProvider.d.ts @@ -15,6 +15,8 @@ import { AsyncCallback } from "./basic"; import formBindingData from "./@ohos.application.formBindingData"; +import formInfo from "./@ohos.application.formInfo"; +import Want from './@ohos.application.Want'; /** * interface of formProvider. @@ -50,5 +52,45 @@ declare namespace formProvider { function updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback): void; function updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise; + + /** + * Request to publish a form to the form host. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + * @param want The want of the form to publish + * @param formBindingData Indicates the form data + * @systemapi hide for inner use. + * @return Returns form id + */ + function requestPublishForm(want: Want, callback: AsyncCallback): void; + function requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, + callback: AsyncCallback): void; + function requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData): Promise; + + /** + * Add the form info. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + * @param formInfo Indicates the form info to be added + * @systemapi hide for inner use. + * @return - + */ + function addFormInfo(formInfo: formInfo.FormInfo, callback: AsyncCallback); + function addFormInfo(formInfo: formInfo.FormInfo): Promise; + + /** + * Remove the specified form info. + * + * @since 9 + * @syscap SystemCapability.Ability.Form + * @param moduleName Indicates the module name of the dynamic form info to be removed + * @param formName Indicates the form name of the dynamic form info to be removed + * @systemapi hide for inner use. + * @return - + */ + function removeFormInfo(moduleName: string, formName: string, callback: AsyncCallback); + function removeFormInfo(moduleName: string, formName: string): Promise; } export default formProvider; \ No newline at end of file -- Gitee