소스 검색

完善布局bug

gavin.chen 2 년 전
부모
커밋
bd6d3c885d
1개의 변경된 파일22개의 추가작업 그리고 16개의 파일을 삭제
  1. 22 16
      lib/popup_layer/popup_layer.dart

+ 22 - 16
lib/popup_layer/popup_layer.dart

@@ -6,18 +6,6 @@ import 'package:calendar_view/popup_layer/popup_layer_controller.dart';
 import 'package:flutter/material.dart';
 import 'package:get/get.dart';
 
-/// 日程详情弹出框宽度
-const double _scheduleDetailPopupWidth = 380;
-
-/// 完成日程列表弹出框最小推荐宽度
-const double _moreSchedulePopupMinWidth = 220;
-
-/// 固定的头部高度
-const double _popupLayerMarginTop = 70;
-
-/// 固定的左侧宽度
-const double _popupLayerMarginLeft = 240;
-
 class PopupLayer extends StatefulWidget {
   const PopupLayer({super.key});
 
@@ -34,6 +22,18 @@ class _PopupLayerState extends State<PopupLayer> {
   GlobalKey moreSchedulePopupKey = GlobalKey();
   GlobalKey scheduleDetailPopupKey = GlobalKey();
 
+  /// 日程详情弹出框宽度
+  static const double _scheduleDetailPopupWidth = 380;
+
+  /// 完成日程列表弹出框最小推荐宽度
+  static const double _moreSchedulePopupMinWidth = 220;
+
+  /// 固定的头部高度
+  static const double _popupLayerMarginTop = 70;
+
+  /// 固定的左侧宽度
+  static const double _popupLayerMarginLeft = 240;
+
   /// 弹出框装饰器
   static final BoxDecoration _popupBoxDecoration = BoxDecoration(
     color: Colors.white,
@@ -226,7 +226,7 @@ class AutoAlignFlowDelegate extends FlowDelegate {
   }
 }
 
-/// 日程框自动对齐委托
+/// 日程详情框自动对齐委托
 class ScheduleAutoAlignFlowDelegate extends FlowDelegate {
   final Offset triggerOffset;
   final Size triggerSize;
@@ -241,9 +241,15 @@ class ScheduleAutoAlignFlowDelegate extends FlowDelegate {
       if (containerSize.height - y < childSize.height) {
         y = containerSize.height - childSize.height;
       }
-      if (containerSize.width <
-          x + childSize.width + _scheduleDetailPopupWidth) {
-        x = x - _scheduleDetailPopupWidth;
+      if (containerSize.width - x - triggerSize.width < childSize.width) {
+        x = x - childSize.width;
+        if (x < 0) {
+          x = 0;
+          y += triggerSize.height + 10;
+          if (containerSize.height - y < childSize.height) {
+            y = containerSize.height - childSize.height;
+          }
+        }
       } else {
         x = x + triggerSize.width;
       }