-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
“
committed
Mar 14, 2019
1 parent
2109efe
commit 44a3cdd
Showing
14 changed files
with
321 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:wanandroid_ngu/public_ui/webview_page.dart'; | ||
|
||
class AboutMePage extends StatefulWidget { | ||
@override | ||
State<StatefulWidget> createState() { | ||
return AboutMePageState(); | ||
} | ||
} | ||
|
||
class AboutMePageState extends State<AboutMePage> { | ||
TextStyle textStyle = new TextStyle( | ||
color: Colors.blue, | ||
decoration: new TextDecoration.combine([TextDecoration.underline])); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return new Scaffold( | ||
appBar: new AppBar( | ||
title: new Text("关于作者"), | ||
centerTitle: true, | ||
), | ||
body: new Container( | ||
padding: EdgeInsets.fromLTRB(35, 50, 35, 15), | ||
child: new Column( | ||
children: <Widget>[ | ||
|
||
CircleAvatar( | ||
minRadius: 60, | ||
maxRadius: 60, | ||
backgroundImage: AssetImage('images/head.jpg'), | ||
), | ||
|
||
Padding(padding: EdgeInsets.only(top: 30)), | ||
|
||
new Text("基于Google Flutter的玩Android客户端"), | ||
|
||
Container( | ||
margin: const EdgeInsets.fromLTRB(0.0, 80.0, 0.0, 0.0), | ||
child: new Row( | ||
|
||
children: <Widget>[ | ||
new Text("邮箱:"), | ||
new Text( | ||
"zw20082012@126.com", | ||
style: TextStyle(color: Colors.blue), | ||
|
||
), | ||
], | ||
), | ||
), | ||
|
||
GestureDetector( | ||
child: new Container( | ||
margin: const EdgeInsets.fromLTRB(0.0, 20.0, 0.0, 0.0), | ||
child: new Row( | ||
|
||
children: <Widget>[ | ||
new Text("CSDN:"), | ||
new Text( | ||
"https://blog.csdn.net/zw2008224044", | ||
style: textStyle, | ||
), | ||
], | ||
), | ||
), | ||
onTap: () { | ||
Navigator.of(context) | ||
.push(new MaterialPageRoute(builder: (ctx) { | ||
return new WebViewPage( | ||
title: "ngu2008", | ||
url: "https://blog.csdn.net/zw2008224044"); | ||
})); | ||
}, | ||
), | ||
GestureDetector( | ||
child: new Container( | ||
margin: const EdgeInsets.fromLTRB(0.0, 20.0, 0.0, 0.0), | ||
child: new Row( | ||
|
||
children: <Widget>[ | ||
new Text("GitHub:"), | ||
new Text( | ||
"https://github.com/ngu2008/wanandroid", | ||
style: textStyle, | ||
), | ||
], | ||
), | ||
), | ||
onTap: () { | ||
Navigator.of(context) | ||
.push(new MaterialPageRoute(builder: (ctx) { | ||
return new WebViewPage( | ||
title: "GitHub", | ||
url: "https://github.com/ngu2008/wanandroid"); | ||
})); | ||
}, | ||
), | ||
Expanded(child: Container(), flex: 1), | ||
new Text( | ||
"本项目仅供学习使用,不得用作商业目的", | ||
style: new TextStyle(fontSize: 12.0), | ||
) | ||
], | ||
), | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import 'package:dio/dio.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:wanandroid_ngu/http/common_service.dart'; | ||
import 'package:wanandroid_ngu/model/common_websit_model.dart'; | ||
import 'package:wanandroid_ngu/model/projectlist_model.dart'; | ||
import 'package:wanandroid_ngu/public_ui/webview_page.dart'; | ||
import 'package:wanandroid_ngu/util/utils.dart'; | ||
|
||
class CommonWebsitePage extends StatefulWidget { | ||
@override | ||
State<StatefulWidget> createState() { | ||
return new CommonWebsitePageState(); | ||
} | ||
} | ||
|
||
class CommonWebsitePageState extends State<CommonWebsitePage> { | ||
List<DataListBean> _datas = new List(); | ||
ScrollController _scrollController = ScrollController(); | ||
|
||
bool showToTopBtn = false; //是否显示“返回到顶部”按钮 | ||
|
||
Future<Null> _getData() async { | ||
CommonService().getCommonWebsite((CommonWebsitModel commonWebsitModel) { | ||
setState(() { | ||
_datas = commonWebsitModel.data; | ||
}); | ||
}); | ||
} | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
_getData(); | ||
|
||
_scrollController.addListener(() { | ||
//当前位置是否超过屏幕高度 | ||
if (_scrollController.offset < 200 && showToTopBtn) { | ||
setState(() { | ||
showToTopBtn = false; | ||
}); | ||
} else if (_scrollController.offset >= 200 && showToTopBtn == false) { | ||
setState(() { | ||
showToTopBtn = true; | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text("常用网站"), | ||
centerTitle: true, | ||
), | ||
body: RefreshIndicator( | ||
onRefresh: _getData, | ||
child: GridView.builder( | ||
padding: EdgeInsets.all(15), | ||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( | ||
crossAxisCount: 2, //每行2列 | ||
mainAxisSpacing: 15, | ||
crossAxisSpacing: 15, | ||
childAspectRatio: 1.333 // | ||
|
||
), | ||
controller: _scrollController, | ||
itemCount: _datas.length, | ||
itemBuilder: _renderItem), | ||
), | ||
floatingActionButton: !showToTopBtn | ||
? null | ||
: FloatingActionButton( | ||
child: Icon(Icons.arrow_upward), | ||
onPressed: () { | ||
//返回到顶部时执行动画 | ||
_scrollController.animateTo(.0, | ||
duration: Duration(milliseconds: 200), curve: Curves.ease); | ||
}), | ||
); | ||
} | ||
|
||
Color _getColor(int index) { | ||
switch (index % 8) { | ||
case 0: | ||
return const Color(0xFFfb6e52); | ||
case 1: | ||
return const Color(0xFFa1d46f); | ||
case 2: | ||
return const Color(0xFF5cc0e2); | ||
case 3: | ||
return const Color(0xFFffbb44); | ||
case 4: | ||
return const Color(0xFFef6666); | ||
case 5: | ||
return const Color(0xFFf8d19e); | ||
case 6: | ||
return const Color(0xFF48cfae); | ||
case 7: | ||
return const Color(0xFFaa9ef8); | ||
} | ||
} | ||
|
||
Widget _renderItem(BuildContext context, int index) { | ||
return new InkWell( | ||
onTap: () { | ||
Navigator.of(context).push(new MaterialPageRoute(builder: (context) { | ||
return new WebViewPage( | ||
title: _datas[index].name, url: _datas[index].link); | ||
})); | ||
}, | ||
child: Container( | ||
padding: EdgeInsets.only(top: 25,left: 25), | ||
color: _getColor(index), | ||
child:Text(_datas[index].name,style: TextStyle(color: Colors.white,fontSize: 16,fontWeight: FontWeight.bold),), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.