Skip to content

Commit f4e68f5

Browse files
committed
add user header
1 parent 86f6525 commit f4e68f5

5 files changed

Lines changed: 174 additions & 13 deletions

File tree

‎README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ welcome -> login
2525

2626
生成序列化模板
2727
flutter packages pub run build_runner build
28+
29+
30+
### 配合AutomaticKeepAliveClientMixin可以keep住tab

‎lib/page/MyPage.dart‎

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,36 @@
22
import 'package:flutter/material.dart';
33
import 'package:flutter_redux/flutter_redux.dart';
44
import 'package:gsy_github_app_flutter/common/redux/GSYState.dart';
5+
import 'package:gsy_github_app_flutter/widget/UserHeader.dart';
6+
class MyPage extends StatefulWidget {
7+
@override
8+
_MyPageState createState() => _MyPageState();
9+
}
10+
11+
// ignore: mixin_inherits_from_not_object
12+
class _MyPageState extends State<MyPage> with AutomaticKeepAliveClientMixin {
13+
14+
@override
15+
bool get wantKeepAlive => true;
16+
17+
@override
18+
void initState() {
19+
super.initState();
20+
}
21+
22+
@override
23+
void didChangeDependencies() {
24+
super.didChangeDependencies();
25+
}
26+
27+
528

6-
class MyPage extends StatelessWidget {
729
@override
830
Widget build(BuildContext context) {
931
return new StoreConnector<GSYState, String>(
1032
converter: (store) => store.state.userInfo.name,
1133
builder: (context, count) {
12-
return new Text(
13-
count,
14-
style: Theme.of(context).textTheme.display1,
15-
);
34+
return new UserHeaderItem();
1635
},
1736
);
1837
}

‎lib/widget/EventItem.dart‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class EventItem extends StatelessWidget {
2727
mainAxisSize: MainAxisSize.min,
2828
children: <Widget>[
2929
new Row(
30+
crossAxisAlignment: CrossAxisAlignment.start,
3031
children: <Widget>[
3132
new ClipOval(
3233
child: new FadeInImage.assetNetwork(
@@ -38,7 +39,7 @@ class EventItem extends StatelessWidget {
3839
height: 30.0,
3940
),
4041
),
41-
new Padding(padding: EdgeInsets.all(10.0)),
42+
new Padding(padding: EdgeInsets.all(5.0)),
4243
new Expanded(child: new Text(eventViewModel.actionUser, style: GSYConstant.smallTextBold)),
4344
new Text(eventViewModel.actionTime, style: GSYConstant.subSmallText),
4445
],

‎lib/widget/GSYCardItem.dart‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,26 @@ import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart';
33

44
class GSYCardItem extends StatelessWidget {
55
final Widget child;
6+
final EdgeInsets margin;
7+
final Color color;
8+
final RoundedRectangleBorder shape;
69

7-
GSYCardItem({@required this.child});
10+
GSYCardItem({@required this.child, this.margin, this.color, this.shape});
811

912
@override
1013
Widget build(BuildContext context) {
11-
return new Card(
12-
elevation: 5.0,
13-
shape: new RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4.0))),
14-
color: Color(GSYColors.cardWhite),
15-
margin: new EdgeInsets.only(left: 10.0, top: 10.0, right: 10.0, bottom: 10.0),
16-
child: child);
14+
EdgeInsets margin = this.margin;
15+
RoundedRectangleBorder shape = this.shape;
16+
Color color = this.color;
17+
if (margin == null) {
18+
margin = EdgeInsets.only(left: 10.0, top: 10.0, right: 10.0, bottom: 10.0);
19+
}
20+
if (shape == null) {
21+
shape = new RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4.0)));
22+
}
23+
if (color == null) {
24+
color = new Color(GSYColors.cardWhite);
25+
}
26+
return new Card(elevation: 5.0, shape: shape, color: color, margin: margin, child: child);
1727
}
1828
}

