From 1ce875be27d9011c3944c6b975d9f817947ecdf8 Mon Sep 17 00:00:00 2001 From: wwf <1971391498@qq.com> Date: 星期三, 01 十月 2025 16:22:24 +0800 Subject: [PATCH] 登录、注册 --- entry/src/main/ets/pages/MainPage.ets | 76 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 76 insertions(+), 0 deletions(-) diff --git a/entry/src/main/ets/pages/MainPage.ets b/entry/src/main/ets/pages/MainPage.ets new file mode 100644 index 0000000..a55e4b1 --- /dev/null +++ b/entry/src/main/ets/pages/MainPage.ets @@ -0,0 +1,76 @@ +import { Home } from './home/Home' + +/** + * @Description : 搴曢儴瀵艰埅锛孉PP妯″潡 + * Tabs 閫夐」鍗″姛鑳� + */ +class TabBarBase { + icon: ResourceStr = '' + title: string = '' +} +@Entry +@Component +struct MainPage { + @State tabBarList: TabBarBase[] = [ + { icon: 'tabs_home_icon', title: '涓婚〉' }, + { icon: 'tabs_search_platform_icon', title: '鍙戠幇' }, + { icon: 'tabs_message_icon', title: '娑堟伅' }, + { icon: 'tabs_account_icon', title: '鎴戠殑' } + ] + @State selectIndex: number = 0 + private tabController: TabsController = new TabsController() + + @Builder tabItem(icon: ResourceStr,title: string,index: number){ + Column({space: 5}){ + Image($r('app.media.' + icon + (index===this.selectIndex ? '_active' : '' ))) + .width(22) + .height(22) + Text(title) + .fontSize(14) + .fontColor(index === this.selectIndex ? "#1756f4" : '#6a6a6a') + } + .onClick(() => { + this.selectIndex = index + this.tabController.changeIndex(this.selectIndex) + }) + } + build() { + Stack({alignContent: Alignment.Bottom}){ + Tabs({barPosition: BarPosition.End,controller: this.tabController}){ + ForEach(this.tabBarList,(item: TabBarBase,index:number) => { + TabContent(){ + if (index === 0) { + Home() + } else if (index === 1){ + // SearchPage() + } else if (index === 2){ + // MessagePage() + } else if (index === 3){ + // AccountPage() + } + } + //璋冪敤鑷畾涔夌殑鏍峰紡 + // .tabBar(this.tabItem(item.icon,item.title,index)) + }) + } + .barHeight(0) + .onChange((index: number) => { + this.selectIndex = index + }) + + Row() { + ForEach(this.tabBarList, (item: TabBarBase, index) => { + this.tabItem(item.icon, item.title, index) + }) + } + .justifyContent(FlexAlign.SpaceAround) + .width('100%') + .height(60) + .padding(10) + .border({ width: { top: 1 }, color: { top: '#e3e3e3' }, style: { top: BorderStyle.Solid }}) + .backgroundColor(Color.White) + } + .width('100%') + .height('100%') + } +} -- Gitblit v1.8.0