Skip to content

Commit 38f3716

Browse files
Merge branch 'master' into improvement
2 parents ab301fc + c56c6a7 commit 38f3716

11 files changed

Lines changed: 942 additions & 1973 deletions

File tree

example/lib/main_temp.dart

Lines changed: 607 additions & 1644 deletions
Large diffs are not rendered by default.

lib/components/appbar/gf_appbar.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ class _GFAppBarState extends State<GFAppBar> {
293293
static const double _defaultElevation = 4;
294294
Widget searchBar;
295295
bool showSearchBar = false;
296+
final TextEditingController _searchController = TextEditingController();
296297

297298
void _handleDrawerButton() {
298299
Scaffold.of(context).openDrawer();
@@ -455,7 +456,7 @@ class _GFAppBarState extends State<GFAppBar> {
455456
),
456457
onTap: widget.onTap,
457458
onChanged: widget.onChanged,
458-
controller: widget.searchController,
459+
controller: _searchController ?? widget.searchController,
459460
onSubmitted: widget.onSubmitted,
460461
);
461462
}

lib/components/button/gf_button.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,13 +1014,15 @@ class _GFButtonState extends State<GFButton> {
10141014
bool get _disabled => _states.contains(MaterialState.disabled);
10151015

10161016
double buttonWidth() {
1017+
double buttonWidth = 0;
10171018
if (widget.blockButton == true) {
1018-
return MediaQuery.of(context).size.width * 0.88;
1019+
buttonWidth = MediaQuery.of(context).size.width * 0.88;
10191020
} else if (widget.fullWidthButton == true) {
1020-
return MediaQuery.of(context).size.width;
1021+
buttonWidth = MediaQuery.of(context).size.width;
10211022
} else {
1022-
return MediaQuery.of(context).size.width * 0.88;
1023+
buttonWidth = null;
10231024
}
1025+
return buttonWidth;
10241026
}
10251027

10261028
void _updateState(MaterialState state, bool value) {

lib/components/checkbox/gf_checkbox.dart

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,36 @@ import 'package:flutter/material.dart';
22
import 'package:getwidget/getwidget.dart';
33

44
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);
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+
this.autofocus = false,
24+
this.focusNode})
25+
: assert(autofocus != null),
26+
super(key: key);
2427

2528
/// type of [GFCheckboxType] which is of four type is basic, sqaure, circular and custom
2629
final GFCheckboxType type;
2730

2831
/// type of [double] which is GFSize ie, small, medium and large and can use any double value
2932
final double size;
3033

31-
// type pf [Color] used to change the checkcolor when the checkbox is active
34+
/// type pf [Color] used to change the checkcolor when the checkbox is active
3235
final Color checkColor;
3336

3437
/// type of [Color] used to change the backgroundColor of the active checkbox
@@ -58,40 +61,42 @@ class GFCheckbox extends StatefulWidget {
5861
/// type of [Color] used to change the background color of the custom active checkbox only
5962
final Color custombgColor;
6063

64+
/// {@macro flutter.widgets.Focus.autofocus}
65+
final bool autofocus;
66+
67+
/// {@macro flutter.widgets.Focus.focusNode}
68+
final FocusNode focusNode;
69+
6170
@override
6271
_GFCheckboxState createState() => _GFCheckboxState();
6372
}
6473

6574
class _GFCheckboxState extends State<GFCheckbox> {
6675
bool get enabled => widget.onChanged != null;
67-
bool isSelected = false;
6876

6977
@override
7078
void initState() {
7179
super.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-
}
8280
}
8381

8482
@override
8583
Widget build(BuildContext context) => FocusableActionDetector(
84+
focusNode: widget.focusNode,
85+
autofocus: widget.autofocus,
8686
enabled: enabled,
8787
child: InkWell(
88-
onTap: onStatusChange,
88+
canRequestFocus: enabled,
89+
onTap: widget.onChanged != null
90+
? () {
91+
widget.onChanged(!widget.value);
92+
}
93+
: null,
8994
child: Container(
9095
height: widget.size,
9196
width: widget.size,
9297
decoration: BoxDecoration(
9398
color: enabled
94-
? isSelected
99+
? widget.value
95100
? widget.type == GFCheckboxType.custom
96101
? Colors.white
97102
: widget.activebgColor
@@ -103,12 +108,12 @@ class _GFCheckboxState extends State<GFCheckbox> {
103108
? BorderRadius.circular(50)
104109
: BorderRadius.zero,
105110
border: Border.all(
106-
color: isSelected
111+
color: widget.value
107112
? widget.type == GFCheckboxType.custom
108113
? Colors.black87
109114
: widget.activeBorderColor
110115
: widget.inactiveBorderColor)),
111-
child: isSelected
116+
child: widget.value
112117
? widget.type == GFCheckboxType.custom
113118
? Stack(
114119
children: <Widget>[

0 commit comments

Comments
 (0)