Skip to content

Commit

Permalink
feat: animation controllers (#54)
Browse files Browse the repository at this point in the history
feat: animation controllers
  • Loading branch information
jogboms authored Aug 17, 2019
2 parents c68eb0e + 8cb3c6a commit 636d940
Show file tree
Hide file tree
Showing 30 changed files with 213 additions and 115 deletions.
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,27 @@

A collection of loading indicators animated with flutter. Heavily inspired by @tobiasahlin's SpinKit.

## 4.0.0

### Feature

- `controller` parameter [20248d](https://github.com/jogboms/flutter_spinkit/commit/20248d2f8bd1056a453a5e57f063e8d59dba9b36). Closes [#51](https://github.com/jogboms/flutter_spinkit/issues/51)

```dart
SpinKitFadingCircle(
color: Colors.white,
size: 50.0,
controller: AnimationController(vsync: this, duration: const Duration(milliseconds: 1200)),
);
```
- DualRing `lineWidth` parameter [5873e7](https://github.com/jogboms/flutter_spinkit/commit/5873e75430aca52d2ec0c483dcd71a02438f3e8b). Closes [#42](https://github.com/jogboms/flutter_spinkit/issues/42)

## 3.1.0

### Feature

- duration parameter [70b113b](https://github.com/jogboms/flutter_spinkit/commit/70b113b384200e344336d521704a1c96d2864909)
- `duration` parameter [70b113b](https://github.com/jogboms/flutter_spinkit/commit/70b113b384200e344336d521704a1c96d2864909)

### Fixes

Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A collection of loading indicators animated with flutter. Heavily inspired by [@

```yaml
dependencies:
flutter_spinkit: "^3.1.0"
flutter_spinkit: "^4.0.0"
```
### ⚡️ Import
Expand All @@ -26,8 +26,6 @@ SpinKitRotatingCircle(
);
```

#### As from 3.0.0

```dart
SpinKitFadingCircle(
itemBuilder: (_, int index) {
Expand All @@ -40,13 +38,19 @@ SpinKitFadingCircle(
);
```

#### Which produces
#### As from 4.0.0

<img src="https://raw.githubusercontent.com/jogboms/flutter_spinkit/master/screenshots/itemBuilder.gif" width="100px">
```dart
SpinKitFadingCircle(
color: Colors.white,
size: 50.0,
controller: AnimationController(vsync: this, duration: const Duration(milliseconds: 1200)),
);
```

For more info, please, refer to the `showcase.dart` in the example.

## 🚀 Roadmap
## 🚀 Showcase

<table>
<tr>
Expand Down
2 changes: 0 additions & 2 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ linter:
# - parameter_assignments # we do this commonly
- prefer_adjacent_string_concatenation
- prefer_asserts_in_initializer_lists
- prefer_bool_in_asserts
- prefer_collection_literals
- prefer_conditional_assignment
# - prefer_const_constructors
Expand All @@ -135,7 +134,6 @@ linter:
- slash_for_doc_comments
- sort_constructors_first
- sort_unnamed_constructors_first
- super_goes_last
- test_types_in_equals
- throw_in_finally
# - type_annotate_public_apis # subset of always_specify_types
Expand Down
4 changes: 0 additions & 4 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
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, ); }; };
Expand Down Expand Up @@ -41,7 +40,6 @@
/* Begin PBXFileReference section */
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>"; };
2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
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>"; };
Expand Down Expand Up @@ -74,7 +72,6 @@
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
2D5378251FAA1A9400D5DBA9 /* flutter_assets */,
3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
9740EEBA1CF902C7004384FC /* Flutter.framework */,
Expand Down Expand Up @@ -192,7 +189,6 @@
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
27 changes: 17 additions & 10 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Generated by pub
# See https://www.dartlang.org/tools/pub/glossary#lockfile
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
version: "2.2.0"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -40,7 +40,7 @@ packages:
path: ".."
relative: true
source: path
version: "3.1.0"
version: "4.0.0"
flutter_test:
dependency: "direct dev"
description: flutter
Expand All @@ -52,7 +52,7 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.3+1"
version: "0.12.5"
meta:
dependency: transitive
description:
Expand All @@ -67,13 +67,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.2"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
version: "2.0.3"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -85,7 +92,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.1"
version: "1.5.5"
stack_trace:
dependency: transitive
description:
Expand All @@ -99,7 +106,7 @@ packages:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.8"
version: "2.0.0"
string_scanner:
dependency: transitive
description:
Expand All @@ -113,14 +120,14 @@ packages:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
version: "1.1.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.1"
version: "0.2.5"
typed_data:
dependency: transitive
description:
Expand All @@ -136,5 +143,5 @@ packages:
source: hosted
version: "2.0.8"
sdks:
dart: ">=2.0.0 <3.0.0"
dart: ">=2.2.2 <3.0.0"
flutter: ">=0.1.4 <2.0.0"
3 changes: 3 additions & 0 deletions flutter_spinkit.iml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<excludeFolder url="file://$MODULE_DIR$/.idea" />
<excludeFolder url="file://$MODULE_DIR$/.pub" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/example/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/example/.pub" />
<excludeFolder url="file://$MODULE_DIR$/example/build" />
</content>
<orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
Expand Down
5 changes: 3 additions & 2 deletions lib/src/chasing_dots.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';

class SpinKitChasingDots extends StatefulWidget {
// ignore: prefer_const_constructors_in_immutables
SpinKitChasingDots({
Key key,
this.color,
Expand Down Expand Up @@ -37,7 +38,7 @@ class _SpinKitChasingDotsState extends State<SpinKitChasingDots>
_scale = Tween(begin: -1.0, end: 1.0).animate(
CurvedAnimation(parent: _scaleCtrl, curve: Curves.easeInOut),
)
..addListener(() => setState(() => <String, void>{}))
..addListener(() => setState(() {}))
..addStatusListener((status) {
if (status == AnimationStatus.completed) {
_scaleCtrl.reverse();
Expand All @@ -48,7 +49,7 @@ class _SpinKitChasingDotsState extends State<SpinKitChasingDots>

_rotate = Tween(begin: 0.0, end: 360.0).animate(
CurvedAnimation(parent: _rotateCtrl, curve: Curves.linear),
)..addListener(() => setState(() => <String, void>{}));
)..addListener(() => setState(() {}));

_rotateCtrl.repeat();
_scaleCtrl.forward();
Expand Down
6 changes: 5 additions & 1 deletion lib/src/circle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import 'package:flutter/widgets.dart';
import 'package:flutter_spinkit/src/utils.dart';

class SpinKitCircle extends StatefulWidget {
// ignore: prefer_const_constructors_in_immutables
SpinKitCircle({
Key key,
this.color,
this.size = 50.0,
this.itemBuilder,
this.duration = const Duration(milliseconds: 1200),
this.controller,
}) : assert(
!(itemBuilder is IndexedWidgetBuilder && color is Color) &&
!(itemBuilder == null && color == null),
Expand All @@ -19,6 +21,7 @@ class SpinKitCircle extends StatefulWidget {
final double size;
final IndexedWidgetBuilder itemBuilder;
final Duration duration;
final AnimationController controller;

@override
_SpinKitCircleState createState() => _SpinKitCircleState();
Expand All @@ -31,7 +34,8 @@ class _SpinKitCircleState extends State<SpinKitCircle>
@override
void initState() {
super.initState();
_controller = AnimationController(vsync: this, duration: widget.duration)
_controller = (widget.controller ??
AnimationController(vsync: this, duration: widget.duration))
..repeat();
}

Expand Down
6 changes: 5 additions & 1 deletion lib/src/cube_grid.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import 'package:flutter/widgets.dart';

class SpinKitCubeGrid extends StatefulWidget {
// ignore: prefer_const_constructors_in_immutables
SpinKitCubeGrid({
Key key,
this.color,
this.size = 50.0,
this.itemBuilder,
this.duration = const Duration(milliseconds: 1200),
this.controller,
}) : assert(
!(itemBuilder is IndexedWidgetBuilder && color is Color) &&
!(itemBuilder == null && color == null),
Expand All @@ -18,6 +20,7 @@ class SpinKitCubeGrid extends StatefulWidget {
final double size;
final IndexedWidgetBuilder itemBuilder;
final Duration duration;
final AnimationController controller;

@override
_SpinKitCubeGridState createState() => _SpinKitCubeGridState();
Expand All @@ -31,7 +34,8 @@ class _SpinKitCubeGridState extends State<SpinKitCubeGrid>
@override
void initState() {
super.initState();
_controller = AnimationController(vsync: this, duration: widget.duration);
_controller = widget.controller ??
AnimationController(vsync: this, duration: widget.duration);
_anim1 = Tween(begin: 1.0, end: 0.0).animate(
CurvedAnimation(
parent: _controller,
Expand Down
11 changes: 6 additions & 5 deletions lib/src/double_bounce.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import 'package:flutter/material.dart';

class SpinKitDoubleBounce extends StatefulWidget {
// ignore: prefer_const_constructors_in_immutables
SpinKitDoubleBounce({
Key key,
this.color,
this.size = 50.0,
this.itemBuilder,
this.duration = const Duration(milliseconds: 2000),
this.controller,
}) : assert(
!(itemBuilder is IndexedWidgetBuilder && color is Color) &&
!(itemBuilder == null && color == null),
Expand All @@ -18,6 +20,7 @@ class SpinKitDoubleBounce extends StatefulWidget {
final double size;
final IndexedWidgetBuilder itemBuilder;
final Duration duration;
final AnimationController controller;

@override
_SpinKitDoubleBounceState createState() => _SpinKitDoubleBounceState();
Expand All @@ -39,18 +42,16 @@ class _SpinKitDoubleBounceState extends State<SpinKitDoubleBounce>
@override
void initState() {
super.initState();
_controller = AnimationController(
vsync: this,
duration: widget.duration,
);
_controller = widget.controller ??
AnimationController(vsync: this, duration: widget.duration);

_animation1 = Tween(begin: -1.0, end: 1.0).animate(
CurvedAnimation(
parent: _controller,
curve: Curves.easeInOut,
),
)
..addListener(() => setState(() => <String, void>{}))
..addListener(() => setState(() {}))
..addStatusListener(_statusListener);

_controller.forward();
Expand Down
Loading

0 comments on commit 636d940

Please sign in to comment.