diff --git a/features/home/src/main/ets/view/Home.ets b/features/home/src/main/ets/view/Home.ets index 61a954e8ef00cfbac4507105ddec21297281651e..62278eb7e7bec7f06d9da9220c311f8eb4dd561f 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 0bc538be5a7256c6c3736e65614174dc0dc925cd..7bba9877de8a4c28f7691b75e096846aaf23bf4b 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 37b359b79ab5a12724835b568839286dde8f880f..f30275b895da6c882dbd0f1d3a87e0152e28368e 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 f4a42f32ca556d8c9395154258983d78ea6f6f0f..1902051108954706efdd6eb57e97effe35772934 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