Skip to content

Commit

Permalink
Merge pull request diegoveloper#60 from diegoveloper/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
diegoveloper authored Jun 2, 2020
2 parents 3555894 + a04cdb6 commit a82efad
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 112 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 2.1.4
- `restartAnimation` was added to restart the animation when reached the end. Thanks to superciccio for the contribution

# 2.1.3
- Added `StrokeCap` on background. Thanks @mifama

Expand Down
18 changes: 18 additions & 0 deletions example/ios/Flutter/Flutter.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# NOTE: This podspec is NOT to be published. It is only used as a local source!
#

Pod::Spec.new do |s|
s.name = 'Flutter'
s.version = '1.0.0'
s.summary = 'High-performance, high-fidelity mobile apps.'
s.description = <<-DESC
Flutter provides an easy and productive way to build and deploy high-performance mobile apps for Android and iOS.
DESC
s.homepage = 'https://flutter.io'
s.license = { :type => 'MIT' }
s.author = { 'Flutter Dev Team' => '[email protected]' }
s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s }
s.ios.deployment_target = '8.0'
s.vendored_frameworks = 'Flutter.framework'
end
4 changes: 3 additions & 1 deletion example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/diegoveloper/Development/SDKS/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/diegoveloper/Development/git-diegoveloper/flutter_packages/flutter-percent-indicator/percent_indicator/example"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_TARGET=/Users/diegoveloper/Development/git-diegoveloper/flutter_packages/flutter-percent-indicator/percent_indicator/example/lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "OTHER_LDFLAGS=$(inherited) -framework Flutter"
export "FLUTTER_FRAMEWORK_DIR=/Users/diegoveloper/Development/SDKS/flutter/bin/cache/artifacts/engine/ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "TRACK_WIDGET_CREATION=true"
14 changes: 1 addition & 13 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; };
9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB31CF90195004384FC /* Generated.xcconfig */; };
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
Expand All @@ -29,8 +25,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -41,13 +35,11 @@
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
Expand All @@ -61,8 +53,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -72,9 +62,7 @@
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
9740EEBA1CF902C7004384FC /* Flutter.framework */,
9740EEB21CF90195004384FC /* Debug.xcconfig */,
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
9740EEB31CF90195004384FC /* Generated.xcconfig */,
Expand Down Expand Up @@ -208,7 +196,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
Expand Down

This file was deleted.

14 changes: 14 additions & 0 deletions example/lib/sample_circular_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,20 @@ class _SampleCircularPageState extends State<SampleCircularPage> {
percent: 0.90,
center: Text("90%"),
progressColor: Colors.green,
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 10.0),
),
CircularPercentIndicator(
radius: 45.0,
lineWidth: 4.0,
percent: 1.0,
animation: true,
restartAnimation: true,
center: CircleAvatar(
child: Icon(Icons.person),
),
progressColor: Colors.redAccent,
)
],
),
Expand Down
11 changes: 11 additions & 0 deletions example/lib/sample_linear_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ class _SampleLinearPageState extends State<SampleLinearPage> {
lineHeight: 8.0,
percent: 0.9,
progressColor: Colors.blue,
),
SizedBox(
height: 10,
),
LinearPercentIndicator(
width: 100.0,
lineHeight: 8.0,
percent: 1.0,
progressColor: Colors.lightBlueAccent,
restartAnimation: true,
animation: true,
)
],
),
Expand Down
4 changes: 2 additions & 2 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.11"
version: "1.14.12"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -26,7 +26,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.1.3"
version: "2.1.4"
sky_engine:
dependency: transitive
description: flutter
Expand Down
40 changes: 19 additions & 21 deletions lib/circular_percent_indicator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ enum ArcType {
FULL,
}

