ForCAX/entry/src/main/ets/pages/LeftSideLayout/LeftSideTab.ets
JackLee ba448cd637 解耦事件,把事件类型分为Page和Event.
Page主要针对Arkui侧的子窗口事件
Event主要针对Native侧的事件.

后续考虑解耦为如下:
Arkui_Page(主要针对子窗口归一化调用)
Arkui_Event(主要针对arkui侧的归一化动态组件操作)
Native_Page(主要针对Native侧对Arkui侧的页面数据更新和回调)
Native_Event(主要针对单一从Aarkui侧调用Native指令)

本次更新后btnEvent中增加了page地址和args.可以在预置功能中预置命令和参数.
2026-04-13 01:06:38 +08:00

75 lines
2.9 KiB
Plaintext

import { TitleButton } from '../LayoutInterface/Interface/ButtonInterface';
import {LeftSideBars} from '../LayoutInterface/Layout/LeftSideBar'
import { mwInfo } from '../DispWinInfo/DispWinInfo'
import {LeftSideComponent} from './LeftSideComponent'
@ComponentV2
export struct LeftSideTab {
private leftSideBarTabs: TabsController = new TabsController();
@Local leftSideBarFocusIndex: number = 0;
@Local isExpanded:boolean=true;
@Consumer('LeftSideWidth') leftSideWidth:number=mwInfo.width * 0.1;
build() {
Row() {
Column({space:1}){
Button()
.backgroundImagePosition({ x: '5%', y: '5%' })
.backgroundColor(Color.Transparent)
.backgroundImageSize({
width: '90%', // 图片宽度占满按钮
height: '90%' // 图片高度占满按钮
})
.backgroundImage(this.isExpanded ? $r('app.media.base_expand_on'):$r('app.media.base_expand_off'))
.type(ButtonType.Normal)
.width(mwInfo.width*0.013)
.height(mwInfo.width*0.013)
.onClick(()=>{
this.isExpanded = !this.isExpanded;
this.leftSideWidth=this.isExpanded?mwInfo.width * 0.1:0
}).margin({ top: 2,left:1,bottom:0,right:2})
Scroll() {
Flex({ direction: FlexDirection.Column}) {
Column({ space: 5 }) {
ForEach(LeftSideBars, (item: TitleButton, index: number) => {
Button()
.backgroundImagePosition({ x: '5%', y: '5%' })
.backgroundColor(Color.Transparent)
.backgroundImageSize({
width: '90%', // 图片宽度占满按钮
height: '90%' // 图片高度占满按钮
})
.backgroundImage($r('app.media.'+item.btnIcon))
.fontWeight(index === this.leftSideBarFocusIndex ? FontWeight.Bold : FontWeight.Normal)
.width(mwInfo.width*0.013)
.height(mwInfo.width*0.013)
.type(ButtonType.Normal)
.onClick(() => {
this.leftSideBarTabs.changeIndex(index);
this.leftSideBarFocusIndex = index;
})
})}
Blank().layoutWeight(1)
}
}
.align(Alignment.Start)
.scrollable(ScrollDirection.Vertical)
.scrollBar(BarState.Off)
.width(mwInfo.width*0.013)
.height(mwInfo.width*0.013)
.height('100%')
}.borderWidth(1)
.borderColor(Color.Grey)
Column({space:1}){
Tabs({ barPosition: BarPosition.Start, controller: this.leftSideBarTabs }) {
ForEach(LeftSideBars, (item: TitleButton, index: number) => {
TabContent() {
LeftSideComponent();
}
})
}.barHeight(0)
}.width(this.isExpanded?this.leftSideWidth:0)
}.width('auto')
.backgroundColor($r('sys.color.background_secondary'))
}
}