Skip to content

Commit 0729af8

Browse files
authored
Merge pull request #98 from deepikahr/shimmer
Shimmer
2 parents ecf8374 + f53772a commit 0729af8

File tree

9 files changed

+185
-92
lines changed

9 files changed

+185
-92
lines changed

lib/components/alert/gf_alert.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class _GFAlertState extends State<GFAlert> with TickerProviderStateMixin {
9393
Container(
9494
width: widget.type == GFAlertType.fullWidth
9595
? MediaQuery.of(context).size.width
96-
: widget.width?? MediaQuery.of(context).size.width*0.885,
96+
: widget.width ?? MediaQuery.of(context).size.width * 0.885,
9797
constraints: const BoxConstraints(minHeight: 50),
9898
margin: widget.type == GFAlertType.fullWidth
9999
? const EdgeInsets.only(left: 0, right: 0)

lib/components/appbar/gf_appbar.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,12 @@ class _GFAppBarState extends State<GFAppBar> {
321321
IconThemeData actionsIconTheme = widget.actionsIconTheme ??
322322
appBarTheme.actionsIconTheme ??
323323
overallIconTheme;
324-
TextStyle centerStyle = widget.textTheme?.title ??
325-
appBarTheme.textTheme?.title ??
326-
theme.primaryTextTheme.title;
327-
TextStyle sideStyle = widget.textTheme?.body1 ??
328-
appBarTheme.textTheme?.body1 ??
329-
theme.primaryTextTheme.body1;
324+
TextStyle centerStyle = widget.textTheme?.headline6 ??
325+
appBarTheme.textTheme?.headline6 ??
326+
theme.primaryTextTheme.headline6;
327+
TextStyle sideStyle = widget.textTheme?.bodyText2 ??
328+
appBarTheme.textTheme?.bodyText2 ??
329+
theme.primaryTextTheme.bodyText2;
330330

331331
if (widget.toolbarOpacity != 1.0) {
332332
final double opacity = const Interval(

lib/components/avatar/gf_avatar.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class GFAvatar extends StatelessWidget {
8787
final Color foregroundColor = GFColors.getGFColor(this.foregroundColor);
8888
assert(debugCheckHasMediaQuery(context));
8989
final ThemeData theme = Theme.of(context);
90-
TextStyle textStyle = theme.primaryTextTheme.subhead.copyWith(
90+
TextStyle textStyle = theme.primaryTextTheme.subtitle1.copyWith(
9191
color: foregroundColor,
9292
);
9393
Color effectiveBackgroundColor = backgroundColor;

lib/components/card/gf_card.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class GFCard extends StatelessWidget {
103103
/// A border to draw above the [GFCard].
104104
final Border border;
105105

106+
/// defines the gradient background
106107
final LinearGradient gradient;
107108

108109
static const double _defaultElevation = 1;

lib/components/floating_widget/gf_floating_widget.dart

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ class GFFloatingWidget extends StatefulWidget {
66
/// Inside floating widget [GFToast] can be used as body. See [GFToast]
77
const GFFloatingWidget(
88
{Key key,
9-
this.child,
10-
this.horizontalPosition,
11-
this.verticalPosition,
12-
this.blurnessColor,
13-
this.showblurness = false,
14-
this.body})
9+
this.child,
10+
this.horizontalPosition,
11+
this.verticalPosition,
12+
this.blurnessColor,
13+
this.showblurness = false,
14+
this.body})
1515
: super(key: key);
1616

1717
///child of type [Widget] which floats across the body based on horizontal and vertical position
@@ -39,17 +39,17 @@ class GFFloatingWidget extends StatefulWidget {
3939
class _GFFloatingWidgetState extends State<GFFloatingWidget> {
4040
@override
4141
Widget build(BuildContext context) => Stack(
42-
alignment: Alignment.center,
43-
fit: StackFit.loose,
44-
children: <Widget>[
45-
Container(
46-
height: MediaQuery.of(context).size.height,
47-
child: widget.body ?? Container(),
48-
),
49-
Positioned(
50-
child: Container(
42+
alignment: Alignment.center,
43+
fit: StackFit.loose,
44+
children: <Widget>[
45+
Container(
5146
height: MediaQuery.of(context).size.height,
52-
width: MediaQuery.of(context).size.width,
47+
child: widget.body ?? Container(),
48+
),
49+
Positioned(
50+
child: Container(
51+
height: MediaQuery.of(context).size.height,
52+
width: MediaQuery.of(context).size.width,
5353
color: widget.showblurness
5454
? widget.blurnessColor ?? Colors.black54
5555
: null,
@@ -67,6 +67,6 @@ class _GFFloatingWidgetState extends State<GFFloatingWidget> {
6767
],
6868
),
6969
))
70-
],
71-
);
70+
],
71+
);
7272
}

lib/components/rating/gf_rating.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ class GFRating extends StatefulWidget {
2828
final int itemCount;
2929

3030
/// defines the color of items
31-
final Color color;
31+
final dynamic color;
3232

3333
/// defines the border color of [halfFilledIcon]
34-
final Color borderColor;
34+
final dynamic borderColor;
3535

3636
/// defines the size of items. GFSize can be used for size variations like small. medium. large
3737
final dynamic size;
@@ -86,7 +86,8 @@ class _GFRatingState extends State<GFRating> {
8686
icon = widget.defaultIcon ??
8787
Icon(
8888
Icons.star_border,
89-
color: widget.borderColor ?? Theme.of(context).primaryColor,
89+
color: GFColors.getGFColor(widget.borderColor) ??
90+
Theme.of(context).primaryColor,
9091
size: GFSizesClass.getGFSize(widget.size),
9192
);
9293
} else if (!widget.showTextForm
@@ -96,14 +97,16 @@ class _GFRatingState extends State<GFRating> {
9697
icon = widget.halfFilledIcon ??
9798
Icon(
9899
Icons.star_half,
99-
color: widget.color ?? Theme.of(context).primaryColor,
100+
color: GFColors.getGFColor(widget.color) ??
101+
Theme.of(context).primaryColor,
100102
size: GFSizesClass.getGFSize(widget.size),
101103
);
102104
} else {
103105
icon = widget.filledIcon ??
104106
Icon(
105107
Icons.star,
106-
color: widget.color ?? Theme.of(context).primaryColor,
108+
color: GFColors.getGFColor(widget.color) ??
109+
Theme.of(context).primaryColor,
107110
size: GFSizesClass.getGFSize(widget.size),
108111
);
109112
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter/rendering.dart';
3+
4+
enum GFShimmerDirection { leftToRight, rightToLeft, topToBottom, bottomToTop }
5+
6+
@immutable
7+
class GFShimmer extends StatefulWidget {
8+
const GFShimmer({
9+
Key key,
10+
@required this.child,
11+
@required this.gradient,
12+
this.direction = GFShimmerDirection.leftToRight,
13+
this.duration = const Duration(milliseconds: 1500),
14+
this.loop = 0,
15+
this.enabled = true,
16+
}) : super(key: key);
17+
18+
/// The widget below this widget in the tree.
19+
final Widget child;
20+
21+
/// Controls the speed of the shimmer effect. The default value is 1500 milliseconds.
22+
final Duration duration;
23+
24+
/// Controls the direction of the shimmer effect. The default value is GFShimmerDirection.leftToRight.
25+
final GFShimmerDirection direction;
26+
27+
/// Controls the [child]'s shades of color.
28+
final Gradient gradient;
29+
30+
/// Controls the animation loop. The default value is '0', that makes animation forever.
31+
final int loop;
32+
33+
/// Controls animation effect, defaults true state that makes animation active.
34+
final bool enabled;
35+
36+
@override
37+
_GFShimmerState createState() => _GFShimmerState();
38+
}
39+
40+
class _GFShimmerState extends State<GFShimmer>
41+
with SingleTickerProviderStateMixin {
42+
AnimationController _controller;
43+
int _count;
44+
45+
@override
46+
void initState() {
47+
super.initState();
48+
_count = 0;
49+
_controller = AnimationController(vsync: this, duration: widget.duration)
50+
..addStatusListener((AnimationStatus status) {
51+
if (status != AnimationStatus.completed) {
52+
return;
53+
}
54+
_count++;
55+
if (widget.loop <= 0) {
56+
_controller.repeat();
57+
} else if (_count < widget.loop) {
58+
_controller.forward(from: 0);
59+
}
60+
});
61+
if (widget.enabled) {
62+
_controller.forward();
63+
}
64+
}
65+
66+
@override
67+
void didUpdateWidget(GFShimmer oldWidget) {
68+
if (widget.enabled) {
69+
_controller.forward();
70+
} else {
71+
_controller.stop();
72+
}
73+
super.didUpdateWidget(oldWidget);
74+
}
75+
76+
@override
77+
Widget build(BuildContext context) => AnimatedBuilder(
78+
animation: _controller,
79+
child: widget.child,
80+
builder: (BuildContext context, Widget child) => Transform.rotate(
81+
angle: _controller.value * 2.0 * 22 / 7,
82+
child: child,
83+
),
84+
);
85+
86+
@override
87+
void dispose() {
88+
_controller.dispose();
89+
super.dispose();
90+
}
91+
}

lib/components/toast/gf_toast.dart

Lines changed: 58 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -109,64 +109,63 @@ class _GFToastState extends State<GFToast> with TickerProviderStateMixin {
109109
}
110110

111111
@override
112-
Widget build(BuildContext context) => hideToast? Container():FadeTransition(
113-
opacity: widget.autoDismiss ? fadeanimation : animation,
114-
child:
115-
Column(
116-
children: <Widget>[
117-
Container(
118-
width: widget.type == GFToastType.fullWidth
119-
? MediaQuery.of(context).size.width
120-
: widget.width?? MediaQuery.of(context).size.width*0.885,
121-
constraints: const BoxConstraints(minHeight: 50),
122-
margin: widget.type == GFToastType.fullWidth
123-
? const EdgeInsets.only(left: 0, right: 0)
124-
: const EdgeInsets.only(left: 10, right: 10),
125-
padding: const EdgeInsets.all(10),
126-
decoration: BoxDecoration(
127-
borderRadius: widget.type == GFToastType.basic
128-
? BorderRadius.circular(0)
129-
: widget.type == GFToastType.rounded
130-
? BorderRadius.circular(10)
131-
: BorderRadius.zero,
132-
color: widget.backgroundColor != null
133-
? GFColors.getGFColor(widget.backgroundColor)
134-
: const Color(0xff323232),
135-
boxShadow: [
136-
BoxShadow(
137-
color: Colors.black.withOpacity(0.40),
138-
blurRadius: 6,
139-
)
140-
]),
141-
child: Row(
142-
children: <Widget>[
143-
Flexible(
144-
flex: 7,
145-
fit: FlexFit.tight,
146-
child: Align(
147-
alignment: widget.alignment ?? Alignment.topLeft,
148-
child: widget.text != null
149-
? Text(widget.text, style: widget.textStyle)
150-
: (widget.child ?? Container()),
151-
),
112+
Widget build(BuildContext context) => hideToast
113+
? Container()
114+
: FadeTransition(
115+
opacity: widget.autoDismiss ? fadeanimation : animation,
116+
child: Column(
117+
children: <Widget>[
118+
Container(
119+
width: widget.type == GFToastType.fullWidth
120+
? MediaQuery.of(context).size.width
121+
: widget.width ?? MediaQuery.of(context).size.width * 0.885,
122+
constraints: const BoxConstraints(minHeight: 50),
123+
margin: widget.type == GFToastType.fullWidth
124+
? const EdgeInsets.only(left: 0, right: 0)
125+
: const EdgeInsets.only(left: 10, right: 10),
126+
padding: const EdgeInsets.all(10),
127+
decoration: BoxDecoration(
128+
borderRadius: widget.type == GFToastType.basic
129+
? BorderRadius.circular(0)
130+
: widget.type == GFToastType.rounded
131+
? BorderRadius.circular(10)
132+
: BorderRadius.zero,
133+
color: widget.backgroundColor != null
134+
? GFColors.getGFColor(widget.backgroundColor)
135+
: const Color(0xff323232),
136+
boxShadow: [
137+
BoxShadow(
138+
color: Colors.black.withOpacity(0.40),
139+
blurRadius: 6,
140+
)
141+
]),
142+
child: Row(
143+
children: <Widget>[
144+
Flexible(
145+
flex: 7,
146+
fit: FlexFit.tight,
147+
child: Align(
148+
alignment: widget.alignment ?? Alignment.topLeft,
149+
child: widget.text != null
150+
? Text(widget.text, style: widget.textStyle)
151+
: (widget.child ?? Container()),
152+
),
153+
),
154+
const SizedBox(
155+
width: 10,
156+
),
157+
widget.button != null
158+
? Flexible(
159+
flex: 4,
160+
fit: FlexFit.tight,
161+
child: Align(
162+
alignment: Alignment.topRight,
163+
child: widget.button,
164+
))
165+
: Container()
166+
],
152167
),
153-
const SizedBox(
154-
width: 10,
155-
),
156-
widget.button != null
157-
? Flexible(
158-
flex: 4,
159-
fit: FlexFit.tight,
160-
child: Align(
161-
alignment: Alignment.topRight,
162-
child: widget.button,
163-
))
164-
: Container()
165-
],
166-
),
167-
),
168-
],
169-
)
170-
171-
);
168+
),
169+
],
170+
));
172171
}

lib/getflutter.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export 'package:getflutter/components/toggle/gf_toggle.dart';
3030
export 'package:getflutter/components/typography/gf_typography.dart';
3131
export 'package:getflutter/components/rating/gf_rating.dart';
3232
export 'package:getflutter/components/slidable/gf_slidable.dart';
33+
export 'package:getflutter/components/shimmer/gf_shimmer.dart';
3334
export 'package:getflutter/components/loader/gf_loader.dart';
3435

3536
// exports shape, color, position, size, types
@@ -47,5 +48,3 @@ export 'types/gf_loader_type.dart';
4748
export 'types/gf_toast_type.dart';
4849
export 'types/gf_toggle_type.dart';
4950
export 'types/gf_typography_type.dart';
50-
51-

0 commit comments

Comments
 (0)