diff --git a/CHANGELOG.md b/CHANGELOG.md index a5be2ce..e21ea43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [2.0.8] +* Added success and error icons parameters +* Added completion curve and duration parameters + ## [2.0.7] * Updated rxdart constraints * Updated the screenshot diff --git a/README.md b/README.md index de5e433..f23af97 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ RoundedLoadingButton is a Flutter package with a simple implementation of an ani Add this to your pubspec.yaml: dependencies: - rounded_loading_button: ^2.0.6 + rounded_loading_button: ^2.0.8 ## Usage @@ -48,6 +48,8 @@ The Rounded Loading Button has many configurable properties, including: * `resetAfterDuration` - Reset the animation after specified duration, defaults to 15 seconds * `errorColor` - The color of the button when it is in the error state * `successColor` - The color of the button when it is in the success state +* `successIcon` - The icon for the success state +* `failedIcon` - The icon for the failed state ## Contributions diff --git a/example/lib/main.dart b/example/lib/main.dart index 6c352c1..f3b0b34 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -50,6 +50,8 @@ class _MyHomePageState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ RoundedLoadingButton( + successIcon: Icons.cloud, + failedIcon: Icons.cottage, child: Text('Tap me!', style: TextStyle(color: Colors.white)), controller: _btnController1, onPressed: () => _doSomething(_btnController1), diff --git a/lib/rounded_loading_button.dart b/lib/rounded_loading_button.dart index 1f29d29..774f402 100644 --- a/lib/rounded_loading_button.dart +++ b/lib/rounded_loading_button.dart @@ -68,6 +68,18 @@ class RoundedLoadingButton extends StatefulWidget { /// The color of the button when it is disabled final Color? disabledColor; + /// The icon for the success state + final IconData successIcon; + + /// The icon for the failed state + final IconData failedIcon; + + /// The success and failed animation curve + final Curve completionCurve; + + /// The duration of the success and failed animation + final Duration completionDuration; + Duration get _borderDuration { return Duration(milliseconds: (duration.inMilliseconds / 2).round()); } @@ -93,6 +105,10 @@ class RoundedLoadingButton extends StatefulWidget { this.successColor, this.resetDuration = const Duration(seconds: 15), this.resetAfterDuration = false, + this.successIcon = Icons.check, + this.failedIcon = Icons.close, + this.completionCurve = Curves.elasticOut, + this.completionDuration = const Duration(milliseconds: 1000), this.disabledColor}) : super(key: key); @override @@ -127,7 +143,7 @@ class RoundedLoadingButtonState extends State height: _bounceAnimation.value, child: _bounceAnimation.value > 20 ? Icon( - Icons.check, + widget.successIcon, color: widget.valueColor, ) : null); @@ -143,7 +159,7 @@ class RoundedLoadingButtonState extends State height: _bounceAnimation.value, child: _bounceAnimation.value > 20 ? Icon( - Icons.close, + widget.failedIcon, color: widget.valueColor, ) : null); @@ -168,6 +184,7 @@ class RoundedLoadingButtonState extends State final _btn = ButtonTheme( shape: RoundedRectangleBorder(borderRadius: _borderAnimation.value), disabledColor: widget.disabledColor, + padding: EdgeInsets.all(0), child: ElevatedButton( style: ElevatedButton.styleFrom( onSurface: widget.disabledColor, @@ -201,14 +218,14 @@ class RoundedLoadingButtonState extends State AnimationController(duration: widget.duration, vsync: this); _checkButtonControler = AnimationController( - duration: Duration(milliseconds: 1000), vsync: this); + duration: widget.completionDuration, vsync: this); _borderController = AnimationController(duration: widget._borderDuration, vsync: this); _bounceAnimation = Tween(begin: 0, end: widget.height).animate( CurvedAnimation( - parent: _checkButtonControler, curve: Curves.elasticOut)); + parent: _checkButtonControler, curve: widget.completionCurve)); _bounceAnimation.addListener(() { setState(() {}); }); diff --git a/pubspec.yaml b/pubspec.yaml index 8d59b64..b67b95c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: rounded_loading_button description: A simple implementation of an animated loading button widget for Flutter -version: 2.0.7 +version: 2.0.8 homepage: https://github.com/chrisedg87/flutter_rounded_loading_button environment: