手势滑动退出HarmonyOS应用的规格

通过手势滑动(按住右侧屏幕边缘向左滑)退出应用,有些应用会提示再次返回退出,然后再滑一次退出当前应用到桌面,有些应用只需要滑一次就直接退出,这个有明确的规格吗?

HarmonyOS
2024-12-26 14:18:12
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
Heiang

二次滑动退出应用可以参考如下Demo:

import common from '@ohos.app.ability.common';
import { promptAction } from '@kit.ArkUI';
@Entry
@Component
struct IndexComponent {
  @State textColor: Color = Color.Black;
  onPageShow() {
    this.textColor = Color.Blue;
    console.info('IndexComponent onPageShow');
  }
  onPageHide() {
    this.textColor = Color.Transparent;
    console.info('IndexComponent onPageHide');
  }
  firstBcakTimestamp: number = 0;
  onBackPress() {
    console.info('IndexComponent onBackPress');
    this.textColor = Color.Red;
    let now = Date.now();
    if (now - this.firstBcakTimestamp < 1000) {
      const context = getContext(this) as common.UIAbilityContext
      context.terminateSelf(); // 终止程序
    } else {
      this.firstBcakTimestamp = now;
      let option : promptAction.ShowToastOptions = {
        message: "是否继续退出" // 可以是$r图片
      }
      promptAction.showToast(option);
    }
    return true
  }
  build() {
    Column() {
      Text('Hello World')
        .fontColor(this.textColor)
        .fontSize(30)
        .margin(30)
    }.width('100%')
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.

退出应用非代码实现目前是一次就退出应用。请查看考如下文档:https://developer.huawei.com/consumer/cn/doc/design-guides/hmi-touchscreen-0000001928273206#section1442461065315

分享
微博
QQ
微信
回复
2024-12-26 17:18:22
相关问题
HarmonyOS 图片组件手势滑动
626浏览 • 1回复 待解决
HarmonyOS 手势滑动登录UI实现
774浏览 • 1回复 待解决
HarmonyOS 禁用滑动返回手势问题
699浏览 • 1回复 待解决
HarmonyOS 退出应用
1281浏览 • 1回复 待解决
应用运行时进程资源使用规格
2715浏览 • 1回复 待解决
HarmonyOS 主动退出应用
1597浏览 • 1回复 待解决
HarmonyOS 是否有退出应用api?
1190浏览 • 1回复 待解决
HarmonyOS 如何彻底退出应用
942浏览 • 1回复 待解决
Swiper组件设置不跟随手势滑动
1425浏览 • 1回复 待解决
HarmonyOS 如何监听应用启动和退出
1053浏览 • 1回复 待解决
HarmonyOS 如何退出应用程序?
1877浏览 • 1回复 待解决
ets开发应用怎么退出当前应用
4582浏览 • 1回复 待解决
HarmonyOS 主动退出应用程序问题
1870浏览 • 1回复 待解决
HarmonyOS 退出应用程序代码
1054浏览 • 1回复 待解决