Skip to content

Commit 4e37a1c

Browse files
authored
Merge pull request #140 from shravyackm/loader
Loader
2 parents cfdf491 + 00d938d commit 4e37a1c

File tree

7 files changed

+530
-0
lines changed

7 files changed

+530
-0
lines changed

lib/components/accordian/gf_accordian.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class _GFAccordionState extends State<GFAccordion>
102102
@override
103103
void dispose() {
104104
animationController.dispose();
105+
controller.dispose();
105106
super.dispose();
106107
}
107108

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:getflutter/getflutter.dart';
3+
4+
class GFCheckbox extends StatefulWidget {
5+
const GFCheckbox({
6+
Key key,
7+
this.size = GFSize.MEDIUM,
8+
this.type = GFCheckboxType.basic,
9+
this.checkColor = GFColors.WHITE,
10+
this.activebgColor = GFColors.PRIMARY,
11+
this.inactivebgColor = GFColors.WHITE,
12+
this.activeBorderColor = GFColors.WHITE,
13+
this.inactiveBorderColor = GFColors.DARK,
14+
this.onChanged,
15+
this.value,
16+
this.activeIcon = const Icon(
17+
Icons.check,
18+
size: 20,
19+
color: GFColors.WHITE,
20+
),
21+
this.inactiveIcon = const Icon(Icons.close),
22+
this.custombgColor = GFColors.SUCCESS,
23+
}) : super(key: key);
24+
25+
/// type of [GFCheckboxType] which is of four type is basic, sqaure, circular and custom
26+
final GFCheckboxType type;
27+
28+
/// type of [double] which is GFSize ie, small, medium and large and can use any double value
29+
final double size;
30+
31+
// type pf [Color] used to change the checkcolor when the checkbox is active
32+
final Color checkColor;
33+
34+
/// type of [Color] used to change the backgroundColor of the active checkbox
35+
final Color activebgColor;
36+
37+
/// type of [Color] used to change the backgroundColor of the inactive checkbox
38+
final Color inactivebgColor;
39+
40+
/// type of [Color] used to change the border color of the active checkbox
41+
final Color activeBorderColor;
42+
43+
/// type of [Color] used to change the border color of the inactive checkbox
44+
final Color inactiveBorderColor;
45+
46+
/// Called when the user checks or unchecks the checkbox.
47+
final ValueChanged<bool> onChanged;
48+
49+
///Used to set the current state of the checkbox
50+
final bool value;
51+
52+
///type of Widget used to change the checkbox's active icon
53+
final Widget activeIcon;
54+
55+
///type of [Widget] used to change the checkbox's inactive icon
56+
final Widget inactiveIcon;
57+
58+
/// type of [Color] used to change the background color of the custom active checkbox only
59+
final Color custombgColor;
60+
61+
@override
62+
_GFCheckboxState createState() => _GFCheckboxState();
63+
}
64+
65+
class _GFCheckboxState extends State<GFCheckbox> {
66+
//
67+
68+
bool isSelected = false;
69+
70+
@override
71+
void initState(){
72+
isSelected = widget.value??false;
73+
}
74+
75+
void onStatusChange() {
76+
setState(() {
77+
isSelected = !isSelected;
78+
});
79+
if (widget.onChanged != null) {
80+
widget.onChanged(isSelected);
81+
}
82+
}
83+
@override
84+
Widget build(BuildContext context) => InkWell(
85+
onTap: onStatusChange,
86+
child: Container(
87+
height: widget.size,
88+
width: widget.size,
89+
decoration: BoxDecoration(
90+
color: isSelected
91+
? widget.type == GFCheckboxType.custom
92+
? Colors.white
93+
: widget.activebgColor
94+
: widget.inactivebgColor,
95+
borderRadius: widget.type == GFCheckboxType.basic
96+
? BorderRadius.circular(3)
97+
: widget.type == GFCheckboxType.circle
98+
? BorderRadius.circular(50)
99+
: BorderRadius.zero,
100+
border: Border.all(
101+
color: isSelected
102+
? widget.type == GFCheckboxType.custom
103+
? Colors.black87
104+
: widget.activeBorderColor
105+
: widget.inactiveBorderColor)),
106+
child: isSelected
107+
? widget.type == GFCheckboxType.custom
108+
? Stack(
109+
children: <Widget>[
110+
Container(
111+
alignment: Alignment.center,
112+
),
113+
Container(
114+
margin: const EdgeInsets.all(5),
115+
alignment: Alignment.center,
116+
width: widget.size * 0.8,
117+
height: widget.size * 0.8,
118+
decoration: BoxDecoration(
119+
shape: BoxShape.rectangle,
120+
color: widget.custombgColor),
121+
)
122+
],
123+
)
124+
: widget.activeIcon
125+
: widget.inactiveIcon,
126+
),
127+
);
128+
}
Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:getflutter/getflutter.dart';
3+
4+
5+
class GFCheckboxListTile extends StatefulWidget {
6+
7+
const GFCheckboxListTile({
8+
Key key,
9+
this.titleText,
10+
this.subtitleText,
11+
this.color,
12+
this.avatar,
13+
this.title,
14+
this.subTitle,
15+
this.description,
16+
this.padding = const EdgeInsets.all(8),
17+
this.margin = const EdgeInsets.all(16),
18+
this.size = GFSize.MEDIUM,
19+
this.type = GFCheckboxType.basic,
20+
this.checkColor = GFColors.WHITE,
21+
this.activebgColor = GFColors.PRIMARY,
22+
this.inactivebgColor = GFColors.WHITE,
23+
this.activeBorderColor = GFColors.WHITE,
24+
this.inactiveBorderColor = GFColors.DARK,
25+
this.onChanged,
26+
this.value,
27+
this.activeIcon = const Icon(
28+
Icons.check,
29+
size: 20,
30+
color: GFColors.WHITE,
31+
),
32+
this.inactiveIcon = const Icon(Icons.close),
33+
this.custombgColor = GFColors.SUCCESS,
34+
}) : super(key: key);
35+
36+
///type of [String] used to pass text, alternative to title property and gets higher priority than title
37+
final String titleText;
38+
39+
///type of [String] used to pass text, alternative to subtitle property and gets higher priority than subtitle
40+
final String subtitleText;
41+
42+
/// The GFListTile's background color. Can be given [Color] or [GFColors]
43+
final Color color;
44+
45+
/// type of [Widget] or [GFAvatar] used to create rounded user profile
46+
final Widget avatar;
47+
48+
/// The title to display inside the [GFListTile]. see [Text]
49+
final Widget title;
50+
51+
/// The subTitle to display inside the [GFListTile]. see [Text]
52+
final Widget subTitle;
53+
54+
/// The description to display inside the [GFListTile]. see [Text]
55+
final Widget description;
56+
57+
58+
/// defines the margin of GFListTile
59+
final EdgeInsets margin;
60+
61+
/// defines the padding of GFListTile
62+
final EdgeInsets padding;
63+
64+
/// type of [GFCheckboxType] which is of four type is basic, sqaure, circular and custom
65+
final GFCheckboxType type;
66+
67+
/// type of [double] which is GFSize ie, small, medium and large and can use any double value
68+
final double size;
69+
70+
// type pf [Color] used to change the checkcolor when the checkbox is active
71+
final Color checkColor;
72+
73+
/// type of [Color] used to change the backgroundColor of the active checkbox
74+
final Color activebgColor;
75+
76+
/// type of [Color] used to change the backgroundColor of the inactive checkbox
77+
final Color inactivebgColor;
78+
79+
/// type of [Color] used to change the border color of the active checkbox
80+
final Color activeBorderColor;
81+
82+
/// type of [Color] used to change the border color of the inactive checkbox
83+
final Color inactiveBorderColor;
84+
85+
/// Called when the user checks or unchecks the checkbox.
86+
final ValueChanged<bool> onChanged;
87+
88+
///Used to set the current state of the checkbox
89+
final bool value;
90+
91+
///type of Widget used to change the checkbox's active icon
92+
final Widget activeIcon;
93+
94+
///type of [Widget] used to change the checkbox's inactive icon
95+
final Widget inactiveIcon;
96+
97+
/// type of [Color] used to change the background color of the custom active checkbox only
98+
final Color custombgColor;
99+
100+
101+
102+
@override
103+
_GFCheckboxListTileState createState() => _GFCheckboxListTileState();
104+
}
105+
106+
class _GFCheckboxListTileState extends State<GFCheckboxListTile> {
107+
108+
109+
bool isSelected = false;
110+
@override
111+
void initState(){
112+
isSelected = widget.value??false;
113+
}
114+
115+
void onStatusChange() {
116+
setState(() {
117+
isSelected = !isSelected;
118+
});
119+
if (widget.onChanged != null) {
120+
widget.onChanged(isSelected);
121+
}
122+
}
123+
124+
125+
// void onStatusChange() {
126+
// if (widget.onChanged != null) {
127+
// setState(() {
128+
// isSelected = !isSelected;
129+
// });
130+
// switch (widget.value) {
131+
// case false:
132+
// widget.onChanged(true);
133+
// break;
134+
// case true:
135+
//// widget.onChanged(widget.tristate ? null : true);
136+
//// break;
137+
// default: // case null:
138+
// widget.onChanged(isSelected);
139+
// break;
140+
// }
141+
// }
142+
//// }
143+
@override
144+
Widget build(BuildContext context) =>
145+
InkWell(
146+
// onTap: widget.onChanged != null ? () { widget.onChanged(isSelected); } : null,
147+
onTap: onStatusChange,
148+
149+
// onTap: (){
150+
// setState((){
151+
// isSelected = !isSelected;
152+
// });
153+
// },
154+
child: GestureDetector(
155+
156+
child: GFListTile(
157+
avatar: widget.avatar,
158+
titleText: widget.titleText,
159+
subTitle: widget.subTitle,
160+
subtitleText: widget.subtitleText,
161+
description: widget.description,
162+
color: widget.color,
163+
padding: widget.padding,
164+
margin: widget.margin,
165+
title: widget.title,
166+
167+
icon: GFCheckbox(
168+
size: widget.size,
169+
activebgColor: widget.activebgColor,
170+
// onChanged:widget.onChanged,
171+
// value: widget.value,
172+
inactiveIcon: widget.inactiveIcon,
173+
activeBorderColor: widget.activeBorderColor,
174+
inactivebgColor: widget.inactivebgColor,
175+
activeIcon: widget.activeIcon,
176+
inactiveBorderColor: widget.inactiveBorderColor,
177+
custombgColor: widget.custombgColor,
178+
checkColor: widget.checkColor,
179+
type: widget.type,
180+
),
181+
),
182+
)
183+
);
184+
// InkWell(
185+
// onTap: onStatusChange,
186+
// child: Container(
187+
// constraints: const BoxConstraints(minHeight: 50),
188+
// padding: widget.padding,
189+
// margin: widget.margin,
190+
// decoration: BoxDecoration(
191+
// color: widget.color,
192+
// borderRadius: const BorderRadius.all(Radius.circular(5)),
193+
// ),
194+
// child: Row(
195+
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
196+
// children: <Widget>[
197+
// widget.avatar ?? Container(),
198+
// Expanded(
199+
// child: Padding(
200+
// padding: const EdgeInsets.symmetric(horizontal: 10),
201+
// child: Column(
202+
// crossAxisAlignment: CrossAxisAlignment.start,
203+
// children: <Widget>[
204+
// widget.titleText != null
205+
// ? Text(
206+
// widget.titleText,
207+
// style: const TextStyle(
208+
// fontSize: 17,
209+
// fontWeight: FontWeight.w500,
210+
// color: GFColors.DARK),
211+
// )
212+
// : widget.title ?? Container(),
213+
// widget.subtitleText != null
214+
// ? Text(
215+
// widget.subtitleText,
216+
// style: TextStyle(
217+
// fontSize: 14.5,
218+
// color: Colors.black54,
219+
// ),
220+
// )
221+
// : widget.subTitle ?? Container(),
222+
// widget.description ?? Container()
223+
// ],
224+
// ),
225+
// ),
226+
// ),
227+
//// widget.icon ?? Container(),
228+
//
229+
// GFCheckbox(
230+
// size: widget.size,
231+
// activebgColor: widget.activebgColor,
232+
// onChanged: widget.onChanged,
233+
// value: widget.value,
234+
// inactiveIcon: widget.inactiveIcon,
235+
// activeBorderColor: widget.activeBorderColor,
236+
// inactivebgColor: widget.inactivebgColor,
237+
// activeIcon: widget.activeIcon,
238+
// inactiveBorderColor: widget.inactiveBorderColor,
239+
// custombgColor: widget.custombgColor,
240+
// checkColor: widget.checkColor,
241+
// type: widget.type,
242+
// ),
243+
// ],
244+
// ),
245+
// ),
246+
// );
247+
}
248+

0 commit comments

Comments
 (0)