94 lines
3.1 KiB
Plaintext
94 lines
3.1 KiB
Plaintext
import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
import { ArrayList } from '@kit.ArkTS';
|
|
import { AddFormMenuItem } from '@ohos.arkui.advanced.FormMenu';
|
|
import { SceneResourceType } from '@kit.ArkGraphics3D';
|
|
|
|
//导入布局模块
|
|
import {TitleData,TitleConfig,CAXModel} from '../LayoutData/TitleLayoutData'
|
|
import { BtnEvent } from '../LayoutData/TitleInterface'
|
|
import {TitleTabContent} from './TitleTabContent'
|
|
|
|
@Component
|
|
export struct TitleTab {
|
|
//顶部导航组件
|
|
private titleBarTabs: TabsController = new TabsController();
|
|
//当前的顶部导航选择页
|
|
@State titleBarFocusIndex: number = 1;
|
|
@State titleBarDefaultFocusIndex: number = 1;
|
|
@Builder
|
|
FileMenu(menus: Array<BtnEvent>) {
|
|
Menu() {
|
|
ForEach(menus, (item: BtnEvent, index: number) => {
|
|
MenuItem({ startIcon: $r('app.media.'+item.eIcon), content: item.eName })
|
|
.width('150')
|
|
.margin({
|
|
top: 0,
|
|
left: 0,
|
|
bottom: 0,
|
|
right: 0
|
|
})
|
|
})
|
|
}
|
|
}
|
|
build() {
|
|
Flex({ direction: FlexDirection.Column }){
|
|
Scroll() {
|
|
Row() {
|
|
ForEach(TitleData.mModel, (item: CAXModel, index: number) => {
|
|
Row({ space: 1 }) {
|
|
if(index>0){
|
|
Button(item.cmName)
|
|
.fontWeight(index === this.titleBarFocusIndex ? FontWeight.Bold : FontWeight.Normal)
|
|
.height(25)
|
|
.width(60)
|
|
.padding(5)
|
|
.type(ButtonType.Normal)
|
|
.backgroundColor(Color.Brown)
|
|
}else{
|
|
Button(item.cmName)
|
|
.fontWeight(index === this.titleBarFocusIndex ? FontWeight.Bold : FontWeight.Normal)
|
|
.height(25)
|
|
.width(60)
|
|
.padding(5)
|
|
.bindMenu(this.FileMenu(item.cmBtnEvents))
|
|
.type(ButtonType.Normal)
|
|
.backgroundColor(Color.Brown)
|
|
}
|
|
|
|
}.onClick(() => {
|
|
if(index!=0){
|
|
this.titleBarTabs.changeIndex(index);
|
|
this.titleBarFocusIndex = index;
|
|
}else{
|
|
this.titleBarTabs.changeIndex(this.titleBarDefaultFocusIndex);
|
|
this.titleBarFocusIndex = this.titleBarDefaultFocusIndex;
|
|
}
|
|
})
|
|
})
|
|
}
|
|
}
|
|
.align(Alignment.Start)
|
|
.scrollable(ScrollDirection.Horizontal)
|
|
.scrollBar(BarState.Off)
|
|
.margin({ top: 2,left:2,bottom:2,right:2})
|
|
.width('100%')
|
|
Tabs({barPosition: BarPosition.Start, index: this.titleBarDefaultFocusIndex,controller: this.titleBarTabs}){
|
|
ForEach(TitleData.mModel,(item:CAXModel, index: number)=>{
|
|
TabContent() {
|
|
if(item.cmBtnEvents.length==0){
|
|
TitleTabContent({tabLayout:item.cmEvents})
|
|
}
|
|
}.align(Alignment.Start)
|
|
.padding(1)
|
|
.margin({ top: 0,left:0,bottom:2,right:0})
|
|
})
|
|
}.scrollable(false)
|
|
.barHeight(0)
|
|
.margin({ top: 0,left:0,bottom:0,right:0})
|
|
.height('auto')
|
|
.barMode(BarMode.Fixed)
|
|
}.borderWidth('1')
|
|
.height('auto')
|
|
}
|
|
}
|