OpenCAX/entry/src/main/ets/pages/TitleLayout/TitleTab.ets

76 lines
2.7 KiB
Plaintext

import { hilog } from '@kit.PerformanceAnalysisKit';
import {TitleTabData, TitleModel} from '../LayoutInterface/Layout/TitleTabData'
import { FileMenuData } from "../LayoutInterface/Layout/FileMenuData";
import {TitleTabContent} from './TitleTabContent'
import { mwInfo } from '../DispWinInfo/DispWinInfo'
import { TitleButton } from '../LayoutInterface/Interface/ButtonInterface';
import { BaseMenu } from '../CustomController/Menu';
@Entry
@ComponentV2
export struct TitleTab {
//顶部导航组件
private titleBarTabs: TabsController = new TabsController();
//当前的顶部导航选择页
@Local titleBarFocusIndex: number = 0;
//TabBar默认焦点
@Local titleBarDefaultFocusIndex: number = 0;
//模块Bar栏
@Provider('curtModel') curtModel:Array<TitleModel>|undefined= TitleTabData.mModels.get(this.titleBarFocusIndex)
build() {
Flex({ direction: FlexDirection.Column }){
Scroll() {
Row({space:0}) {
Button((FileMenuData.aMenus[0] as TitleButton).eName)
.fontSize(16)
.fontColor(Color.Black)
.height(mwInfo.height*0.025)
.bindMenu(BaseMenu(FileMenuData))
.type(ButtonType.Normal)
.backgroundColor($r('sys.color.background_secondary'))
.fontColor($r('sys.color.font_emphasize'))
ForEach(this.curtModel, (item: TitleModel, index: number) => {
Button(item.cmName)
.fontSize(16)
.fontColor(Color.Black)
.fontWeight(index === this.titleBarFocusIndex ? FontWeight.Bold : FontWeight.Normal)
.height(mwInfo.height*0.025)
.type(ButtonType.Normal)
.backgroundColor($r('sys.color.background_secondary'))
.fontColor($r('sys.color.font_emphasize'))
.onClick(() => {
this.titleBarTabs.changeIndex(index);
this.titleBarFocusIndex = index;
})
})
Blank().layoutWeight(1)
}
}
.align(Alignment.Start)
.scrollable(ScrollDirection.Horizontal)
.scrollBar(BarState.Off)
.margin({ top: 0,left:0,bottom:0,right:0})
//分割线
Divider()
.vertical(false)
.strokeWidth(1)
.lineCap(LineCapStyle.Round)
.width('100%')
.backgroundColor(Color.Grey)
Tabs({barPosition: BarPosition.Start, index: this.titleBarDefaultFocusIndex,controller: this.titleBarTabs}){
ForEach(this.curtModel,(item:TitleModel, index: number)=>{
TabContent() {
TitleTabContent({curtLayout:item})
}
})
}.scrollable(true)
.barHeight(0)
.barMode(BarMode.Fixed)
}.width('100%')
.height(mwInfo.height * 0.08)
}
}