Skip to content

Commit

Permalink
FIX: Shape & Needle Pointer Interactivity ListView
Browse files Browse the repository at this point in the history
  • Loading branch information
Afroz-Shaikh committed Jul 31, 2023
1 parent 07308b1 commit 408a026
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/src/radial_gauge/pointer/needle_pointer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class NeedlePointer extends LeafRenderObjectWidget {
this.gradient,
this.color = Colors.red,
this.tailColor = Colors.red,
this.needleWidth = 30,
this.needleWidth = 40,
this.needleHeight = 300,
this.onChanged,
this.isInteractive = false,
Expand Down
9 changes: 5 additions & 4 deletions lib/src/radial_gauge/pointer/needle_pointer_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ class RenderNeedlePointer extends RenderBox {
Offset calulatedPosition = localToGlobal(position);
if (needlePointerRect.contains(calulatedPosition)) {
return true;
} else if (needlePointerRect.contains(position)) {
return true;
} else {
return false;
}
Expand Down Expand Up @@ -182,8 +184,8 @@ class RenderNeedlePointer extends RenderBox {
double startAngle = (_radialGauge!.track.startAngle - 180) * (pi / 180);
double endAngle = (_radialGauge!.track.endAngle - 180) * (pi / 180);

final maxH = size.shortestSide / 2 * getRadialGauge.radiusFactor -
2 * getRadialGauge.track.thickness;
final maxH = size.shortestSide / (2 * getRadialGauge.radiusFactor) -
(2 * getRadialGauge.track.thickness);

final double needleMultiplier = _needleHeight.clamp(0, maxH);

Expand Down Expand Up @@ -221,8 +223,7 @@ class RenderNeedlePointer extends RenderBox {
needleStartY - (needleWidth) * sin(angle + pi / 2));

needlePath.lineTo(needleEndX, needleEndY);
// Offset c = Offset(offset.dx, offset.dy - getTailRadius);
// canvas.drawCircle(c, 100, Paint()..color = Colors.black);

needlePath.close();

needlePointerRect = needlePath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class RenderRadialShapePointer extends RenderBox {

if (pointerRect.contains(calculatedPosition)) {
return true;
} else if (pointerRect.contains(position)) {
return true;
} else {
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/src/radial_gauge/radial_gauge_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class RenderRadialGauge extends RenderBox
child.parentData as RadialGaugeParentData;

if (child is RenderRadialShapePointer) {
childParentData.offset = const Offset(0, 0);
childParentData.offset = Offset.zero;
centOffset = childParentData.offset;
final childConstrainst = BoxConstraints(
maxWidth: size.width,
Expand All @@ -144,7 +144,7 @@ class RenderRadialGauge extends RenderBox

child.layout(childConstrainst, parentUsesSize: true);
} else if (child is RenderRadialWidgetPointer) {
childParentData.offset = const Offset(0, 0);
childParentData.offset = Offset.zero;
final childConstrainst = BoxConstraints(
maxWidth: size.width,
maxHeight: size.height,
Expand All @@ -169,7 +169,7 @@ class RenderRadialGauge extends RenderBox
);
child.layout(childConstraints, parentUsesSize: true);
} else if (child is RenderNeedlePointer) {
childParentData.offset = const Offset(0, 0);
childParentData.offset = Offset.zero;
centOffset = childParentData.offset;
final childConstraints = BoxConstraints(
maxWidth: size.width,
Expand Down

0 comments on commit 408a026

Please sign in to comment.