@@ -23,6 +23,8 @@ import 'package:getflutter/components/tabs/gf_tabs.dart';
2323import 'package:getflutter/components/tabs/gf_tabBarView.dart' ;
2424import 'package:getflutter/types/gf_button_type.dart' ;
2525import 'package:getflutter/position/gf_position.dart' ;
26+ import 'package:getflutter/components/tabs/gf_tabBar.dart' ;
27+ import 'dart:io' ;
2628
2729final List <String > imageList = [
2830 "https://cdn.pixabay.com/photo/2017/12/03/18/04/christmas-balls-2995437_960_720.jpg" ,
@@ -60,12 +62,16 @@ class MyHomePage extends StatefulWidget {
6062
6163class _MyHomePageState extends State <MyHomePage >
6264 with SingleTickerProviderStateMixin {
65+ static final GlobalKey <ScaffoldState > scaffoldKey =
66+ new GlobalKey <ScaffoldState >();
67+
6368 TabController tabController;
6469
6570 @override
6671 void initState () {
6772 super .initState ();
6873 tabController = TabController (length: 3 , vsync: this );
74+ _searchQuery = new TextEditingController ();
6975 }
7076
7177 @override
@@ -77,6 +83,101 @@ class _MyHomePageState extends State<MyHomePage>
7783 bool switchValue = true ;
7884 bool showToast = false ;
7985
86+ Widget appBarTitle = new Text ("UI Kit" );
87+ Icon actionIcon = new Icon (Icons .search);
88+
89+ TextEditingController _searchQuery;
90+ bool _isSearching = false ;
91+ String searchQuery = "Search query" ;
92+
93+ void _startSearch () {
94+ ModalRoute .of (context)
95+ .addLocalHistoryEntry (new LocalHistoryEntry (onRemove: _stopSearching));
96+
97+ setState (() {
98+ _isSearching = true ;
99+ });
100+ }
101+
102+ void _stopSearching () {
103+ _clearSearchQuery ();
104+
105+ setState (() {
106+ _isSearching = false ;
107+ });
108+ }
109+
110+ void _clearSearchQuery () {
111+ setState (() {
112+ _searchQuery.clear ();
113+ updateSearchQuery ("Search query" );
114+ });
115+ }
116+
117+ Widget _buildTitle (BuildContext context) {
118+ var horizontalTitleAlignment =
119+ Platform .isIOS ? CrossAxisAlignment .center : CrossAxisAlignment .start;
120+
121+ return new InkWell (
122+ onTap: () => scaffoldKey.currentState.openDrawer (),
123+ child: new Padding (
124+ padding: const EdgeInsets .symmetric (horizontal: 12.0 ),
125+ child: new Column (
126+ mainAxisAlignment: MainAxisAlignment .center,
127+ crossAxisAlignment: horizontalTitleAlignment,
128+ children: < Widget > [
129+ const Text ('Seach box' ),
130+ ],
131+ ),
132+ ),
133+ );
134+ }
135+
136+ Widget _buildSearchField () {
137+ return new TextField (
138+ controller: _searchQuery,
139+ autofocus: true ,
140+ decoration: const InputDecoration (
141+ hintText: 'Search...' ,
142+ border: InputBorder .none,
143+ hintStyle: const TextStyle (color: Colors .white30),
144+ ),
145+ style: const TextStyle (color: Colors .white, fontSize: 16.0 ),
146+ onChanged: updateSearchQuery,
147+ );
148+ }
149+
150+ void updateSearchQuery (String newQuery) {
151+ setState (() {
152+ searchQuery = newQuery;
153+ });
154+ print ("search query " + newQuery);
155+ }
156+
157+ List <Widget > _buildActions () {
158+ if (_isSearching) {
159+ return < Widget > [
160+ new IconButton (
161+ icon: const Icon (Icons .clear),
162+ onPressed: () {
163+ if (_searchQuery == null || _searchQuery.text.isEmpty) {
164+ Navigator .pop (context);
165+ return ;
166+ }
167+ _clearSearchQuery ();
168+ },
169+ ),
170+ ];
171+ }
172+
173+ return < Widget > [
174+ new IconButton (
175+ icon: const Icon (Icons .search),
176+ onPressed: _startSearch,
177+ ),
178+ ];
179+ }
180+
80181 @override
81182 Widget build (BuildContext context) {
82183 return Scaffold (
@@ -140,48 +241,50 @@ class _MyHomePageState extends State<MyHomePage>
140241 ],
141242 ),
142243 ),
143- appBar: GFAppBar (
144- backgroundColor: Colors .tealAccent,
145- centerTitle: true ,
146- leading: GFIconButton (icon: Icon (Icons .directions_bus), onPressed: null ),
147- title: Text ("ui-kit" ),
148- // GFSegmentTabs(
149- // tabController: tabController,
150- // initialIndex: 0,
151- // length: 3,
152- // tabs: <Widget>[
153- // Text(
154- // "Tab1",
155- // ),
156- // Text(
157- // "Tab2",
158- // ),
159- // Text(
160- // "Tab3",
161- // ),
162- // ],
163- // ),
164- trailing: < Widget > [
165- IconButton (
166- icon: Icon (Icons .title),
167- onPressed: null ,
168- color: Colors .orange,
169- ),
170- GFIconButton (
171- icon: Icon (Icons .title),
172- onPressed: null ,
173- ),
174- GFIconButton (icon: Icon (Icons .directions_bus), onPressed: null ),
175- // GFIconButton(icon: Icon(Icons.directions_bus), onPressed: null),
176- // GFIconButton(icon: Icon(Icons.directions_bus), onPressed: null),
177- // GFIconButton(icon: Icon(Icons.directions_bus), onPressed: null),
178- // GFIconButton(icon: Icon(Icons.directions_bus), onPressed: null),
179- // GFIconButton(icon: Icon(Icons.directions_bus), onPressed: null),
180- // GFIconButton(icon: Icon(Icons.directions_bus), onPressed: null),
181- // GFIconButton(icon: Icon(Icons.directions_bus), onPressed: null),
182- ],
244+ appBar: AppBar (
245+ leading: _isSearching ? const BackButton () : null ,
246+ title: _isSearching ? _buildSearchField () : _buildTitle (context),
247+ actions: _buildActions (),
183248 ),
184- backgroundColor: Colors .teal,
249+ // GFAppBar(
250+ //// backgroundColor: Colors.tealAccent,
251+ // centerTitle: true,
252+ //// leading: GFIconButton(icon: Icon(Icons.directions_bus), onPressed: (){}),
253+ // title: appBarTitle,
254+ //// bottom: TabBar(
255+ //// controller: tabController,
256+ //// tabs: [
257+ //// Tab(icon: Icon(Icons.directions_car)),
258+ //// Tab(icon: Icon(Icons.directions_transit)),
259+ //// Tab(icon: Icon(Icons.directions_bike)),
260+ //// ],
261+ //// ),
262+ // actions: <Widget>[
263+ // new IconButton(
264+ // icon: actionIcon,
265+ // onPressed: () {
266+ // setState(() {
267+ // if (this.actionIcon.icon == Icons.search) {
268+ // this.actionIcon = new Icon(Icons.close);
269+ // this.appBarTitle = new TextField(
270+ // style: new TextStyle(
271+ // color: Colors.white,
272+ // ),
273+ // decoration: new InputDecoration(
274+ // prefixIcon: new Icon(Icons.search, color: Colors.white),
275+ // hintText: "Search...",
276+ // hintStyle: new TextStyle(color: Colors.white)),
277+ // );
278+ // } else {
279+ // this.actionIcon = new Icon(Icons.search);
280+ // this.appBarTitle = new Text("UI Kit");
281+ // }
282+ // });
283+ // },
284+ // ),
285+ // ],
286+ // ),
287+ // backgroundColor: Colors.teal,
185288 body:
186289// GFTabBarView(
187290// height: 200.0,
@@ -196,6 +299,12 @@ class _MyHomePageState extends State<MyHomePage>
196299 mainAxisAlignment: MainAxisAlignment .center,
197300 crossAxisAlignment: CrossAxisAlignment .center,
198301 children: < Widget > [
302+ GFIconButton (
303+ icon: Icon (Icons .title),
304+ onPressed: null ,
305+ // color: GFColor.secondary,
306+ ),
307+
199308 GFCard (
200309 content: Column (
201310 children: < Widget > [
0 commit comments