|
@@ -16,12 +16,15 @@ class PopupLayer extends StatefulWidget {
|
|
|
class _PopupLayerState extends State<PopupLayer> {
|
|
|
PopupLayerController popupLayerController = Get.find<PopupLayerController>();
|
|
|
bool _isShowMoreSchedulePopup = false;
|
|
|
+ bool _isNeedCloseMoreSchedulePopup = false;
|
|
|
bool _isShowSchedulePopup = false;
|
|
|
+ bool _isNeedCloseSchedulePopup = false;
|
|
|
GlobalKey moreSchedulePopupKey = GlobalKey();
|
|
|
@override
|
|
|
void initState() {
|
|
|
super.initState();
|
|
|
popupLayerController.onPopupMoreSchedule.addListener(_onPopupMoreSchedule);
|
|
|
+ popupLayerController.onGlobalClick.addListener(_onGlobalClick);
|
|
|
popupLayerController.onPopupSchedule.addListener(_onPopupSchedule);
|
|
|
}
|
|
|
|
|
@@ -30,6 +33,7 @@ class _PopupLayerState extends State<PopupLayer> {
|
|
|
super.dispose();
|
|
|
popupLayerController.onPopupMoreSchedule
|
|
|
.removeListener(_onPopupMoreSchedule);
|
|
|
+ popupLayerController.onGlobalClick.removeListener(_onGlobalClick);
|
|
|
popupLayerController.onPopupSchedule.removeListener(_onPopupSchedule);
|
|
|
}
|
|
|
|
|
@@ -49,26 +53,46 @@ class _PopupLayerState extends State<PopupLayer> {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ /// 收到全局点击事件
|
|
|
+ /// 全局按下时设置 _needClosePopup 为 true
|
|
|
+ /// 弹层组件收到 onPointerUp 时设置 _needClosePopup 为 false
|
|
|
+ /// 全局抬起时判断 _needClosePopup 是否为 true,为 true 则关闭弹层
|
|
|
+ void _onGlobalClick(e, PointerEvent event) {
|
|
|
+ if (event is PointerDownEvent) {
|
|
|
+ _isNeedCloseMoreSchedulePopup = true;
|
|
|
+ _isNeedCloseSchedulePopup = true;
|
|
|
+ } else if (event is PointerUpEvent) {
|
|
|
+ if (_isNeedCloseMoreSchedulePopup) {
|
|
|
+ setState(() {
|
|
|
+ _isShowMoreSchedulePopup = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (_isNeedCloseSchedulePopup) {
|
|
|
+ setState(() {
|
|
|
+ _isShowSchedulePopup = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
return Stack(
|
|
|
children: [
|
|
|
if (_isShowMoreSchedulePopup)
|
|
|
Listener(
|
|
|
- behavior: HitTestBehavior.translucent,
|
|
|
+ behavior: HitTestBehavior.deferToChild,
|
|
|
onPointerUp: (event) {
|
|
|
- setState(() {
|
|
|
- _isShowMoreSchedulePopup = false;
|
|
|
- });
|
|
|
+ _isShowMoreSchedulePopup = false;
|
|
|
},
|
|
|
child: _buildMoreSchedulePopup(moreSchedulePopupKey),
|
|
|
),
|
|
|
if (_isShowSchedulePopup)
|
|
|
Listener(
|
|
|
- behavior: HitTestBehavior.translucent,
|
|
|
+ behavior: HitTestBehavior.deferToChild,
|
|
|
onPointerUp: (event) {
|
|
|
setState(() {
|
|
|
- _isShowSchedulePopup = false;
|
|
|
+ _isNeedCloseSchedulePopup = false;
|
|
|
});
|
|
|
popupLayerController.onCloseSchedulePopup.emit(this, false);
|
|
|
},
|