liyubing

fix: 进入直播间,向右滑动简介,和向左滑动大家聊tab ,预期不支持滑动,实际可以滑动

... ... @@ -12,7 +12,8 @@ export struct TabComponent {
@State fontColor: string = '#999999'
@State selectedFontColor: string = '#222222'
@State currentIndex: number = 0
private controller: TabsController = new TabsController()
// private controller: TabsController = new TabsController()
private swiperController: SwiperController = new SwiperController()
@Prop tabs: string[] = []
@Prop lastInputedLiveComment: LiveRoomItemBean // 上次输入的直播间消息
@Prop lastInputedChatComment: LiveRoomItemBean // 上次输入的大家聊消息
... ... @@ -20,48 +21,24 @@ export struct TabComponent {
aboutToAppear(): void {
}
/**
* 评论切换到大家聊
*/
changeToChart() {
const index = this.tabs.findIndex(item => item === '大家聊')
if (index !== -1) {
this.controller.changeIndex(index)
this.swiperController.changeIndex(index)
}
}
build() {
Stack({alignContent: Alignment.TopStart}) {
Tabs({ barPosition: BarPosition.Start, index: this.currentIndex, controller: this.controller }) {
ForEach(this.tabs, (item: string, index: number) => {
TabContent() {
if ('简介' === item) {
TabInfoComponent()
} else if ('直播间' === item) {
TabLiveComponent({lastInputedComment: this.lastInputedLiveComment})
} else if ('大家聊' === item) {
TabChatComponent({lastInputedComment: this.lastInputedChatComment})
}
}
.backgroundColor('#F5F5F5')
}, (item: string, index: number) => {
return item + index
})
}
.layoutWeight(1)
.vertical(false)
.barMode(BarMode.Fixed)
.barHeight(48)
.animationDuration(100)
.onChange((index: number) => {
this.currentIndex = index
})
.backgroundColor(Color.White)
Column() {
// 页签
Row() {
Scroll() {
Row({space: '24vp'}) {
Row({ space: '24vp' }) {
ForEach(this.tabs, (item: string, index: number) => {
this.tabBuilder(index, item)
})
... ... @@ -79,8 +56,33 @@ export struct TabComponent {
.height('48vp')
.alignItems(VerticalAlign.Bottom)
.width('100%')
}.layoutWeight(1)
Swiper(this.swiperController) {
ForEach(this.tabs, (item: string, index: number) => {
if ('简介' === item) {
TabInfoComponent().backgroundColor('#F5F5F5')
} else if ('直播间' === item) {
TabLiveComponent({ lastInputedComment: this.lastInputedLiveComment }).backgroundColor('#F5F5F5')
} else if ('大家聊' === item) {
TabChatComponent({ lastInputedComment: this.lastInputedChatComment }).backgroundColor('#F5F5F5')
}
}, (item: string, index: number) => {
return item + index
})
}
.layoutWeight(1)
.vertical(false)
.indicator(false)
.loop(false)
.alignSelf(ItemAlign.Start)
.effectMode(EdgeEffect.None)
.onChange((index: number) => {
this.currentIndex = index
})
.backgroundColor(Color.White)
}.layoutWeight(1)
}
... ... @@ -102,7 +104,7 @@ export struct TabComponent {
.constraintSize({ minWidth: 35 })
.height('48vp')
.onClick(() => {
this.controller.changeIndex(index)
this.swiperController.changeIndex(index)
this.currentIndex = index
})
}
... ...
... ... @@ -169,7 +169,6 @@ export struct VideoChannelPage {
}, (item: TopNavDTO) => item.channelId + '')
}
.indicator(false)
.disableSwipe(true)
.loop(false)
.width('100%')
.height('100%')
... ...