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
      })
    }
  })
相关推荐
奋斗的小青年!!14 分钟前
OpenHarmony Flutter 拖拽排序组件性能优化与跨平台适配指南
flutter·harmonyos·鸿蒙
sinat_3842410926 分钟前
HarmonyOS应用开发的trae cn全面实战指南
华为·harmonyos
小雨下雨的雨1 小时前
Flutter 框架跨平台鸿蒙开发 —— Stack 控件之三维层叠艺术
flutter·华为·harmonyos
行者962 小时前
OpenHarmony平台Flutter手风琴菜单组件的跨平台适配实践
flutter·harmonyos·鸿蒙
Van_Moonlight3 小时前
RN for OpenHarmony 实战 TodoList 项目:已完成未完成数量显示
javascript·开源·harmonyos
陈_杨3 小时前
前端成功转鸿蒙开发者真实案例,教大家如何开发鸿蒙APP--ArkTS 卡片开发完全指南
前端·harmonyos
陈_杨3 小时前
前端成功转鸿蒙开发者真实案例,教大家如何开发鸿蒙APP--ArkTS 卡片刷新机制
前端·harmonyos
哈__4 小时前
从入门小白到精通,玩转 React Native 鸿蒙跨平台开发:TouchableOpacity 触摸反馈组件
react native·react.js·harmonyos
小雨下雨的雨4 小时前
Flutter 框架跨平台鸿蒙开发 —— Flex 控件之响应式弹性布局
flutter·ui·华为·harmonyos·鸿蒙系统
哈__4 小时前
入门小白到精通,玩转 React Native 鸿蒙跨平台开发:Button 按钮组件与点击事件
react native·react.js·harmonyos