diff --git a/CHANGELOG.md b/CHANGELOG.md index 504554f..b5793bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 1.0.3 + +**Fixes** + +- Fixed Drawing of `Pointer` over `valueBar` + + ## 1.0.2 **Features** diff --git a/example/lib/gauge_vertical.dart b/example/lib/gauge_vertical.dart index 7e601de..eca59c0 100644 --- a/example/lib/gauge_vertical.dart +++ b/example/lib/gauge_vertical.dart @@ -14,26 +14,36 @@ class _MyVerticalGaugeState extends State { return Scaffold( body: Center( child: Padding( - padding: const EdgeInsets.all(2.0), - child: LinearGauge( - linearGaugeBoxDecoration: const LinearGaugeBoxDecoration( - thickness: 30, - borderRadius: 10, - ), - // enableAnimation: true, - gaugeOrientation: GaugeOrientation.horizontal, - rulers: RulerStyle( - primaryRulersWidth: 10, - primaryRulersHeight: 30, - primaryRulerColor: const Color(0xff310072), - inverseRulers: false, - showLabel: false, - showSecondaryRulers: false, - showPrimaryRulers: true, - rulerPosition: RulerPosition.center, - ), - ), - ), + padding: const EdgeInsets.all(2.0), + child: LinearGauge( + end: 126, + gaugeOrientation: GaugeOrientation.vertical, + rulers: RulerStyle( + rulerPosition: RulerPosition.right, + ), + pointers: const [ + Pointer( + value: 50, + height: 20, + color: Colors.green, + width: 20, + shape: PointerShape.triangle, + isInteractive: true, + onChanged: null, + pointerPosition: PointerPosition.left, + ), + ], + curves: const [ + CustomCurve( + startHeight: 4, + endHeight: 50, + midHeight: 5, + curvePosition: CurvePosition.left, + end: 126, + midPoint: 50 * 0.8, + ), + ], + )), ), ); } diff --git a/example/lib/main.dart b/example/lib/main.dart index cb40c6d..b143450 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,3 +1,4 @@ +import 'package:example/gauge_vertical.dart'; import 'package:flutter/material.dart'; import 'package:geekyants_flutter_gauges/geekyants_flutter_gauges.dart'; @@ -5,7 +6,7 @@ void main() { runApp( const MaterialApp( debugShowCheckedModeBanner: false, - home: RadialGaugeExample(), + home: MyVerticalGauge(), ), ); } diff --git a/lib/src/radial_gauge/pointer/needle_pointer.dart b/lib/src/radial_gauge/pointer/needle_pointer.dart index 1dee303..b952c7e 100644 --- a/lib/src/radial_gauge/pointer/needle_pointer.dart +++ b/lib/src/radial_gauge/pointer/needle_pointer.dart @@ -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, diff --git a/lib/src/radial_gauge/pointer/needle_pointer_painter.dart b/lib/src/radial_gauge/pointer/needle_pointer_painter.dart index e3f4849..d623f95 100644 --- a/lib/src/radial_gauge/pointer/needle_pointer_painter.dart +++ b/lib/src/radial_gauge/pointer/needle_pointer_painter.dart @@ -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; } @@ -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); @@ -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; diff --git a/lib/src/radial_gauge/pointer/radial_shape_pointer_painter.dart b/lib/src/radial_gauge/pointer/radial_shape_pointer_painter.dart index 8e2d94c..e35bb02 100644 --- a/lib/src/radial_gauge/pointer/radial_shape_pointer_painter.dart +++ b/lib/src/radial_gauge/pointer/radial_shape_pointer_painter.dart @@ -46,6 +46,8 @@ class RenderRadialShapePointer extends RenderBox { if (pointerRect.contains(calculatedPosition)) { return true; + } else if (pointerRect.contains(position)) { + return true; } else { return false; } diff --git a/lib/src/radial_gauge/radial_gauge_painter.dart b/lib/src/radial_gauge/radial_gauge_painter.dart index 7312e75..b2ef0dd 100644 --- a/lib/src/radial_gauge/radial_gauge_painter.dart +++ b/lib/src/radial_gauge/radial_gauge_painter.dart @@ -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, @@ -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, @@ -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, diff --git a/pubspec.yaml b/pubspec.yaml index 033680d..650fbf1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: geekyants_flutter_gauges description: A linear gauge package for Flutter that displays progress and can be customized for appearance and behavior. -version: 1.0.2 +version: 1.0.3 homepage: https://github.com/GeekyAnts/GaugesFlutter environment: