Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import 'dart:math';
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:intervalprogressbar/intervalprogressbar.dart';
import 'package:zireh/widgets/interval_progress_bar/interval_progress_bar.dart';

class CircleProgressPainter extends IntervalProgressPainter {
final double strokeWidth;
Expand All @@ -19,22 +18,13 @@ class CircleProgressPainter extends IntervalProgressPainter {
bool reverse,
double intervalPercent,
this.strokeWidth)
: super(
max,
progress,
intervalSize,
highlightColor,
defaultColor,
intervalColor,
intervalHighlightColor,
radius,
reverse,
intervalPercent);
: super(max, progress, intervalSize, highlightColor, defaultColor, intervalColor,
intervalHighlightColor, radius, reverse, intervalPercent);

@override
Size calBlockSize() {
//Circle Progress will not call this
return null;
return Size(0, 0);
}

@override
Expand All @@ -53,12 +43,11 @@ class CircleProgressPainter extends IntervalProgressPainter {

Rect rect = Offset.zero & size;
final radius = min(rect.height, rect.width);
final r =
Rect.fromCenter(center: rect.center, width: radius, height: radius);
final r = Rect.fromCenter(center: rect.center, width: radius, height: radius);

final incr = (360.0 - this.intervalDegrees * (this.max - 1)) / (this.max);
final degrees = (360.0 - this.intervalDegrees * (this.max - 1)) / (this.max);
final intervalRadians = degrees2radians(this.intervalDegrees);
final swap = degrees2radians(incr);
final swap = degrees2radians(degrees);

var start = 0.0;

Expand Down
52 changes: 26 additions & 26 deletions lib/intervalprogressbar.dart → lib/interval_progress_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ library intervalprogressbar;
import 'dart:ui';

import 'package:flutter/widgets.dart';
import 'package:intervalprogressbar/CircleProgressPainter.dart';
import 'package:zireh/widgets/interval_progress_bar/circle_progress_painter.dart';

class IntervalProgressBar extends StatelessWidget {
final IntervalProgressDirection direction;
Expand All @@ -21,20 +21,20 @@ class IntervalProgressBar extends StatelessWidget {
final double strokeWith;

const IntervalProgressBar(
{Key key,
this.direction = IntervalProgressDirection.horizontal,
@required this.max,
@required this.progress,
@required this.intervalSize,
@required this.size,
@required this.highlightColor,
@required this.defaultColor,
@required this.intervalColor,
@required this.intervalHighlightColor,
@required this.radius,
this.reverse = false,
this.intervalDegrees = 0.0,
this.strokeWith = 0})
{Key? key,
this.direction = IntervalProgressDirection.horizontal,
required this.max,
required this.progress,
required this.intervalSize,
required this.size,
required this.highlightColor,
required this.defaultColor,
required this.intervalColor,
required this.intervalHighlightColor,
required this.radius,
this.reverse = false,
this.intervalDegrees = 0.0,
this.strokeWith = 0})
: super(key: key);

static const IntervalProgressBar demo = IntervalProgressBar(
Expand Down Expand Up @@ -117,7 +117,7 @@ abstract class IntervalProgressPainter extends CustomPainter {
..style = PaintingStyle.fill
..isAntiAlias = true;

Rect bound;
Rect bound = Rect.zero;

IntervalProgressPainter(
this.max,
Expand Down Expand Up @@ -173,8 +173,8 @@ abstract class IntervalProgressPainter extends CustomPainter {

bool shouldDrawInterval(int index) =>
index != this.max - 1 &&
(intervalColor != IntervalProgressBar.TRANSPARENT ||
intervalHighlightColor != IntervalProgressBar.TRANSPARENT);
(intervalColor != IntervalProgressBar.TRANSPARENT ||
intervalHighlightColor != IntervalProgressBar.TRANSPARENT);
}

class HorizontalProgressPainter extends IntervalProgressPainter {
Expand All @@ -189,7 +189,7 @@ class HorizontalProgressPainter extends IntervalProgressPainter {
double radius,
bool reverse)
: super(max, progress, intervalSize, highlightColor, defaultColor,
intervalColor, intervalHighlightColor, radius, reverse, 0.0);
intervalColor, intervalHighlightColor, radius, reverse, 0.0);

@override
Size calBlockSize() => Size(
Expand Down Expand Up @@ -217,7 +217,7 @@ class HorizontalProgressPainter extends IntervalProgressPainter {

if (shouldDrawInterval(i)) {
painter.color =
highlightInterval(i) ? intervalHighlightColor : intervalColor;
highlightInterval(i) ? intervalHighlightColor : intervalColor;
canvas.drawRect(
Rect.fromLTRB(
blockWidth,
Expand All @@ -232,14 +232,14 @@ class HorizontalProgressPainter extends IntervalProgressPainter {

Rect _drawLeftRound(Canvas canvas, Rect rect) {
final clipRect =
Rect.fromLTRB(rect.left + radius, rect.top, rect.right, rect.bottom);
Rect.fromLTRB(rect.left + radius, rect.top, rect.right, rect.bottom);
_drawRadius(canvas, rect, clipRect);
return clipRect;
}

Rect _drawRightRound(Canvas canvas, Rect rect) {
final clipRect =
Rect.fromLTRB(rect.left, rect.top, rect.right - radius, rect.bottom);
Rect.fromLTRB(rect.left, rect.top, rect.right - radius, rect.bottom);
_drawRadius(canvas, rect, clipRect);
return clipRect;
}
Expand Down Expand Up @@ -267,7 +267,7 @@ class VerticalProgressPainter extends IntervalProgressPainter {
double radius,
bool reverse)
: super(max, progress, intervalSize, highlightColor, defaultColor,
intervalColor, intervalHighlightColor, radius, reverse, 0.0);
intervalColor, intervalHighlightColor, radius, reverse, 0.0);

@override
void paintBlock(Canvas canvas, int i, Size blockSize) {
Expand All @@ -287,7 +287,7 @@ class VerticalProgressPainter extends IntervalProgressPainter {
canvas.drawRect(rect, painter);
if (shouldDrawInterval(i)) {
painter.color =
highlightInterval(i) ? intervalHighlightColor : intervalColor;
highlightInterval(i) ? intervalHighlightColor : intervalColor;
final intervalRect = Rect.fromLTRB(
0, blockHeight, bound.width, blockHeight + intervalSize);
canvas.drawRect(intervalRect, painter);
Expand All @@ -301,14 +301,14 @@ class VerticalProgressPainter extends IntervalProgressPainter {

Rect _drawStartRadius(Canvas canvas, Rect rect) {
final clipRect =
Rect.fromLTRB(rect.left, rect.top + radius, rect.right, rect.bottom);
Rect.fromLTRB(rect.left, rect.top + radius, rect.right, rect.bottom);
_drawRadius(canvas, rect, clipRect);
return clipRect;
}

Rect _drawEndRadius(Canvas canvas, Rect rect) {
final clipRect =
Rect.fromLTRB(rect.left, rect.top, rect.right, rect.bottom - radius);
Rect.fromLTRB(rect.left, rect.top, rect.right, rect.bottom - radius);
_drawRadius(canvas, rect, clipRect);
return clipRect;
}
Expand Down
188 changes: 0 additions & 188 deletions pubspec.lock

This file was deleted.

4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: intervalprogressbar
description: A interval progress bar for Flutter. Horizontal, vertical, colorful and interval progress.
version: 2.0.1
version: 2.1.0
homepage: https://github.com/stefanJi/IntervalProgressBar

environment:
sdk: ">=2.1.0 <3.0.0"
sdk: ">=2.13.0 <3.0.0"

dependencies:
flutter:
Expand Down