From 0a75b2606fe958037d138389f6967c448c974989 Mon Sep 17 00:00:00 2001 From: fanzhaonan Date: Sat, 8 Oct 2022 19:29:14 +0800 Subject: [PATCH 1/6] refactor navigation Signed-off-by: fanzhaonan --- .../component/ets/nav_destination.d.ts | 53 ++++++++ api/@internal/component/ets/nav_router.d.ts | 41 ++++++ api/@internal/component/ets/navigation.d.ts | 123 +++++++++++++++++- 3 files changed, 216 insertions(+), 1 deletion(-) create mode 100644 api/@internal/component/ets/nav_destination.d.ts create mode 100644 api/@internal/component/ets/nav_router.d.ts diff --git a/api/@internal/component/ets/nav_destination.d.ts b/api/@internal/component/ets/nav_destination.d.ts new file mode 100644 index 0000000000..9c4311a906 --- /dev/null +++ b/api/@internal/component/ets/nav_destination.d.ts @@ -0,0 +1,53 @@ +/* + * 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. + */ + +/** + * The construct function of NavDestination. + * @since 9 + */ + interface NavDestinationInterface { + /** + * constructor. + * @since 9 + */ + constructor(): NavDestinationAttribute; +} + +/** + * The attribute function of NavDestination + * @since 9 + */ +declare class NavDestinationAttribute extends CommonMethod { + /** + * Navigation title bar + * @since 9 + */ + title(value: string | CustomBuilder): NavDestinationAttribute; + + /** + * Hide navigation title bar + * @since 9 + */ + hideTitleBar(value: boolean): NavDestinationAttribute; + + /** + * Navigation title bar's menus + * @since 9 + */ + menus(value: Array | CustomBuilder): NavDestinationAttribute; +} + +declare const NavDestination: NavDestinationInterface; +declare const NavDestinationInstance: NavDestinationAttribute; diff --git a/api/@internal/component/ets/nav_router.d.ts b/api/@internal/component/ets/nav_router.d.ts new file mode 100644 index 0000000000..7fe7a308d6 --- /dev/null +++ b/api/@internal/component/ets/nav_router.d.ts @@ -0,0 +1,41 @@ +/* + * 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. + */ + +/** + * The construct function of NavRouter. + * @since 9 + */ +interface NavRouterInterface { + /** + * constructor. + * @since 9 + */ + constructor(): NavRouterAttribute; +} + +/** + * The attribute function of NavRouter + * @since 9 + */ +declare class NavRouterAttribute extends CommonMethod { + /** + * Trigger callback when NavigationView state change. + * @since 9 + */ + onStateChange(callback: (isActivated: boolean) => void): NavRouterAttribute; +} + +declare const NavRouter: NavRouterInterface; +declare const NavRouterInstance: NavRouterAttribute; diff --git a/api/@internal/component/ets/navigation.d.ts b/api/@internal/component/ets/navigation.d.ts index 420438d98b..e2d2ac9e6f 100644 --- a/api/@internal/component/ets/navigation.d.ts +++ b/api/@internal/component/ets/navigation.d.ts @@ -13,6 +13,57 @@ * limitations under the License. */ +/** + * Nativation mode + * @since 9 + */ + declare enum NavigationMode { + /** + * The navigation bar and the content area are displayed in stack. + * @since 9 + */ + Stack, + /** + * The navigation bar is displayed as an overlay above the content area. + * @since 9 + */ + Overlay, + /** + * The navigation bar and the content area are displayed side by side. + * @since 9 + */ + Split, + /** + * If the width of navigation component is less than the sum of minNavBarWidth and minContentWidth, + * the navigation component is displayed in stack mode. Otherwise it's displayed in split mode. + * @since 9 + */ + AutoStackSplit, + /** + * If the width of navigation component is less than the sum of minNavBarWidth and minContentWidth, + * the navigation component is displayed in overlay mode. Otherwise it's displayed in split mode. + * @since 9 + */ + AutoOverlaySplit, +} + +/** + * Navigation bar position + * @since 9 + */ + declare enum NavBarPosition { + /** + * The navigation bar is on the Start of the container + * @since 9 + */ + Start, + /** + * The navigation bar is on the End of the container + * @since 9 + */ + End, +} + /** * Naivagtion title mode. * @since 8 @@ -72,6 +123,70 @@ interface NavigationInterface { * @since 8 */ declare class NavigationAttribute extends CommonMethod { + /** + * Sets the width of navigation bar. + * @since 9 + */ + navBarWidth(value: Length): NavigationAttribute; + + /** + * Sets the minimum width of navigation bar. + * @since 9 + */ + minNavBarWidth(value: Length): NavigationAttribute; + + /** + * Sets the maximum width of navigation bar. + * @since 9 + */ + maxNavBarWidth(value: Length): NavigationAttribute; + + /** + * Sets the minimum width of content area. + * @since 9 + */ + minContentWidth(value: Length): NavigationAttribute; + + /** + * Sets the position of navigation bar. + * @since 9 + */ + navBarPosition(value: NavBarPosition): NavigationAttribute; + + /** + * Sets the mode of navigation. + * @since 9 + */ + mode(value: NavigationMode): NavigationAttribute; + + /** + * Sets the icon of button which controls navigation bar show or hide. + * @since 9 + */ + controlButtonIcon(value: { + shown: string | PixelMap | Resource; + hidden: string | PixelMap | Resource; + switching?: string | PixelMap | Resource; + }): NavigationAttribute; + + /** + * Sets the back button icon. + * @since 9 + */ + backButtonIcon(value: string | PixelMap | Resource): NavigationAttribute; + + /** + * Hide the button which controls the navigation bar show or hide. + * @since 9 + */ + hideControlButton(value: boolean): NavigationAttribute; + + /** + * Hide the navigation bar. + * @since 9 + */ + hideNavBar(value: boolean): NavigationAttribute; + /** * Navigation title * @since 8 @@ -85,7 +200,7 @@ declare class NavigationAttribute extends CommonMethod { subTitle(value: string): NavigationAttribute; /** - * Hide navigation bar + * Hide navigation title bar * @since 8 */ hideTitleBar(value: boolean): NavigationAttribute; @@ -125,6 +240,12 @@ declare class NavigationAttribute extends CommonMethod { * @since 8 */ onTitleModeChange(callback: (titleMode: NavigationTitleMode) => void): NavigationAttribute; + + /** + * Trigger callback when the visibility of navigation bar change in overlay or split mode. + * @since 9 + */ + onNavBarVisibilityChange(callback: (isVisible: boolean) => void): NavigationAttribute; } declare const Navigation: NavigationInterface; -- Gitee From 31b79bcc19db049c364c7a0723d8c39e9b6c9fa7 Mon Sep 17 00:00:00 2001 From: fanzhaonan Date: Sat, 8 Oct 2022 20:27:37 +0800 Subject: [PATCH 2/6] refactor navigation Signed-off-by: fanzhaonan --- .../component/ets/nav_destination.d.ts | 62 ++++++++++++++++--- api/@internal/component/ets/navigation.d.ts | 56 ++++++++++++++++- 2 files changed, 110 insertions(+), 8 deletions(-) diff --git a/api/@internal/component/ets/nav_destination.d.ts b/api/@internal/component/ets/nav_destination.d.ts index 9c4311a906..30df1c902f 100644 --- a/api/@internal/component/ets/nav_destination.d.ts +++ b/api/@internal/component/ets/nav_destination.d.ts @@ -13,6 +13,60 @@ * limitations under the License. */ +/** + * Navigation tile height. + * @since 9 + */ + declare enum TitleHeight { + /** + * Title height when only main title is avaliable. + * @since 9 + */ + MainOnly, + + /** + * Title height when main title and subtitle are both avaliable. + * @since 9 + */ + MainWithSub, +} + +/** + * Defines the navigation common title. + * @since 9 + */ + declare interface NavigatinCommonTitle { + /** + * Sets the main title. + * @since 9 + */ + main: string; + + /** + * Sets the sub title. + * @since 9 + */ + sub?: string; +} + +/** + * Defines the navigation custom title. + * @since 9 + */ + declare interface NavigatinCustomTitle { + /** + * Sets the custom title builder. + * @since 9 + */ + builder: string; + + /** + * Sets the custom title height. + * @since 9 + */ + height?: TitleHeight | Length; +} + /** * The construct function of NavDestination. * @since 9 @@ -34,19 +88,13 @@ declare class NavDestinationAttribute extends CommonMethod | CustomBuilder): NavDestinationAttribute; } declare const NavDestination: NavDestinationInterface; diff --git a/api/@internal/component/ets/navigation.d.ts b/api/@internal/component/ets/navigation.d.ts index e2d2ac9e6f..e749730607 100644 --- a/api/@internal/component/ets/navigation.d.ts +++ b/api/@internal/component/ets/navigation.d.ts @@ -13,6 +13,60 @@ * limitations under the License. */ +/** + * Navigation tile height. + * @since 9 + */ + declare enum TitleHeight { + /** + * Title height when only main title is avaliable. + * @since 9 + */ + MainOnly, + + /** + * Title height when main title and subtitle are both avaliable. + * @since 9 + */ + MainWithSub, +} + +/** + * Defines the navigation common title. + * @since 9 + */ + declare interface NavigatinCommonTitle { + /** + * Sets the main title. + * @since 9 + */ + main: string; + + /** + * Sets the sub title. + * @since 9 + */ + sub?: string; +} + +/** + * Defines the navigation custom title. + * @since 9 + */ + declare interface NavigatinCustomTitle { + /** + * Sets the custom title builder. + * @since 9 + */ + builder: string; + + /** + * Sets the custom title height. + * @since 9 + */ + height?: TitleHeight | Length; +} + /** * Nativation mode * @since 9 @@ -191,7 +245,7 @@ declare class NavigationAttribute extends CommonMethod { * Navigation title * @since 8 */ - title(value: string | CustomBuilder): NavigationAttribute; + title(value: string | CustomBuilder | NavigatinCommonTitle | NavigatinCustomTitle): NavigationAttribute; /** * Navigation subtitle -- Gitee From e6719277f5921f160f91ef57d1d6c92507b79a41 Mon Sep 17 00:00:00 2001 From: fanzhaonan Date: Sat, 8 Oct 2022 20:53:55 +0800 Subject: [PATCH 3/6] refactor navigation Signed-off-by: fanzhaonan --- api/@internal/component/ets/navigation.d.ts | 52 +++------------------ 1 file changed, 6 insertions(+), 46 deletions(-) diff --git a/api/@internal/component/ets/navigation.d.ts b/api/@internal/component/ets/navigation.d.ts index e749730607..da44ede3ec 100644 --- a/api/@internal/component/ets/navigation.d.ts +++ b/api/@internal/component/ets/navigation.d.ts @@ -88,17 +88,11 @@ */ Split, /** - * If the width of navigation component is less than the sum of minNavBarWidth and minContentWidth, - * the navigation component is displayed in stack mode. Otherwise it's displayed in split mode. + * If the window width is greater than 520vp, the navigation component is displayed in split mode. + * Otherwise it's displayed in stack mode. * @since 9 */ - AutoStackSplit, - /** - * If the width of navigation component is less than the sum of minNavBarWidth and minContentWidth, - * the navigation component is displayed in overlay mode. Otherwise it's displayed in split mode. - * @since 9 - */ - AutoOverlaySplit, + Auto, } /** @@ -183,24 +177,6 @@ declare class NavigationAttribute extends CommonMethod { */ navBarWidth(value: Length): NavigationAttribute; - /** - * Sets the minimum width of navigation bar. - * @since 9 - */ - minNavBarWidth(value: Length): NavigationAttribute; - - /** - * Sets the maximum width of navigation bar. - * @since 9 - */ - maxNavBarWidth(value: Length): NavigationAttribute; - - /** - * Sets the minimum width of content area. - * @since 9 - */ - minContentWidth(value: Length): NavigationAttribute; - /** * Sets the position of navigation bar. * @since 9 @@ -213,33 +189,17 @@ declare class NavigationAttribute extends CommonMethod { */ mode(value: NavigationMode): NavigationAttribute; - /** - * Sets the icon of button which controls navigation bar show or hide. - * @since 9 - */ - controlButtonIcon(value: { - shown: string | PixelMap | Resource; - hidden: string | PixelMap | Resource; - switching?: string | PixelMap | Resource; - }): NavigationAttribute; - /** * Sets the back button icon. * @since 9 */ backButtonIcon(value: string | PixelMap | Resource): NavigationAttribute; - /** - * Hide the button which controls the navigation bar show or hide. - * @since 9 - */ - hideControlButton(value: boolean): NavigationAttribute; - /** * Hide the navigation bar. * @since 9 */ - hideNavBar(value: boolean): NavigationAttribute; + hideNavBar(value: boolean): NavigationAttribute; /** * Navigation title @@ -296,10 +256,10 @@ declare class NavigationAttribute extends CommonMethod { onTitleModeChange(callback: (titleMode: NavigationTitleMode) => void): NavigationAttribute; /** - * Trigger callback when the visibility of navigation bar change in overlay or split mode. + * Trigger callback when the visibility of navigation bar change. * @since 9 */ - onNavBarVisibilityChange(callback: (isVisible: boolean) => void): NavigationAttribute; + onNavBarStateChange(callback: (isVisible: boolean) => void): NavigationAttribute; } declare const Navigation: NavigationInterface; -- Gitee From f13f96d8c137f5ab955e11aafcb7eb54ac426fa8 Mon Sep 17 00:00:00 2001 From: fanzhaonan Date: Sat, 8 Oct 2022 20:59:26 +0800 Subject: [PATCH 4/6] refactor navigation Signed-off-by: fanzhaonan --- api/@internal/component/ets/navigation.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/api/@internal/component/ets/navigation.d.ts b/api/@internal/component/ets/navigation.d.ts index da44ede3ec..9527e583b1 100644 --- a/api/@internal/component/ets/navigation.d.ts +++ b/api/@internal/component/ets/navigation.d.ts @@ -210,6 +210,7 @@ declare class NavigationAttribute extends CommonMethod { /** * Navigation subtitle * @since 8 + * @deprecated since 9 */ subTitle(value: string): NavigationAttribute; -- Gitee From 3576c0c9b197a6ac71a95a3b7cb20fff5688afb1 Mon Sep 17 00:00:00 2001 From: fanzhaonan Date: Sun, 9 Oct 2022 09:55:48 +0800 Subject: [PATCH 5/6] refactor navigation Signed-off-by: fanzhaonan --- api/@internal/component/ets/enums.d.ts | 18 ++++++++++++ .../component/ets/nav_destination.d.ts | 28 ++++--------------- api/@internal/component/ets/navigation.d.ts | 24 ++-------------- 3 files changed, 26 insertions(+), 44 deletions(-) diff --git a/api/@internal/component/ets/enums.d.ts b/api/@internal/component/ets/enums.d.ts index b77938feff..948f60397c 100644 --- a/api/@internal/component/ets/enums.d.ts +++ b/api/@internal/component/ets/enums.d.ts @@ -1503,4 +1503,22 @@ declare enum CopyOptions { * @since 9 */ None, +} + +/** + * Title height. + * @since 9 + */ + declare enum TitleHeight { + /** + * Title height when only main title is avaliable. + * @since 9 + */ + MainOnly, + + /** + * Title height when main title and subtitle are both avaliable. + * @since 9 + */ + MainWithSub, } \ No newline at end of file diff --git a/api/@internal/component/ets/nav_destination.d.ts b/api/@internal/component/ets/nav_destination.d.ts index 30df1c902f..a0eff3f3ae 100644 --- a/api/@internal/component/ets/nav_destination.d.ts +++ b/api/@internal/component/ets/nav_destination.d.ts @@ -14,28 +14,10 @@ */ /** - * Navigation tile height. + * Defines the navigation destination common title. * @since 9 */ - declare enum TitleHeight { - /** - * Title height when only main title is avaliable. - * @since 9 - */ - MainOnly, - - /** - * Title height when main title and subtitle are both avaliable. - * @since 9 - */ - MainWithSub, -} - -/** - * Defines the navigation common title. - * @since 9 - */ - declare interface NavigatinCommonTitle { + declare interface NavDestinationCommonTitle { /** * Sets the main title. * @since 9 @@ -50,10 +32,10 @@ } /** - * Defines the navigation custom title. + * Defines the navigation destination custom title. * @since 9 */ - declare interface NavigatinCustomTitle { + declare interface NavDestinationCustomTitle { /** * Sets the custom title builder. * @since 9 @@ -88,7 +70,7 @@ declare class NavDestinationAttribute extends CommonMethod { * Navigation title * @since 8 */ - title(value: string | CustomBuilder | NavigatinCommonTitle | NavigatinCustomTitle): NavigationAttribute; + title(value: string | CustomBuilder | NavigationCommonTitle | NavigationCustomTitle): NavigationAttribute; /** * Navigation subtitle -- Gitee From 795e62f31348df631909447d03e96e07d19998af Mon Sep 17 00:00:00 2001 From: fanzhaonan Date: Sun, 9 Oct 2022 10:08:36 +0800 Subject: [PATCH 6/6] refactor navigation Signed-off-by: fanzhaonan --- api/@internal/component/ets/nav_destination.d.ts | 6 +++--- api/@internal/component/ets/navigation.d.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/@internal/component/ets/nav_destination.d.ts b/api/@internal/component/ets/nav_destination.d.ts index a0eff3f3ae..188758d47e 100644 --- a/api/@internal/component/ets/nav_destination.d.ts +++ b/api/@internal/component/ets/nav_destination.d.ts @@ -28,7 +28,7 @@ * Sets the sub title. * @since 9 */ - sub?: string; + sub: string; } /** @@ -46,7 +46,7 @@ * Sets the custom title height. * @since 9 */ - height?: TitleHeight | Length; + height: TitleHeight | Length; } /** @@ -70,7 +70,7 @@ declare class NavDestinationAttribute extends CommonMethod