Skip to content

Commit 80130e2

Browse files
author
srinivas
committed
added validations & code refactoring in widgets
1 parent 2cdec77 commit 80130e2

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

lib/components/animation/gf_animation.dart

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class GFAnimation extends StatefulWidget {
2929
this.textWidthBasis,
3030
this.fontSize,
3131
this.fontWeight,
32+
this.changedWidth,
33+
this.changedHeight,
3234
}) : super(key: key);
3335

3436
/// The duration for animations of the [Decoration].
@@ -49,9 +51,18 @@ class GFAnimation extends StatefulWidget {
4951
///type of [GFAnimation] which takes the type ie, align, size, container, rotateTransition, scaleTransition, slideTransition, and textStyle for the [GFAnimation]
5052
final GFAnimationType type;
5153

54+
/// [AnimatedContainer] initial width
5255
final double width;
56+
57+
/// [AnimatedContainer] changed width
58+
final double changedWidth;
59+
60+
/// [AnimatedContainer] initial height
5361
final double height;
5462

63+
/// [AnimatedContainer] changed height
64+
final double changedHeight;
65+
5566
/// defines the color of items when onTap triggers
5667
final Color activeColor;
5768

@@ -83,6 +94,8 @@ class GFAnimation extends StatefulWidget {
8394
final TextStyle style;
8495
final TextAlign textAlign;
8596
final TextOverflow textOverflow;
97+
98+
/// [AnimatedDefaultTextStyle] maxlines
8699
final int maxLines;
87100
final TextWidthBasis textWidthBasis;
88101
final double fontSize;
@@ -95,7 +108,6 @@ class GFAnimation extends StatefulWidget {
95108
class _GFAnimationState extends State<GFAnimation>
96109
with SingleTickerProviderStateMixin {
97110
bool selected = false;
98-
bool expand = false;
99111

100112
AnimationController controller;
101113
Animation<double> animation;
@@ -158,8 +170,10 @@ class _GFAnimationState extends State<GFAnimation>
158170
child: AnimatedContainer(
159171
margin: widget.margin ?? const EdgeInsets.all(0),
160172
padding: widget.padding ?? const EdgeInsets.all(8),
161-
width: selected ? widget.width ?? 200.0 : 100.0,
162-
height: selected ? widget.width ?? 100.0 : 200.0,
173+
width:
174+
selected ? widget.changedWidth ?? 200.0 : widget.width ?? 100.0,
175+
height:
176+
selected ? widget.changedHeight ?? 200.0 : widget.height ?? 100.0,
163177
color: selected
164178
? widget.activeColor ?? Colors.red
165179
: widget.color ?? Colors.blue,
@@ -174,10 +188,14 @@ class _GFAnimationState extends State<GFAnimation>
174188

175189
Widget buildAnimatedAlignWidget() => GestureDetector(
176190
onTap: () {
177-
if (mounted) {
178-
setState(() {
179-
selected = !selected;
180-
});
191+
if (widget.onTap == null) {
192+
if (mounted) {
193+
setState(() {
194+
selected = !selected;
195+
});
196+
}
197+
} else {
198+
widget.onTap();
181199
}
182200
},
183201
child: Container(

0 commit comments

Comments
 (0)