|
@@ -25,8 +25,8 @@ class _PopupLayerState extends State<PopupLayer> {
|
|
|
.removeListener(_onPopupMoreSchedule);
|
|
|
}
|
|
|
|
|
|
+ /// 收到显示更多日程的事件
|
|
|
void _onPopupMoreSchedule(e, GlobalKey key) {
|
|
|
- print('onPopupMoreSchedule $key');
|
|
|
setState(() {
|
|
|
moreSchedulePopupKey = key;
|
|
|
});
|
|
@@ -48,27 +48,34 @@ class _PopupLayerState extends State<PopupLayer> {
|
|
|
final Offset popupOffset =
|
|
|
_calcPopupLayerOffset(triggerOffset, triggerSize);
|
|
|
print('计算得的弹出层位置: $popupOffset');
|
|
|
- return Container(
|
|
|
- decoration: BoxDecoration(
|
|
|
- color: Colors.white,
|
|
|
- borderRadius: BorderRadius.circular(8),
|
|
|
- border: Border.all(color: Colors.black12, width: 1),
|
|
|
+ return Positioned(
|
|
|
+ left: triggerOffset.dx,
|
|
|
+ top: triggerOffset.dy,
|
|
|
+ child: 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,
|
|
|
- ),
|
|
|
- ],
|
|
|
+ /// 简单阴影
|
|
|
+ boxShadow: const [
|
|
|
+ BoxShadow(
|
|
|
+ color: Colors.black12,
|
|
|
+ offset: Offset(3, 3),
|
|
|
+ blurRadius: 25,
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ width: triggerSize.width,
|
|
|
+ height: 400,
|
|
|
+ child: Text(popupLayerController.currMoreScheduleData.toString()),
|
|
|
),
|
|
|
- width: 240,
|
|
|
- height: 400,
|
|
|
- child: Text(popupLayerController.currMoreScheduleData.toString()),
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ static const double _popupLayerMarginTop = 70;
|
|
|
+ static const double _popupLayerMarginLeft = 240;
|
|
|
+
|
|
|
/// 通过组件的 key 获取对应的组件的大小信息
|
|
|
/// [key] 组件的 key
|
|
|
Size getWidgetSize(GlobalKey key) {
|
|
@@ -77,18 +84,22 @@ class _PopupLayerState extends State<PopupLayer> {
|
|
|
key.currentContext?.findRenderObject() as RenderBox;
|
|
|
return renderBox.size;
|
|
|
} catch (e) {
|
|
|
+ print('获取大小信息失败: $e');
|
|
|
return Size.zero;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /// 通过组件的 key 获取对应的组件的位置信息
|
|
|
+ /// 通过组件的 key 获取对应的组件在弹出层的位置
|
|
|
/// [key] 组件的 key
|
|
|
Offset getWidgetOffset(GlobalKey key) {
|
|
|
try {
|
|
|
final RenderBox renderBox =
|
|
|
key.currentContext?.findRenderObject() as RenderBox;
|
|
|
- return renderBox.localToGlobal(Offset.zero);
|
|
|
+ return renderBox
|
|
|
+ .localToGlobal(Offset.zero)
|
|
|
+ .translate(-_popupLayerMarginLeft, -_popupLayerMarginTop);
|
|
|
} catch (e) {
|
|
|
+ print('获取位置信息失败: $e');
|
|
|
return Offset.zero;
|
|
|
}
|
|
|
}
|