Skip to content

Commit 154d789

Browse files
Sandip KakadiyaSandip Kakadiya
authored andcommitted
loader, listtile, progressbar, radiotile changes & comments changes
1 parent 13cee3a commit 154d789

File tree

5 files changed

+74
-104
lines changed

5 files changed

+74
-104
lines changed

lib/components/list_tile/gf_list_tile.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class GFListTile extends StatelessWidget {
107107
selected: selected,
108108
enabled: enabled,
109109
child: Container(
110-
// constraints: const BoxConstraints(minHeight: 50),
110+
// constraints: const BoxConstraints(minHeight: 50),
111111
padding: padding,
112112
margin: margin,
113113
decoration: BoxDecoration(

lib/components/loader/gf_loader.dart

Lines changed: 22 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
33
import 'package:getwidget/getwidget.dart';
44

55
class GFLoader extends StatefulWidget {
6+
/// [GFLoader] shows differnt type of loaders with different customization options.
67
const GFLoader(
78
{Key key,
89
this.loaderColorOne = Colors.redAccent,
@@ -66,51 +67,25 @@ class _GFLoaderState extends State<GFLoader>
6667
Animation<double> loaderanimation2;
6768
Animation<double> loaderanimation3;
6869
AnimationController controller;
70+
Interval interval = const Interval(0.1, 0.81, curve: Curves.linear);
6971

7072
@override
7173
void initState() {
72-
super.initState();
73-
7474
controller = AnimationController(duration: widget.duration, vsync: this);
75-
7675
loaderanimation1 = Tween<double>(begin: 0, end: 1).animate(
77-
CurvedAnimation(
78-
parent: controller,
79-
curve: const Interval(
80-
0,
81-
0.71,
82-
curve: Curves.linear,
83-
),
84-
),
76+
CurvedAnimation(parent: controller, curve: interval),
8577
);
86-
8778
loaderanimation2 = Tween<double>(begin: 0, end: 1).animate(
88-
CurvedAnimation(
89-
parent: controller,
90-
curve: const Interval(
91-
0.1,
92-
0.81,
93-
curve: Curves.linear,
94-
),
95-
),
79+
CurvedAnimation(parent: controller, curve: interval),
9680
);
97-
9881
loaderanimation3 = Tween<double>(begin: 0, end: 1).animate(
99-
CurvedAnimation(
100-
parent: controller,
101-
curve: const Interval(
102-
0.2,
103-
0.91,
104-
curve: Curves.linear,
105-
),
106-
),
82+
CurvedAnimation(parent: controller, curve: interval),
10783
);
108-
10984
controller.addListener(() {
11085
setState(() {});
11186
});
112-
11387
controller.repeat();
88+
super.initState();
11489
}
11590

11691
@override
@@ -129,7 +104,7 @@ class _GFLoaderState extends State<GFLoader>
129104
child: CircularProgressIndicator(
130105
valueColor: widget.androidLoaderColor,
131106
strokeWidth: widget.loaderstrokeWidth,
132-
// value: 20,
107+
// value: 20,
133108
),
134109
))
135110
: widget.type == GFLoaderType.ios
@@ -172,7 +147,6 @@ class _GFLoaderState extends State<GFLoader>
172147
color: widget.loaderColorTwo,
173148
type: widget.type,
174149
icon: widget.loaderIconTwo,
175-
//
176150
),
177151
),
178152
),
@@ -190,7 +164,6 @@ class _GFLoaderState extends State<GFLoader>
190164
color: widget.loaderColorThree,
191165
type: widget.type,
192166
icon: widget.loaderIconThree,
193-
//
194167
),
195168
),
196169
),
@@ -200,7 +173,9 @@ class _GFLoaderState extends State<GFLoader>
200173

201174
@override
202175
void dispose() {
203-
controller.dispose();
176+
if (controller != null) {
177+
controller.dispose();
178+
}
204179
super.dispose();
205180
}
206181
}
@@ -215,7 +190,6 @@ class Loader extends StatelessWidget {
215190
this.size,
216191
this.child})
217192
: super(key: key);
218-
219193
final double radius;
220194
final Color color;
221195
final GFLoaderType type;
@@ -225,15 +199,16 @@ class Loader extends StatelessWidget {
225199

226200
@override
227201
Widget build(BuildContext context) => Center(
228-
child: type == GFLoaderType.custom
229-
? Container(child: child != null ? child : icon ?? Container())
230-
: Container(
231-
width: radius,
232-
height: radius,
233-
decoration: BoxDecoration(
234-
color: color,
235-
shape: type == GFLoaderType.circle
236-
? BoxShape.circle
237-
: BoxShape.rectangle),
238-
));
202+
child: type == GFLoaderType.custom
203+
? Container(child: child != null ? child : icon ?? Container())
204+
: Container(
205+
width: radius,
206+
height: radius,
207+
decoration: BoxDecoration(
208+
color: color,
209+
shape: type == GFLoaderType.circle
210+
? BoxShape.circle
211+
: BoxShape.rectangle),
212+
),
213+
);
239214
}

