Skip to content

Commit 7e5df7c

Browse files
committed
统一使用 fluro 跳转页面
1 parent 5ab7b88 commit 7e5df7c

File tree

7 files changed

+170
-153
lines changed

7 files changed

+170
-153
lines changed

lib/views/profile/general/general_page.dart

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@ import 'package:fluro/fluro.dart';
44
import 'package:flutter_wechat/constant/cache_key.dart';
55
import 'package:flutter_wechat/routers/fluro_navigator.dart';
66
import 'package:flutter_wechat/views/login/login_router.dart';
7+
import 'package:flutter_wechat/views/profile/profile_rourer.dart';
78

89
import 'package:flutter_wechat/model/common/common_item.dart';
910
import 'package:flutter_wechat/model/common/common_group.dart';
1011

1112
import 'package:flutter_wechat/widgets/common/common_group_widget.dart';
1213

13-
import 'package:flutter_wechat/views/profile/chat_background/chat_background_page.dart';
14-
import 'package:flutter_wechat/views/profile/discover_manager/discover_manager_page.dart';
15-
import 'package:flutter_wechat/views/profile/resource/resource_page.dart';
16-
import 'package:flutter_wechat/views/profile/chat_record_backup/chat_record_backup.dart';
17-
1814
class GeneralPage extends StatelessWidget {
1915
const GeneralPage({Key key}) : super(key: key);
2016

@@ -72,11 +68,7 @@ class GeneralPage extends StatelessWidget {
7268
final chatBg = CommonItem(
7369
title: "聊天背景",
7470
onTap: (_) {
75-
Navigator.of(context).push(new MaterialPageRoute(
76-
builder: (_) {
77-
return ChatBackgroundPage();
78-
},
79-
));
71+
NavigatorUtils.push(context, ProfileRouter.chatBackgroundPage);
8072
},
8173
);
8274

@@ -88,11 +80,7 @@ class GeneralPage extends StatelessWidget {
8880
final resource = CommonItem(
8981
title: "照片、视频和文件",
9082
onTap: (_) {
91-
Navigator.of(context).push(new MaterialPageRoute(
92-
builder: (_) {
93-
return ResourcePage();
94-
},
95-
));
83+
NavigatorUtils.push(context, ProfileRouter.resourcePage);
9684
},
9785
);
9886
final group1 = CommonGroup(
@@ -115,11 +103,7 @@ class GeneralPage extends StatelessWidget {
115103
final discoverManager = CommonItem(
116104
title: "发现页管理",
117105
onTap: (_) {
118-
Navigator.of(context).push(new MaterialPageRoute(
119-
builder: (_) {
120-
return DiscoverManagerPage();
121-
},
122-
));
106+
NavigatorUtils.push(context, ProfileRouter.discoverManagerPage);
123107
},
124108
);
125109

@@ -136,11 +120,7 @@ class GeneralPage extends StatelessWidget {
136120
final chatRecord = CommonItem(
137121
title: "聊天记录备份与迁移",
138122
onTap: (_) {
139-
Navigator.of(context).push(new MaterialPageRoute(
140-
builder: (_) {
141-
return ChatRecordBackupPage();
142-
},
143-
));
123+
NavigatorUtils.push(context, ProfileRouter.chatRecordBackupPage);
144124
},
145125
);
146126
// 存储空间

lib/views/profile/more_info/more_info_page.dart

Lines changed: 36 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
import 'package:flutter/gestures.dart';
21
import 'package:flutter/material.dart';
3-
import 'package:shared_preferences/shared_preferences.dart';
42

5-
import 'package:flutter_wechat/constant/cache_key.dart';
3+
import 'package:flutter_wechat/routers/fluro_navigator.dart';
4+
import 'package:flutter_wechat/views/profile/profile_rourer.dart';
65

76
import 'package:flutter_wechat/model/common/common_item.dart';
87
import 'package:flutter_wechat/model/common/common_group.dart';
9-
import 'package:flutter_wechat/model/common/common_footer.dart';
10-
import 'package:flutter_wechat/model/common/common_header.dart';
118

129
import 'package:flutter_wechat/widgets/common/common_group_widget.dart';
1310

14-
import 'package:flutter_wechat/views/profile/setting_gender/setting_gender_page.dart';
15-
import 'package:flutter_wechat/views/profile/signature/signature_page.dart';
16-
1711
/// 账号与安全
1812
class MoreInfoPage extends StatefulWidget {
1913
MoreInfoPage({Key key}) : super(key: key);
@@ -40,68 +34,56 @@ class _MoreInfoPageState extends State<MoreInfoPage> {
4034
final gender = CommonItem(
4135
title: "性别",
4236
subtitle: '男',
43-
onTap: (item) async {
44-
final String result = await Navigator.of(context).push(
45-
new MaterialPageRoute(
46-
builder: (_) {
47-
return SettingGenderPage(
48-
value: item.subtitle.isEmpty ? '男' : item.subtitle,
49-
);
50-
},
51-
),
37+
onTap: (item) {
38+
final String value = item.subtitle.isEmpty ? '男' : item.subtitle;
39+
// 跳转
40+
NavigatorUtils.pushResult(
41+
context,
42+
'${ProfileRouter.settingGenderPage}?value=${Uri.encodeComponent(value)}',
43+
(result) {
44+
if (null != result && item.subtitle != result) {
45+
setState(() {
46+
item.subtitle = result;
47+
});
48+
}
49+
},
5250
);
53-
if (null != result && item.subtitle != result) {
54-
setState(() {
55-
item.subtitle = result;
56-
});
57-
}
5851
},
5952
);
6053
// 地址
6154
final address = CommonItem(
6255
title: "地址",
6356
subtitle: '广东 深圳',
64-
onTap: (_) {
65-
// Navigator.of(context).push(new MaterialPageRoute(
66-
// builder: (_) {
67-
// return BindingMailboxPage();
68-
// },
69-
// ));
70-
},
57+
onTap: (_) {},
7158
);
7259
// 签名
7360
final sign = CommonItem(
7461
title: "个性签名",
7562
subtitle: '生死看淡,不服就干',
7663
onTap: (item) async {
77-
final String result =
78-
await Navigator.of(context).push(new MaterialPageRoute(
79-
builder: (_) {
80-
return SignaturePage(
81-
text: (item.subtitle != null &&
82-
item.subtitle.isNotEmpty &&
83-
item.subtitle != '未填写')
84-
? item.subtitle
85-
: '',
86-
);
64+
final String text = (item.subtitle != null &&
65+
item.subtitle.isNotEmpty &&
66+
item.subtitle != '未填写')
67+
? item.subtitle
68+
: '';
69+
// 跳转
70+
NavigatorUtils.pushResult(
71+
context,
72+
'${ProfileRouter.signaturePage}?text=${Uri.encodeComponent(text)}',
73+
(result) {
74+
if (null != result && item.subtitle != result) {
75+
setState(() {
76+
item.subtitle =
77+
(result != null && (result as String).isNotEmpty)
78+
? result
79+
: '未填写';
80+
});
81+
}
8782
},
88-
));
89-
// 取消,不做处理
90-
if (result != null && item.subtitle != result) {
91-
setState(() {
92-
item.subtitle =
93-
(result != null && result.isNotEmpty) ? result : '未填写';
94-
});
95-
}
83+
);
9684
},
9785
);
98-
final group0 = CommonGroup(
99-
items: [
100-
gender,
101-
address,
102-
sign,
103-
],
104-
);
86+
final group0 = CommonGroup(items: [gender, address, sign]);
10587

10688
// 添加数据源
10789
_dataSource = [group0];

lib/views/profile/more_security_setting/more_security_setting_page.dart

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
import 'package:flutter/gestures.dart';
21
import 'package:flutter/material.dart';
3-
import 'package:shared_preferences/shared_preferences.dart';
4-
5-
import 'package:flutter_wechat/constant/cache_key.dart';
2+
import 'package:flutter_wechat/routers/fluro_navigator.dart';
3+
import 'package:flutter_wechat/views/profile/profile_rourer.dart';
64

75
import 'package:flutter_wechat/model/common/common_item.dart';
86
import 'package:flutter_wechat/model/common/common_group.dart';
9-
import 'package:flutter_wechat/model/common/common_footer.dart';
10-
import 'package:flutter_wechat/model/common/common_header.dart';
117

128
import 'package:flutter_wechat/widgets/common/common_group_widget.dart';
139

14-
import 'package:flutter_wechat/views/profile/add_way/add_way_page.dart';
15-
import 'package:flutter_wechat/views/profile/binding_mailbox/binding_mailbox_page.dart';
16-
1710
/// 账号与安全
1811
class MoreSecuritySettingPage extends StatefulWidget {
1912
MoreSecuritySettingPage({Key key}) : super(key: key);
@@ -47,11 +40,7 @@ class _MoreSecuritySettingPageState extends State<MoreSecuritySettingPage> {
4740
title: "邮箱地址",
4841
subtitle: '未绑定',
4942
onTap: (_) {
50-
Navigator.of(context).push(new MaterialPageRoute(
51-
builder: (_) {
52-
return BindingMailboxPage();
53-
},
54-
));
43+
NavigatorUtils.push(context, ProfileRouter.bindingMailboxPage);
5544
},
5645
);
5746
final group0 = CommonGroup(

lib/views/profile/privates/privates_page.dart

Lines changed: 23 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import 'package:flutter/gestures.dart';
22
import 'package:flutter/material.dart';
3-
import 'package:shared_preferences/shared_preferences.dart';
3+
import 'package:flustars/flustars.dart';
4+
5+
import 'package:flutter_wechat/routers/fluro_navigator.dart';
6+
import 'package:flutter_wechat/views/profile/profile_rourer.dart';
47

58
import 'package:flutter_wechat/constant/cache_key.dart';
69

@@ -11,9 +14,6 @@ import 'package:flutter_wechat/model/common/common_header.dart';
1114

1215
import 'package:flutter_wechat/widgets/common/common_group_widget.dart';
1316

14-
import 'package:flutter_wechat/views/profile/add_way/add_way_page.dart';
15-
import 'package:flutter_wechat/views/profile/check_scope/check_scope_page.dart';
16-
1717
/// 隐私
1818
class PrivatesPage extends StatefulWidget {
1919
PrivatesPage({Key key}) : super(key: key);
@@ -25,9 +25,6 @@ class _PrivatesPageState extends State<PrivatesPage> {
2525
/// 数据源
2626
List<CommonGroup> _dataSource = [];
2727

28-
/// 查看范围 item
29-
CommonItem _checkScope;
30-
3128
/// 点击事件
3229
final TapGestureRecognizer _tapGr0 = TapGestureRecognizer();
3330
final TapGestureRecognizer _tapGr1 = TapGestureRecognizer();
@@ -68,8 +65,6 @@ class _PrivatesPageState extends State<PrivatesPage> {
6865

6966
// 配置数据源
7067
_configData();
71-
// 赋值
72-
_getCheckScopeCache();
7368
}
7469

7570
/// 配置数据
@@ -89,11 +84,7 @@ class _PrivatesPageState extends State<PrivatesPage> {
8984
final addWay = CommonItem(
9085
title: "添加我的方式",
9186
onTap: (_) {
92-
Navigator.of(context).push(new MaterialPageRoute(
93-
builder: (_) {
94-
return AddWayPage();
95-
},
96-
));
87+
NavigatorUtils.push(context, ProfileRouter.addWayPage);
9788
},
9889
);
9990
// 向我推荐通讯录朋友
@@ -130,30 +121,29 @@ class _PrivatesPageState extends State<PrivatesPage> {
130121
title: "不看他(她)的朋友圈",
131122
);
132123
// 允许朋友查看朋友圈的范围
124+
// 获取缓存中范围
125+
final String scope =
126+
SpUtil.getString(CacheKey.momentsCheckScopeKey, defValue: '全部');
133127
final checkScope = CommonItem(
134128
title: "允许朋友查看朋友圈的范围",
135-
subtitle: '',
136-
onTap: (item) async {
137-
final String result = await Navigator.of(context).push(
138-
new MaterialPageRoute(
139-
builder: (_) {
140-
return CheckScopePage(
141-
value: item.subtitle.isEmpty ? '全部' : item.subtitle,
142-
);
143-
},
144-
),
129+
subtitle: scope,
130+
onTap: (item) {
131+
// 跳转
132+
NavigatorUtils.pushResult(
133+
context,
134+
'${ProfileRouter.checkScopePage}?value=${Uri.encodeComponent(scope)}',
135+
(result) {
136+
if (null != result && item.subtitle != result) {
137+
setState(() {
138+
item.subtitle = result;
139+
});
140+
// 保存缓存
141+
SpUtil.putString(CacheKey.momentsCheckScopeKey, result);
142+
}
143+
},
145144
);
146-
if (null != result && item.subtitle != result) {
147-
setState(() {
148-
item.subtitle = result;
149-
});
150-
// 存储本地
151-
SharedPreferences sp = await SharedPreferences.getInstance();
152-
sp.setString(CacheKey.momentsCheckScopeKey, result);
153-
}
154145
},
155146
);
156-
_checkScope = checkScope;
157147

158148
// 允许陌生人查看十条朋友圈
159149
final stranger = CommonSwitchItem(
@@ -192,15 +182,6 @@ class _PrivatesPageState extends State<PrivatesPage> {
192182
_dataSource = [group0, group1, group2, group3, group4, group5];
193183
}
194184

195-
/// 读取缓存
196-
void _getCheckScopeCache() async {
197-
SharedPreferences sp = await SharedPreferences.getInstance();
198-
String value = sp.getString(CacheKey.momentsCheckScopeKey);
199-
setState(() {
200-
_checkScope.subtitle = null == value ? '全部' : value;
201-
});
202-
}
203-
204185
/// 点击状态事件 they occur: down, up, tap, cancel
205186
void _handleTapDown(TapDownDetails details, int type) {
206187
setState(() {

lib/views/profile/profile_page.dart

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import 'package:flutter_wechat/model/common/common_item.dart';
99
import 'package:flutter_wechat/model/common/common_group.dart';
1010
import 'package:flutter_wechat/widgets/common/common_group_widget.dart';
1111

12-
import 'package:flutter_wechat/views/profile/user_info/user_info_page.dart';
13-
1412
import 'package:flutter_wechat/views/profile/widgets/profile_header.dart';
1513

1614
class ProfilePage extends StatefulWidget {
@@ -106,16 +104,9 @@ class _ProfilePageState extends State<ProfilePage> {
106104
slivers: <Widget>[
107105
// 头部
108106
ProfileHeader(
109-
onTapTitle: () {
110-
print('点击昵称');
111-
},
107+
onTapTitle: () {},
112108
onTapContent: () {
113-
print('除了点击名称');
114-
Navigator.of(context).push(new MaterialPageRoute(
115-
builder: (_) {
116-
return UserInfoPage();
117-
},
118-
));
109+
NavigatorUtils.push(context, ProfileRouter.userInfoPage);
119110
},
120111
),
121112
// 列表

0 commit comments

Comments
 (0)