Skip to content

Commit e930774

Browse files
authored
Merge pull request #64 from deepikahr/appbar
Appbar
2 parents 94214b8 + 382b581 commit e930774

File tree

4 files changed

+244
-237
lines changed

4 files changed

+244
-237
lines changed

example/lib/main.dart

Lines changed: 25 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import 'package:getflutter/components/tabs/gf_tabs.dart';
2222
import 'package:getflutter/components/tabs/gf_tabBarView.dart';
2323
import 'package:getflutter/types/gf_button_type.dart';
2424
import 'package:getflutter/position/gf_position.dart';
25-
import 'dart:io';
2625

2726
final List<String> imageList = [
2827
"https://cdn.pixabay.com/photo/2017/12/03/18/04/christmas-balls-2995437_960_720.jpg",
@@ -69,7 +68,6 @@ class _MyHomePageState extends State<MyHomePage>
6968
void initState() {
7069
super.initState();
7170
tabController = TabController(length: 3, vsync: this);
72-
_searchQuery = new TextEditingController();
7371
}
7472

7573
@override
@@ -80,102 +78,9 @@ class _MyHomePageState extends State<MyHomePage>
8078

8179
bool switchValue = true;
8280
bool showToast = false;
83-
8481
Widget appBarTitle = new Text("UI Kit");
8582
Icon actionIcon = new Icon(Icons.search);
8683

87-
TextEditingController _searchQuery;
88-
bool _isSearching = false;
89-
String searchQuery = "Search query";
90-
91-
void _startSearch() {
92-
ModalRoute.of(context)
93-
.addLocalHistoryEntry(new LocalHistoryEntry(onRemove: _stopSearching));
94-
95-
setState(() {
96-
_isSearching = true;
97-
});
98-
}
99-
100-
void _stopSearching() {
101-
_clearSearchQuery();
102-
103-
setState(() {
104-
_isSearching = false;
105-
});
106-
}
107-
108-
void _clearSearchQuery() {
109-
setState(() {
110-
_searchQuery.clear();
111-
updateSearchQuery("Search query");
112-
});
113-
}
114-
115-
Widget _buildTitle(BuildContext context) {
116-
var horizontalTitleAlignment =
117-
Platform.isIOS ? CrossAxisAlignment.center : CrossAxisAlignment.start;
118-
119-
return new InkWell(
120-
onTap: () => scaffoldKey.currentState.openDrawer(),
121-
child: new Padding(
122-
padding: const EdgeInsets.symmetric(horizontal: 12.0),
123-
child: new Column(
124-
mainAxisAlignment: MainAxisAlignment.center,
125-
crossAxisAlignment: horizontalTitleAlignment,
126-
children: <Widget>[
127-
const Text('Seach box'),
128-
],
129-
),
130-
),
131-
);
132-
}
133-
134-
Widget _buildSearchField() {
135-
return new TextField(
136-
controller: _searchQuery,
137-
autofocus: true,
138-
decoration: const InputDecoration(
139-
hintText: 'Search...',
140-
border: InputBorder.none,
141-
hintStyle: const TextStyle(color: Colors.white30),
142-
),
143-
style: const TextStyle(color: Colors.white, fontSize: 16.0),
144-
onChanged: updateSearchQuery,
145-
);
146-
}
147-
148-
void updateSearchQuery(String newQuery) {
149-
setState(() {
150-
searchQuery = newQuery;
151-
});
152-
print("search query " + newQuery);
153-
}
154-
155-
List<Widget> _buildActions() {
156-
if (_isSearching) {
157-
return <Widget>[
158-
new IconButton(
159-
icon: const Icon(Icons.clear),
160-
onPressed: () {
161-
if (_searchQuery == null || _searchQuery.text.isEmpty) {
162-
Navigator.pop(context);
163-
return;
164-
}
165-
_clearSearchQuery();
166-
},
167-
),
168-
];
169-
}
170-
171-
return <Widget>[
172-
new IconButton(
173-
icon: const Icon(Icons.search),
174-
onPressed: _startSearch,
175-
),
176-
];
177-
}
178-
17984
@override
18085
Widget build(BuildContext context) {
18186
return Scaffold(
@@ -239,50 +144,32 @@ class _MyHomePageState extends State<MyHomePage>
239144
],
240145
),
241146
),
242-
appBar: AppBar(
243-
leading: _isSearching ? const BackButton() : null,
244-
title: _isSearching ? _buildSearchField() : _buildTitle(context),
245-
actions: _buildActions(),
246-
),
247-
// GFAppBar(
248-
//// backgroundColor: Colors.tealAccent,
147+
148+
appBar: GFAppBar(
149+
backgroundColor: Colors.teal,
249150
// centerTitle: true,
250-
//// leading: GFIconButton(icon: Icon(Icons.directions_bus), onPressed: (){}),
251-
// title: appBarTitle,
252-
//// bottom: TabBar(
253-
//// controller: tabController,
254-
//// tabs: [
255-
//// Tab(icon: Icon(Icons.directions_car)),
256-
//// Tab(icon: Icon(Icons.directions_transit)),
257-
//// Tab(icon: Icon(Icons.directions_bike)),
258-
//// ],
259-
//// ),
260-
// actions: <Widget>[
261-
// new IconButton(
262-
// icon: actionIcon,
263-
// onPressed: () {
264-
// setState(() {
265-
// if (this.actionIcon.icon == Icons.search) {
266-
// this.actionIcon = new Icon(Icons.close);
267-
// this.appBarTitle = new TextField(
268-
// style: new TextStyle(
269-
// color: Colors.white,
270-
// ),
271-
// decoration: new InputDecoration(
272-
// prefixIcon: new Icon(Icons.search, color: Colors.white),
273-
// hintText: "Search...",
274-
// hintStyle: new TextStyle(color: Colors.white)),
275-
// );
276-
// } else {
277-
// this.actionIcon = new Icon(Icons.search);
278-
// this.appBarTitle = new Text("UI Kit");
279-
// }
280-
// });
281-
// },
282-
// ),
283-
// ],
284-
// ),
285-
// backgroundColor: Colors.teal,
151+
// leading: GFIconButton(icon: Icon(Icons.directions_bus), onPressed: (){}),
152+
title: Text("UI Kit"),
153+
// bottom: TabBar(
154+
// controller: tabController,
155+
// tabs: [
156+
// Tab(icon: Icon(Icons.directions_car)),
157+
// Tab(icon: Icon(Icons.directions_transit)),
158+
// Tab(icon: Icon(Icons.directions_bike)),
159+
// ],
160+
// ),
161+
// searchBar: true,
162+
// searchHintText: "aaaaaaa",
163+
// searchHintStyle: TextStyle(fontSize: 18.0, color: Colors.redAccent),
164+
// searchStyle: TextStyle(fontSize: 10.0, color: Colors.green),
165+
// searchBarColorTheme: Colors.greenAccent,
166+
167+
actions: <Widget>[
168+
GFIconButton(icon: Icon(Icons.access_time), onPressed: () {}),
169+
GFIconButton(icon: Icon(Icons.favorite), onPressed: null),
170+
],
171+
),
172+
backgroundColor: Colors.blueGrey,
286173
body:
287174
// GFTabBarView(
288175
// height: 200.0,

0 commit comments

Comments
 (0)