Skip to content

Commit

Permalink
Merge branch 'main' into fix/linter-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Afroz-Shaikh authored Mar 5, 2024
2 parents b9fc52f + 4682569 commit 366f3c4
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 30 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.0.3

**Fixes**

- Fixed Drawing of `Pointer` over `valueBar`


## 1.0.2

**Features**
Expand Down
50 changes: 30 additions & 20 deletions example/lib/gauge_vertical.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,36 @@ class _MyVerticalGaugeState extends State<MyVerticalGauge> {
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,
),
],
)),
),
);
}
Expand Down
3 changes: 2 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import 'package:example/gauge_vertical.dart';
import 'package:flutter/material.dart';
import 'package:geekyants_flutter_gauges/geekyants_flutter_gauges.dart';

void main() {
runApp(
const MaterialApp(
debugShowCheckedModeBanner: false,
home: RadialGaugeExample(),
home: MyVerticalGauge(),
),
);
}
Expand Down
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
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 366f3c4

Please sign in to comment.