diff --git a/README.md b/README.md index 2deb391..abb5149 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,8 @@ Liquid progress indicator for Flutter. borderWidth: 5.0, direction: Axis.horizontal, // The direction the liquid moves (Axis.vertical = bottom to top, Axis.horizontal = left to right). Defaults to Axis.vertical. center: Text("Loading..."), + waveCount: 2.0, //Defaults to 1.0 + amplitude: 4.0, //Defaults to 2.0 ); ### LiquidLinearProgressIndicator @@ -43,6 +45,8 @@ Liquid progress indicator for Flutter. borderRadius: 12.0, direction: Axis.vertical, // The direction the liquid moves (Axis.vertical = bottom to top, Axis.horizontal = left to right). Defaults to Axis.horizontal. center: Text("Loading..."), + waveCount: 2.0, //Defaults to 1.0 + amplitude: 4.0, //Defaults to 2.0 ); ### LiquidCustomProgressIndicator @@ -53,6 +57,8 @@ Liquid progress indicator for Flutter. backgroundColor: Colors.white, // Defaults to the current Theme's backgroundColor. direction: Axis.vertical, // The direction the liquid moves (Axis.vertical = bottom to top, Axis.horizontal = left to right). shapePath: _buildBoatPath(), // A Path object used to draw the shape of the progress indicator. The size of the progress indicator is created from the bounds of this path. + waveCount: 2.0, //Defaults to 1.0 + amplitude: 4.0, //Defaults to 2.0 ) diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh new file mode 100644 index 0000000..81a9d02 --- /dev/null +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# This is a generated file; do not edit or check into version control. +export "FLUTTER_ROOT=C:\src\flutter" +export "FLUTTER_APPLICATION_PATH=D:\Krishworks\liquid_progress_indicator\example" +export "COCOAPODS_PARALLEL_CODE_SIGN=true" +export "FLUTTER_TARGET=lib\main.dart" +export "FLUTTER_BUILD_DIR=build" +export "FLUTTER_BUILD_NAME=1.0.0" +export "FLUTTER_BUILD_NUMBER=1" +export "DART_OBFUSCATION=false" +export "TRACK_WIDGET_CREATION=false" +export "TREE_SHAKE_ICONS=false" +export "PACKAGE_CONFIG=.dart_tool/package_config.json" diff --git a/example/lib/main.dart b/example/lib/main.dart index 4d51147..f3cf6d3 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -11,7 +11,7 @@ class Example extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text("Liquid Progress Indicator Examples"), + title: Text("Liquid Progress Indicator - Subhopriyo"), ), body: Padding( padding: const EdgeInsets.all(28.0), diff --git a/lib/src/liquid_circular_progress_indicator.dart b/lib/src/liquid_circular_progress_indicator.dart index 7cf767f..eeb461d 100644 --- a/lib/src/liquid_circular_progress_indicator.dart +++ b/lib/src/liquid_circular_progress_indicator.dart @@ -20,6 +20,12 @@ class LiquidCircularProgressIndicator extends ProgressIndicator { ///The direction the liquid travels. final Axis direction; + ///The number of waves that will be shown in one time frame + final double waveCount; + + ///The amplitude of the waves + final double amplitude; + LiquidCircularProgressIndicator({ Key? key, double value = 0.5, @@ -29,6 +35,8 @@ class LiquidCircularProgressIndicator extends ProgressIndicator { this.borderColor, this.center, this.direction = Axis.vertical, + this.waveCount = 1, + this.amplitude = 2, }) : super( key: key, value: value, @@ -72,6 +80,8 @@ class _LiquidCircularProgressIndicatorState value: widget.value, color: widget._getValueColor(context), direction: widget.direction, + waveCount: widget.waveCount, + amplitude: widget.amplitude, ), if (widget.center != null) Center(child: widget.center), ], @@ -113,8 +123,8 @@ class _CircleBorderPainter extends CustomPainter { ..style = PaintingStyle.stroke ..strokeWidth = width!; final newSize = Size(size.width - width!, size.height - width!); - canvas.drawArc( - Offset(width! / 2, width! / 2) & newSize, 0, _sweep, false, borderPaint); + canvas.drawArc(Offset(width! / 2, width! / 2) & newSize, 0, _sweep, false, + borderPaint); } @override diff --git a/lib/src/liquid_custom_progress_indicator.dart b/lib/src/liquid_custom_progress_indicator.dart index be7cafa..3a638b0 100644 --- a/lib/src/liquid_custom_progress_indicator.dart +++ b/lib/src/liquid_custom_progress_indicator.dart @@ -11,6 +11,12 @@ class LiquidCustomProgressIndicator extends ProgressIndicator { ///The path used to draw the shape of the progress indicator. The size of the progress indicator is controlled by the bounds of this path. final Path shapePath; + ///The number of waves that will be shown in one time frame + final double waveCount; + + ///The amplitude of the waves + final double amplitude; + LiquidCustomProgressIndicator({ Key? key, double value = 0.5, @@ -19,6 +25,8 @@ class LiquidCustomProgressIndicator extends ProgressIndicator { this.center, required this.direction, required this.shapePath, + this.waveCount = 1, + this.amplitude = 2, }) : super( key: key, value: value, @@ -62,6 +70,8 @@ class _LiquidCustomProgressIndicatorState value: widget.value, color: widget._getValueColor(context), direction: widget.direction, + waveCount: widget.waveCount, + amplitude: widget.amplitude, ), ), if (widget.center != null) Center(child: widget.center), diff --git a/lib/src/liquid_linear_progress_indicator.dart b/lib/src/liquid_linear_progress_indicator.dart index a7d76a3..5a31ba6 100644 --- a/lib/src/liquid_linear_progress_indicator.dart +++ b/lib/src/liquid_linear_progress_indicator.dart @@ -17,6 +17,12 @@ class LiquidLinearProgressIndicator extends ProgressIndicator { ///The direction the liquid travels. final Axis direction; + ///The number of waves that will be shown in one time frame + final double waveCount; + + ///The amplitude of the waves + final double amplitude; + LiquidLinearProgressIndicator({ Key? key, double value = 0.5, @@ -27,6 +33,8 @@ class LiquidLinearProgressIndicator extends ProgressIndicator { this.borderRadius, this.center, this.direction = Axis.horizontal, + this.waveCount = 1, + this.amplitude = 2, }) : super( key: key, value: value, @@ -73,6 +81,8 @@ class _LiquidLinearProgressIndicatorState value: widget.value, color: widget._getValueColor(context), direction: widget.direction, + waveCount: widget.waveCount, + amplitude: widget.amplitude, ), if (widget.center != null) Center(child: widget.center), ], diff --git a/lib/src/wave.dart b/lib/src/wave.dart index eee2208..424a0d4 100644 --- a/lib/src/wave.dart +++ b/lib/src/wave.dart @@ -6,12 +6,16 @@ class Wave extends StatefulWidget { final double? value; final Color color; final Axis direction; + final double waveCount; + final double amplitude; const Wave({ Key? key, required this.value, required this.color, required this.direction, + required this.waveCount, + required this.amplitude, }) : super(key: key); @override @@ -50,10 +54,11 @@ class _WaveState extends State with SingleTickerProviderStateMixin { color: widget.color, ), clipper: _WaveClipper( - animationValue: _animationController.value, - value: widget.value, - direction: widget.direction, - ), + animationValue: _animationController.value, + value: widget.value, + direction: widget.direction, + waveCount: widget.waveCount, + amplitude: widget.amplitude), ), ); } @@ -63,11 +68,15 @@ class _WaveClipper extends CustomClipper { final double animationValue; final double? value; final Axis direction; + final double waveCount; + final double amplitude; _WaveClipper({ required this.animationValue, required this.value, required this.direction, + required this.waveCount, + required this.amplitude, }); @override @@ -81,11 +90,27 @@ class _WaveClipper extends CustomClipper { return path; } - Path path = Path() - ..addPolygon(_generateVerticalWavePath(size), false) - ..lineTo(size.width, size.height) - ..lineTo(0.0, size.height) - ..close(); + double p = value ?? 50 / 100.0; + double n = waveCount; + double amp = amplitude; + double baseHeight = (1 - p) * size.height; + + Path path = Path(); + path.moveTo(0.0, baseHeight); + for (double i = 0.0; i < size.width; i++) { + path.lineTo( + i, + baseHeight + + math.sin((i / size.width * 2 * math.pi * n) + + (animationValue * 2 * math.pi) + + math.pi * 1) * + amp); + } + + path.lineTo(size.width, size.height); + path.lineTo(0.0, size.height); + path.close(); + return path; }