From 8532f7b0015114788834b3b1c8a6903089e72185 Mon Sep 17 00:00:00 2001 From: guangda Date: Thu, 30 Oct 2025 19:20:05 +0800 Subject: [PATCH] fix bug --- features/home/src/main/ets/view/Home.ets | 20 +++++++++---------- .../src/main/ets/view/SegmentHomeHeader.ets | 12 +++++++---- features/home/src/main/ets/view/TVHome.ets | 11 +++++----- .../home/src/main/ets/view/TVHomeContent.ets | 12 +++++++---- 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/features/home/src/main/ets/view/Home.ets b/features/home/src/main/ets/view/Home.ets index 61a954e..62278eb 100644 --- a/features/home/src/main/ets/view/Home.ets +++ b/features/home/src/main/ets/view/Home.ets @@ -13,8 +13,8 @@ * limitations under the License. */ -// import { SearchView } from '@ohos/search'; -import { ImmersiveType, WindowInfo, WindowUtil } from '@ohos/commons'; +import { SearchView } from '@ohos/search'; +import { WindowInfo, WindowUtil } from '@ohos/commons'; import { FooterTab, FooterTabViewModel } from '../viewmodel/FooterTabViewModel'; import { HomeHeader } from './HomeHeader'; import { HomeContent } from './HomeContent'; @@ -196,8 +196,8 @@ export struct Home { HomeContent({ mainWindowInfo: this.mainWindowInfo }) .visibility(!this.isSearching ? Visibility.Visible : Visibility.None) - // SearchView({ isSearching: $isSearching }) - // .visibility(!this.isSearching ? Visibility.None : Visibility.Visible) + SearchView({ isSearching: $isSearching, mainWindowInfo: this.windowUtil?.mainWindowInfo }) + .visibility(!this.isSearching ? Visibility.None : Visibility.Visible) } .width('100%') } @@ -239,8 +239,8 @@ export struct Home { HomeContent({ mainWindowInfo: this.mainWindowInfo }) .visibility(!this.isSearching ? Visibility.Visible : Visibility.None) - // SearchView({ isSearching: $isSearching }) - // .visibility(!this.isSearching ? Visibility.None : Visibility.Visible) + SearchView({ isSearching: $isSearching, mainWindowInfo: this.windowUtil?.mainWindowInfo }) + .visibility(!this.isSearching ? Visibility.None : Visibility.Visible) } .width('100%') } @@ -279,8 +279,8 @@ export struct Home { HomeContent({ mainWindowInfo: this.mainWindowInfo }) .visibility(!this.isSearching ? Visibility.Visible : Visibility.None) - // SearchView({ isSearching: $isSearching }) - // .visibility(!this.isSearching ? Visibility.None : Visibility.Visible) + SearchView({ isSearching: $isSearching, mainWindowInfo: this.windowUtil?.mainWindowInfo }) + .visibility(!this.isSearching ? Visibility.None : Visibility.Visible) } .width('100%') } @@ -343,8 +343,8 @@ export struct Home { HomeContent({ mainWindowInfo: this.mainWindowInfo }) .visibility(!this.isSearching ? Visibility.Visible : Visibility.None) - // SearchView({ isSearching: $isSearching }) - // .visibility(!this.isSearching ? Visibility.None : Visibility.Visible) + SearchView({ isSearching: $isSearching, mainWindowInfo: this.windowUtil?.mainWindowInfo }) + .visibility(!this.isSearching ? Visibility.None : Visibility.Visible) } .width('100%') } diff --git a/features/home/src/main/ets/view/SegmentHomeHeader.ets b/features/home/src/main/ets/view/SegmentHomeHeader.ets index 0bc538b..7bba987 100644 --- a/features/home/src/main/ets/view/SegmentHomeHeader.ets +++ b/features/home/src/main/ets/view/SegmentHomeHeader.ets @@ -30,7 +30,7 @@ export struct SegmentHomeHeader { .width($r('app.float.history_img_size')) .height($r('app.float.history_img_size')) } - .backgroundColor('#ff555756') + .backgroundColor(this.currentBottomIndex === index ? '#ff818384' : '#ff555756') .width('40vp') .height('100%') .border({ @@ -42,7 +42,10 @@ export struct SegmentHomeHeader { .onClick(() => { if (index === 2) { this.isSearching = true; + } else { + this.isSearching = false; } + this.currentBottomIndex = index; }) } }, (item: Resource) => JSON.stringify(item)) @@ -67,9 +70,9 @@ export struct SegmentHomeHeader { Text(item) .fontSize('18fp') .fontWeight(800) - .fontColor(this.currentBottomIndex === index ? Color.White : '#aeafaf') + .fontColor(this.currentBottomIndex === index + this.iconList.length ? Color.White : '#aeafaf') } - .backgroundColor(this.currentBottomIndex === index ? '#ff555756': Color.Transparent) + .backgroundColor(this.currentBottomIndex === index + this.iconList.length ? '#ff555756': Color.Transparent) .width('78vp') .height('100%') .border({ @@ -79,7 +82,8 @@ export struct SegmentHomeHeader { .alignItems(VerticalAlign.Center) .justifyContent(FlexAlign.Center) .onClick(() => { - this.currentBottomIndex = index; + this.isSearching = false; + this.currentBottomIndex = index + this.iconList.length; }) } .align(Alignment.Center) diff --git a/features/home/src/main/ets/view/TVHome.ets b/features/home/src/main/ets/view/TVHome.ets index 37b359b..f30275b 100644 --- a/features/home/src/main/ets/view/TVHome.ets +++ b/features/home/src/main/ets/view/TVHome.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -// import { SearchView } from '@ohos/search'; +import { SearchViewForTv } from '@ohos/search'; import { WindowInfo, WindowUtil } from '@ohos/commons'; import { SegmentHomeHeader } from './SegmentHomeHeader'; import { TVHomeContent } from './TVHomeContent'; @@ -24,7 +24,7 @@ export struct TVHome { @StorageLink('scrollHeight') scrollHeight: number = 0; @StorageLink('currentTopIndex') currentTopIndex: number = 2; @StorageLink('windowUtil') windowUtil: WindowUtil | undefined = undefined; - @State currentBottomIndex: number = 0; + @State currentBottomIndex: number = 3; @State isSearching: boolean = false; private sideScroller: Scroller = new Scroller(); @@ -35,15 +35,14 @@ export struct TVHome { Scroll(this.sideScroller) { Column() { TVHomeContent() - .visibility(!this.isSearching ? Visibility.Visible : Visibility.None) + .visibility(!this.isSearching && this.currentBottomIndex === 3 ? Visibility.Visible : Visibility.None) - // SearchView({ isSearching: $isSearching }) - // .visibility(!this.isSearching ? Visibility.None : Visibility.Visible) + SearchViewForTv({ isSearching: $isSearching }) + .visibility(!this.isSearching ? Visibility.None : Visibility.Visible) } .width('100%') } .scrollBar(BarState.Off) - .height('100%') // Obtains the sliding offset on the y axis during sliding. .onScrollFrameBegin((offset: number) => { this.scrollHeight = this.sideScroller.currentOffset().yOffset; diff --git a/features/home/src/main/ets/view/TVHomeContent.ets b/features/home/src/main/ets/view/TVHomeContent.ets index f4a42f3..1902051 100644 --- a/features/home/src/main/ets/view/TVHomeContent.ets +++ b/features/home/src/main/ets/view/TVHomeContent.ets @@ -30,12 +30,16 @@ export struct TVHomeContent { Column() { TVBannerView({ mainWindowInfo: this.windowUtil!.mainWindowInfo}) TVTopBarView() - RecommendedVideo({ mainWindowInfo: this.windowUtil!.mainWindowInfo, isTVShow: true }) - NewVideoRelease({ mainWindowInfo: this.windowUtil!.mainWindowInfo, isTVShow: true }) - DailyVideo({ mainWindowInfo: this.windowUtil!.mainWindowInfo, isTVShow: true }) - TVPreviousVideo({ mainWindowInfo: this.windowUtil!.mainWindowInfo }) + Column() { + RecommendedVideo({ mainWindowInfo: this.windowUtil!.mainWindowInfo, isTVShow: true }) + NewVideoRelease({ mainWindowInfo: this.windowUtil!.mainWindowInfo, isTVShow: true }) + DailyVideo({ mainWindowInfo: this.windowUtil!.mainWindowInfo, isTVShow: true }) + TVPreviousVideo({ mainWindowInfo: this.windowUtil!.mainWindowInfo }) + } + .visibility(this.currentTVTopIndex === 0 ? Visibility.Visible : Visibility.None) } .alignItems(HorizontalAlign.Start) + .justifyContent(FlexAlign.Start) .width('100%') } } \ No newline at end of file -- Gitee