import { DecisionItem, decisionItemList, YTAvoid, yTRouter } from "basic"


@Component
export struct MainView {
  @StorageProp(YTAvoid.SAFE_TOP_KEY)
  top:number=0
  build() {
    Column(){
      Row(){
        Text('樱桃决定').fontSize(18)
          .fontWeight(700)
          .fontColor(Color.Black)
      }.width('100%')
      .justifyContent(FlexAlign.Center)
      .height(44 + this.top)
      .padding({ top: this.top,left:18,right:9 }) //27 padding18


      Column(){

        // Text('我是首页的swiper组件')
        Image($r('[basic].media.banner')).width('100%').height(170).objectFit(ImageFit.Fill)

      }.width('100%')
      .height(170)
      // .margin({left:20,right:20})
      // .backgroundColor(Color.Green)


      Column() {
        List({ space: 10 }) {
          ForEach(decisionItemList, (item: DecisionItem, index) => {
            ListItem() {
              Row() {
                Text(item.title).fontSize(30)

              }
              .width('95%')
              .height(100)
              .borderRadius(20)
              .backgroundImage(item.icon)
              .backgroundImageSize({ width: '100%', height: 100 })
              // .backgroundColor(Color.Red)
              .justifyContent(FlexAlign.Center)
              .onClick(() => {
                yTRouter.router2DecisionPage(item.pageName)
              })
            }
          })

        }.margin({top:10})
        .alignListItem(ListItemAlign.Center)
        .scrollBar(BarState.Off)

      }
      .offset({y:-20})
      .layoutWeight(1)
      .padding({left:10,right:10})
      .borderRadius({topLeft:20,topRight:20})
      .backgroundColor(Color.White)





    }.width('100%')
    .height('100%')
    .backgroundImage($r('[basic].media.back'))
    .backgroundImageSize({width:'100%',height:'100%'})
  }
}