|
@@ -6,6 +6,18 @@ 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});
|
|
|
|
|
@@ -17,16 +29,31 @@ class _PopupLayerState extends State<PopupLayer> {
|
|
|
PopupLayerController popupLayerController = Get.find<PopupLayerController>();
|
|
|
bool _isShowMoreSchedulePopup = false;
|
|
|
bool _isNeedCloseMoreSchedulePopup = false;
|
|
|
- bool _isShowSchedulePopup = false;
|
|
|
- bool _isNeedCloseSchedulePopup = false;
|
|
|
+ bool _isShowScheduleDetailPopup = false;
|
|
|
+ bool _isNeedCloseScheduleDetailPopup = false;
|
|
|
GlobalKey moreSchedulePopupKey = GlobalKey();
|
|
|
- GlobalKey schedulePopupKey = GlobalKey();
|
|
|
+ GlobalKey scheduleDetailPopupKey = GlobalKey();
|
|
|
+
|
|
|
+ /// 弹出框装饰器
|
|
|
+ static final BoxDecoration _popupBoxDecoration = BoxDecoration(
|
|
|
+ color: Colors.white,
|
|
|
+ borderRadius: BorderRadius.circular(8),
|
|
|
+ border: Border.all(color: Colors.black12, width: 1),
|
|
|
+ boxShadow: const [
|
|
|
+ BoxShadow(
|
|
|
+ color: Colors.black12,
|
|
|
+ offset: Offset(3, 3),
|
|
|
+ blurRadius: 25,
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ );
|
|
|
@override
|
|
|
void initState() {
|
|
|
super.initState();
|
|
|
popupLayerController.onPopupMoreSchedule.addListener(_onPopupMoreSchedule);
|
|
|
popupLayerController.onGlobalClick.addListener(_onGlobalClick);
|
|
|
- popupLayerController.onPopupSchedule.addListener(_onPopupSchedule);
|
|
|
+ popupLayerController.onPopupScheduleDatail
|
|
|
+ .addListener(_onPopupScheduleDatail);
|
|
|
}
|
|
|
|
|
|
@override
|
|
@@ -35,7 +62,8 @@ class _PopupLayerState extends State<PopupLayer> {
|
|
|
popupLayerController.onPopupMoreSchedule
|
|
|
.removeListener(_onPopupMoreSchedule);
|
|
|
popupLayerController.onGlobalClick.removeListener(_onGlobalClick);
|
|
|
- popupLayerController.onPopupSchedule.removeListener(_onPopupSchedule);
|
|
|
+ popupLayerController.onPopupScheduleDatail
|
|
|
+ .removeListener(_onPopupScheduleDatail);
|
|
|
}
|
|
|
|
|
|
/// 收到显示更多日程的事件
|
|
@@ -46,11 +74,11 @@ class _PopupLayerState extends State<PopupLayer> {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- /// 收到显示日程的事件
|
|
|
- void _onPopupSchedule(e, GlobalKey key) {
|
|
|
+ /// 收到显示日程详情的事件
|
|
|
+ void _onPopupScheduleDatail(e, GlobalKey key) {
|
|
|
setState(() {
|
|
|
- _isShowSchedulePopup = true;
|
|
|
- schedulePopupKey = key;
|
|
|
+ _isShowScheduleDetailPopup = true;
|
|
|
+ scheduleDetailPopupKey = key;
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -61,17 +89,18 @@ class _PopupLayerState extends State<PopupLayer> {
|
|
|
void _onGlobalClick(e, PointerEvent event) {
|
|
|
if (event is PointerDownEvent) {
|
|
|
_isNeedCloseMoreSchedulePopup = true;
|
|
|
- _isNeedCloseSchedulePopup = true;
|
|
|
+ _isNeedCloseScheduleDetailPopup = true;
|
|
|
} else if (event is PointerUpEvent) {
|
|
|
if (_isNeedCloseMoreSchedulePopup) {
|
|
|
setState(() {
|
|
|
_isShowMoreSchedulePopup = false;
|
|
|
});
|
|
|
}
|
|
|
- if (_isNeedCloseSchedulePopup) {
|
|
|
+ if (_isNeedCloseScheduleDetailPopup) {
|
|
|
setState(() {
|
|
|
- _isShowSchedulePopup = false;
|
|
|
+ _isShowScheduleDetailPopup = false;
|
|
|
});
|
|
|
+ popupLayerController.onCloseSchedulePopup.emit(this, null);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -88,16 +117,15 @@ class _PopupLayerState extends State<PopupLayer> {
|
|
|
},
|
|
|
child: _buildMoreSchedulePopup(moreSchedulePopupKey),
|
|
|
),
|
|
|
- if (_isShowSchedulePopup)
|
|
|
+ if (_isShowScheduleDetailPopup)
|
|
|
Listener(
|
|
|
behavior: HitTestBehavior.deferToChild,
|
|
|
onPointerUp: (event) {
|
|
|
setState(() {
|
|
|
- _isNeedCloseSchedulePopup = false;
|
|
|
+ _isNeedCloseScheduleDetailPopup = false;
|
|
|
});
|
|
|
- popupLayerController.onCloseSchedulePopup.emit(this, false);
|
|
|
},
|
|
|
- child: _buildSchedulePopup(schedulePopupKey),
|
|
|
+ child: _buildScheduleDetailPopup(scheduleDetailPopupKey),
|
|
|
)
|
|
|
],
|
|
|
);
|
|
@@ -112,27 +140,10 @@ class _PopupLayerState extends State<PopupLayer> {
|
|
|
delegate: AutoAlignFlowDelegate(triggerOffset),
|
|
|
children: [
|
|
|
Container(
|
|
|
- decoration: BoxDecoration(
|
|
|
- color: Colors.white,
|
|
|
- borderRadius: BorderRadius.circular(8),
|
|
|
- border: Border.all(color: Colors.black12, width: 1),
|
|
|
- boxShadow: const [
|
|
|
- BoxShadow(
|
|
|
- color: Colors.black12,
|
|
|
- offset: Offset(3, 3),
|
|
|
- blurRadius: 25,
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
- width: max(triggerSize.width, 220),
|
|
|
+ decoration: _popupBoxDecoration,
|
|
|
+ width: max(triggerSize.width, _moreSchedulePopupMinWidth),
|
|
|
child: MoreSchedulePopup(
|
|
|
scheduleData: popupLayerController.currMoreScheduleData,
|
|
|
- onTapShowSchedule: (value) {
|
|
|
- popupLayerController.handlePopupSchedule(
|
|
|
- value,
|
|
|
- popupLayerController.currMoreScheduleData,
|
|
|
- );
|
|
|
- },
|
|
|
),
|
|
|
),
|
|
|
],
|
|
@@ -141,39 +152,27 @@ class _PopupLayerState extends State<PopupLayer> {
|
|
|
|
|
|
/// 只做容器而无需负责内容
|
|
|
/// [trigger] 触发器的 key
|
|
|
- Widget _buildSchedulePopup(GlobalKey trigger) {
|
|
|
+ Widget _buildScheduleDetailPopup(GlobalKey trigger) {
|
|
|
final Size triggerSize = getWidgetSize(trigger);
|
|
|
final Offset triggerOffset = getWidgetOffset(trigger);
|
|
|
return Flow(
|
|
|
delegate: ScheduleAutoAlignFlowDelegate(triggerOffset, triggerSize),
|
|
|
children: [
|
|
|
Container(
|
|
|
- decoration: BoxDecoration(
|
|
|
- color: Colors.white,
|
|
|
- borderRadius: BorderRadius.circular(8),
|
|
|
- border: Border.all(color: Colors.black12, width: 1),
|
|
|
- boxShadow: const [
|
|
|
- BoxShadow(
|
|
|
- color: Colors.black12,
|
|
|
- offset: Offset(3, 3),
|
|
|
- blurRadius: 25,
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
- width: 360,
|
|
|
- child: SchedulePopup(
|
|
|
- scheduleData: popupLayerController.currMoreScheduleData,
|
|
|
+ padding: const EdgeInsets.symmetric(horizontal: 10),
|
|
|
+ width: _scheduleDetailPopupWidth,
|
|
|
+ child: Container(
|
|
|
+ decoration: _popupBoxDecoration,
|
|
|
+ child: SchedulePopup(
|
|
|
+ scheduleData: popupLayerController.currScheduleData,
|
|
|
+ ),
|
|
|
),
|
|
|
),
|
|
|
],
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- static const double _popupLayerMarginTop = 70;
|
|
|
- static const double _popupLayerMarginLeft = 240;
|
|
|
-
|
|
|
/// 通过组件的 key 获取对应的组件的大小信息
|
|
|
- /// [key] 组件的 key
|
|
|
Size getWidgetSize(GlobalKey key) {
|
|
|
try {
|
|
|
final RenderBox renderBox =
|
|
@@ -186,7 +185,6 @@ class _PopupLayerState extends State<PopupLayer> {
|
|
|
}
|
|
|
|
|
|
/// 通过组件的 key 获取对应的组件在弹出层的位置
|
|
|
- /// [key] 组件的 key
|
|
|
Offset getWidgetOffset(GlobalKey key) {
|
|
|
try {
|
|
|
final RenderBox renderBox =
|
|
@@ -243,10 +241,11 @@ class ScheduleAutoAlignFlowDelegate extends FlowDelegate {
|
|
|
if (containerSize.height - y < childSize.height) {
|
|
|
y = containerSize.height - childSize.height;
|
|
|
}
|
|
|
- if (containerSize.width < x + childSize.width + 370) {
|
|
|
- x = x - 370;
|
|
|
+ if (containerSize.width <
|
|
|
+ x + childSize.width + _scheduleDetailPopupWidth) {
|
|
|
+ x = x - _scheduleDetailPopupWidth;
|
|
|
} else {
|
|
|
- x = x + triggerSize.width + 10;
|
|
|
+ x = x + triggerSize.width;
|
|
|
}
|
|
|
context.paintChild(i, transform: Matrix4.translationValues(x, y, 0));
|
|
|
}
|