feat(entry): 底部导航图标改用小程序 PNG

This commit is contained in:
AndyChen1024
2026-09-15 14:49:51 +08:00
parent f7fb81e7b4
commit b62e2c0a5b

View File

@@ -17,22 +17,22 @@ struct Index {
TabContent() { TabContent() {
HomePage({ onGoLogin: () => { this.currentIndex = 3; } }) HomePage({ onGoLogin: () => { this.currentIndex = 3; } })
} }
.tabBar(this.tabBarBuilder(0, '首页', '🏠')) .tabBar(this.tabBarBuilder(0, '首页', $r('app.media.home'), $r('app.media.home_active')))
TabContent() { TabContent() {
CheckinPage({ onGoLogin: () => { this.currentIndex = 3; } }) CheckinPage({ onGoLogin: () => { this.currentIndex = 3; } })
} }
.tabBar(this.tabBarBuilder(1, '打卡', '✅')) .tabBar(this.tabBarBuilder(1, '打卡', $r('app.media.checkin'), $r('app.media.checkin_active')))
TabContent() { TabContent() {
PlanPage({ onGoLogin: () => { this.currentIndex = 3; } }) PlanPage({ onGoLogin: () => { this.currentIndex = 3; } })
} }
.tabBar(this.tabBarBuilder(2, '计划', '📝')) .tabBar(this.tabBarBuilder(2, '计划', $r('app.media.plan'), $r('app.media.plan_active')))
TabContent() { TabContent() {
ProfilePage() ProfilePage()
} }
.tabBar(this.tabBarBuilder(3, '我的', '👤')) .tabBar(this.tabBarBuilder(3, '我的', $r('app.media.profile'), $r('app.media.profile_active')))
} }
.onChange((index: number) => { .onChange((index: number) => {
this.currentIndex = index; this.currentIndex = index;
@@ -43,10 +43,12 @@ struct Index {
} }
@Builder @Builder
tabBarBuilder(index: number, title: string, icon: string) { tabBarBuilder(index: number, title: string, normalIcon: Resource, activeIcon: Resource) {
Column({ space: 2 }) { Column({ space: 2 }) {
Text(icon) Image(index === this.currentIndex ? activeIcon : normalIcon)
.fontSize(20) .width(24)
.height(24)
.objectFit(ImageFit.Contain)
Text(title) Text(title)
.fontSize(AppFontSize.caption) .fontSize(AppFontSize.caption)
.fontColor(index === this.currentIndex ? AppColor.tabActive : AppColor.tabInactive) .fontColor(index === this.currentIndex ? AppColor.tabActive : AppColor.tabInactive)