Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于遮罩(onMask)的触发时机问题 #71

Closed
LiWenHui96 opened this issue Aug 5, 2022 · 6 comments
Closed

关于遮罩(onMask)的触发时机问题 #71

LiWenHui96 opened this issue Aug 5, 2022 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@LiWenHui96
Copy link

LiWenHui96 commented Aug 5, 2022

版本信息

  • Flutter版本:v2.10.5
  • flutter_smart_dialog版本:^4.0.9+7

描述bug/需求

_buildBgAnimation 里面的 Listener 监听事件需要使用一个 onPointerMove 解决在 CustomScrollView 内使用时滚动但未关闭Attach的情况。

问题demo

SmartDialog.showAttach<void>(
  targetContext: context,
  builder: (_) {
    return SizedBox(
      width: MediaQueryData.fromWindow(window).size.width,
      height: builder.menuHeight,
    );
  },
  clickMaskDismiss: false,
  animationTime: widget.animationDuration ?? defaultDuration,
  maskWidget: GestureDetector(
    onTap: () => SmartDialog.dismiss<void>(status: SmartStatus.attach),
    child: Container(
      constraints: const BoxConstraints.expand(),
      color: Color(0x3a000000),
      margin: EdgeInsets.only(top: topHeight),
    ),
  ),
  onMask: () => SmartDialog.dismiss<void>(status: SmartStatus.attach),
  debounce: true,
);

double get topHeight {
  final RenderBox renderBox = context.findRenderObject()! as RenderBox;
  final Offset targetOffset = renderBox.localToGlobal(Offset.zero);
  final Size targetSize = renderBox.size;
  return targetSize.height + targetOffset.dy;
}

想添加一个 onMaskMove的监听以用来解决关闭页面的问题

@xdd666t
Copy link
Member

xdd666t commented Aug 5, 2022

有点搞不懂你想干嘛

  • clickMaskDismiss设置成true,根本不需要你搞这一堆兜底关闭措施
  • 点击遮罩或者滑动操作,都会自动关闭弹窗

你搞这些就是为了在遮罩上面搞个高亮效果?你可以看看highlightBuilder参数

@LiWenHui96
Copy link
Author

想要实现的效果是在监听到遮罩层外的部分滑动过程中关闭attach,而非在抬起时关闭。
目前可以实现的效果是在遮罩层外的部分进行滑动并抬起手后会自动关闭。

@xdd666t
Copy link
Member

xdd666t commented Aug 5, 2022

问一下,你这是想你的所有弹窗都是这种表现吗?

  • 在遮罩上面移动手势的时候,关闭弹窗

@LiWenHui96
Copy link
Author

是的,因为产品设计的原因会出现较多的这种效果...

xdd666t added a commit that referenced this issue Aug 6, 2022
@xdd666t
Copy link
Member

xdd666t commented Aug 6, 2022

你这个问题解决了

  • 先升级下版本
dependencies:
  flutter_smart_dialog: ^4.0.9+8
  • 全局配置下
SmartDialog.config
  //show 全局配置
  ..custom = SmartConfigCustom(
    maskTriggerType: SmartMaskTriggerType.move,
  )
  //showAttach 全局配置
  ..attach = SmartConfigAttach(
    maskTriggerType: SmartMaskTriggerType.move,
  );

@xdd666t xdd666t changed the title 使用 showAttach 存在的监听不完全问题 关闭遮罩(onMask)的触发时机问题 Aug 6, 2022
@xdd666t xdd666t changed the title 关闭遮罩(onMask)的触发时机问题 关于遮罩(onMask)的触发时机问题 Aug 6, 2022
@xdd666t xdd666t added the enhancement New feature or request label Aug 6, 2022
@LiWenHui96
Copy link
Author

感谢作者大大的支持,谢谢。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants