黑马健康(二)

介绍:

黑马健康App是一款功能全面的健康管理应用,黑马健康App通过提供个性化的饮食记录、健康评估等功能,帮助用户轻松管理健康,改善饮食和生活习惯。 还提供个性化的推荐服务,确保用户能够获得最适合自己的健康和运动建议。总的来说,黑马健康App是一款功能全面、注重个性化推荐的健康管理应用,旨在为用户提供一站式的健康和运动解决方案

一、结构分析

在这个应用中,我们采用了 Tabs 组件来实现多标签页的布局。Tabs 组件内包含了 TabBar,用于展示不同的标签选项,以及与之对应的 TabContent组件,用于展示每个标签页的具体内容。

对于黑马健康app,我们需要用到三个标签页,因此我们在 TabBar 中添加了三个标签选项,并在 Tabs 组件内部添加了三个对应的 TabContent 组件。这样,用户就可以通过点击 TabBar 中的不同标签,来切换并查看不同的 TabContent,从而在不同界面之间自由切换。

同时,每个界面的标签栏都有自己的样式所以需要用@builder组件更改 TabBar的样式

二、首页代码

import RecordIndex from '../view/record/RecordIndex'

@Entry
@Component
struct Index {
  @State ColorIndex: number = 0

  @Builder tabBar(title: string, image: ResourceStr, index: number) {
    Column({ space: 5 }) {
      Image(image)
        .width(22)
        .fillColor(this.tabBerColor(index))
      Text(title)
        .fontSize(14)
        .fontColor(this.tabBerColor(index))
    }
  }

  tabBerColor(index: number) {
    return this.ColorIndex === index ? $r('app.color.primary_color') : $r('app.color.gray')
  }

  build() {
    Tabs({ barPosition: BarPosition.End }) {
      TabContent() {
       // RecordIndex()
      }.tabBar(this.tabBar('记录', $r('app.media.ic_calendar'), 0))

      TabContent() {
        Text('121')
      }.tabBar(this.tabBar('交流', $r('app.media.discover'), 1))

      TabContent() {
        Text('333')
      }.tabBar(this.tabBar('个人', $r('app.media.ic_user_portrait'), 2))
    }
    .backgroundColor($r('app.color.index_page_background'))
    .onChange(index => {
      this.ColorIndex = index
    })
  }
}

三、效果展示

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值