‎lib/widget/UserHeader.dart‎

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart';
3+
import 'package:gsy_github_app_flutter/widget/GSYCardItem.dart';
4+
import 'package:gsy_github_app_flutter/widget/GSYIConText.dart';
5+
6+
/**
7+
* Created by guoshuyu
8+
* Date: 2018-07-17
9+
*/
10+
class UserHeaderItem extends StatelessWidget {
11+
@override
12+
Widget build(BuildContext context) {
13+
return new Column(
14+
mainAxisSize: MainAxisSize.min,
15+
children: <Widget>[
16+
new GSYCardItem(
17+
color: Color(GSYColors.primaryValue),
18+
margin: EdgeInsets.all(0.0),
19+
shape: new RoundedRectangleBorder(borderRadius: BorderRadius.only(bottomLeft: Radius.circular(4.0), bottomRight: Radius.circular(4.0))),
20+
child: new Padding(
21+
padding: new EdgeInsets.only(left: 10.0, top: 10.0, right: 10.0, bottom: 10.0),
22+
child: new Column(
23+
mainAxisSize: MainAxisSize.min,
24+
children: <Widget>[
25+
new Row(
26+
crossAxisAlignment: CrossAxisAlignment.start,
27+
children: <Widget>[
28+
new ClipOval(
29+
child: new FadeInImage.assetNetwork(
30+
placeholder: "static/images/logo.png",
31+
//预览图
32+
fit: BoxFit.fitWidth,
33+
image: "fffffff",
34+
width: 80.0,
35+
height: 80.0,
36+
),
37+
),
38+
new Padding(padding: EdgeInsets.all(10.0)),
39+
new Expanded(
40+
child: new Column(
41+
crossAxisAlignment: CrossAxisAlignment.start,
42+
children: <Widget>[
43+
new Text("Login", style: GSYConstant.normalTextBold),
44+
new GSYIConText(
45+
GSYICons.REPOS_ITEM_USER,
46+
"Name ",
47+
GSYConstant.subLightSmallText,
48+
Color(GSYColors.subLightTextColor),
49+
10.0,
50+
padding: 3.0,
51+
),
52+
new GSYIConText(
53+
GSYICons.REPOS_ITEM_USER,
54+
"company ",
55+
GSYConstant.subLightSmallText,
56+
Color(GSYColors.subLightTextColor),
57+
10.0,
58+
padding: 3.0,
59+
),
60+
new GSYIConText(
61+
GSYICons.REPOS_ITEM_USER,
62+
"location ",
63+
GSYConstant.subLightSmallText,
64+
Color(GSYColors.subLightTextColor),
65+
10.0,
66+
padding: 3.0,
67+
),
68+
],
69+
),
70+
),
71+
],
72+
),
73+
new Container(
74+
child: new Text(
75+
"link",
76+
style: GSYConstant.subSmallText,
77+
maxLines: 3,
78+
overflow: TextOverflow.ellipsis,
79+
),
80+
margin: new EdgeInsets.only(top: 6.0, bottom: 2.0),
81+
alignment: Alignment.topLeft),
82+
new Container(
83+
child: new Text(
84+
"desssssssssssss",
85+
style: GSYConstant.subSmallText,
86+
maxLines: 3,
87+
overflow: TextOverflow.ellipsis,
88+
),
89+
margin: new EdgeInsets.only(top: 6.0, bottom: 2.0),
90+
alignment: Alignment.topLeft),
91+
new Padding(padding: EdgeInsets.all(10.0)),
92+
new Row(
93+
crossAxisAlignment: CrossAxisAlignment.start,
94+
children: <Widget>[
95+
new Expanded(
96+
child: new Center(
97+
child: new Text("fff\nff"),
98+
),
99+
),
100+
new Expanded(
101+
child: new Center(
102+
child: new Text("fff\nff"),
103+
),
104+
),
105+
new Expanded(
106+
child: new Center(
107+
child: new Text("fff\nff"),
108+
),
109+
),
110+
new Expanded(
111+
child: new Center(
112+
child: new Text("fff\nff"),
113+
),
114+
),
115+
new Expanded(
116+
child: new Center(
117+
child: new Text("fff\nff"),
118+
),
119+
),
120+
],
121+
),
122+
],
123+
),
124+
))
125+
],
126+
);
127+
}
128+
}

0 commit comments

Comments
 (0)