Harmony鸿蒙实战开发-健康饮食运动记录app「记录饮食摄入、运动消耗、每日早餐、午餐、晚餐、加餐、运动卡路里信息,并包含开发者简介」「饮食记录」「能量记录」【源码在文末】
文章目录
运行工具:DevEco Studio
一、运行演示
1、主页面

2、开机动画

3、饮食记录-早饭

4、饮食记录-午饭

5、饮食记录-晚饭

6、饮食记录-加餐

7、运动记录

8、我的信息

9、总览

二、部分代码
import BreakpointType from '../common/bean/BreanpointType'
import BreakpointConstants from '../common/constants/BreakpointConstants'
import { CommonConstants } from '../common/constants/CommonConstants'
import BreakpointSystem from '../common/utils/BreakpointSystem'
import RecordIndex from '../view/record/RecordIndex'
@Entry
@Component
struct Index {
@State currentIndex: number = 0
private breakpointSystem: BreakpointSystem = new BreakpointSystem()
@StorageProp('currentBreakpoint') currentBreakpoint: string = BreakpointConstants.BREAKPOINT_SM
@State isPageShow: boolean = false
onPageShow(){
this.isPageShow = true
}
onPageHide(){
this.isPageShow = false
}
@Builder TabBarBuilder(title: ResourceStr, image: ResourceStr, index: number) {
Column({ space: CommonConstants.SPACE_8 }) {
Image(image)
.width(22)
.fillColor(this.selectColor(index))
Text(title)
.fontSize(14)
.fontColor(this.selectColor(index))
}
}
aboutToAppear(){
this.breakpointSystem.register()
}
aboutToDisappear(){
this.breakpointSystem.unregister()
}
selectColor(index: number) {
return this.currentIndex === index ? $r('app.color.primary_color') : $r('app.color.gray')
}
build() {
Tabs({ barPosition: BreakpointConstants.BAR_POSITION.getValue(this.currentBreakpoint) }) {
TabContent() {
RecordIndex({isPageShow: this.isPageShow})
}
.tabBar(this.TabBarBuilder($r('app.string.tab_record'), $r('app.media.ic_calendar'), 0))
//TabContent() {
//Text('发现页面')
//}
//.tabBar(this.TabBarBuilder($r('app.string.tab_discover'), $r('app.media.discover'), 1))
TabContent() {
Column({ space: CommonConstants.SPACE_8 }) {
Text('应用信息')
.fontSize(20)
.fontWeight(FontWeight.Bold)
Text('记录饮食')
.fontSize(16)
Text('作者信息')
.fontSize(20)
.fontWeight(FontWeight.Bold)
Text('作者: XXX')
.fontSize(16)
Text('邮箱: XX@QQ.com')
.fontSize(16)
Text('版本号: 1.0.0')
.fontSize(16)
}
}
.tabBar(this.TabBarBuilder($r('app.string.tab_user'), $r('app.media.ic_user_portrait'), 2))
}
.width('100%')
.height('100%')
.onChange(index => this.currentIndex = index)
.vertical(new BreakpointType({
sm: false,
md: true,
lg: true
}).getValue(this.currentBreakpoint))
}
}
三、源码
通过百度网盘分享的文件:…zip 链接:百度网盘 请输入提取码
文件已经加密,请点击下方名片获取源码
或:One_PQ