• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2* Copyright (C) 2024 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 * @file Provides an advanced struct of tabs for atomic services
18 * @kit ArkUI
19 */
20
21/**
22 * Defines AtomicServiceTabs.
23 *
24 * @struct AtomicServiceTabs
25 * @syscap SystemCapability.ArkUI.ArkUI.Full
26 * @atomicservice
27 * @since 12
28 */
29@Component
30export declare struct AtomicServiceTabs {
31  /**
32   * The TabContent array of tabs.
33   *
34   * @type { ?[TabContentBuilder?, TabContentBuilder?, TabContentBuilder?, TabContentBuilder?, TabContentBuilder?] }.
35   * @syscap SystemCapability.ArkUI.ArkUI.Full
36   * @atomicservice
37   * @since 12
38   */
39  @BuilderParam
40  tabContents?: [
41    TabContentBuilder?,
42    TabContentBuilder?,
43    TabContentBuilder?,
44    TabContentBuilder?,
45    TabContentBuilder?
46  ];
47  /**
48   * The tabBar array of tabs.
49   *
50   * @type { [TabBarOptions, TabBarOptions, TabBarOptions?, TabBarOptions?, TabBarOptions?] }.
51   * @syscap SystemCapability.ArkUI.ArkUI.Full
52   * @atomicservice
53   * @since 12
54   */
55  @Prop
56  tabBarOptionsArray: [
57    TabBarOptions,
58    TabBarOptions,
59    TabBarOptions?,
60    TabBarOptions?,
61    TabBarOptions?
62  ];
63  /**
64   * set the positions of tabbar.
65   *
66   * @type { ?TabBarPosition }.
67   * @syscap SystemCapability.ArkUI.ArkUI.Full
68   * @atomicservice
69   * @since 12
70   */
71  @Prop
72  tabBarPosition?: TabBarPosition;
73  /**
74   * Sets the barBackgroundColor of tabs.
75   *
76   * @type { ?ResourceColor }.
77   * @syscap SystemCapability.ArkUI.ArkUI.Full
78   * @atomicservice
79   * @since 12
80   */
81  @Prop
82  barBackgroundColor?: ResourceColor;
83  /**
84   * Sets the index of tabs.
85   *
86   * @type { ?number }.
87   * @syscap SystemCapability.ArkUI.ArkUI.Full
88   * @atomicservice
89   * @since 12
90   */
91  @Prop
92  index?: number;
93  /**
94   * set if need overlap, default value is true.
95   *
96   * @type { ?boolean }.
97   * @syscap SystemCapability.ArkUI.ArkUI.Full
98   * @atomicservice
99   * @since 12
100   */
101  @Prop
102  barOverlap?: boolean;
103  /**
104   * Provide methods for switching tabs.
105   *
106   * @type { ?TabsController }.
107   * @syscap SystemCapability.ArkUI.ArkUI.Full
108   * @atomicservice
109   * @since 12
110   */
111  controller?: TabsController;
112  /**
113   * onChange callback of tabs when tabs changed.
114   *
115   * @type { ?Callback<number> }.
116   * @syscap SystemCapability.ArkUI.ArkUI.Full
117   * @atomicservice
118   * @since 12
119   */
120  onChange?: Callback<number>;
121  /**
122   * onTabBarClick callback of tabs when tabbar is clicked.
123   *
124   * @type { ?Callback<number> }.
125   * @syscap SystemCapability.ArkUI.ArkUI.Full
126   * @atomicservice
127   * @since 12
128   */
129  onTabBarClick?: Callback<number>;
130  /**
131   * onContentWillChange callback of tabs when tabbar is clicked.
132   *
133   * @type { ?OnContentWillChangeCallback }.
134   * @syscap SystemCapability.ArkUI.ArkUI.Full
135   * @atomicservice
136   * @since 12
137   */
138  onContentWillChange?: OnContentWillChangeCallback;
139}
140
141/**
142 * the class for TabBarOption
143 *
144 * @syscap SystemCapability.ArkUI.ArkUI.Full
145 * @atomicservice
146 * @since 12
147 */
148export declare class TabBarOptions {
149  /**
150   * constructor to init the tabbar including icon, text, unselectedColor and selectedColor.
151   *
152   * @param { (ResourceStr | TabBarSymbol) } - icon - cannot be empty
153   * @param { ResourceStr } text - cannot be empty
154   * @param { ?ResourceColor } - unselectedColor - the color of icon and text when tabbar is unselected
155   * @param { ?ResourceColor } - selectedColor - the color of icon and text when tabbar is selected
156   * @syscap SystemCapability.ArkUI.ArkUI.Full
157   * @atomicservice
158   * @since 12
159   **/
160  constructor(icon: ResourceStr | TabBarSymbol, text: ResourceStr,
161    unselectedColor?: ResourceColor, selectedColor?: ResourceColor);
162}
163
164/**
165 * the enum for TabBarOption.
166 *
167 * @enum { number }.
168 * @syscap SystemCapability.ArkUI.ArkUI.Full
169 * @atomicservice
170 * @since 12
171 */
172export declare enum TabBarPosition {
173
174  /**
175   * when the TabBarPosition set left,the tabs is located on the left of the tabs
176   *
177   * @syscap SystemCapability.ArkUI.ArkUI.Full
178   * @atomicservice
179   * @since 12
180   */
181  LEFT = 0,
182
183  /**
184   * when the TabBarPosition set bottom,the tabs is located on the bottom of the tabs
185   *
186   * @syscap SystemCapability.ArkUI.ArkUI.Full
187   * @atomicservice
188   * @since 12
189   */
190  BOTTOM = 1,
191}
192
193/**
194 * CustomBuilder for tabContent
195 *
196 * @typedef { function } TabContentBuilder
197 * @syscap SystemCapability.ArkUI.ArkUI.Full
198 * @atomicservice
199 * @since 12
200 */
201export type TabContentBuilder = () => void;
202
203/**
204 * Callback for OnContentWillChange
205 *
206 * @typedef { function } OnContentWillChange
207 * @param { number } currentIndex - the index value of the current tab.
208 * @param { number } comingIndex - the index value of the tab that will change.
209 * @returns { boolean }
210 * @syscap SystemCapability.ArkUI.ArkUI.Full
211 * @atomicservice
212 * @since 12
213 */
214export type OnContentWillChangeCallback = (currentIndex: number, comingIndex: number) => boolean;