Skip to content

Commit

Permalink
release: 3.0 (#45)
Browse files Browse the repository at this point in the history
* chore: first look

* chore: second pass

* chore: code clean

* chore: update README & CHANGELOG

* chore: doc clean up
  • Loading branch information
jogboms committed Nov 4, 2018
1 parent 4f756b5 commit f9f9d32
Show file tree
Hide file tree
Showing 33 changed files with 748 additions and 406 deletions.
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 3.0.0

### Before

```dart
SpinKitFadingCircle(
color: Colors.white,
size: 50.0,
);
```

### Now, there is an itemBuilder alternative

```dart
SpinKitFadingCircle(
itemBuilder: (_, int index) {
return DecoratedBox(
decoration: BoxDecoration(
color: index.isEven ? Colors.red : Colors.green,
),
);
},
);
```

### Which produces

<img src="https://raw.githubusercontent.com/jogboms/flutter_spinkit/master/screenshots/itemBuilder.gif" width="100px">
20 changes: 19 additions & 1 deletion 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: "^2.1.0"
flutter_spinkit: "^3.0.0"
```
### ⚡️ Import
Expand All @@ -26,6 +26,24 @@ SpinKitRotatingCircle(
);
```

#### As from 3.0.0

```dart
SpinKitFadingCircle(
itemBuilder: (_, int index) {
return DecoratedBox(
decoration: BoxDecoration(
color: index.isEven ? Colors.red : Colors.green,
),
);
},
);
```

#### Which produces

<img src="https://raw.githubusercontent.com/jogboms/flutter_spinkit/master/screenshots/itemBuilder.gif" width="100px">

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

## 🚀 Roadmap
Expand Down
7 changes: 4 additions & 3 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ analyzer:
# allow having TODOs in the code
todo: ignore
exclude:
- 'bin/cache/**'
- "bin/cache/**"
# the following two are relative to the stocks example and the flutter package respectively
# see https://github.com/dart-lang/sdk/issues/28463
- 'lib/i18n/stock_messages_*.dart'
- 'lib/src/http/**'
- "lib/i18n/stock_messages_*.dart"
- "lib/src/http/**"

linter:
rules:
Expand Down Expand Up @@ -146,6 +146,7 @@ linter:
- unnecessary_brace_in_string_interps
- unnecessary_getters_setters
# - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498
- unnecessary_new
- unnecessary_null_aware_assignments
- unnecessary_null_in_if_null_operators
- unnecessary_overrides
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildSystemType</key>
<string>Original</string>
</dict>
</plist>
8 changes: 4 additions & 4 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import 'package:flutter/material.dart';
import './showcase.dart';
import './workspace.dart';

void main() => runApp(new App());
void main() => runApp(App());

class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
return MaterialApp(
title: 'SpinKit Demo',
debugShowCheckedModeBanner: false,
theme: new ThemeData(
theme: ThemeData(
brightness: Brightness.dark,
),
home: new Scaffold(
home: Scaffold(
body: SafeArea(
child: Stack(
children: <Widget>[
Expand Down
24 changes: 12 additions & 12 deletions example/lib/showcase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import 'package:flutter_spinkit/flutter_spinkit.dart';
class ShowCase extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
return Scaffold(
appBar: AppBar(
elevation: 0.0,
backgroundColor: Colors.transparent,
title: Text("SpinKit", style: TextStyle(fontSize: 24.0)),
),
body: SingleChildScrollView(
child: new Column(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(height: 32.0),
new Row(
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SpinKitRotatingCircle(color: Colors.white),
Expand All @@ -24,7 +24,7 @@ class ShowCase extends StatelessWidget {
],
),
const SizedBox(height: 48.0),
new Row(
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SpinKitPumpingHeart(color: Colors.white),
Expand All @@ -33,7 +33,7 @@ class ShowCase extends StatelessWidget {
],
),
const SizedBox(height: 48.0),
new Row(
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SpinKitWave(color: Colors.white, type: SpinKitWaveType.start),
Expand All @@ -42,7 +42,7 @@ class ShowCase extends StatelessWidget {
],
),
const SizedBox(height: 48.0),
new Row(
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SpinKitThreeBounce(color: Colors.white),
Expand All @@ -52,7 +52,7 @@ class ShowCase extends StatelessWidget {
],
),
const SizedBox(height: 48.0),
new Row(
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SpinKitCircle(color: Colors.white),
Expand All @@ -62,7 +62,7 @@ class ShowCase extends StatelessWidget {
],
),
const SizedBox(height: 48.0),
new Row(
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SpinKitFadingCube(color: Colors.white),
Expand All @@ -71,7 +71,7 @@ class ShowCase extends StatelessWidget {
],
),
const SizedBox(height: 48.0),
new Row(
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SpinKitRing(color: Colors.white),
Expand All @@ -80,7 +80,7 @@ class ShowCase extends StatelessWidget {
],
),
const SizedBox(height: 48.0),
new Row(
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SpinKitFadingGrid(color: Colors.white),
Expand All @@ -90,7 +90,7 @@ class ShowCase extends StatelessWidget {
],
),
const SizedBox(height: 48.0),
new Row(
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SpinKitSpinningCircle(color: Colors.white),
Expand All @@ -100,7 +100,7 @@ class ShowCase extends StatelessWidget {
],
),
const SizedBox(height: 48.0),
new Row(
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SpinKitPouringHourglass(color: Colors.white),
Expand Down
14 changes: 10 additions & 4 deletions example/lib/workspace.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ class WorkSpace extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
color: Colors.orangeAccent,
color: Colors.white,
width: 300.0,
height: 300.0,
child: SpinKitPouringHourglass(
color: Colors.white,
size: 100.0,
child: SpinKitFadingCircle(
itemBuilder: (_, int index) {
return DecoratedBox(
decoration: BoxDecoration(
color: index.isEven ? Colors.red : Colors.green,
),
);
},
size: 120.0,
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.1.0"
version: "3.0.0"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down
2 changes: 1 addition & 1 deletion lib/flutter_spinkit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export 'src/fading_four.dart';
export 'src/fading_grid.dart';
export 'src/folding_cube.dart';
export 'src/hour_glass.dart';
export 'src/pouring_hour_glass.dart';
export 'src/pulse.dart';
export 'src/pumping_heart.dart';
export 'src/ring.dart';
Expand All @@ -21,4 +22,3 @@ export 'src/spinning_circle.dart';
export 'src/three_bounce.dart';
export 'src/wandering_cubes.dart';
export 'src/wave.dart';
export 'src/pouring_hour_glass.dart';
53 changes: 33 additions & 20 deletions lib/src/chasing_dots.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@ import 'package:flutter/material.dart';
class SpinKitChasingDots extends StatefulWidget {
final Color color;
final double size;
final IndexedWidgetBuilder itemBuilder;

const SpinKitChasingDots({
SpinKitChasingDots({
Key key,
@required this.color,
this.color,
this.size = 50.0,
}) : super(key: key);
this.itemBuilder,
}) : assert(
!(itemBuilder is IndexedWidgetBuilder && color is Color) &&
!(itemBuilder == null && color == null),
'You should specify either a itemBuilder or a color'),
assert(size != null),
super(key: key);

@override
_SpinKitChasingDotsState createState() => new _SpinKitChasingDotsState();
_SpinKitChasingDotsState createState() => _SpinKitChasingDotsState();
}

class _SpinKitChasingDotsState extends State<SpinKitChasingDots>
Expand All @@ -23,11 +30,11 @@ class _SpinKitChasingDotsState extends State<SpinKitChasingDots>
@override
void initState() {
super.initState();
_scaleCtrl = new AnimationController(vsync: this, duration: _duration);
_rotateCtrl = new AnimationController(vsync: this, duration: _duration);
_scaleCtrl = AnimationController(vsync: this, duration: _duration);
_rotateCtrl = AnimationController(vsync: this, duration: _duration);

_scale = Tween(begin: -1.0, end: 1.0).animate(
new CurvedAnimation(parent: _scaleCtrl, curve: Curves.easeInOut),
CurvedAnimation(parent: _scaleCtrl, curve: Curves.easeInOut),
)
..addListener(() => setState(() => <String, void>{}))
..addStatusListener((status) {
Expand All @@ -39,7 +46,7 @@ class _SpinKitChasingDotsState extends State<SpinKitChasingDots>
});

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

_rotateCtrl.repeat();
Expand All @@ -64,11 +71,11 @@ class _SpinKitChasingDotsState extends State<SpinKitChasingDots>
children: <Widget>[
Positioned(
top: 0.0,
child: _circle(1.0 - _scale.value.abs()),
child: _circle(1.0 - _scale.value.abs(), 0),
),
Positioned(
bottom: 0.0,
child: _circle(_scale.value.abs()),
child: _circle(_scale.value.abs(), 1),
),
],
),
Expand All @@ -77,19 +84,25 @@ class _SpinKitChasingDotsState extends State<SpinKitChasingDots>
);
}

Widget _circle(double scale) {
Widget _itemBuilder(int index) {
final _size = widget.size * 0.6;
return SizedBox.fromSize(
size: Size.square(_size),
child: widget.itemBuilder != null
? widget.itemBuilder(context, index)
: DecoratedBox(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: widget.color,
),
),
);
}

return new Transform.scale(
Widget _circle(double scale, int index) {
return Transform.scale(
scale: scale,
child: new Container(
height: _size,
width: _size,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: widget.color,
),
),
child: _itemBuilder(index),
);
}
}
Loading

0 comments on commit f9f9d32

Please sign in to comment.