Skip to content

Commit 5d0cd70

Browse files
committed
import changes in all components
1 parent b85701e commit 5d0cd70

21 files changed

+204
-100
lines changed

example/lib/main.dart

Lines changed: 150 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import 'package:getflutter/components/tabs/gf_tabs.dart';
2323
import 'package:getflutter/components/tabs/gf_tabBarView.dart';
2424
import 'package:getflutter/types/gf_button_type.dart';
2525
import 'package:getflutter/position/gf_position.dart';
26+
import 'package:getflutter/components/tabs/gf_tabBar.dart';
27+
import 'dart:io';
2628

2729
final 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

6163
class _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>[

lib/components/appbar/gf_appbar.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//import 'dart:math' as math;
21
import 'package:flutter/foundation.dart';
32
import 'package:flutter/rendering.dart';
43
import 'package:flutter/services.dart';
@@ -27,7 +26,7 @@ class GFAppBar extends StatefulWidget implements PreferredSizeWidget {
2726
this.leading,
2827
this.automaticallyImplyLeading = true,
2928
this.title,
30-
this.trailing,
29+
this.actions,
3130
this.flexibleSpace,
3231
this.bottom,
3332
this.elevation,
@@ -73,7 +72,7 @@ class GFAppBar extends StatefulWidget implements PreferredSizeWidget {
7372
/// Typically these widgets are [IconButton]s representing common operations.
7473
/// For less common operations, consider using a [PopupMenuButton] as the
7574
/// last action.
76-
final List<Widget> trailing;
75+
final List<Widget> actions;
7776

7877
/// This widget is stacked behind the toolbar and the tab bar. It's height will
7978
/// be the same as the app bar's overall height.
@@ -201,7 +200,7 @@ class GFAppBar extends StatefulWidget implements PreferredSizeWidget {
201200
case TargetPlatform.fuchsia:
202201
return false;
203202
case TargetPlatform.iOS:
204-
return trailing == null || trailing.length < 2;
203+
return actions == null || actions.length < 2;
205204
default:
206205
return false;
207206
}
@@ -311,11 +310,11 @@ class _GFAppBarState extends State<GFAppBar> {
311310
}
312311

313312
Widget actions;
314-
if (widget.trailing != null && widget.trailing.isNotEmpty) {
313+
if (widget.actions != null && widget.actions.isNotEmpty) {
315314
actions = Row(
316315
mainAxisSize: MainAxisSize.min,
317316
crossAxisAlignment: CrossAxisAlignment.stretch,
318-
children: widget.trailing,
317+
children: widget.actions,
319318
);
320319
} else if (hasEndDrawer) {
321320
actions = IconButton(
@@ -325,7 +324,7 @@ class _GFAppBarState extends State<GFAppBar> {
325324
);
326325
}
327326

328-
// Allow the trailing actions to have their own theme if necessary.
327+
// Allow the actions actions to have their own theme if necessary.
329328
if (actions != null) {
330329
actions = IconTheme.merge(
331330
data: actionsIconTheme,
@@ -396,6 +395,7 @@ class _GFAppBarState extends State<GFAppBar> {
396395
],
397396
);
398397
}
398+
399399
final Brightness brightness = widget.brightness ??
400400
appBarTheme.brightness ??
401401
theme.primaryColorBrightness;

lib/components/avatar/gf_avatar.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import 'package:flutter/widgets.dart';
22
import 'package:flutter/material.dart';
3-
import 'package:getflutter/shape/gf_avatar_shape.dart';
4-
import 'package:getflutter/size/gf_size.dart';
5-
import 'package:getflutter/colors/gf_color.dart';
6-
export 'package:getflutter/shape/gf_avatar_shape.dart';
7-
export 'package:getflutter/size/gf_size.dart';
3+
import 'package:getflutter/getflutter.dart';
84

95
class GFAvatar extends StatelessWidget {
106
/// Typically a [Text] widget. If the [CircleAvatar] is to have an image, use [backgroundImage] instead.

lib/components/badge/gf_badge.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import 'package:flutter/material.dart';
2-
import 'package:getflutter/shape/gf_badge_shape.dart';
3-
import 'package:getflutter/size/gf_size.dart';
4-
import 'package:getflutter/colors/gf_color.dart';
2+
import 'package:getflutter/getflutter.dart';
53

64
class GFBadge extends StatefulWidget {
75
/// The border side for the badge's [Material].

lib/components/badge/gf_button_badge.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@ import 'package:flutter/foundation.dart';
22
import 'package:flutter/rendering.dart';
33
import 'package:flutter/widgets.dart';
44
import 'package:flutter/material.dart';
5-
import 'package:getflutter/components/button/gf_button.dart';
6-
import 'package:getflutter/shape/gf_button_shape.dart';
7-
import 'package:getflutter/size/gf_size.dart';
8-
import 'package:getflutter/types/gf_button_type.dart';
9-
import 'package:getflutter/position/gf_position.dart';
10-
import 'package:getflutter/colors/gf_color.dart';
5+
import 'package:getflutter/getflutter.dart';
116

127
class GFButtonBadge extends GFButton {
138
/// Called when the button is tapped or otherwise activated.

lib/components/badge/gf_icon_badge.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'package:flutter/material.dart';
2-
import 'package:getflutter/components/button/gf_icon_button.dart';
2+
import 'package:getflutter/getflutter.dart';
33

44
class GFIconBadge extends StatefulWidget {
55
/// child of type [Widget] is used to show icon.

lib/components/button/gf_button.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ import 'package:flutter/gestures.dart';
44
import 'package:flutter/rendering.dart';
55
import 'package:flutter/widgets.dart';
66
import 'package:flutter/material.dart';
7-
import 'package:getflutter/shape/gf_button_shape.dart';
8-
import 'package:getflutter/size/gf_size.dart';
9-
import 'package:getflutter/types/gf_button_type.dart';
10-
import 'package:getflutter/position/gf_position.dart';
11-
import 'package:getflutter/colors/gf_color.dart';
7+
import 'package:getflutter/getflutter.dart';
128

139
class GFButton extends StatefulWidget {
1410
/// Called when the button is tapped or otherwise activated.

lib/components/button/gf_button_bar.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'package:flutter/material.dart';
2-
import 'package:getflutter/components/button/gf_button.dart';
3-
import 'package:getflutter/components/button/gf_icon_button.dart';
42
import 'package:flutter/rendering.dart';
3+
import 'package:getflutter/getflutter.dart';
54

65
class GFButtonBar extends StatelessWidget {
76
/// Create buttons bar for all types of buttons.

lib/components/button/gf_icon_button.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import 'dart:math' as math;
22
import 'package:flutter/foundation.dart';
33
import 'package:flutter/widgets.dart';
44
import 'package:flutter/material.dart';
5-
import 'package:getflutter/shape/gf_icon_button_shape.dart';
6-
import 'package:getflutter/size/gf_size.dart';
7-
import 'package:getflutter/types/gf_button_type.dart';
8-
import 'package:getflutter/colors/gf_color.dart';
5+
import 'package:getflutter/getflutter.dart';
96

107
class GFIconButton extends StatefulWidget {
118
/// The size of the icon inside the button.

lib/components/button/gf_social_button.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@ import 'package:flutter/foundation.dart';
22
import 'package:flutter/rendering.dart';
33
import 'package:flutter/widgets.dart';
44
import 'package:flutter/material.dart';
5-
import 'package:getflutter/components/button/gf_button.dart';
6-
import 'package:getflutter/shape/gf_button_shape.dart';
7-
import 'package:getflutter/size/gf_size.dart';
8-
import 'package:getflutter/types/gf_button_type.dart';
9-
import 'package:getflutter/position/gf_position.dart';
10-
import 'package:getflutter/colors/gf_color.dart';
5+
import 'package:getflutter/getflutter.dart';
116

127
class GFSocialButton extends GFButton {
138
/// Called when the button is tapped or otherwise activated.

0 commit comments

Comments
 (0)