Skip to content

Commit e67b5a6

Browse files
authored
Merge pull request #46 from deepikahr/GFDropdown
GF Dropdown and GFMultiselect completed
2 parents 53794f0 + e0a9c72 commit e67b5a6

File tree

11 files changed

+334
-238
lines changed

11 files changed

+334
-238
lines changed

lib/components/bottom_sheet/gf_bottom_sheet.dart

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class GFBottomSheet extends StatefulWidget {
1414
this.elevation = 0.0,
1515
this.stickyFooterHeight = 0.0,
1616
this.stickyHeaderHeight = 0.0,
17-
this.animationDuration = 300,
17+
this.animationDuration = 1200,
1818
this.enableExpandableContent = false,
1919
}) : assert(elevation >= 0.0),
2020
assert(minContentHeight >= 0.0),
@@ -71,7 +71,8 @@ class GFBottomSheet extends StatefulWidget {
7171

7272
class _GFBottomSheetState extends State<GFBottomSheet>
7373
with TickerProviderStateMixin {
74-
final StreamController<double> controller = StreamController.broadcast();
74+
final StreamController<double> _streamController =
75+
StreamController.broadcast();
7576
bool isDragDirectionUp;
7677
bool showBottomSheet = false;
7778
Function _controllerListener;
@@ -152,11 +153,20 @@ class _GFBottomSheetState extends State<GFBottomSheet>
152153
child: widget.contentBody),
153154
),
154155
)
155-
: showContent
156-
? StreamBuilder(
157-
stream: controller.stream,
156+
: widget.controller.height == widget.minContentHeight
157+
? Container()
158+
: StreamBuilder(
159+
stream: _streamController.stream,
158160
initialData: widget.controller.height,
159-
builder: (context, snapshot) => GestureDetector(
161+
builder: (BuildContext context, AsyncSnapshot snapshot) =>
162+
AnimatedContainer(
163+
curve: Curves.easeOut,
164+
duration: Duration(
165+
milliseconds: widget.controller.animationDuration),
166+
height: snapshot.hasData == null
167+
? widget.minContentHeight
168+
: snapshot.data,
169+
child: GestureDetector(
160170
onVerticalDragUpdate: (DragUpdateDetails details) {
161171
if (((widget.controller.height - details.delta.dy) >
162172
widget.minContentHeight) &&
@@ -167,19 +177,15 @@ class _GFBottomSheetState extends State<GFBottomSheet>
167177
isDragDirectionUp = details.delta.dy <= 0;
168178
widget.controller.height -= details.delta.dy;
169179
}
170-
controller.add(widget.controller.height);
180+
_streamController.add(widget.controller.height);
171181
},
172182
onVerticalDragEnd: _onVerticalDragEnd,
173183
onTap: _onTap,
174184
behavior: HitTestBehavior.translucent,
175-
child: Container(
176-
height: snapshot.hasData == null
177-
? widget.minContentHeight
178-
: snapshot.data,
179-
child: widget.contentBody,
180-
)),
181-
)
182-
: Container(),
185+
child: widget.contentBody,
186+
),
187+
),
188+
),
183189
widget.stickyFooter == null
184190
? Container()
185191
: AnimatedBuilder(

lib/components/button/gf_icon_button.dart

Lines changed: 57 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class _GFIconButtonState extends State<GFIconButton> {
111111
BoxShadow boxShadow;
112112
double height;
113113
double width;
114-
double iconPixel;
114+
double iconPixel = 18;
115115

116116
@override
117117
void initState() {
@@ -230,31 +230,34 @@ class _GFIconButtonState extends State<GFIconButton> {
230230
} else if (widget.size == GFSize.MEDIUM) {
231231
height = 35.0;
232232
width = 35.0;
233-
iconPixel = 18.0;
233+
iconPixel = 28.0;
234234
} else if (widget.size == GFSize.LARGE) {
235235
height = 40.0;
236236
width = 40.0;
237-
iconPixel = 18.0;
238-
} else {
239-
height = 35.0;
240-
width = 35.0;
241-
iconPixel = 18.0;
237+
iconPixel = 38.0;
242238
}
243239

244240
Widget result = Container(
245-
height: widget.shape == GFIconButtonShape.circle ? height + 6.0 : height,
246-
width: widget.shape == GFIconButtonShape.pills
247-
? width + 10
248-
: widget.shape == GFIconButtonShape.circle
249-
? height + 6
250-
: width,
241+
// height: widget.shape == GFIconButtonShape.circle ? height + 6.0 : height,
242+
// width: widget.shape == GFIconButtonShape.pills
243+
// ? width + 10
244+
// : widget.shape == GFIconButtonShape.circle
245+
// ? height + 6
246+
// : width,
251247
padding: widget.padding,
252-
child: IconTheme.merge(
253-
data: IconThemeData(
254-
size: widget.iconSize > 0.0 ? widget.iconSize : iconPixel,
255-
color: getIconColor(),
248+
child: SizedBox(
249+
height: widget.iconSize != 0 ? widget.iconSize : iconPixel,
250+
width: widget.iconSize != 0 ? widget.iconSize : iconPixel,
251+
child: Align(
252+
alignment: Alignment.center,
253+
child: IconTheme.merge(
254+
data: IconThemeData(
255+
size: widget.iconSize > 0.0 ? widget.iconSize : iconPixel,
256+
color: getIconColor(),
257+
),
258+
child: widget.icon,
259+
),
256260
),
257-
child: widget.icon,
258261
),
259262
);
260263

@@ -308,46 +311,42 @@ class _GFIconButtonState extends State<GFIconButton> {
308311
child: Focus(
309312
focusNode: widget.focusNode,
310313
autofocus: widget.autofocus,
311-
child: ConstrainedBox(
312-
constraints: const BoxConstraints(maxWidth: 60, maxHeight: 60),
313-
child: Container(
314-
height:
315-
widget.shape == GFIconButtonShape.circle ? height + 6 : height,
316-
width: widget.shape == GFIconButtonShape.pills
317-
? width + 10
318-
: widget.shape == GFIconButtonShape.circle
319-
? height + 6
320-
: width,
321-
decoration:
322-
widget.type == GFButtonType.solid ? getBoxShadow() : null,
323-
child: Material(
324-
shape: widget.type == GFButtonType.transparent
325-
? null
326-
: widget.borderShape ?? shapeBorderType,
327-
color: widget.onPressed != null
328-
? getColor()
329-
: getDisabledFillColor(),
330-
type: widget.type == GFButtonType.transparent
331-
? MaterialType.transparency
332-
: MaterialType.button,
333-
child: InkResponse(
334-
onTap: widget.onPressed,
335-
child: result,
336-
focusColor: widget.focusColor ?? Theme.of(context).focusColor,
337-
hoverColor: widget.hoverColor ?? Theme.of(context).hoverColor,
338-
highlightColor:
339-
widget.highlightColor ?? Theme.of(context).highlightColor,
340-
splashColor:
341-
widget.splashColor ?? Theme.of(context).splashColor,
342-
radius: math.max(
343-
Material.defaultSplashRadius,
344-
(widget.iconSize +
345-
math.min(
346-
widget.padding.horizontal,
347-
widget.padding.vertical,
348-
)) *
349-
0.7),
350-
),
314+
child: Container(
315+
// height:
316+
// widget.shape == GFIconButtonShape.circle ? height + 6 : height,
317+
// width: widget.shape == GFIconButtonShape.pills
318+
// ? width + 10
319+
// : widget.shape == GFIconButtonShape.circle
320+
// ? height + 6
321+
// : width,
322+
decoration: widget.type == GFButtonType.solid ? getBoxShadow() : null,
323+
child: Material(
324+
shape: widget.type == GFButtonType.transparent
325+
? null
326+
: widget.borderShape ?? shapeBorderType,
327+
color:
328+
widget.onPressed != null ? getColor() : getDisabledFillColor(),
329+
type: widget.type == GFButtonType.transparent
330+
? MaterialType.transparency
331+
: MaterialType.button,
332+
child: InkResponse(
333+
onTap: widget.onPressed,
334+
child: result,
335+
focusColor: widget.focusColor ?? Theme.of(context).focusColor,
336+
hoverColor: widget.hoverColor ?? Theme.of(context).hoverColor,
337+
highlightColor:
338+
widget.highlightColor ?? Theme.of(context).highlightColor,
339+
splashColor: widget.splashColor ?? Theme.of(context).splashColor,
340+
radius: math.max(
341+
Material.defaultSplashRadius,
342+
(widget.iconSize > 0.0
343+
? widget.iconSize
344+
: iconPixel +
345+
math.min(
346+
widget.padding.horizontal,
347+
widget.padding.vertical,
348+
)) *
349+
0.7),
351350
),
352351
),
353352
),

lib/components/checkbox_list_tile/gf_checkbox_list_tile.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class GFCheckboxListTile extends StatelessWidget {
1616
this.icon,
1717
this.description,
1818
this.padding = const EdgeInsets.all(8),
19-
this.margin = const EdgeInsets.all(16),
19+
this.margin = const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
2020
this.size = GFSize.MEDIUM,
2121
this.type = GFCheckboxType.basic,
2222
this.checkColor = GFColors.WHITE,

lib/components/dropdown/gf_dropdown.dart

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:getwidget/getwidget.dart';
23

34
class GFDropdown<T> extends StatefulWidget {
45
///
@@ -18,7 +19,7 @@ class GFDropdown<T> extends StatefulWidget {
1819
this.iconDisabledColor,
1920
this.iconEnabledColor,
2021
this.iconSize = 24.0,
21-
this.isDense = false,
22+
this.isDense = true,
2223
this.isExpanded = false,
2324
this.itemHeight = kMinInteractiveDimension,
2425
this.focusColor,
@@ -27,7 +28,9 @@ class GFDropdown<T> extends StatefulWidget {
2728
this.dropdownColor,
2829
this.padding = const EdgeInsets.all(5),
2930
this.borderRadius = const BorderRadius.all(Radius.circular(4)),
30-
this.borderColor})
31+
this.border = const BorderSide(
32+
color: Colors.white, width: 1, style: BorderStyle.solid),
33+
this.dropdownButtonColor = GFColors.WHITE})
3134
: super(key: key);
3235

3336
final DropdownButtonBuilder selectedItemBuilder;
@@ -44,7 +47,7 @@ class GFDropdown<T> extends StatefulWidget {
4447
final T value;
4548

4649
/// the color of the border of the dropdown button
47-
final Color borderColor;
50+
final BorderSide border;
4851

4952
///The padding given inside the dropdown
5053
final EdgeInsets padding;
@@ -108,18 +111,23 @@ class GFDropdown<T> extends StatefulWidget {
108111
/// The border radius of the dropdown.
109112
final BorderRadius borderRadius;
110113

114+
/// The background color of the dropdownButton.
115+
final dynamic dropdownButtonColor;
116+
111117
@override
112118
_GFDropdownState createState() => _GFDropdownState();
113119
}
114120

115121
class _GFDropdownState extends State<GFDropdown> {
116122
@override
117-
Widget build(BuildContext context) => Card(
118-
child: Container(
123+
Widget build(BuildContext context) => Material(
124+
color: widget.dropdownButtonColor,
125+
shape: RoundedRectangleBorder(
126+
side: widget.border,
127+
borderRadius: widget.borderRadius,
128+
),
129+
child: Padding(
119130
padding: widget.padding,
120-
decoration: BoxDecoration(
121-
borderRadius: widget.borderRadius,
122-
border: Border.all(color: widget.borderColor ?? Colors.white)),
123131
child: DropdownButton(
124132
items: widget.items,
125133
selectedItemBuilder: widget.selectedItemBuilder,

0 commit comments

Comments
 (0)