Skip to content

Commit

Permalink
Merge pull request #3 from SplashByte/dev
Browse files Browse the repository at this point in the history
version 0.3.1
  • Loading branch information
maeddin authored Feb 26, 2022
2 parents 2ade585 + 6478392 commit a52809b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.3.1 [2022-02-26]
- fixes alignment

## 0.3.0 [2022-02-26]
- adds parameters for manipulating size animation
- enables disabling of size animation for performance reasons
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.2.1"
version: "0.3.0"
fake_async:
dependency: transitive
description:
Expand Down
30 changes: 16 additions & 14 deletions lib/src/cross_fade_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,18 @@ class _CrossFadeState<T> extends State<CrossFade<T>>
super.initState();
_todo = [widget.value];
_opacityController =
AnimationController(vsync: this, duration: widget.duration, value: 1.0)
..addStatusListener((status) {
if (status == AnimationStatus.completed) {
if (_todo.length <= 1) return;
_todo.removeAt(0);
// rebuild necessary for setting GlobalKeys simultaneously
setState(() {});
if (_todo.length > 1) {
_animateNext();
}
}
});
AnimationController(vsync: this, duration: widget.duration, value: 1.0)
..addStatusListener((status) {
if (status == AnimationStatus.completed) {
if (_todo.length <= 1) return;
_todo.removeAt(0);
// rebuild necessary for setting GlobalKeys simultaneously
setState(() {});
if (_todo.length > 1) {
_animateNext();
}
}
});

_sizeController = AnimationController(
vsync: this,
Expand Down Expand Up @@ -199,6 +199,7 @@ class _CrossFadeState<T> extends State<CrossFade<T>>
Widget build(BuildContext context) {
bool twoActive = _todo.length > 1;
T current = twoActive ? _todo[1] : _todo[0];
T first = _todo[0];
return LayoutBuilder(
builder: (context, constraints) => Stack(
fit: StackFit.passthrough,
Expand All @@ -223,8 +224,8 @@ class _CrossFadeState<T> extends State<CrossFade<T>>
child: child,
),
child: EmptyWidget(
key: _getKey(_todo[0]),
child: widget.builder(context, _todo[0])),
key: _getKey(first),
child: widget.builder(context, first)),
),
),
),
Expand All @@ -241,6 +242,7 @@ class _CrossFadeState<T> extends State<CrossFade<T>>
clipBehavior: widget.clipBehavior,
duration: widget.sizeDuration ?? widget.duration,
curve: widget.sizeCurve,
alignment: widget.stackAlignment,
child: AnimatedBuilder(
animation: _opacityAnimation,
builder: (context, child) => Opacity(
Expand Down
5 changes: 4 additions & 1 deletion lib/src/widgets/animated_size.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ class CustomAnimatedSize extends StatefulWidget {
final Duration duration;
final Curve curve;
final Widget child;
final AlignmentGeometry alignment;

const CustomAnimatedSize({
Key? key,
this.clipBehavior = Clip.hardEdge,
required this.duration,
this.curve = Curves.linear,
required this.child,
this.alignment = Alignment.center,
}) : super(key: key);

@override
Expand All @@ -32,7 +34,8 @@ class _CustomAnimatedSizeState extends State<CustomAnimatedSize> {
clipBehavior: widget.clipBehavior,
duration: widget.duration,
curve: widget.curve,
alignment: widget.alignment,
child: child,
);
}
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: cross_fade
description: A widget to apply a crossfade animation between different states and/or widgets.
version: 0.3.0
version: 0.3.1
repository: https://github.com/SplashByte/cross_fade

environment:
Expand Down

0 comments on commit a52809b

Please sign in to comment.