lib/components/progress_bar/gf_progress_bar.dart

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
22
import 'package:getwidget/getwidget.dart';
33

44
class GFProgressBar extends StatefulWidget {
5+
/// Shows progress as a completed and remaining percentage in bar of given state
56
GFProgressBar({
67
Key key,
78
this.percentage = 0.2,
@@ -33,7 +34,6 @@ class GFProgressBar extends StatefulWidget {
3334
throw ArgumentError(
3435
' linearGradient and progressBarColor cannot be given');
3536
}
36-
3737
assert(circleStartAngle >= 0.0);
3838
if (percentage < 0.0 || percentage > 1.0) {
3939
throw Exception('Percentage value must be be tween 0.0 and 1.0');
@@ -276,7 +276,6 @@ class _GFProgressBarState extends State<GFProgressBar>
276276
if (widget.trailing != null) {
277277
item.add(widget.trailing);
278278
}
279-
280279
return widget.type == GFProgressType.linear
281280
? Material(
282281
color: Colors.transparent,
@@ -334,7 +333,6 @@ class LinearPainter extends CustomPainter {
334333
_paintBackground.strokeCap = StrokeCap.round;
335334
}
336335
}
337-
338336
final Paint _paintBackground = Paint();
339337
final Paint _paintLine = Paint();
340338
final double circleWidth;
@@ -353,11 +351,9 @@ class LinearPainter extends CustomPainter {
353351
final start = Offset(0, size.height / 2);
354352
final end = Offset(size.width, size.height / 2);
355353
canvas.drawLine(start, end, _paintBackground);
356-
357354
if (mask != null) {
358355
_paintLine.maskFilter = mask;
359356
}
360-
361357
if (fromRightToLeft) {
362358
final xProgress = size.width - size.width * progress;
363359
if (linearGradient != null) {
@@ -416,7 +412,6 @@ class CirclePainter extends CustomPainter {
416412
_paintBackground.color = backgroundColor;
417413
_paintBackground.style = PaintingStyle.stroke;
418414
_paintBackground.strokeWidth = circleWidth;
419-
420415
_paintLine.color = progressBarColor;
421416
_paintLine.style = PaintingStyle.stroke;
422417
_paintLine.strokeWidth = circleWidth;
@@ -444,7 +439,6 @@ class CirclePainter extends CustomPainter {
444439
void paint(Canvas canvas, Size size) {
445440
final child = Offset(size.width / 2, size.height / 2);
446441
canvas.drawCircle(child, radius, _paintBackground);
447-
448442
if (mask != null) {
449443
_paintLine.maskFilter = mask;
450444
}
@@ -456,11 +450,8 @@ class CirclePainter extends CustomPainter {
456450
),
457451
);
458452
}
459-
460453
final double fixedStartAngle = circleStartAngle;
461-
462454
const double circleStartAngleFixedMargin = 1;
463-
464455
if (reverse) {
465456
final start =
466457
radians(360 * circleStartAngleFixedMargin - 90.0 + fixedStartAngle);

lib/components/radio/gf_radio.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'package:flutter/rendering.dart';
55
import 'package:flutter/widgets.dart';
66

77
class GFRadio<T> extends StatefulWidget {
8+
/// [GFRadio] is one type of selection indicator in a list of options.
89
const GFRadio(
910
{Key key,
1011
@required this.value,
@@ -95,7 +96,6 @@ class _GFRadioState<T> extends State<GFRadio<T>> with TickerProviderStateMixin {
9596
T groupValue;
9697

9798
void onStatusChange() {
98-
print('wer ${widget.value == widget.groupValue}');
9999
groupValue = widget.value;
100100
_handleChanged(widget.value == groupValue);
101101
}
@@ -112,10 +112,7 @@ class _GFRadioState<T> extends State<GFRadio<T>> with TickerProviderStateMixin {
112112

113113
@override
114114
Widget build(BuildContext context) {
115-
// print('gr ${widget.value} ${widget.groupValue}');
116115
selected = widget.value == widget.groupValue;
117-
// print('sel $selected');
118-
119116
return InkWell(
120117
enableFeedback: enabled,
121118
onTap: onStatusChange,

lib/components/radio_list_tile/gf_radio_list_tile.dart

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class GFRadioListTile<T> extends StatelessWidget {
1414
this.inactivebgColor = GFColors.WHITE,
1515
this.activeBorderColor = GFColors.DARK,
1616
this.inactiveBorderColor = GFColors.DARK,
17+
this.position = GFPosition.end,
1718
this.activeIcon = const Icon(
1819
Icons.check,
1920
size: 20,
@@ -59,7 +60,7 @@ class GFRadioListTile<T> extends StatelessWidget {
5960
/// The GFListTile's background color. Can be given [Color] or [GFColors]
6061
final Color color;
6162

62-
/// type of [Widget] or [GFAvatar] used to create rounded user profile
63+
/// If position is start Checkbox will come instead of avatar, type of [Widget] or [GFAvatar] used to create rounded user profile
6364
final Widget avatar;
6465

6566
/// The title to display inside the [GFListTile]. see [Text]
@@ -71,7 +72,7 @@ class GFRadioListTile<T> extends StatelessWidget {
7172
/// The description to display inside the [GFListTile]. see [Text]
7273
final Widget description;
7374

74-
/// The icon to display inside the [GFListTile]. see [Icon]
75+
/// If position is end Checkbox will come instead of icon, The icon to display inside the [GFListTile]. see [Icon]
7576
final Widget icon;
7677

7778
/// defines the margin of GFListTile
@@ -92,6 +93,9 @@ class GFRadioListTile<T> extends StatelessWidget {
9293
/// Inoperative if [enabled] is false.
9394
final GestureTapCallback onTap;
9495

96+
/// Position allows user to set position of [GFCheckbox] based on given [GFPosition]
97+
final GFPosition position;
98+
9599
/// Called when the user long-presses on this list tile.
96100
///
97101
/// Inoperative if [enabled] is false.
@@ -163,45 +167,48 @@ class GFRadioListTile<T> extends StatelessWidget {
163167
bool get checked => value == groupValue;
164168

165169
@override
166-
Widget build(BuildContext context) => MergeSemantics(
167-
child: GFListTile(
168-
autofocus: autofocus,
169-
enabled: onChanged != null,
170-
onTap: onChanged != null
171-
? () {
172-
if (toggleable && checked) {
173-
onChanged(null);
174-
return;
175-
}
176-
if (!checked) {
177-
onChanged(value);
178-
}
170+
Widget build(BuildContext context) {
171+
GFRadio radio = GFRadio(
172+
autofocus: autofocus,
173+
onChanged: onChanged,
174+
value: value,
175+
groupValue: groupValue,
176+
size: size,
177+
activebgColor: activebgColor,
178+
inactiveIcon: inactiveIcon,
179+
activeBorderColor: activeBorderColor,
180+
inactivebgColor: inactivebgColor,
181+
activeIcon: activeIcon,
182+
inactiveBorderColor: inactiveBorderColor,
183+
custombgColor: custombgColor,
184+
);
185+
return MergeSemantics(
186+
child: GFListTile(
187+
autofocus: autofocus,
188+
enabled: onChanged != null,
189+
onTap: onChanged != null
190+
? () {
191+
if (toggleable && checked) {
192+
onChanged(null);
193+
return;
194+
}
195+
if (!checked) {
196+
onChanged(value);
179197
}
180-
: null,
181-
selected: selected,
182-
avatar: avatar,
183-
titleText: titleText,
184-
subTitle: subTitle,
185-
subtitleText: subtitleText,
186-
description: description,
187-
color: color,
188-
padding: padding,
189-
margin: margin,
190-
title: title,
191-
icon: GFRadio(
192-
autofocus: autofocus,
193-
onChanged: onChanged,
194-
value: value,
195-
groupValue: groupValue,
196-
size: size,
197-
activebgColor: activebgColor,
198-
inactiveIcon: inactiveIcon,
199-
activeBorderColor: activeBorderColor,
200-
inactivebgColor: inactivebgColor,
201-
activeIcon: activeIcon,
202-
inactiveBorderColor: inactiveBorderColor,
203-
custombgColor: custombgColor,
204-
),
205-
),
206-
);
198+
}
199+
: null,
200+
selected: selected,
201+
avatar: position == GFPosition.start ? radio : avatar,
202+
titleText: titleText,
203+
subTitle: subTitle,
204+
subtitleText: subtitleText,
205+
description: description,
206+
color: color,
207+
padding: padding,
208+
margin: margin,
209+
title: title,
210+
icon: position == GFPosition.end ? radio : icon,
211+
),
212+
);
213+
}
207214
}

0 commit comments

Comments
 (0)