Repository navigation
Expand file tree
/
Copy pathUserProfilePage.dart
More file actions
118 lines (109 loc) · 4.55 KB
/
Copy pathUserProfilePage.dart
File metadata and controls
118 lines (109 loc) · 4.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import 'package:flutter/material.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:gsy_github_app_flutter/common/dao/UserDao.dart';
import 'package:gsy_github_app_flutter/common/model/User.dart';
import 'package:gsy_github_app_flutter/common/redux/GSYState.dart';
import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart';
import 'package:gsy_github_app_flutter/common/utils/CommonUtils.dart';
import 'package:gsy_github_app_flutter/widget/GSYCardItem.dart';
import 'package:redux/redux.dart';
/**
* 用户信息中心
* Created by guoshuyu
* Date: 2018-08-08
*/
class UserProfileInfo extends StatefulWidget {
UserProfileInfo();
@override
_UserProfileState createState() => _UserProfileState();
}
class _UserProfileState extends State<UserProfileInfo> {
_renderItem(IconData leftIcon, String title, String value, VoidCallback onPressed) {
return new GSYCardItem(
child: new RawMaterialButton(
onPressed: onPressed,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
padding: const EdgeInsets.all(15.0),
constraints: const BoxConstraints(minWidth: 0.0, minHeight: 0.0),
child: new Row(
children: <Widget>[
new Icon(leftIcon),
new Container(
width: 10.0,
),
new Text(title, style: GSYConstant.normalSubText),
new Container(
width: 10.0,
),
new Expanded(child: new Text(value, style: GSYConstant.normalText)),
new Container(
width: 10.0,
),
new Icon(GSYICons.REPOS_ITEM_NEXT, size: 12.0),
],
),
),
);
}
static const String user_profile_name = "名字";
static const String user_profile_email = "邮箱";
static const String user_profile_link = "链接";
static const String user_profile_org = "公司";
static const String user_profile_location = "位置";
static const String user_profile_info = "简介";
_showEditDialog(String title, String value, String key, Store store) {
String content = value ?? "";
CommonUtils.showEditDialog(context, title, (title) {}, (res) {
content = res;
}, () {
if (content == null || content.length == 0) {
return;
}
CommonUtils.showLoadingDialog(context);
UserDao.updateUserDao({key: content}, store).then((res) {
Navigator.of(context).pop();
if(res != null && res.result) {
Navigator.of(context).pop();
}
});
}, titleController: new TextEditingController(), valueController: new TextEditingController(text: value), needTitle: false);
}
List<Widget> _renderList(User userInfo, Store store) {
return [
_renderItem(Icons.info, CommonUtils.getLocale(context).user_profile_name, userInfo.name ?? "---", () {
_showEditDialog(CommonUtils.getLocale(context).user_profile_name, userInfo.name, "name", store);
}),
_renderItem(Icons.email, CommonUtils.getLocale(context).user_profile_email, userInfo.email ?? "---", () {
_showEditDialog(CommonUtils.getLocale(context).user_profile_email, userInfo.email, "email", store);
}),
_renderItem(Icons.link, CommonUtils.getLocale(context).user_profile_link, userInfo.blog ?? "---", () {
_showEditDialog(CommonUtils.getLocale(context).user_profile_link, userInfo.blog, "blog", store);
}),
_renderItem(Icons.group, CommonUtils.getLocale(context).user_profile_org, userInfo.company ?? "---", () {
_showEditDialog(CommonUtils.getLocale(context).user_profile_org, userInfo.company, "company", store);
}),
_renderItem(Icons.location_on, CommonUtils.getLocale(context).user_profile_location, userInfo.location ?? "---", () {
_showEditDialog(CommonUtils.getLocale(context).user_profile_location, userInfo.location, "location", store);
}),
_renderItem(Icons.message, CommonUtils.getLocale(context).user_profile_info, userInfo.bio ?? "---", () {
_showEditDialog(CommonUtils.getLocale(context).user_profile_info, userInfo.bio, "bio", store);
}),
];
}
@override
Widget build(BuildContext context) {
return new StoreBuilder<GSYState>(builder: (context, store) {
return Scaffold(
appBar: new AppBar(title: new Text(CommonUtils.getLocale(context).home_user_info)),
body: new Container(
color: Color(GSYColors.white),
child: new SingleChildScrollView(
child: new Column(
children: _renderList(store.state.userInfo, store),
),
),
),
);
});
}
}