Skip to content
200 changes: 95 additions & 105 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,16 @@ class _MyHomePageState extends State<MyHomePage>
Widget appBarTitle = new Text("UI Kit");
Icon actionIcon = new Icon(Icons.search);

List list = ["Flutter", "Flutterjjk", "Flutterhy", "jhFlutter"];
List list = [
"Flutter",
"React",
"Ionic",
"Xamarin",
"Flutter2",
"React2",
"Ionic2",
"Xamarin2",
];

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -138,15 +147,22 @@ class _MyHomePageState extends State<MyHomePage>
// Tab(icon: Icon(Icons.directions_bike)),
// ],
// ),
// searchBar: true,
searchBar: true,
// searchHintText: "aaaaaaa",
// searchHintStyle: TextStyle(fontSize: 18.0, color: Colors.redAccent),
// searchStyle: TextStyle(fontSize: 10.0, color: Colors.green),
// searchBarColorTheme: Colors.greenAccent,

actions: <Widget>[
GFIconButton(icon: Icon(Icons.access_time), onPressed: () {}),
GFIconButton(icon: Icon(Icons.favorite), onPressed: null),
// GFIconButton(icon: Icon(Icons.access_time), onPressed: () {}),
GFIconButton(
icon: Icon(
Icons.favorite,
color: Colors.white,
),
onPressed: () {},
type: GFButtonType.transparent,
),
],
),
// backgroundColor: Colors.blueGrey,
Expand All @@ -164,66 +180,36 @@ class _MyHomePageState extends State<MyHomePage>
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
GFIconButton(
icon: Icon(Icons.title),
onPressed: null,
// color: GFColor.secondary,
GFSearchBar(
searchList: list,
hideSearchBoxWhenItemSelected: false,
overlaySearchListHeight: 100.0,
searchQueryBuilder: (query, list) {
return list
.where((item) =>
item.toLowerCase().contains(query.toLowerCase()))
.toList();
},
overlaySearchListItemBuilder: (item) {
return Container(
padding: const EdgeInsets.all(12),
child: Text(
item,
style: const TextStyle(fontSize: 18),
),
);
},
noItemsFoundWidget: Container(
color: Colors.green,
child: Text("no items found"),
),
onItemSelected: (item) {
setState(() {
print('ssssssss $item');
});
},
),

// GFSearchBar(
// dataList: list,
// hideSearchBoxWhenItemSelected: false,
// listContainerHeight: MediaQuery.of(context).size.height / 4,
// queryBuilder: (query, list) {
// return list
// .where((item) => item.username
// .toLowerCase()
// .contains(query.toLowerCase()))
// .toList();
// },
// popupListItemBuilder: (item) {
// return item;
// },
//// selectedItemBuilder: (selectedItem, deleteSelectedItem) {
//// return SelectedItemWidget(selectedItem, deleteSelectedItem);
//// },
// // widget customization
// noItemsFoundWidget: Container(child: Text("fgv"),),
// textFieldBuilder: (controller, focusNode) {
// return Padding(
// padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
// child: TextField(
// controller: controller,
// focusNode: focusNode,
// style: TextStyle(fontSize: 16, color: Colors.grey[600]),
// decoration: InputDecoration(
// enabledBorder: const OutlineInputBorder(
// borderSide: BorderSide(
// color: Color(0x4437474F),
// ),
// ),
// focusedBorder: OutlineInputBorder(
// borderSide: BorderSide(color: Theme.of(context).primaryColor),
// ),
// suffixIcon: Icon(Icons.search),
// border: InputBorder.none,
// hintText: "Search here...",
// contentPadding: const EdgeInsets.only(
// left: 16,
// right: 20,
// top: 14,
// bottom: 14,
// ),
// ),
// ));
// },
// onItemSelected: (item) {
// setState(() {
//// _selectedItem = item;
// });
// },
// ),

// GFCard(
// content: Column(
// children: <Widget>[
Expand Down Expand Up @@ -1162,49 +1148,53 @@ class _MyHomePageState extends State<MyHomePage>
],
),
),
// bottomNavigationBar: GFTabBar(
// initialIndex: 0,
// length: 3,
// controller: tabController,
// tabs: [
// Tab(
// icon: Icon(Icons.directions_bike),
// child: Text(
// "Tab1",
// ),
// ),
// Tab(
// icon: Icon(Icons.directions_bus),
// child: Text(
// "Tab2",
// ),
// ),
// Tab(
// icon: Icon(Icons.directions_railway),
// child: Text(
// "Tab3",
// ),
// ),
// ],
// indicatorColor: Colors.white,
//// indicatorSize: TabBarIndicatorSize.label,
// labelColor: Colors.lightGreen,
// labelPadding: EdgeInsets.all(8.0),
// tabBarColor: Colors.blueGrey,
// unselectedLabelColor: Colors.black,
// labelStyle: TextStyle(
// fontWeight: FontWeight.w500,
// fontSize: 13.0,
// color: Colors.deepOrange,
// fontFamily: 'OpenSansBold',
// ),
// unselectedLabelStyle: TextStyle(
// fontWeight: FontWeight.w500,
// fontSize: 13.0,
// color: Colors.black,
// fontFamily: 'OpenSansBold',
// ),
// ),
bottomNavigationBar: GFTabBar(
initialIndex: 0,
length: 3,
controller: tabController,
tabs: [
Tab(
icon: Icon(Icons.directions_bike),
child: Text(
"Tab1",
),
),
Tab(
icon: Icon(Icons.directions_bus),
child: Text(
"Tab2",
),
),
Tab(
icon: Icon(Icons.directions_railway),
child: Text(
"Tab3",
),
),
],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(24.0),
topRight: Radius.circular(24.0))),
indicatorColor: Colors.white,
// indicatorSize: TabBarIndicatorSize.label,
labelColor: Colors.lightGreen,
labelPadding: EdgeInsets.all(8.0),
tabBarColor: Colors.blueGrey,
unselectedLabelColor: Colors.black,
labelStyle: TextStyle(
fontWeight: FontWeight.w500,
fontSize: 13.0,
color: Colors.deepOrange,
fontFamily: 'OpenSansBold',
),
unselectedLabelStyle: TextStyle(
fontWeight: FontWeight.w500,
fontSize: 13.0,
color: Colors.black,
fontFamily: 'OpenSansBold',
),
),
);
}
}
147 changes: 147 additions & 0 deletions lib/components/accordian/gf_accordian.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import 'package:flutter/material.dart';
import 'package:getflutter/colors/gf_color.dart';

