Skip to content

Commit 560fab1

Browse files
committed
1、增加导航页。
1 parent ebed8e2 commit 560fab1

12 files changed

+484
-76
lines changed

lib/http/api.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ class CommonApi{
288288

289289
static String HOT_SEARCH_KEY = '/hotkey/json';
290290

291+
static String NAVIGATION = '/navi/json';
292+
291293

292294
///搜索文章。页码从1开始
293295
static Future<Response> searchArticles(int page,String searchKey){
@@ -300,4 +302,9 @@ class CommonApi{
300302
return dio.get(HOT_SEARCH_KEY);
301303
}
302304

305+
///导航
306+
static Future<Response> getNavigations(){
307+
return dio.get(NAVIGATION);
308+
}
309+
303310
}

lib/page/home/article/article_page.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import 'package:wanandroid_flutter/views/load_more_footer.dart';
1616
import 'package:wanandroid_flutter/views/loading_view.dart';
1717

1818
///博文页
19+
///BloC模式
1920
class ArticleSubPage extends StatefulWidget {
2021
PageStorageKey pageStorageKey;
2122

@@ -159,7 +160,7 @@ class _ArticleSubPageState extends State<ArticleSubPage>
159160
return;
160161
},
161162
child: CustomScrollView(
162-
key: widget.pageStorageKey,
163+
// key: widget.pageStorageKey,
163164
//在NestedScrollView的文档注释里有这句话:
164165
// The "controller" and "primary" members should be left
165166
// unset, so that the NestedScrollView can control this

lib/page/home/drawer/support_author.dart

Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -21,64 +21,66 @@ class _SupportAuthorPageState extends State<SupportAuthorPage> {
2121
),
2222
body: Builder(
2323
builder: (context) {
24-
return Column(
25-
children: <Widget>[
26-
//问题:如何保存asset文件到本地呢?
27-
Image.asset('images/ccy_pay_qr.jpeg'),
28-
RaisedButton(
29-
onPressed: () {
30-
_launchURL();
31-
},
32-
color: WColors.theme_color,
33-
padding: EdgeInsets.symmetric(vertical: 5, horizontal: 10),
34-
child: Text(
35-
'去网页版打赏作者',
36-
style: TextStyle(fontSize: 16, color: Colors.white),
24+
return SingleChildScrollView(
25+
child: Column(
26+
children: <Widget>[
27+
//问题:如何保存asset文件到本地呢?
28+
Image.asset('images/ccy_pay_qr.jpeg'),
29+
RaisedButton(
30+
onPressed: () {
31+
_launchURL();
32+
},
33+
color: WColors.theme_color,
34+
padding: EdgeInsets.symmetric(vertical: 5, horizontal: 10),
35+
child: Text(
36+
'去网页版打赏作者',
37+
style: TextStyle(fontSize: 16, color: Colors.white),
38+
),
3739
),
38-
),
39-
Padding(
40-
padding:
41-
EdgeInsets.only(top: 16, left: 16, right: 16, bottom: 16),
42-
child: Row(
43-
children: <Widget>[
44-
Expanded(
45-
child: Text(
46-
'微信:ccy01220122',
47-
style: TextStyle(fontSize: 20),
40+
Padding(
41+
padding:
42+
EdgeInsets.only(top: 16, left: 16, right: 16, bottom: 16),
43+
child: Row(
44+
children: <Widget>[
45+
Expanded(
46+
child: Text(
47+
'微信:ccy01220122',
48+
style: TextStyle(fontSize: 20),
49+
),
4850
),
49-
),
50-
RaisedButton(
51-
onPressed: () {
52-
Clipboard.setData(
53-
ClipboardData(text: 'ccy01220122'),
54-
);
55-
DisplayUtil.showMsg(context, text: '已复制微信号');
56-
},
57-
color: WColors.theme_color_dark,
58-
padding:
59-
EdgeInsets.symmetric(vertical: 5, horizontal: 10),
60-
child: Text(
61-
'点击复制',
62-
style: TextStyle(fontSize: 20, color: Colors.white),
63-
),
64-
)
65-
],
51+
RaisedButton(
52+
onPressed: () {
53+
Clipboard.setData(
54+
ClipboardData(text: 'ccy01220122'),
55+
);
56+
DisplayUtil.showMsg(context, text: '已复制微信号');
57+
},
58+
color: WColors.theme_color_dark,
59+
padding:
60+
EdgeInsets.symmetric(vertical: 5, horizontal: 10),
61+
child: Text(
62+
'点击复制',
63+
style: TextStyle(fontSize: 20, color: Colors.white),
64+
),
65+
)
66+
],
67+
),
68+
),
69+
Image.asset(
70+
'images/nice_xiongdei.jpeg',
71+
width: 150,
72+
height: 150,
6673
),
67-
),
68-
Image.asset(
69-
'images/nice_xiongdei.jpeg',
70-
width: 150,
71-
height: 150,
72-
),
73-
],
74+
],
75+
),
7476
);
7577
},
7678
),
7779
);
7880
}
7981

8082
_launchURL() async {
81-
var url = 'https://github.com/CCY0122/FocusLayoutManager/blob/master/pic/341561604648_.pic.jpg';
83+
var url = 'https://github.com/CCY0122/WanAndroid_Flutter/blob/master/WechatIMG34.jpeg';
8284
if (await canLaunch(url)) {
8385
await launch(url);
8486
} else {

lib/page/home/home/home_page.dart

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'package:wanandroid_flutter/page/base/custom_sliver_app_bar_delegate.dart
55
import 'package:wanandroid_flutter/page/home/article/article_page.dart';
66
import 'package:wanandroid_flutter/page/home/home/bloc/home_index.dart';
77
import 'package:wanandroid_flutter/page/home/home/home_drawer.dart';
8+
import 'package:wanandroid_flutter/page/home/navigation/navigation_page.dart';
89
import 'package:wanandroid_flutter/page/home/project/project_page.dart';
910
import 'package:wanandroid_flutter/page/home/wxarticle/wx_article_page.dart';
1011
import 'package:wanandroid_flutter/page/search/search_page.dart';
@@ -15,7 +16,8 @@ import 'package:wanandroid_flutter/views/loading_view.dart';
1516
import 'package:wanandroid_flutter/views/saerch_bar.dart';
1617

1718
///主页
18-
///本页存在该问题:【flutter关于NestedScrollView的这个bug:https://github.com/flutter/flutter/issues/36419】
19+
///BloC模式
20+
///本页结构存在该问题:【flutter关于NestedScrollView的这个bug:https://github.com/flutter/flutter/issues/36419】
1921
class HomePage extends StatefulWidget {
2022
static const ROUTER_NAME = '/HomePage';
2123

@@ -33,6 +35,7 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
3335
TabController _tabController;
3436
ScrollController _scrollController;
3537
bool isSearchWXArticle = false;
38+
bool showFAB = true;
3639
TextEditingController _searchTextContriller;
3740

3841
static List<PageStorageKey<String>> keys = [
@@ -43,15 +46,12 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
4346
PageStorageKey<String>('5'),
4447
];
4548

49+
//实际上如果子页已经AutomaticKeepAliveClientMixin了,那也没必要再用PageStorageKey去保存滚动状态了,因为切换tab时页面根本不会被销毁
4650
Map<String, Widget> tabs = {
4751
res.project: ProjectSubPage(keys[0]),
4852
res.article: ArticleSubPage(keys[1]),
49-
res.vxArticle: WXArticleSubPage(keys[1]),
50-
res.navigation: Scaffold(
51-
body: Center(
52-
child: Text('敬请期待'),
53-
),
54-
),
53+
res.vxArticle: WXArticleSubPage(keys[2]),
54+
res.navigation: NavigationPage(),
5555
res.collect: Scaffold(
5656
body: Center(
5757
child: Text('敬请期待'),
@@ -73,6 +73,15 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
7373
isSearchWXArticle = false;
7474
});
7575
}
76+
if(_tabController.index == 3){
77+
setState(() {
78+
showFAB = false;
79+
});
80+
}else{
81+
setState(() {
82+
showFAB = true;
83+
});
84+
}
7685
});
7786
_scrollController = ScrollController();
7887
_searchTextContriller = TextEditingController();
@@ -175,20 +184,23 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
175184
drawer: Drawer(
176185
child: HomeDrawer(isLogin, userName, bmobUserEntity),
177186
),
178-
floatingActionButton: FloatingActionButton(
179-
onPressed: () {
180-
//本打算监听_scrollController,当滑动距离较大时再显示"返回顶部"按钮,但实际发现在NestedScrollView头部被收起后就收不到监听了。
181-
//那么只能在TabBarView子页中监听它们自己的滚动距离,然后再通知到主页(可以用bloc发一个event、也可以发一个自定义Notification)显示"返回顶部"按钮。(嫌麻烦,不做了,永久显示吧)
182-
_scrollController.animateTo(1,
183-
duration: Duration(seconds: 1),
184-
curve: Curves.decelerate);
185-
},
186-
child: Padding(
187-
padding: const EdgeInsets.all(4.0),
188-
child: Image.asset('images/rocket.png'),
187+
floatingActionButton: Offstage(
188+
offstage: !showFAB,
189+
child: FloatingActionButton(
190+
onPressed: () {
191+
//本打算监听_scrollController,当滑动距离较大时再显示"返回顶部"按钮,但实际发现在NestedScrollView头部被收起后就收不到监听了。
192+
//那么只能在TabBarView子页中监听它们自己的滚动距离,然后再通知到主页(可以用bloc发一个event、也可以发一个自定义Notification)显示"返回顶部"按钮。(嫌麻烦,不做了,永久显示吧)
193+
_scrollController.animateTo(1,
194+
duration: Duration(seconds: 1),
195+
curve: Curves.decelerate);
196+
},
197+
child: Padding(
198+
padding: const EdgeInsets.all(4.0),
199+
child: Image.asset('images/rocket.png'),
200+
),
201+
mini: true,
202+
backgroundColor: WColors.theme_color,
189203
),
190-
mini: true,
191-
backgroundColor: WColors.theme_color,
192204
),
193205
),
194206
Offstage(

0 commit comments

Comments
 (0)