Skip to content

Commit

Permalink
新增常用网站、分享、关于作者
Browse files Browse the repository at this point in the history
  • Loading branch information
committed Mar 14, 2019
1 parent 2109efe commit 44a3cdd
Show file tree
Hide file tree
Showing 14 changed files with 321 additions and 6 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@

## 功能介绍

#### V1.2版本

- 新增分享[share](https://pub.flutter-io.cn/packages/share)
- 新增常用网站
- 新增关于作者,退出登录

#### V1.1版本

- 新增引导页[flutter-intro-slider](https://github.com/duytq94/flutter-intro-slider)
Expand Down Expand Up @@ -51,8 +57,9 @@

<img src="/screenshot/b2.jpg" width="240">&emsp;&emsp; <img src="/screenshot/b1.jpg" width="240">&emsp;&emsp;<img src="/screenshot/a0.png" width="240">

<img src="/screenshot/b3.png" width="240">&emsp;&emsp; <img src="/screenshot/b4.jpg" width="240">&emsp;&emsp;<img src="/screenshot/b5.jpg" width="240">

<img src="/screenshot/a01.png" width="240"> &emsp;&emsp; <img src="/screenshot/a02.jpg" width="240">&emsp;&emsp; <img src="/screenshot/a1.jpg" width="240">
<img src="/screenshot/a01.png" width="240"> &emsp;&emsp; <img src="/screenshot/a02.jpg" width="240">&emsp;&emsp;<img src="/screenshot/a1.jpg" width="240">


<img src="/screenshot/a2.jpg" width="240">&emsp;&emsp; <img src="/screenshot/a3.jpg" width="240">&emsp;&emsp;<img src="/screenshot/a4.jpg" width="240">
Expand All @@ -70,6 +77,7 @@

## 使用开源库

- [share](https://pub.flutter-io.cn/packages/share)
- [flutter_swiper](https://pub.flutter-io.cn/packages/flutter_swiper)
- [cupertino_icons](https://pub.flutter-io.cn/packages/cupertino_icons)
- [flutter_webview_plugin](https://pub.flutter-io.cn/packages/flutter_webview_plugin)
Expand Down
2 changes: 2 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}


apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

Expand Down Expand Up @@ -60,6 +61,7 @@ android {
}
}


flutter {
source '../..'
}
Expand Down
108 changes: 108 additions & 0 deletions lib/drawer/about.dart
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),
)
],
),
));
}
}
119 changes: 119 additions & 0 deletions lib/drawer/common_website.dart
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),),
),
);
}
}
15 changes: 12 additions & 3 deletions lib/drawer/drawer.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:wanandroid_ngu/common/application.dart';
import 'package:wanandroid_ngu/common/user.dart';
import 'package:wanandroid_ngu/drawer/about.dart';
import 'package:wanandroid_ngu/drawer/common_website.dart';
import 'package:wanandroid_ngu/drawer/my_collections.dart';
import 'package:wanandroid_ngu/drawer/setting.dart';
import 'package:wanandroid_ngu/event/login_event.dart';
import 'package:wanandroid_ngu/login/login_page.dart';
import 'package:wanandroid_ngu/public_ui/webview_page.dart';
import 'package:share/share.dart';

class DrawerPage extends StatefulWidget {
@override
Expand Down Expand Up @@ -42,6 +46,9 @@ class DrawerPageState extends State<DrawerPage> {
});
}




@override
Widget build(BuildContext context) {
return Drawer(
Expand Down Expand Up @@ -96,7 +103,9 @@ class DrawerPageState extends State<DrawerPage> {
),
leading: Icon(Icons.web, size: 22.0),
onTap: () {
Fluttertoast.showToast(msg: "常用网站");
Navigator.of(context).push(new MaterialPageRoute(builder: (context){
return new CommonWebsitePage();
}));
},
),
ListTile(
Expand All @@ -118,7 +127,7 @@ class DrawerPageState extends State<DrawerPage> {
),
leading: Icon(Icons.share, size: 22.0),
onTap: () {
Fluttertoast.showToast(msg: "分享");
Share.share('给你推荐一个特别好玩的应用玩安卓客户端,点击下载:https://www.pgyer.com/haFL');
},
),
ListTile(
Expand All @@ -129,7 +138,7 @@ class DrawerPageState extends State<DrawerPage> {
leading: Icon(Icons.info, size: 22.0),
onTap: () {
Navigator.of(context).push(new MaterialPageRoute(builder: (context){
return new WebViewPage(title: "ngu2008",url: "https://github.com/ngu2008/wanandroid");
return new AboutMePage();
}));
},
),
Expand Down
2 changes: 1 addition & 1 deletion lib/drawer/setting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SettingPage extends StatelessWidget {
children: <Widget>[
Expanded(
child: Text(
"切换主题",
"切换语言",
style: TextStyle(fontSize: 16),
)),
new Image.asset(
Expand Down
4 changes: 3 additions & 1 deletion lib/http/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ class Api{
static const String USER_REGISTER = "https://www.wanandroid.com/user/register";
// 收藏列表
static const String COLLECTION_LIST = "https://www.wanandroid.com/lg/collect/list/";

//常用网站
static const String COMMON_WEBSITE = "https://www.wanandroid.com/friend/json";

// 我的收藏-取消收藏
static const String CANCEL_COLLECTION = "https://www.wanandroid.com/lg/uncollect/";

Expand Down
14 changes: 14 additions & 0 deletions lib/http/common_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:wanandroid_ngu/model/article_model.dart';
import 'package:wanandroid_ngu/model/banner_model.dart';
import 'package:wanandroid_ngu/model/base_model.dart';
import 'package:wanandroid_ngu/model/collection_model.dart';
import 'package:wanandroid_ngu/model/common_websit_model.dart';
import 'package:wanandroid_ngu/model/hotword_model.dart';
import 'package:wanandroid_ngu/model/navi_model.dart';
import 'package:wanandroid_ngu/model/projectlist_model.dart';
Expand Down Expand Up @@ -153,6 +154,19 @@ class CommonService{
callback(WebsiteCollectionModel(response.data));
});
}

///常用网站
void getCommonWebsite(Function callback) async{
DioManager.singleton.dio.get(Api.COMMON_WEBSITE,options:_getOptions()).then((response){
callback(CommonWebsitModel.fromMap(response.data));
});

}





/// 取消网站收藏
void cancelWebsiteCollectionList(Function callback,int _id) async {
FormData formData = new FormData.from({
Expand Down
Loading

0 comments on commit 44a3cdd

Please sign in to comment.