HarmonyOS flutter-flutter返回手势提示问题?

现在华为验收app的时候,测试提出在根视图的时候使用滑动手势,需要双击退出的提示才可以返回到系统桌面,这个功能flutter-flutter能否支持或者当前情况下如何实现?

阅读 538
1 个回答

示例参考:

import { TipsDialog } from '@kit.ArkUI';
import { image } from '@kit.ImageKit';

@Entry
@Component
struct Index {
  @State pixelMap: PixelMap | undefined = undefined;
  @State states: boolean = true
  isChecked = false;
  dialogControllerImage: CustomDialogController = new CustomDialogController({
    builder: TipsDialog({
      imageRes: $r('sys.media.ohos_ic_public_voice'),
      content: '确认退出这个APP嘛?',
      primaryButton: {
        value: '确认后再次侧滑退出',
        action: () => {
          this.states = false
        },
      },
      secondaryButton: {
        value: '取消',
        role: ButtonRole.ERROR,
        action: () => {
          this.states = true
        }
      },
      onCheckedChange: () => {
        console.info('Callback when the checkbox is clicked')
      }
    }),
  })

  onBackPress(): boolean | void {
    this.dialogControllerImage.open()
    console.log("" + this.states)
    if (!this.states) {
      this.dialogControllerImage.close()
    }
    return this.states
  }

  build() {
    Row() {
      Stack() {
        Column() {
          Button("上图下文弹出框")
            .width(96)
            .height(40)
            .onClick(() => {
              this.dialogControllerImage.open()
            })
        }.margin({ bottom: 300 })
      }.align(Alignment.Bottom)
      .width('100%').height('100%')
    }
    .backgroundImageSize({ width: '100%', height: '100%' })
    .height('100%')
  }
}