class GFAccordion extends StatefulWidget {
const GFAccordion(
{Key key,
this.child,
this.content,
this.titlebackgroundColor,
this.collapsedIcon = const Icon(Icons.keyboard_arrow_down),
this.expandedIcon =
const Icon(Icons.keyboard_arrow_up, color: Colors.red),
this.title,
this.textStyle = const TextStyle(color: Colors.black, fontSize: 16),
this.titlePadding,
this.descriptionPadding,
this.descriptionbackgroundColor,
this.contentChild,
this.margin})
: super(key: key);

/// child of type [Widget]is alternative to title key. title will get priority over child
final Widget child;

/// content of type[String] which shows the messages after the [GFAccordion] is expanded
final String content;

/// contentChild of type [Widget]is alternative to content key. content will get priority over contentChild
final Widget contentChild;

/// type of [Color] or [GFColor] which is used to change the background color of the [GFAccordion] title
final dynamic titlebackgroundColor;

///collapsedIcon of type [Widget] which is used to show when the [GFAccordion] is collapsed
final Widget collapsedIcon;

///expandedIcon of type[Widget] which is used when the [GFAccordion] is expanded
final Widget expandedIcon;

/// text of type [String] is alternative to child. text will get priority over child
final String title;

/// textStyle of type [textStyle] will be applicable to text only and not for the child
final TextStyle textStyle;

///titlePadding of type [EdgeInsets] which is used to set the padding of the [GFAccordion] title
final EdgeInsets titlePadding;

///descriptionPadding of type [EdgeInsets] which is used to set the padding of the [GFAccordion] description
final EdgeInsets descriptionPadding;

/// type of [Color] or [GFColor] which is used to change the background color of the [GFAccordion] description
final dynamic descriptionbackgroundColor;

///margin of type [EdgeInsets] which is used to set the margin of the [GFAccordion]
final EdgeInsets margin;

@override
_GFAccordionState createState() => _GFAccordionState();
}

class _GFAccordionState extends State<GFAccordion>
with TickerProviderStateMixin {
AnimationController animationController;
AnimationController controller;
Animation<Offset> offset;

@override
void initState() {
super.initState();
animationController =
AnimationController(duration: Duration(seconds: 2), vsync: this);
controller =
AnimationController(vsync: this, duration: Duration(milliseconds: 300));
offset = Tween(begin: Offset(0.0, -0.06), end: Offset.zero).animate(
CurvedAnimation(
parent: controller,
curve: Curves.fastOutSlowIn,
),
);
}

bool showAccordion = false;

@override
Widget build(BuildContext context) {
return Container(
margin: widget.margin != null ? widget.margin : EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
GestureDetector(
onTap: () {
setState(() {
switch (controller.status) {
case AnimationStatus.completed:
controller.forward(from: 0);
break;
case AnimationStatus.dismissed:
controller.forward();
break;
default:
}
showAccordion = !showAccordion;
});
},
child: Container(
color: widget.titlebackgroundColor != null
? widget.titlebackgroundColor
: Colors.white,
padding: widget.titlePadding != null
? widget.titlePadding
: EdgeInsets.all(10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
child: widget.title != null
? Text(widget.title, style: widget.textStyle)
: (widget.child ?? Container()),
),
showAccordion ? widget.expandedIcon : widget.collapsedIcon
],
),
),
),
showAccordion
? Container(
width: MediaQuery.of(context).size.width,
color: widget.descriptionbackgroundColor != null
? widget.descriptionbackgroundColor
: Colors.white70,
padding: widget.descriptionPadding != null
? widget.descriptionPadding
: EdgeInsets.all(10),
child: SlideTransition(
position: offset,
child: widget.content != null
? Text(widget.content)
: (widget.contentChild ?? Container()),
))
: Container()
],
),
);
}
}
Loading