import { hilog } from '@kit.PerformanceAnalysisKit'; import {ModelView} from './modelView' class TaskTab{ icon:string='' str:string='default model' event:string='' } let dTab:Array=[ {icon:'',str:'默认任务',event:''} ] @Component export struct ModelViewTab { //顶部导航组件 private modelViewBarTabs: TabsController = new TabsController(); //当前的顶部导航选择页 @State modelViewBarFocusIndex: number = 0; @State modelFilePath:string=''; build() { Flex({ direction: FlexDirection.Column }) { Scroll() { Row() { ForEach(dTab, (item: TaskTab, index: number) => { Row({ space: 0 }) { Image($r('app.media.startIcon')) .width(25) .height(25) .objectFit(ImageFit.Contain) Button(item.str) .fontWeight(index === this.modelViewBarFocusIndex ? FontWeight.Bold : FontWeight.Normal) .height(25) .width(60) .padding(5) .type(ButtonType.Normal) Button('X') .height(25) .width(25) .type(ButtonType.Normal) .padding(1) .align(Alignment.Center) }.onClick(() => { this.modelViewBarTabs.changeIndex(index); this.modelViewBarFocusIndex = index; }) }) } }.borderWidth('1') .borderColor(Color.Gray) .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: 0, controller: this.modelViewBarTabs }) { TabContent() { ModelView() }.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') } }