Skip to content

Commit 0521133

Browse files
authored
Merge pull request #84 from deepikahr/rating
Rating
2 parents 330e258 + cc922d6 commit 0521133

3 files changed

Lines changed: 142 additions & 141 deletions

File tree

example/lib/main.dart

Lines changed: 113 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class _MyHomePageState extends State<MyHomePage>
4141

4242
TabController tabController;
4343
final _ratingController = TextEditingController();
44-
double _rating = 3.5;
44+
double _rating = 3;
4545
double _userRating = 4.5;
4646

4747
@override
@@ -138,7 +138,24 @@ class _MyHomePageState extends State<MyHomePage>
138138
backgroundColor: Colors.teal,
139139
// centerTitle: true,
140140
// leading: GFIconButton(icon: Icon(Icons.directions_bus), onPressed: (){}),
141-
title: const Text('UI Kit'),
141+
title:
142+
// const Text('UI Kit'),
143+
GFSegmentTabs(
144+
tabController: tabController,
145+
initialIndex: 0,
146+
length: 3,
147+
tabs: const <Widget>[
148+
Text(
149+
'Tab1',
150+
),
151+
Text(
152+
'Tab2',
153+
),
154+
Text(
155+
'Tab3',
156+
),
157+
],
158+
),
142159
// bottom: TabBar(
143160
// controller: tabController,
144161
// tabs: [
@@ -147,7 +164,7 @@ class _MyHomePageState extends State<MyHomePage>
147164
// Tab(icon: Icon(Icons.directions_bike)),
148165
// ],
149166
// ),
150-
searchBar: true,
167+
// searchBar: true,
151168
// searchHintText: "aaaaaaa",
152169
// searchHintStyle: TextStyle(fontSize: 18.0, color: Colors.redAccent),
153170
// searchStyle: TextStyle(fontSize: 10.0, color: Colors.green),
@@ -175,20 +192,12 @@ class _MyHomePageState extends State<MyHomePage>
175192
// Container(color: Colors.green),
176193
// Container(color: Colors.blue)
177194
// ]),
178-
179-
<<<<<<< HEAD
180-
SingleChildScrollView(
181-
child: Column(
182-
mainAxisAlignment: MainAxisAlignment.center,
183-
=======
184-
// SingleChildScrollView(
185-
// child:
186-
Column(
187-
mainAxisAlignment: MainAxisAlignment.start,
188-
>>>>>>> ccc97fde38d7e90bca8ef572ba85c4254a92c687
189-
crossAxisAlignment: CrossAxisAlignment.center,
190-
children: <Widget>[
191-
GFSearchBar(
195+
SingleChildScrollView(
196+
child: Column(
197+
mainAxisAlignment: MainAxisAlignment.center,
198+
crossAxisAlignment: CrossAxisAlignment.center,
199+
children: <Widget>[
200+
GFSearchBar(
192201
// searchBoxInputDecoration: InputDecoration(
193202
// enabledBorder: OutlineInputBorder(
194203
// borderSide: BorderSide(
@@ -197,103 +206,96 @@ class _MyHomePageState extends State<MyHomePage>
197206
// borderRadius: BorderRadius.circular(50)
198207
// ),
199208
// ),
200-
searchList: list,
209+
searchList: list,
201210
// hideSearchBoxWhenItemSelected: false,
202211
// overlaySearchListHeight: 100.0,
203-
searchQueryBuilder: (query, list) => list
204-
.where((item) =>
205-
item.toLowerCase().contains(query.toLowerCase()))
206-
.toList(),
207-
overlaySearchListItemBuilder: (item) => Container(
208-
padding: const EdgeInsets.all(8),
209-
child: Text(
210-
item,
211-
style: const TextStyle(fontSize: 18),
212+
searchQueryBuilder: (query, list) => list
213+
.where((item) =>
214+
item.toLowerCase().contains(query.toLowerCase()))
215+
.toList(),
216+
overlaySearchListItemBuilder: (item) => Container(
217+
padding: const EdgeInsets.all(8),
218+
child: Text(
219+
item,
220+
style: const TextStyle(fontSize: 18),
221+
),
212222
),
213-
),
214223
// noItemsFoundWidget: Container(
215224
// color: Colors.green,
216225
// child: Text("no items found..."),
217226
// ),
218-
onItemSelected: (item) {
219-
setState(() {
220-
print('ssssssss $item');
221-
});
222-
}),
227+
onItemSelected: (item) {
228+
setState(() {
229+
print('ssssssss $item');
230+
});
231+
}),
223232

224-
GFRating(
225-
rating: _rating,
226-
itemSize: 50,
227-
// filledIcon: Image.asset(
228-
// 'lib/assets/heart.png',
229-
// height: 50,
230-
// width: 50,
231-
// color: Colors.amber,
232-
// ),
233-
// halfFilledIcon: Image.asset(
234-
// 'lib/assets/heart_half.png',
235-
// height: 50,
236-
// width: 50,
237-
// color: Colors.amber,
238-
// ),
239-
// defaultIcon: Image.asset(
240-
// 'lib/assets/heart_border.png',
241-
// height: 50,
242-
// width: 50,
243-
// color: Colors.amber,
244-
// ),
233+
GFRating(
234+
value: _rating,
235+
// size: 50,
236+
filledIcon: Icon(
237+
Icons.done_outline,
238+
size: 40,
239+
color: Colors.teal,
240+
),
241+
halfFilledIcon: Icon(
242+
Icons.done_all,
243+
size: 40,
244+
color: Colors.teal.withOpacity(0.75),
245+
),
246+
defaultIcon: Icon(
247+
Icons.done,
248+
size: 40,
249+
color: Colors.teal.withOpacity(0.25),
250+
),
251+
spacing: 8,
252+
// color: Colors.teal,
253+
// borderColor: Colors.tealAccent,
245254
// allowHalfRating: false,
246-
spacing: 8,
247-
color: Colors.teal,
248-
borderColor: Colors.tealAccent,
249-
onRatingChanged: (value) {
250-
setState(() {
251-
_rating = value;
252-
print('user selected $_rating');
253-
});
254-
},
255-
),
256-
257-
SizedBox(
258-
height: 20,
259-
child: Text('selected rating ${_rating.toStringAsFixed(1)}'),
260-
),
261-
262-
GFRating(
263-
rating: _userRating,
264-
itemSize: 50,
265-
filledIcon: Image.asset(
266-
'lib/assets/heart.png',
267-
height: 50,
268-
width: 50,
269-
color: Colors.amber,
270-
),
271-
halfFilledIcon: Image.asset(
272-
'lib/assets/heart_half.png',
273-
height: 50,
274-
width: 50,
275-
color: Colors.amber,
276-
),
277-
defaultIcon: Image.asset(
278-
'lib/assets/heart_border.png',
279-
height: 50,
280-
width: 50,
281-
color: Colors.amber,
282-
),
283-
ratingController: _ratingController,
284-
textFormRating: true,
285-
spacing: 8,
286-
color: Colors.teal,
287-
borderColor: Colors.tealAccent,
288-
suffixIcon: MaterialButton(
289-
onPressed: () {
255+
onChanged: (value) {
290256
setState(() {
291-
_userRating = double.parse(_ratingController.text ?? '0.0');
257+
_rating = value;
258+
print('user selected $_rating');
292259
});
293260
},
294-
child: const Text('Rate'),
295261
),
296-
),
262+
263+
GFRating(
264+
value: _userRating,
265+
filledIcon: Image.asset(
266+
'lib/assets/heart.png',
267+
height: 50,
268+
width: 50,
269+
color: Colors.amber,
270+
),
271+
halfFilledIcon: Image.asset(
272+
'lib/assets/heart_half.png',
273+
height: 50,
274+
width: 50,
275+
color: Colors.amber,
276+
),
277+
defaultIcon: Image.asset(
278+
'lib/assets/heart_border.png',
279+
height: 50,
280+
width: 50,
281+
color: Colors.amber,
282+
),
283+
spacing: 8,
284+
color: Colors.teal,
285+
borderColor: Colors.tealAccent,
286+
controller: _ratingController,
287+
textForm: true,
288+
suffixIcon: GFButton(
289+
type: GFButtonType.transparent,
290+
onPressed: () {
291+
setState(() {
292+
_userRating =
293+
double.parse(_ratingController.text ?? '0.0');
294+
});
295+
},
296+
child: const Text('Rate'),
297+
),
298+
),
297299

298300
// GFCard(
299301
// content: Column(
@@ -660,12 +662,12 @@ class _MyHomePageState extends State<MyHomePage>
660662
// ],
661663
// )),
662664

663-
// Image.asset(
664-
// 'lib/assets/food.jpeg',
665-
// fit: BoxFit.cover,
666-
// color: Color(0xff0d69ff).withOpacity(1.0),
667-
// colorBlendMode: BlendMode.softLight,
668-
// ),
665+
// Image.asset(
666+
// 'lib/assets/food.jpeg',
667+
// fit: BoxFit.cover,
668+
// color: Color(0xff0d69ff).withOpacity(1.0),
669+
// colorBlendMode: BlendMode.softLight,
670+
// ),
669671

670672
// GFCard(
671673
// content: Container(
@@ -1131,7 +1133,7 @@ class _MyHomePageState extends State<MyHomePage>
11311133
//// border: Border.all(color: Colors.pink, width: 2.0),
11321134
// ),
11331135
// GFAvatar(
1134-
// radius: 20.0,
1136+
// radius: 20.0,
11351137
// maxRadius: 50,
11361138

11371139
// child: Text("de"),
@@ -1231,8 +1233,8 @@ class _MyHomePageState extends State<MyHomePage>
12311233
//// borderSide: BorderSide(color: Colors.pink, width: 1.0, style: BorderStyle.solid),
12321234
//// borderShape: RoundedRectangleBorder(side: BorderSide(color: Colors.pink, width: 2.0, style: BorderStyle.solid), borderRadius: BorderRadius.zero),
12331235
// ),
1234-
],
1235-
),
1236+
],
1237+
),
12361238
// ),
12371239
// bottomNavigationBar: GFTabBar(
12381240
// initialIndex: 0,
@@ -1280,6 +1282,6 @@ class _MyHomePageState extends State<MyHomePage>
12801282
// color: Colors.black,
12811283
// fontFamily: 'OpenSansBold',
12821284
// ),
1283-
// ),
1285+
),
12841286
);
12851287
}

0 commit comments

Comments
 (0)