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
      })
    }
  })
相关推荐
lxysbly7 小时前
鸿蒙NDS模拟器app下载
华为·harmonyos
里欧跑得慢7 小时前
Flutter 组件 tavily_dart 的适配 鸿蒙Harmony 实战 - 驾驭 AI 搜索引擎集成、实现鸿蒙端互联网知识精密获取与语义增强方案
flutter·harmonyos·鸿蒙·openharmony·tavily_dart
国医中兴9 小时前
Flutter 三方库 pickled_cucumber 的鸿蒙化适配指南 - 玩转 BDD 行为驱动开发、Gherkin 自动化测试实战、鸿蒙级质量守护神
驱动开发·flutter·harmonyos
里欧跑得慢9 小时前
Flutter 三方库 config 的鸿蒙化适配指南 - 在鸿蒙系统上构建极致、透明、多源叠加的命令行参数解析与环境配置文件加载引擎
flutter·harmonyos·鸿蒙·openharmony
爱学习的小齐哥哥9 小时前
HarmonyOS 5.0元服务深度解析:下一代应用形态的开发与实践指南
华为·harmonyos·harmony pc·harmonyos app
左手厨刀右手茼蒿9 小时前
Flutter 三方库 flutter_azure_tts 深度链接鸿蒙全场景智慧语音中枢适配实录:强势加载云端高拟真情感发音合成系统实现零延迟超自然多端协同-适配鸿蒙 HarmonyOS ohos
flutter·harmonyos·azure
雷帝木木9 小时前
Flutter 三方库 image_compare_2 的鸿蒙化适配指南 - 实现像素级的图像分块对比、支持感知哈希(pHash)与端侧视觉差异检测实战
flutter·harmonyos·鸿蒙·openharmony·image_compare_2
王码码20359 小时前
Flutter 三方库 sum_types 的鸿蒙化适配指南 - 引入函数式编程思维,让鸿蒙应用的状态处理更严谨
flutter·harmonyos·鸿蒙·openharmony·sum_types
加农炮手Jinx9 小时前
Flutter 三方库 cli_script 鸿蒙化极简命令行执行引擎适配探索:在多维沙盒终端环境注入异构 Shell 串联逻辑彻底拔高全自动化容器脚本运维及-适配鸿蒙 HarmonyOS ohos
运维·flutter·harmonyos
亘元有量-流量变现9 小时前
APP自动识别跳转各大应用商店(鸿蒙+iOS+安卓全品牌)|可直接部署落地页源码
android·ios·harmonyos