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
      })
    }
  })
相关推荐
Math_teacher_fan3 小时前
Flutter 跨平台开发实战:鸿蒙与音乐律动艺术(六)、Lissajous 利萨茹曲线:频率耦合的轨迹艺术
flutter·ui·数学建模·华为·harmonyos·鸿蒙系统
xmdy58664 小时前
Flutter+开源鸿蒙实战|智安盾电商溯源平台Day3 溯源查询逻辑+鸿蒙网络请求适配
flutter·开源·harmonyos
maaath5 小时前
【maaath】Flutter 跨平台日历日程应用开发实战
flutter·华为·harmonyos
LeesonWong6 小时前
架构困境与四层结构化设计
harmonyos
梦想不只是梦与想7 小时前
鸿蒙 应用市场更新功能:版本检测与更新提醒
harmonyos·鸿蒙·版本更新
xmdy58667 小时前
Flutter+开源鸿蒙实战|智安盾电商溯源平台Day2 首页+核心入口UI开发(鸿蒙多端适配)
flutter·开源·harmonyos
nashane11 小时前
HarmonyOS 6学习:HAR包与HSP包的选择与优化指南
学习·华为·harmonyos·harmonyos 5
全栈若城11 小时前
自定义 TabBar 实战:浮动标签栏与舵式标签栏
harmonyos·harmonyos6·三方库开发
maaath11 小时前
【maaath】Flutter for OpenHarmony 学习答题应用实战开发
学习·flutter·华为·harmonyos
李游Leo11 小时前
别再拼 JSON 了:HarmonyOS UDMF 跨应用数据流转实践
harmonyos