Skip to content

Commit e210d25

Browse files
committed
GFBottomSheet completed
1 parent a7a3023 commit e210d25

File tree

4 files changed

+57
-109
lines changed

4 files changed

+57
-109
lines changed

example/lib/main_temp.dart

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateM
4545
String searchData;
4646
final TextEditingController _searchController = TextEditingController();
4747
int groupValue = 0;
48-
GFBottomSheetController _controller = GFBottomSheetController();
48+
final GFBottomSheetController _controller = GFBottomSheetController();
4949

5050
@override
5151
void initState() {
@@ -149,19 +149,19 @@ class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateM
149149
),
150150
bottomSheet: GFBottomSheet(
151151
controller: _controller,
152-
maxHeight: 200,
152+
// minContentHeight: 100,
153+
maxContentHeight: 200,
153154
elevation: 10,
154-
smoothness: GFSmoothness.HIGH,
155-
stickyHeader: Container(
156-
decoration: BoxDecoration(
157-
borderRadius: BorderRadius.circular(10),
158-
color: Colors.tealAccent
159-
),
160-
height: 50,
161-
child: const Center(
162-
child: Text('Swipe me!'),
163-
),
164-
),
155+
// stickyHeader: Container(
156+
// decoration: BoxDecoration(
157+
// borderRadius: BorderRadius.circular(10),
158+
// color: Colors.tealAccent
159+
// ),
160+
// height: 50,
161+
// child: const Center(
162+
// child: Text('Swipe me!'),
163+
// ),
164+
// ),
165165
contentBody: Container(
166166
decoration: BoxDecoration(
167167
borderRadius: BorderRadius.circular(10),
@@ -173,13 +173,13 @@ class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateM
173173
],
174174
),
175175
),
176-
stickyFooter: Container(
177-
color: Theme.of(context).primaryColor,
178-
height: 100,
179-
child: const Center(
180-
child: Text('I am Footer!'),
181-
),
182-
),
176+
// stickyFooter: Container(
177+
// color: Theme.of(context).primaryColor,
178+
// height: 100,
179+
// child: const Center(
180+
// child: Text('I am Footer!'),
181+
// ),
182+
// ),
183183
// stickyFooterHeight: 50,
184184
),
185185
floatingActionButton: FloatingActionButton(
Lines changed: 37 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,53 @@
1-
import 'dart:async';
2-
import 'dart:js';
31
import 'package:flutter/material.dart';
4-
import 'package:getwidget/smoothness/gf_smoothness.dart';
5-
62

73
class GFBottomSheet extends StatefulWidget {
8-
94
GFBottomSheet({
105
Key key,
116
@required this.stickyHeader,
127
@required this.contentBody,
138
this.stickyFooter,
149
this.controller,
15-
this.minHeight = 0,
16-
this.maxHeight = 300,
10+
this.minContentHeight = 0,
11+
this.maxContentHeight = 300,
1712
this.elevation = 0.0,
18-
this.smoothness = GFSmoothness.MEDIUM,
1913
this.stickyFooterHeight,
2014
}) : assert(elevation >= 0.0),
21-
assert(minHeight >= 0.0),
15+
assert(minContentHeight >= 0.0),
2216
super(key: key) {
23-
controller.height = minHeight;
24-
controller.smoothness = smoothness;
17+
controller.height = minContentHeight;
18+
controller.smoothness = 500;
2519
controller == null ? controller = GFBottomSheetController() : Container();
2620
}
2721

28-
// This controls the minimum height of the body. Must be greater or equal of
29-
// 0. By default is 0
30-
final double minHeight;
22+
/// [minContentHeight] controls the minimum height of the content body.
23+
/// It Must be greater or equal to 0. Default value is 0.
24+
final double minContentHeight;
3125

32-
// This controls the minimum height of the body. By default is 500
33-
final double maxHeight;
26+
/// [maxContentHeight] controls the maximum height of the content body.
27+
/// It Must be greater or equal to 0. Default value is 300.
28+
final double maxContentHeight;
3429

35-
// This is the header of your bottomSheet. This widget is the swipeable area
36-
// where user will interact. This parameter is required
30+
/// [stickyHeader] is the header of GFBottomSheet.
31+
/// User can interact by swiping or tapping the [stickyHeader]
3732
final Widget stickyHeader;
3833

39-
// This is the content that will be hided of your bottomSheet. You can fit any
40-
// widget. This parameter is required
34+
/// [contentBody] is the body of GFBottomSheet.
35+
/// User can interact by tapping the [contentBody]
4136
final Widget contentBody;
4237

38+
/// [stickyFooter] is the footer of GFBottomSheet.
39+
/// User can interact by swiping or tapping the [stickyFooter]
4340
final Widget stickyFooter;
4441

45-
// This property is the elevation of the bottomSheet. Must be greater or equal
46-
// to 0. By default is 0.
47-
final double elevation;
48-
49-
// This object used to control behavior internally
50-
// from the app and don't depend of user's interaction.
51-
// can hide and show methods plus have isOpened variable
52-
// to check widget visibility on a screen
53-
GFBottomSheetController controller;
54-
55-
/// default medium
56-
final int smoothness;
57-
58-
// default false
42+
/// [stickyFooterHeight] defines the height of GFBottokSheet footer.
5943
final double stickyFooterHeight;
6044

45+
/// [elevation] controls shadow below the GFBottomSheet material.
46+
/// Must be greater or equalto 0. Default value is 0.
47+
final double elevation;
6148

49+
/// [controller] used to control GFBottomSheet behavior like hide/show
50+
GFBottomSheetController controller;
6251

6352
@override
6453
_GFBottomSheetState createState() => _GFBottomSheetState();
@@ -67,11 +56,12 @@ class GFBottomSheet extends StatefulWidget {
6756
class _GFBottomSheetState extends State<GFBottomSheet> with TickerProviderStateMixin {
6857
bool isDragDirectionUp;
6958
bool showBottomSheet = false;
59+
Function _controllerListener;
7060

7161
void _onVerticalDragUpdate(data) {
7262
_setNativeSmoothness();
73-
if (((widget.controller.height - data.delta.dy) > widget.minHeight) &&
74-
((widget.controller.height - data.delta.dy) < widget.maxHeight)) {
63+
if (((widget.controller.height - data.delta.dy) > widget.minContentHeight) &&
64+
((widget.controller.height - data.delta.dy) < widget.maxContentHeight)) {
7565
isDragDirectionUp = data.delta.dy <= 0;
7666
widget.controller.height -= data.delta.dy;
7767
}
@@ -90,12 +80,10 @@ class _GFBottomSheetState extends State<GFBottomSheet> with TickerProviderState
9080
}
9181

9282
void _onTap() {
93-
final bool isBottomSheetOpened = widget.controller.height == widget.maxHeight;
83+
final bool isBottomSheetOpened = widget.controller.height == widget.maxContentHeight;
9484
widget.controller.value = !isBottomSheetOpened;
9585
}
9686

97-
Function _controllerListener;
98-
9987
@override
10088
void initState() {
10189
super.initState();
@@ -111,7 +99,7 @@ class _GFBottomSheetState extends State<GFBottomSheet> with TickerProviderState
11199
final Widget bottomSheet = Column(
112100
mainAxisSize: MainAxisSize.min,
113101
children: <Widget>[
114-
GestureDetector(
102+
widget.stickyHeader == null ? Container() : GestureDetector(
115103
onVerticalDragUpdate: _onVerticalDragUpdate,
116104
onVerticalDragEnd: _onVerticalDragEnd,
117105
onTap: _onTap,
@@ -138,7 +126,7 @@ class _GFBottomSheetState extends State<GFBottomSheet> with TickerProviderState
138126
AnimatedContainer(
139127
curve: Curves.easeOut,
140128
duration: Duration(milliseconds: widget.controller.smoothness),
141-
height: widget.controller.height != widget.minHeight ? widget.stickyFooterHeight : 0.0,
129+
height: widget.controller.height != widget.minContentHeight ? widget.stickyFooterHeight : 0.0,
142130
child: GestureDetector(
143131
onVerticalDragUpdate: _onVerticalDragUpdate,
144132
onVerticalDragEnd: _onVerticalDragEnd,
@@ -156,11 +144,11 @@ class _GFBottomSheetState extends State<GFBottomSheet> with TickerProviderState
156144
}
157145

158146
void _hideBottomSheet() {
159-
widget.controller.height = widget.minHeight;
147+
widget.controller.height = widget.minContentHeight;
160148
}
161149

162150
void _showBottomSheet() {
163-
widget.controller.height = widget.maxHeight;
151+
widget.controller.height = widget.maxContentHeight;
164152
}
165153

166154
@override
@@ -170,40 +158,33 @@ class _GFBottomSheetState extends State<GFBottomSheet> with TickerProviderState
170158
}
171159

172160
void _setUsersSmoothness() {
173-
widget.controller.smoothness = widget.smoothness;
161+
widget.controller.smoothness = 500;
174162
}
175163

176164
void _setNativeSmoothness() {
177-
widget.controller.smoothness = widget.smoothness;
165+
widget.controller.smoothness = 500;
178166
}
179167
}
180168

181169
class GFBottomSheetController extends ValueNotifier<bool> {
182170

183171
GFBottomSheetController() : super(false);
184172

185-
// This is the current height of the GFBottomSheet's contentBody
173+
/// Defines the height of the GFBottomSheet's contentBody
186174
double _height;
187175

188-
// This is the current smoothness of the bottomSheet
176+
/// Defines the drag animation smoothness of the GFBottomSheet
189177
int smoothness;
190178

191-
// This method sets the value of the height
192-
set height(double value) {
193-
_height = value;
194-
}
179+
set height(double value) => _height = value;
195180

196-
// Returns the value of the height
197181
double get height => _height;
198182

199-
// Returns if the solid bottom sheet is opened or not
200183
bool get isBottomSheetOpened => value;
201184

202-
// Updates the visibility value to false
203185
void hideBottomSheet() => value = false;
204-
205-
// Updates the visibility value to true
206186
void showBottomSheet() => value = true;
207187

208188
}
209189

190+

lib/getwidget.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export 'shape/gf_badge_shape.dart';
4747
export 'shape/gf_button_shape.dart';
4848
export 'shape/gf_icon_button_shape.dart';
4949
export 'size/gf_size.dart';
50-
export 'smoothness/gf_smoothness.dart';
5150
export 'types/gf_alert_type.dart';
5251
export 'types/gf_button_type.dart';
5352
export 'types/gf_checkbox_type.dart';

lib/smoothness/gf_smoothness.dart

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)