1/* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * Defines the navigation common title. 18 * @since 9 19 */ 20declare interface NavigationCommonTitle { 21 /** 22 * Sets the main title. 23 * @since 9 24 */ 25 main: string; 26 27 /** 28 * Sets the sub title. 29 * @since 9 30 */ 31 sub: string; 32} 33 34/** 35 * Defines the navigation custom title. 36 * @since 9 37 */ 38declare interface NavigationCustomTitle { 39 /** 40 * Sets the custom title builder. 41 * @since 9 42 */ 43 builder: CustomBuilder; 44 45 /** 46 * Sets the custom title height. 47 * @since 9 48 */ 49 height: TitleHeight | Length; 50} 51 52/** 53 * Navigation mode 54 * @since 9 55 */ 56declare enum NavigationMode { 57 /** 58 * The navigation bar and the content area are displayed in stack. 59 * @since 9 60 */ 61 Stack, 62 /** 63 * The navigation bar and the content area are displayed side by side. 64 * @since 9 65 */ 66 Split, 67 /** 68 * If the window width is greater than 520vp, the navigation component is displayed in split mode. 69 * Otherwise it's displayed in stack mode. 70 * @since 9 71 */ 72 Auto, 73} 74 75/** 76 * Navigation bar position 77 * @since 9 78 */ 79declare enum NavBarPosition { 80 /** 81 * The navigation bar is on the Start of the container 82 * @since 9 83 */ 84 Start, 85 /** 86 * The navigation bar is on the End of the container 87 * @since 9 88 */ 89 End, 90} 91 92/** 93 * Navigation title mode. 94 * @since 8 95 */ 96declare enum NavigationTitleMode { 97 /** 98 * The title is free mode. 99 * @since 8 100 */ 101 Free = 0, 102 103 /** 104 * The title is full mode. 105 * @since 8 106 */ 107 Full, 108 109 /** 110 * The title is mini mode. 111 * @since 8 112 */ 113 Mini, 114} 115 116declare interface NavigationMenuItem { 117 /** 118 * The value of navigation menu item. 119 * @since 8 120 */ 121 value: string; 122 /** 123 * The icon of navigation menu item. 124 * @since 8 125 */ 126 icon?: string; 127 /** 128 * Trigger by navigation menu item click. 129 * @since 8 130 */ 131 action?: () => void; 132} 133 134/** 135 * Provide navigator view interface 136 * @since 8 137 */ 138interface NavigationInterface { 139 /** 140 * Called when the navigator view interface is used. 141 * @since 8 142 */ 143 (): NavigationAttribute; 144} 145 146/** 147 * Declare Navigation view properties. 148 * @since 8 149 */ 150declare class NavigationAttribute extends CommonMethod<NavigationAttribute> { 151 /** 152 * Sets the width of navigation bar. 153 * @since 9 154 */ 155 navBarWidth(value: Length): NavigationAttribute; 156 157 /** 158 * Sets the position of navigation bar. 159 * @since 9 160 */ 161 navBarPosition(value: NavBarPosition): NavigationAttribute; 162 163 /** 164 * Sets the mode of navigation. 165 * @since 9 166 */ 167 mode(value: NavigationMode): NavigationAttribute; 168 169 /** 170 * Sets the back button icon. 171 * @since 9 172 */ 173 backButtonIcon(value: string | PixelMap | Resource): NavigationAttribute; 174 175 /** 176 * Hide the navigation bar. 177 * @since 9 178 */ 179 hideNavBar(value: boolean): NavigationAttribute; 180 181 /** 182 * Navigation title 183 * @type { (string | CustomBuilder) } 184 * @since 8 185 */ 186 /** 187 * Navigation title 188 * @type { (string | CustomBuilder | NavigationCommonTitle | NavigationCustomTitle) } 189 * @since 9 190 */ 191 title(value: string | CustomBuilder | NavigationCommonTitle | NavigationCustomTitle): NavigationAttribute; 192 193 /** 194 * Navigation subtitle 195 * @since 8 196 * @deprecated since 9 197 * @useinstead title 198 */ 199 subTitle(value: string): NavigationAttribute; 200 201 /** 202 * Hide navigation title bar 203 * @since 8 204 */ 205 hideTitleBar(value: boolean): NavigationAttribute; 206 207 /** 208 * Hide navigation back button 209 * @since 8 210 */ 211 hideBackButton(value: boolean): NavigationAttribute; 212 213 /** 214 * Navigation title mode 215 * @since 8 216 */ 217 titleMode(value: NavigationTitleMode): NavigationAttribute; 218 219 /** 220 * Navigation title bar's menus 221 * @since 8 222 */ 223 menus(value: Array<NavigationMenuItem> | CustomBuilder): NavigationAttribute; 224 225 /** 226 * Tool bar 227 * @since 8 228 */ 229 toolBar(value: object | CustomBuilder): NavigationAttribute; 230 231 /** 232 * Hide tool bar 233 * @since 8 234 */ 235 hideToolBar(value: boolean): NavigationAttribute; 236 237 /** 238 * Trigger callback when title mode change finished at free mode. 239 * @since 8 240 */ 241 onTitleModeChange(callback: (titleMode: NavigationTitleMode) => void): NavigationAttribute; 242 243 /** 244 * Trigger callback when the visibility of navigation bar change. 245 * @since 9 246 */ 247 onNavBarStateChange(callback: (isVisible: boolean) => void): NavigationAttribute; 248} 249 250/** 251 * Defines Navigation Component. 252 * @since 8 253 */ 254declare const Navigation: NavigationInterface; 255 256/** 257 * Defines Navigation Component instance. 258 * @since 8 259 */ 260declare const NavigationInstance: NavigationAttribute; 261