1.1.22+3 corrections

This commit is contained in:
bossanyit
2021-09-05 07:47:15 +02:00
parent cebd83648b
commit e34add8185
57 changed files with 1577 additions and 1490 deletions
+170
View File
@@ -307,6 +307,60 @@ class SuperTooltip {
isOpen = true;
}
void showBox(BuildContext targetContext) {
final renderBox = targetContext.findRenderObject() as RenderBox;
var size = renderBox.size;
print("Size $size");
if (containsBackgroundOverlay) {
_backGroundOverlay = OverlayEntry(
builder: (context) => _AnimationWrapper(
builder: (context, opacity) => AnimatedOpacity(
opacity: opacity,
duration: const Duration(milliseconds: 600),
child: GestureDetector(
onTap: () {
if (dismissOnTapOutside) {
close();
}
},
child: Container(
decoration: ShapeDecoration(
shape: _ShapeOverlay(
touchThrougArea, touchThroughAreaShape, touchThroughAreaCornerRadius, outsideBackgroundColor))),
),
),
));
}
_ballonOverlay = OverlayEntry(
builder: (context) => _AnimationWrapper(
builder: (context, opacity) => Positioned(
left: left, //offset.dx,
top: top,
width: size.width > maxWidth! ? maxWidth : size.width,
child: AnimatedOpacity(
duration: Duration(
milliseconds: 300,
),
opacity: opacity,
child: Stack(
fit: StackFit.passthrough,
children: [_buildPopUp(), _buildCloseButton()],
),
)),
));
var overlays = <OverlayEntry>[];
if (containsBackgroundOverlay) {
overlays.add(_backGroundOverlay!);
}
overlays.add(_ballonOverlay!);
Overlay.of(targetContext)!.insertAll(overlays);
isOpen = true;
}
Widget _buildPopUp() {
return Positioned(
child: Container(
@@ -675,6 +729,122 @@ class _PopupBallonLayoutDelegate extends SingleChildLayoutDelegate {
}
}
class _PopupBallonLayoutDelegateBox extends SingleChildLayoutDelegate {
final double? _minWidth;
final double? _maxWidth;
final double? _minHeight;
final double? _maxHeight;
final double? _top;
final double? _bottom;
final double? _left;
final double? _right;
final double? _outSidePadding;
_PopupBallonLayoutDelegateBox({
double? minWidth,
double? maxWidth,
double? minHeight,
double? maxHeight,
double? outSidePadding,
double? top,
double? bottom,
double? left,
double? right,
}) : _minWidth = minWidth,
_maxWidth = maxWidth,
_minHeight = minHeight,
_maxHeight = maxHeight,
_top = top,
_bottom = bottom,
_left = left,
_right = right,
_outSidePadding = outSidePadding;
@override
Offset getPositionForChild(Size size, Size childSize) {
double? calcLeftMostXtoTarget() {
double? leftMostXtoTarget;
if (_left != null) {
leftMostXtoTarget = _left;
} else if (_right != null) {
leftMostXtoTarget = max(
size.topLeft(Offset.zero).dx + _outSidePadding!, size.topRight(Offset.zero).dx - _outSidePadding! - childSize.width - _right!);
}
return leftMostXtoTarget;
}
double? calcTopMostYtoTarget() {
double? topmostYtoTarget;
if (_top != null) {
topmostYtoTarget = _top!;
} else if (_bottom != null) {
topmostYtoTarget = max(size.topLeft(Offset.zero).dy + _outSidePadding!,
size.bottomRight(Offset.zero).dy - _outSidePadding! - childSize.height - _bottom!);
}
return topmostYtoTarget;
}
return new Offset(calcLeftMostXtoTarget()!, _top!);
}
@override
BoxConstraints getConstraintsForChild(BoxConstraints constraints) {
// print("ParentConstraints: $constraints");
var calcMinWidth = _minWidth ?? 0.0;
var calcMaxWidth = _maxWidth ?? double.infinity;
var calcMinHeight = _minHeight ?? 0.0;
var calcMaxHeight = _maxHeight ?? double.infinity;
void calcMinMaxWidth() {
if (_left != null && _right != null) {
calcMaxWidth = constraints.maxWidth - (_left! + _right!);
} else if ((_left != null && _right == null) || (_left == null && _right != null)) {
// make sure that the sum of left, right + maxwidth isn't bigger than the screen width.
var sideDelta = (_left ?? 0.0) + (_right ?? 0.0) + _outSidePadding!;
if (calcMaxWidth > constraints.maxWidth - sideDelta) {
calcMaxWidth = constraints.maxWidth - sideDelta;
}
} else {
if (calcMaxWidth > constraints.maxWidth - 2 * _outSidePadding!) {
calcMaxWidth = constraints.maxWidth - 2 * _outSidePadding!;
}
}
}
void calcMinMaxHeight() {
if (_top != null && _bottom != null) {
calcMaxHeight = constraints.maxHeight - (_top! + _bottom!);
} else if ((_top != null && _bottom == null) || (_top == null && _bottom != null)) {
// make sure that the sum of top, bottom + maxHeight isn't bigger than the screen Height.
var sideDelta = (_top ?? 0.0) + (_bottom ?? 0.0) + _outSidePadding!;
if (calcMaxHeight > constraints.maxHeight - sideDelta) {
calcMaxHeight = constraints.maxHeight - sideDelta;
}
} else {
if (calcMaxHeight > constraints.maxHeight - 2 * _outSidePadding!) {
calcMaxHeight = constraints.maxHeight - 2 * _outSidePadding!;
}
}
}
var childConstraints = new BoxConstraints(
minWidth: calcMinWidth > calcMaxWidth ? calcMaxWidth : calcMinWidth,
maxWidth: calcMaxWidth,
minHeight: calcMinHeight > calcMaxHeight ? calcMaxHeight : calcMinHeight,
maxHeight: calcMaxHeight);
// print("Child constraints: $childConstraints");
return childConstraints;
}
@override
bool shouldRelayout(SingleChildLayoutDelegate oldDelegate) {
return false;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
class _BubbleShape extends ShapeBorder {