Skip to content

Commit f53772a

Browse files
committed
basic shimmer component completed
1 parent f39195c commit f53772a

File tree

9 files changed

+174
-202
lines changed

9 files changed

+174
-202
lines changed

example/lib/main.dart

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ void main() => runApp(MyApp());
88
class MyApp extends StatelessWidget {
99
@override
1010
Widget build(BuildContext context) => MaterialApp(
11-
title: 'GetFlutter',
12-
debugShowCheckedModeBanner: false,
13-
home: MyHomePage(),
14-
);
11+
title: 'GetFlutter',
12+
debugShowCheckedModeBanner: false,
13+
home: MyHomePage(),
14+
);
1515
}
1616

1717
class MyHomePage extends StatefulWidget {
@@ -37,84 +37,84 @@ class _MyHomePageState extends State<MyHomePage> {
3737

3838
@override
3939
Widget build(BuildContext context) => Scaffold(
40-
backgroundColor: GFColors.DARK,
41-
body: Column(
42-
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
43-
crossAxisAlignment: CrossAxisAlignment.center,
44-
children: <Widget>[
45-
InkWell(
46-
onTap: () {
47-
_launchUrl(_githubLibraryRepoLink);
48-
},
49-
child: SvgPicture.asset('lib/assets/logo.svg'),
50-
),
51-
Column(
52-
mainAxisAlignment: MainAxisAlignment.center,
40+
backgroundColor: GFColors.DARK,
41+
body: Column(
42+
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
5343
crossAxisAlignment: CrossAxisAlignment.center,
5444
children: <Widget>[
55-
const Padding(
56-
padding: EdgeInsets.only(bottom: 25),
57-
child: Center(
58-
child: Text(
59-
'To keep library size small and code clean we manage example on different repository. which includes clear usage of each and every component that we provide in GetFlutter library. Please have a look there.',
60-
style: TextStyle(
61-
fontSize: 16,
62-
color: GFColors.WHITE,
45+
InkWell(
46+
onTap: () {
47+
_launchUrl(_githubLibraryRepoLink);
48+
},
49+
child: SvgPicture.asset('lib/assets/logo.svg'),
50+
),
51+
Column(
52+
mainAxisAlignment: MainAxisAlignment.center,
53+
crossAxisAlignment: CrossAxisAlignment.center,
54+
children: <Widget>[
55+
const Padding(
56+
padding: EdgeInsets.only(bottom: 25),
57+
child: Center(
58+
child: Text(
59+
'To keep library size small and code clean we manage example on different repository. which includes clear usage of each and every component that we provide in GetFlutter library. Please have a look there.',
60+
style: TextStyle(
61+
fontSize: 16,
62+
color: GFColors.WHITE,
63+
),
64+
textAlign: TextAlign.center,
65+
),
6366
),
64-
textAlign: TextAlign.center,
6567
),
66-
),
68+
GFButton(
69+
size: GFSize.large,
70+
text: 'View on Github',
71+
textStyle: const TextStyle(
72+
fontSize: 16,
73+
color: GFColors.WHITE,
74+
),
75+
icon: SvgPicture.asset(
76+
'lib/assets/github.svg',
77+
height: 22,
78+
),
79+
color: GFColors.SUCCESS,
80+
blockButton: true,
81+
onPressed: () {
82+
_launchUrl(_githuAppRepoLink);
83+
}),
84+
],
6785
),
68-
GFButton(
69-
size: GFSize.large,
70-
text: 'View on Github',
71-
textStyle: const TextStyle(
72-
fontSize: 16,
73-
color: GFColors.WHITE,
74-
),
75-
icon: SvgPicture.asset(
76-
'lib/assets/github.svg',
77-
height: 22,
78-
),
79-
color: GFColors.SUCCESS,
80-
blockButton: true,
81-
onPressed: () {
82-
_launchUrl(_githuAppRepoLink);
83-
}),
84-
],
85-
),
86-
Column(
87-
children: <Widget>[
88-
const Padding(
89-
padding: EdgeInsets.only(bottom: 25),
90-
child: Center(
91-
child: Text(
92-
'We also have same app on playstore. It shows various possibilities that you can achieve using GetFlutter library.',
93-
style: TextStyle(
94-
fontSize: 16,
95-
color: GFColors.WHITE,
86+
Column(
87+
children: <Widget>[
88+
const Padding(
89+
padding: EdgeInsets.only(bottom: 25),
90+
child: Center(
91+
child: Text(
92+
'We also have same app on playstore. It shows various possibilities that you can achieve using GetFlutter library.',
93+
style: TextStyle(
94+
fontSize: 16,
95+
color: GFColors.WHITE,
96+
),
97+
textAlign: TextAlign.center,
98+
),
9699
),
97-
textAlign: TextAlign.center,
98100
),
99-
),
101+
GFButton(
102+
size: GFSize.large,
103+
text: 'View on Playstore',
104+
textStyle:
105+
const TextStyle(fontSize: 16, color: GFColors.WHITE),
106+
icon: SvgPicture.asset(
107+
'lib/assets/playstore.svg',
108+
height: 20,
109+
),
110+
color: GFColors.SUCCESS,
111+
blockButton: true,
112+
onPressed: () {
113+
_launchUrl(_playStoreLink);
114+
}),
115+
],
100116
),
101-
GFButton(
102-
size: GFSize.large,
103-
text: 'View on Playstore',
104-
textStyle:
105-
const TextStyle(fontSize: 16, color: GFColors.WHITE),
106-
icon: SvgPicture.asset(
107-
'lib/assets/playstore.svg',
108-
height: 20,
109-
),
110-
color: GFColors.SUCCESS,
111-
blockButton: true,
112-
onPressed: () {
113-
_launchUrl(_playStoreLink);
114-
}),
115117
],
116118
),
117-
],
118-
),
119-
);
119+
);
120120
}

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/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: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ class _GFRatingState extends State<GFRating> {
8686
icon = widget.defaultIcon ??
8787
Icon(
8888
Icons.star_border,
89-
color: GFColors.getGFColor(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: GFColors.getGFColor(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: GFColors.getGFColor(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
}

lib/components/shimmer/gf_shimmer.dart

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter/rendering.dart';
33

4-
enum GFShimmerDirection {leftToRight, rightToLeft, topToBottom, bottomToTop}
4+
enum GFShimmerDirection { leftToRight, rightToLeft, topToBottom, bottomToTop }
55

66
@immutable
77
class GFShimmer extends StatefulWidget {
@@ -33,39 +33,12 @@ class GFShimmer extends StatefulWidget {
3333
/// Controls animation effect, defaults true state that makes animation active.
3434
final bool enabled;
3535

36-
GFShimmer.withColors({
37-
Key key,
38-
@required this.child,
39-
@required Color baseColor,
40-
@required Color highlightColor,
41-
this.duration = const Duration(milliseconds: 1500),
42-
this.direction = GFShimmerDirection.leftToRight,
43-
this.loop = 0,
44-
this.enabled = true,
45-
}) : gradient = LinearGradient(
46-
begin: Alignment.topLeft,
47-
end: Alignment.centerRight,
48-
colors: <Color>[
49-
baseColor,
50-
baseColor,
51-
highlightColor,
52-
baseColor,
53-
baseColor
54-
],
55-
stops: const <double>[
56-
0,
57-
0.3,
58-
0.5,
59-
0.7,
60-
1
61-
]),
62-
super(key: key);
63-
6436
@override
6537
_GFShimmerState createState() => _GFShimmerState();
6638
}
6739

68-
class _GFShimmerState extends State<GFShimmer> with SingleTickerProviderStateMixin {
40+
class _GFShimmerState extends State<GFShimmer>
41+
with SingleTickerProviderStateMixin {
6942
AnimationController _controller;
7043
int _count;
7144

@@ -102,18 +75,17 @@ class _GFShimmerState extends State<GFShimmer> with SingleTickerProviderStateMix
10275

10376
@override
10477
Widget build(BuildContext context) => AnimatedBuilder(
105-
animation: _controller,
106-
child: widget.child,
107-
builder: (BuildContext context, Widget child) => Transform.rotate(
108-
angle: _controller.value * 2.0 * 22/7,
109-
child: child,
110-
),
111-
);
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+
);
11285

11386
@override
11487
void dispose() {
11588
_controller.dispose();
11689
super.dispose();
11790
}
11891
}
119-

0 commit comments

Comments
 (0)