• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development 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 */
15import { hilog } from '@kit.PerformanceAnalysisKit';
16import testNapi from 'libentry.so';
17
18import { NAPI_SAMPLE_CATEGORIES } from '../data/CollectionCategory'
19import { FirstLevelCategory } from '../model/CategoricalDataType'
20import { TabContentNavigation } from '../common/TabContentNavigation'
21
22@Entry
23@Component
24struct Index {
25  @State tabsIndex: number = 0
26
27  build() {
28    Tabs({ barPosition: BarPosition.End }) {
29      ForEach(NAPI_SAMPLE_CATEGORIES, (item: FirstLevelCategory, index: number) => {
30        TabContent() {
31          TabContentNavigation({ categories: item.childNodes })
32        }
33        .tabBar(this.TabBarBuilder(index, item.selectedImage, item.unselectedImage, item.tabBarName))
34      })
35    }
36    .barHeight(56)
37    .barWidth('100%')
38    .vertical(false)
39    .backgroundColor($r('app.color.background_shallow_grey'))
40    .onChange((index: number) => {
41      this.tabsIndex = index
42    })
43  }
44
45  @Builder TabBarBuilder(index: number, selectedImage: Resource, unselectedImage: Resource, tabBarName: Resource) {
46    Column() {
47      Image(this.tabsIndex === index ? selectedImage : unselectedImage)
48        .width(24)
49        .height(24)
50        .margin({ bottom: 4 })
51
52      Text(tabBarName)
53        .fontSize(10)
54        .fontFamily('HarmonyHeiTi-Medium')
55        .fontColor(this.tabsIndex === index ? $r('app.color.tab_bar_select') : $r('app.color.tab_bar_unselect'))
56    }
57    .width('100%')
58    .padding({ top: 6, bottom: 6 })
59    .alignItems(HorizontalAlign.Center)
60    .id(`tabBar${index}`)
61  }
62}
63