Skip to content

Commit 03bcb9d

Browse files
authored
Merge pull request #23 from ionicfirebaseapp/master
master pull
2 parents 8568cc7 + 98cf835 commit 03bcb9d

File tree

8 files changed

+663
-243
lines changed

8 files changed

+663
-243
lines changed

example/lib/main.dart

Lines changed: 95 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,16 @@ class _MyHomePageState extends State<MyHomePage>
5959
Widget appBarTitle = new Text("UI Kit");
6060
Icon actionIcon = new Icon(Icons.search);
6161

62-
List list = ["Flutter", "Flutterjjk", "Flutterhy", "jhFlutter"];
62+
List list = [
63+
"Flutter",
64+
"React",
65+
"Ionic",
66+
"Xamarin",
67+
"Flutter2",
68+
"React2",
69+
"Ionic2",
70+
"Xamarin2",
71+
];
6372

6473
@override
6574
Widget build(BuildContext context) {
@@ -138,15 +147,22 @@ class _MyHomePageState extends State<MyHomePage>
138147
// Tab(icon: Icon(Icons.directions_bike)),
139148
// ],
140149
// ),
141-
// searchBar: true,
150+
searchBar: true,
142151
// searchHintText: "aaaaaaa",
143152
// searchHintStyle: TextStyle(fontSize: 18.0, color: Colors.redAccent),
144153
// searchStyle: TextStyle(fontSize: 10.0, color: Colors.green),
145154
// searchBarColorTheme: Colors.greenAccent,
146155

147156
actions: <Widget>[
148-
GFIconButton(icon: Icon(Icons.access_time), onPressed: () {}),
149-
GFIconButton(icon: Icon(Icons.favorite), onPressed: null),
157+
// GFIconButton(icon: Icon(Icons.access_time), onPressed: () {}),
158+
GFIconButton(
159+
icon: Icon(
160+
Icons.favorite,
161+
color: Colors.white,
162+
),
163+
onPressed: () {},
164+
type: GFButtonType.transparent,
165+
),
150166
],
151167
),
152168
// backgroundColor: Colors.blueGrey,
@@ -164,66 +180,36 @@ class _MyHomePageState extends State<MyHomePage>
164180
mainAxisAlignment: MainAxisAlignment.center,
165181
crossAxisAlignment: CrossAxisAlignment.center,
166182
children: <Widget>[
167-
GFIconButton(
168-
icon: Icon(Icons.title),
169-
onPressed: null,
170-
// color: GFColor.secondary,
183+
GFSearchBar(
184+
searchList: list,
185+
hideSearchBoxWhenItemSelected: false,
186+
overlaySearchListHeight: 100.0,
187+
searchQueryBuilder: (query, list) {
188+
return list
189+
.where((item) =>
190+
item.toLowerCase().contains(query.toLowerCase()))
191+
.toList();
192+
},
193+
overlaySearchListItemBuilder: (item) {
194+
return Container(
195+
padding: const EdgeInsets.all(12),
196+
child: Text(
197+
item,
198+
style: const TextStyle(fontSize: 18),
199+
),
200+
);
201+
},
202+
noItemsFoundWidget: Container(
203+
color: Colors.green,
204+
child: Text("no items found"),
205+
),
206+
onItemSelected: (item) {
207+
setState(() {
208+
print('ssssssss $item');
209+
});
210+
},
171211
),
172212

173-
// GFSearchBar(
174-
// dataList: list,
175-
// hideSearchBoxWhenItemSelected: false,
176-
// listContainerHeight: MediaQuery.of(context).size.height / 4,
177-
// queryBuilder: (query, list) {
178-
// return list
179-
// .where((item) => item.username
180-
// .toLowerCase()
181-
// .contains(query.toLowerCase()))
182-
// .toList();
183-
// },
184-
// popupListItemBuilder: (item) {
185-
// return item;
186-
// },
187-
//// selectedItemBuilder: (selectedItem, deleteSelectedItem) {
188-
//// return SelectedItemWidget(selectedItem, deleteSelectedItem);
189-
//// },
190-
// // widget customization
191-
// noItemsFoundWidget: Container(child: Text("fgv"),),
192-
// textFieldBuilder: (controller, focusNode) {
193-
// return Padding(
194-
// padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
195-
// child: TextField(
196-
// controller: controller,
197-
// focusNode: focusNode,
198-
// style: TextStyle(fontSize: 16, color: Colors.grey[600]),
199-
// decoration: InputDecoration(
200-
// enabledBorder: const OutlineInputBorder(
201-
// borderSide: BorderSide(
202-
// color: Color(0x4437474F),
203-
// ),
204-
// ),
205-
// focusedBorder: OutlineInputBorder(
206-
// borderSide: BorderSide(color: Theme.of(context).primaryColor),
207-
// ),
208-
// suffixIcon: Icon(Icons.search),
209-
// border: InputBorder.none,
210-
// hintText: "Search here...",
211-
// contentPadding: const EdgeInsets.only(
212-
// left: 16,
213-
// right: 20,
214-
// top: 14,
215-
// bottom: 14,
216-
// ),
217-
// ),
218-
// ));
219-
// },
220-
// onItemSelected: (item) {
221-
// setState(() {
222-
//// _selectedItem = item;
223-
// });
224-
// },
225-
// ),
226-
227213
// GFCard(
228214
// content: Column(
229215
// children: <Widget>[
@@ -1162,49 +1148,53 @@ class _MyHomePageState extends State<MyHomePage>
11621148
],
11631149
),
11641150
),
1165-
// bottomNavigationBar: GFTabBar(
1166-
// initialIndex: 0,
1167-
// length: 3,
1168-
// controller: tabController,
1169-
// tabs: [
1170-
// Tab(
1171-
// icon: Icon(Icons.directions_bike),
1172-
// child: Text(
1173-
// "Tab1",
1174-
// ),
1175-
// ),
1176-
// Tab(
1177-
// icon: Icon(Icons.directions_bus),
1178-
// child: Text(
1179-
// "Tab2",
1180-
// ),
1181-
// ),
1182-
// Tab(
1183-
// icon: Icon(Icons.directions_railway),
1184-
// child: Text(
1185-
// "Tab3",
1186-
// ),
1187-
// ),
1188-
// ],
1189-
// indicatorColor: Colors.white,
1190-
//// indicatorSize: TabBarIndicatorSize.label,
1191-
// labelColor: Colors.lightGreen,
1192-
// labelPadding: EdgeInsets.all(8.0),
1193-
// tabBarColor: Colors.blueGrey,
1194-
// unselectedLabelColor: Colors.black,
1195-
// labelStyle: TextStyle(
1196-
// fontWeight: FontWeight.w500,
1197-
// fontSize: 13.0,
1198-
// color: Colors.deepOrange,
1199-
// fontFamily: 'OpenSansBold',
1200-
// ),
1201-
// unselectedLabelStyle: TextStyle(
1202-
// fontWeight: FontWeight.w500,
1203-
// fontSize: 13.0,
1204-
// color: Colors.black,
1205-
// fontFamily: 'OpenSansBold',
1206-
// ),
1207-
// ),
1151+
bottomNavigationBar: GFTabBar(
1152+
initialIndex: 0,
1153+
length: 3,
1154+
controller: tabController,
1155+
tabs: [
1156+
Tab(
1157+
icon: Icon(Icons.directions_bike),
1158+
child: Text(
1159+
"Tab1",
1160+
),
1161+
),
1162+
Tab(
1163+
icon: Icon(Icons.directions_bus),
1164+
child: Text(
1165+
"Tab2",
1166+
),
1167+
),
1168+
Tab(
1169+
icon: Icon(Icons.directions_railway),
1170+
child: Text(
1171+
"Tab3",
1172+
),
1173+
),
1174+
],
1175+
shape: RoundedRectangleBorder(
1176+
borderRadius: BorderRadius.only(
1177+
topLeft: Radius.circular(24.0),
1178+
topRight: Radius.circular(24.0))),
1179+
indicatorColor: Colors.white,
1180+
// indicatorSize: TabBarIndicatorSize.label,
1181+
labelColor: Colors.lightGreen,
1182+
labelPadding: EdgeInsets.all(8.0),
1183+
tabBarColor: Colors.blueGrey,
1184+
unselectedLabelColor: Colors.black,
1185+
labelStyle: TextStyle(
1186+
fontWeight: FontWeight.w500,
1187+
fontSize: 13.0,
1188+
color: Colors.deepOrange,
1189+
fontFamily: 'OpenSansBold',
1190+
),
1191+
unselectedLabelStyle: TextStyle(
1192+
fontWeight: FontWeight.w500,
1193+
fontSize: 13.0,
1194+
color: Colors.black,
1195+
fontFamily: 'OpenSansBold',
1196+
),
1197+
),
12081198
);
12091199
}
12101200
}
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:getflutter/colors/gf_color.dart';
3+
4+
class GFAccordion extends StatefulWidget {
5+
const GFAccordion(
6+
{Key key,
7+
this.child,
8+
this.content,
9+
this.titlebackgroundColor,
10+
this.collapsedIcon = const Icon(Icons.keyboard_arrow_down),
11+
this.expandedIcon =
12+
const Icon(Icons.keyboard_arrow_up, color: Colors.red),
13+
this.title,
14+
this.textStyle = const TextStyle(color: Colors.black, fontSize: 16),
15+
this.titlePadding,
16+
this.descriptionPadding,
17+
this.descriptionbackgroundColor,
18+
this.contentChild,
19+
this.margin})
20+
: super(key: key);
21+
22+
/// child of type [Widget]is alternative to title key. title will get priority over child
23+
final Widget child;
24+
25+
/// content of type[String] which shows the messages after the [GFAccordion] is expanded
26+
final String content;
27+
28+
/// contentChild of type [Widget]is alternative to content key. content will get priority over contentChild
29+
final Widget contentChild;
30+
31+
/// type of [Color] or [GFColor] which is used to change the background color of the [GFAccordion] title
32+
final dynamic titlebackgroundColor;
33+
34+
///collapsedIcon of type [Widget] which is used to show when the [GFAccordion] is collapsed
35+
final Widget collapsedIcon;
36+
37+
///expandedIcon of type[Widget] which is used when the [GFAccordion] is expanded
38+
final Widget expandedIcon;
39+
40+
/// text of type [String] is alternative to child. text will get priority over child
41+
final String title;
42+
43+
/// textStyle of type [textStyle] will be applicable to text only and not for the child
44+
final TextStyle textStyle;
45+
46+
///titlePadding of type [EdgeInsets] which is used to set the padding of the [GFAccordion] title
47+
final EdgeInsets titlePadding;
48+
49+
///descriptionPadding of type [EdgeInsets] which is used to set the padding of the [GFAccordion] description
50+
final EdgeInsets descriptionPadding;
51+
52+
/// type of [Color] or [GFColor] which is used to change the background color of the [GFAccordion] description
53+
final dynamic descriptionbackgroundColor;
54+
55+
///margin of type [EdgeInsets] which is used to set the margin of the [GFAccordion]
56+
final EdgeInsets margin;
57+
58+
@override
59+
_GFAccordionState createState() => _GFAccordionState();
60+
}
61+
62+
class _GFAccordionState extends State<GFAccordion>
63+
with TickerProviderStateMixin {
64+
AnimationController animationController;
65+
AnimationController controller;
66+
Animation<Offset> offset;
67+
68+
@override
69+
void initState() {
70+
super.initState();
71+
animationController =
72+
AnimationController(duration: Duration(seconds: 2), vsync: this);
73+
controller =
74+
AnimationController(vsync: this, duration: Duration(milliseconds: 300));
75+
offset = Tween(begin: Offset(0.0, -0.06), end: Offset.zero).animate(
76+
CurvedAnimation(
77+
parent: controller,
78+
curve: Curves.fastOutSlowIn,
79+
),
80+
);
81+
}
82+
83+
bool showAccordion = false;
84+
85+
@override
86+
Widget build(BuildContext context) {
87+
return Container(
88+
margin: widget.margin != null ? widget.margin : EdgeInsets.all(10),
89+
child: Column(
90+
crossAxisAlignment: CrossAxisAlignment.start,
91+
children: <Widget>[
92+
GestureDetector(
93+
onTap: () {
94+
setState(() {
95+
switch (controller.status) {
96+
case AnimationStatus.completed:
97+
controller.forward(from: 0);
98+
break;
99+
case AnimationStatus.dismissed:
100+
controller.forward();
101+
break;
102+
default:
103+
}
104+
showAccordion = !showAccordion;
105+
});
106+
},
107+
child: Container(
108+
color: widget.titlebackgroundColor != null
109+
? widget.titlebackgroundColor
110+
: Colors.white,
111+
padding: widget.titlePadding != null
112+
? widget.titlePadding
113+
: EdgeInsets.all(10),
114+
child: Row(
115+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
116+
children: <Widget>[
117+
Expanded(
118+
child: widget.title != null
119+
? Text(widget.title, style: widget.textStyle)
120+
: (widget.child ?? Container()),
121+
),
122+
showAccordion ? widget.expandedIcon : widget.collapsedIcon
123+
],
124+
),
125+
),
126+
),
127+
showAccordion
128+
? Container(
129+
width: MediaQuery.of(context).size.width,
130+
color: widget.descriptionbackgroundColor != null
131+
? widget.descriptionbackgroundColor
132+
: Colors.white70,
133+
padding: widget.descriptionPadding != null
134+
? widget.descriptionPadding
135+
: EdgeInsets.all(10),
136+
child: SlideTransition(
137+
position: offset,
138+
child: widget.content != null
139+
? Text(widget.content)
140+
: (widget.contentChild ?? Container()),
141+
))
142+
: Container()
143+
],
144+
),
145+
);
146+
}
147+
}

0 commit comments

Comments
 (0)