// ignore: must_be_immutable
class CircularPercentIndicator extends StatefulWidget {
///Percent value between 0.0 and 1.0
final double percent;
Expand Down Expand Up @@ -72,6 +73,10 @@ class CircularPercentIndicator extends StatefulWidget {
/// set a circular curve animation type
final Curve curve;

/// set true when you want to restart the animation, it restarts only when reaches 1.0 as a value
/// defaults to false
final bool restartAnimation;

CircularPercentIndicator(
{Key key,
this.percent = 0.0,
Expand All @@ -94,11 +99,11 @@ class CircularPercentIndicator extends StatefulWidget {
this.animateFromLastPercent = false,
this.reverse = false,
this.curve = Curves.linear,
this.maskFilter})
this.maskFilter,
this.restartAnimation = false})
: super(key: key) {
if (linearGradient != null && progressColor != null) {
throw ArgumentError(
'Cannot provide both linearGradient and progressColor');
throw ArgumentError('Cannot provide both linearGradient and progressColor');
}
_progressColor = progressColor ?? Colors.red;

Expand All @@ -114,8 +119,7 @@ class CircularPercentIndicator extends StatefulWidget {
}

@override
_CircularPercentIndicatorState createState() =>
_CircularPercentIndicatorState();
_CircularPercentIndicatorState createState() => _CircularPercentIndicatorState();
}

class _CircularPercentIndicatorState extends State<CircularPercentIndicator>
Expand All @@ -135,15 +139,17 @@ class _CircularPercentIndicatorState extends State<CircularPercentIndicator>
@override
void initState() {
if (widget.animation) {
_animationController = AnimationController(
vsync: this,
duration: Duration(milliseconds: widget.animationDuration));
_animationController =
AnimationController(vsync: this, duration: Duration(milliseconds: widget.animationDuration));
_animation = Tween(begin: 0.0, end: widget.percent).animate(
CurvedAnimation(parent: _animationController, curve: widget.curve),
)..addListener(() {
setState(() {
_percent = _animation.value;
});
if (widget.restartAnimation && _percent == 1.0) {
_animationController.repeat(min: 0, max: 1.0);
}
});
_animationController.forward();
} else {
Expand All @@ -155,15 +161,10 @@ class _CircularPercentIndicatorState extends State<CircularPercentIndicator>
@override
void didUpdateWidget(CircularPercentIndicator oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.percent != widget.percent ||
oldWidget.startAngle != widget.startAngle) {
if (oldWidget.percent != widget.percent || oldWidget.startAngle != widget.startAngle) {
if (_animationController != null) {
_animationController.duration =
Duration(milliseconds: widget.animationDuration);
_animation = Tween(
begin: widget.animateFromLastPercent ? oldWidget.percent : 0.0,
end: widget.percent)
.animate(
_animationController.duration = Duration(milliseconds: widget.animationDuration);
_animation = Tween(begin: widget.animateFromLastPercent ? oldWidget.percent : 0.0, end: widget.percent).animate(
CurvedAnimation(parent: _animationController, curve: widget.curve),
);
_animationController.forward(from: 0.0);
Expand Down Expand Up @@ -203,9 +204,7 @@ class _CircularPercentIndicatorState extends State<CircularPercentIndicator>
reverse: widget.reverse,
linearGradient: widget.linearGradient,
maskFilter: widget.maskFilter),
child: (widget.center != null)
? Center(child: widget.center)
: Container(),
child: (widget.center != null) ? Center(child: widget.center) : Container(),
)));

if (widget.footer != null) {
Expand Down Expand Up @@ -340,8 +339,7 @@ class CirclePainter extends CustomPainter {
}

if (reverse) {
final start =
radians(360 * startAngleFixedMargin - 90.0 + fixedStartAngle);
final start = radians(360 * startAngleFixedMargin - 90.0 + fixedStartAngle);
final end = radians(-progress * startAngleFixedMargin);
canvas.drawArc(
Rect.fromCircle(
Expand Down
Loading

0 comments on commit a82efad

Please sign in to comment.