From 18d67360b37530f7085eac99122f3429e966f375 Mon Sep 17 00:00:00 2001 From: Okan Demir Date: Sat, 17 Dec 2022 01:20:44 +0300 Subject: [PATCH 1/5] A tryout before condition --- lib/src/animated_text.dart | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/lib/src/animated_text.dart b/lib/src/animated_text.dart index db3f851..c947e6e 100644 --- a/lib/src/animated_text.dart +++ b/lib/src/animated_text.dart @@ -72,6 +72,9 @@ class AnimatedTextKit extends StatefulWidget { /// By default it is set to false. final bool displayFullTextOnTap; + ///Overrides previous text to other one. It's true by default + final bool overrideTexts; + /// If on pause, should a tap remove the remaining pause time ? /// /// By default it is set to false. @@ -117,6 +120,7 @@ class AnimatedTextKit extends StatefulWidget { this.pause = const Duration(milliseconds: 1000), this.displayFullTextOnTap = false, this.stopPauseOnTap = false, + this.overrideTexts = true, this.onTap, this.onNext, this.onNextBeforePause, @@ -165,16 +169,26 @@ class _AnimatedTextKitState extends State Widget build(BuildContext context) { final completeText = _currentAnimatedText.completeText(context); return GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: _onTap, - child: _isCurrentlyPausing || !_controller.isAnimating - ? completeText - : AnimatedBuilder( - animation: _controller, - builder: _currentAnimatedText.animatedBuilder, - child: completeText, - ), - ); + behavior: HitTestBehavior.opaque, + onTap: _onTap, + child: Column( + children: widget.animatedTexts + .take(_index) + .map((e) => Text( + e.text, + style: e.textStyle, + )) + .toList() + + [ + _isCurrentlyPausing || !_controller.isAnimating + ? completeText + : AnimatedBuilder( + animation: _controller, + builder: _currentAnimatedText.animatedBuilder, + child: completeText, + ) + ], + )); } bool get _isLast => _index == widget.animatedTexts.length - 1; From f74795e9cfa3e385afa32f29e60ea9531af2c387 Mon Sep 17 00:00:00 2001 From: Okan Demir Date: Sat, 17 Dec 2022 01:29:48 +0300 Subject: [PATCH 2/5] add condition support --- lib/src/animated_text.dart | 46 +++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/lib/src/animated_text.dart b/lib/src/animated_text.dart index c947e6e..e8515b2 100644 --- a/lib/src/animated_text.dart +++ b/lib/src/animated_text.dart @@ -167,32 +167,36 @@ class _AnimatedTextKitState extends State @override Widget build(BuildContext context) { - final completeText = _currentAnimatedText.completeText(context); return GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: _onTap, - child: Column( - children: widget.animatedTexts - .take(_index) - .map((e) => Text( - e.text, - style: e.textStyle, - )) - .toList() + - [ - _isCurrentlyPausing || !_controller.isAnimating - ? completeText - : AnimatedBuilder( - animation: _controller, - builder: _currentAnimatedText.animatedBuilder, - child: completeText, - ) - ], - )); + behavior: HitTestBehavior.opaque, + onTap: _onTap, + child: widget.overrideTexts + ? _animationRenderer() + : Column( + children: widget.animatedTexts + .take(_index) + .map((e) => Text( + e.text, + style: e.textStyle, + )) + .toList() + + [_animationRenderer()], + ), + ); } bool get _isLast => _index == widget.animatedTexts.length - 1; + Widget _animationRenderer() { + final completeText = _currentAnimatedText.completeText(context); + return _isCurrentlyPausing || !_controller.isAnimating + ? completeText + : AnimatedBuilder( + animation: _controller, + builder: _currentAnimatedText.animatedBuilder, + child: completeText); + } + void _nextAnimation() { final isLast = _isLast; From 7cd446a9fc5879623b3e6c120ef2fe026a589766 Mon Sep 17 00:00:00 2001 From: Okan Demir <43478072+okandemirofficial@users.noreply.github.com> Date: Sat, 17 Dec 2022 01:45:48 +0300 Subject: [PATCH 3/5] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b18288a..e61aef7 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,7 @@ It has many configurable properties, including: - `isRepeatingAnimation` – controls whether the animation repeats - `repeatForever` – controls whether the animation repeats forever - `totalRepeatCount` – number of times the animation should repeat (when `repeatForever` is `false`) +- `overrideTexts` – it allows to show animated texts without override it (default is `true`) There are also custom callbacks: From 4fdd7009d4bd6c1bb7bed49990d5326cbb0ca8e8 Mon Sep 17 00:00:00 2001 From: Okan Demir Date: Sat, 17 Dec 2022 02:46:35 +0300 Subject: [PATCH 4/5] Append Padding option --- lib/src/animated_text.dart | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/src/animated_text.dart b/lib/src/animated_text.dart index e8515b2..39f3ceb 100644 --- a/lib/src/animated_text.dart +++ b/lib/src/animated_text.dart @@ -114,6 +114,9 @@ class AnimatedTextKit extends StatefulWidget { /// By default it is set to 3 final int totalRepeatCount; + ///It appends padding to every child of text widget + final EdgeInsets appendPadding; + const AnimatedTextKit({ Key? key, required this.animatedTexts, @@ -121,6 +124,7 @@ class AnimatedTextKit extends StatefulWidget { this.displayFullTextOnTap = false, this.stopPauseOnTap = false, this.overrideTexts = true, + this.appendPadding = EdgeInsets.zero, this.onTap, this.onNext, this.onNextBeforePause, @@ -175,9 +179,12 @@ class _AnimatedTextKitState extends State : Column( children: widget.animatedTexts .take(_index) - .map((e) => Text( - e.text, - style: e.textStyle, + .map((e) => Padding( + padding: widget.appendPadding, + child: Text( + e.text, + style: e.textStyle, + ), )) .toList() + [_animationRenderer()], From 71450860f73227f6029fdb71f7b2b8351912369a Mon Sep 17 00:00:00 2001 From: Okan Demir Date: Sat, 17 Dec 2022 02:50:02 +0300 Subject: [PATCH 5/5] Revert "Append Padding option" This reverts commit 4fdd7009d4bd6c1bb7bed49990d5326cbb0ca8e8. --- lib/src/animated_text.dart | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/src/animated_text.dart b/lib/src/animated_text.dart index 39f3ceb..e8515b2 100644 --- a/lib/src/animated_text.dart +++ b/lib/src/animated_text.dart @@ -114,9 +114,6 @@ class AnimatedTextKit extends StatefulWidget { /// By default it is set to 3 final int totalRepeatCount; - ///It appends padding to every child of text widget - final EdgeInsets appendPadding; - const AnimatedTextKit({ Key? key, required this.animatedTexts, @@ -124,7 +121,6 @@ class AnimatedTextKit extends StatefulWidget { this.displayFullTextOnTap = false, this.stopPauseOnTap = false, this.overrideTexts = true, - this.appendPadding = EdgeInsets.zero, this.onTap, this.onNext, this.onNextBeforePause, @@ -179,12 +175,9 @@ class _AnimatedTextKitState extends State : Column( children: widget.animatedTexts .take(_index) - .map((e) => Padding( - padding: widget.appendPadding, - child: Text( - e.text, - style: e.textStyle, - ), + .map((e) => Text( + e.text, + style: e.textStyle, )) .toList() + [_animationRenderer()],