HarmonyOS Next应用开发实战——登录页面实现(part1)

HarmonyOS Next应用开发实战------登录页面实现

文章概要

本文聚焦于HarmonyOS Next应用开发中登录页面的实现。详细介绍了登录页面的布局、输入框交互效果、登录方式切换以及协议勾选等功能,同时阐述了如何根据用户操作实现页面的动态变化和导航跳转。

核心功能介绍

1. 页面布局与响应式设计

使用GridRowGridCol进行布局,结合CommonConstants中定义的断点和列数实现响应式设计。

typescript 复制代码
NavDestination(){
  GridRow({
    breakpoints: { value: CommonConstants.BREAK_POINTS_VALUE, reference: BreakpointsReference.WindowSize },
    columns: { sm: CommonConstants.COLUMN_SM, md: CommonConstants.COLUMN_MD, lg: CommonConstants.COLUMN_LG },
    direction: GridRowDirection.Row
  }) {
    // ...
  }
  .onBreakpointChange((breakpoints: string) => {
    this.breakPoint = breakpoints;
  })
}
2. 输入框交互效果

输入框具有动画效果,当输入框获得或失去焦点且内容为空时,标签文本会有大小和位置的变化。

typescript 复制代码
TextInput({ text: this.phone })
  .onFocus(() => {
    if (this.phone === '') {
      animateTo({ duration: 100 }, () => {
        this.isAnimatedPhoNum = !this.isAnimatedPhoNum
      })
    }
  })
  .onBlur(() => {
    if (this.phone === '') {
      animateTo({ duration: 100 }, () => {
        this.isAnimatedPhoNum = !this.isAnimatedPhoNum
      })
    }
  })
```### HarmonyOS Next应用开发实战------登录页面实现

#### 文章概要
本文聚焦于HarmonyOS Next应用开发中登录页面的实现。详细介绍了登录页面的布局、输入框交互效果、登录方式切换以及协议勾选等功能,同时阐述了如何根据用户操作实现页面的动态变化和导航跳转。

#### 核心功能介绍

##### 1. 页面布局与响应式设计
使用`GridRow`和`GridCol`进行布局,结合`CommonConstants`中定义的断点和列数实现响应式设计。
```typescript
NavDestination(){
  GridRow({
    breakpoints: { value: CommonConstants.BREAK_POINTS_VALUE, reference: BreakpointsReference.WindowSize },
    columns: { sm: CommonConstants.COLUMN_SM, md: CommonConstants.COLUMN_MD, lg: CommonConstants.COLUMN_LG },
    direction: GridRowDirection.Row
  }) {
    // ...
  }
  .onBreakpointChange((breakpoints: string) => {
    this.breakPoint = breakpoints;
  })
}
2. 输入框交互效果

输入框具有动画效果,当输入框获得或失去焦点且内容为空时,标签文本会有大小和位置的变化。

typescript 复制代码
TextInput({ text: this.phone })
  .onFocus(() => {
    if (this.phone === '') {
      animateTo({ duration: 100 }, () => {
        this.isAnimatedPhoNum = !this.isAnimatedPhoNum
      })
    }
  })
  .onBlur(() => {
    if (this.phone === '') {
      animateTo({ duration: 100 }, () => {
        this.isAnimatedPhoNum = !this.isAnimatedPhoNum
      })
    }
  })
相关推荐
梦想不只是梦与想4 小时前
鸿蒙 云测试:上架测试流程
harmonyos·鸿蒙·云测试
传奇开心果编程7 小时前
【ArkUI 练中学】第15课:UI 界面设计与实战
学习·ui·华为·harmonyos
HwJack207 小时前
【HarmonyOS开发小实践】ArkUI 动画系统属性动画、显式动画与路径动画
ui·性能优化·harmonyos
李游Leo9 小时前
HarmonyOS 7 实战开发 05:把页面做到可上线状态
ios·harmonyos
贾伟康12 小时前
【HarmonyOS 7新能力|043】可变字体工程封装:把接入逻辑放进可维护的分层结构
harmonyos·arkts·arkui·ui设计·可变字体
HarmonyOS_SDK12 小时前
HarmonyOS智慧多窗,让应用在任意窗口都“恰到好处”
harmonyos
传奇开心果编程15 小时前
【ArkUI 练中学】第14课:应用性能优化实战
学习·ui·华为·harmonyos
用户5930960097816 小时前
Flutter 鸿蒙化实战:flutter_tts 适配 OpenHarmony,文本转语音
harmonyos
威哥爱编程18 小时前
HarmonyOS 互动卡片实战:摇一摇触发静态转动态,前景元素出框
华为·harmonyos·arkts
威哥爱编程18 小时前
HarmonyOS 7 闪控窗实战:标准悬浮窗、侧边栏暂存与闪控球一键切换
华为·harmonyos·arkts