Skip to content

Commit c797b15

Browse files
committed
add event
1 parent 6db3be3 commit c797b15

7 files changed

Lines changed: 59 additions & 26 deletions

File tree

‎lib/common/dao/EventDao.dart‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import 'package:gsy_github_app_flutter/common/model/User.dart';
2+
import 'package:gsy_github_app_flutter/common/net/Address.dart';
3+
import 'package:gsy_github_app_flutter/common/net/Api.dart';
4+
import 'package:gsy_github_app_flutter/common/redux/GSYState.dart';
5+
import 'package:redux/redux.dart';
6+
7+
class EventDao {
8+
static getEventReceived(Store<GSYState> store, {page = 0, callback}) async {
9+
User user = store.state.userInfo;
10+
if (user == null || user.login == null) {
11+
if (callback != null) {
12+
callback(null);
13+
}
14+
return;
15+
}
16+
String userName = user.login;
17+
String url = Address.getEventReceived(userName) + Address.getPageParams("?", page);
18+
var res = await HttpManager.netFetch(url, null, null, null);
19+
if (res != null && res.result) {
20+
print("yyyyyyyyyyyyyyyyyyyy");
21+
print(res.data.toString());
22+
} else {
23+
if (callback != null) {
24+
callback(null);
25+
}
26+
}
27+
}
28+
}

‎lib/common/net/Api.dart‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class HttpManager {
7474
}
7575
if (Config.DEBUG) {
7676
print('请求异常: ' + e.toString());
77+
print('请求异常url: ' + url);
7778
}
7879
return new ResultData(Code.errorHandleFunction(errorResponse.statusCode, e.message), false, errorResponse.statusCode);
7980
}
@@ -86,6 +87,9 @@ class HttpManager {
8687
if (response != null) {
8788
print('返回参数: ' + response.toString());
8889
}
90+
if (optionParams["authorizationCode"] != null) {
91+
print('authorizationCode: ' + optionParams["authorizationCode"]);
92+
}
8993
}
9094

9195
try {

‎lib/common/redux/EventRedux.dart‎

Whitespace-only changes.

‎lib/common/style/GSYStyle.dart‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ class GSYColors {
3131
class GSYConstant {}
3232

3333
class GSYStrings {
34+
static const String app_name = "GSYGithubAppFlutter";
35+
3436
static const String login_text = "登录";
37+
3538
static const String login_username_hint_text = "请输入github用户名";
3639
static const String login_password_hint_text = "请输入密码";
3740
static const String login_success = "登录成功";

‎lib/page/DynamicPage.dart‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import 'dart:async';
22

33
import 'package:flutter/material.dart';
44
import 'package:flutter_redux/flutter_redux.dart';
5-
import 'package:gsy_github_app_flutter/common/model/User.dart';
5+
import 'package:gsy_github_app_flutter/common/dao/EventDao.dart';
66
import 'package:gsy_github_app_flutter/common/redux/GSYState.dart';
7-
import 'package:gsy_github_app_flutter/common/redux/UserRedux.dart';
87
import 'package:gsy_github_app_flutter/widget/EventItem.dart';
98
import 'package:gsy_github_app_flutter/widget/GSYPullLoadWidget.dart';
9+
import 'package:redux/redux.dart';
1010

1111
class DynamicPage extends StatefulWidget {
1212
@override
@@ -24,7 +24,7 @@ class _DynamicPageState extends State<DynamicPage> {
2424
return null;
2525
}
2626

27-
bool _onNotifycation<Notification>(Notification notify) {
27+
bool _onNotification<Notification>(Notification notify) {
2828
if (notify is! OverscrollNotification) {
2929
return true;
3030
}
@@ -34,21 +34,22 @@ class _DynamicPageState extends State<DynamicPage> {
3434
return true;
3535
}
3636

37+
@override
38+
void didChangeDependencies() {
39+
Store<GSYState> store = StoreProvider.of(context);
40+
EventDao.getEventReceived(store);
41+
super.didChangeDependencies();
42+
}
43+
3744
@override
3845
Widget build(BuildContext context) {
3946
return new StoreBuilder<GSYState>(
4047
builder: (context, store) {
41-
new Future.delayed(const Duration(seconds: 2), () {
42-
User user = store.state.userInfo;
43-
user.login = "new login";
44-
user.name = "new name";
45-
store.dispatch(new UpdateUserAction(user));
46-
});
4748
return GSYPullLoadWidget(
4849
pullLoadWidgetControl,
4950
(BuildContext context, int index) => new EventItem(),
5051
_handleRefresh,
51-
_onNotifycation);
52+
_onNotification);
5253
},
5354
);
5455
}

‎lib/page/HomePage.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ class HomePage extends StatelessWidget {
2626
],
2727
backgroundColor: GSYColors.primarySwatch,
2828
indicatorColor: Colors.white,
29-
title: "Title");
29+
title: GSYStrings.app_name);
3030
}
3131
}

‎lib/page/WelcomePage.dart‎

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,29 @@ import 'package:flutter_redux/flutter_redux.dart';
55
import 'package:gsy_github_app_flutter/common/dao/UserDao.dart';
66
import 'package:gsy_github_app_flutter/common/redux/GSYState.dart';
77
import 'package:gsy_github_app_flutter/common/utils/NavigatorUtils.dart';
8+
import 'package:redux/redux.dart';
89

910
class WelcomePage extends StatelessWidget {
1011
static final String sName = "/";
1112

1213
@override
1314
Widget build(BuildContext context) {
14-
toNext(res) {
15-
if (res != null && res.result) {
16-
NavigatorUtils.goHome(context);
17-
} else {
18-
NavigatorUtils.goLogin(context);
19-
}
20-
}
21-
15+
Store<GSYState> store = StoreProvider.of(context);
16+
new Future.delayed(const Duration(seconds: 2), () {
17+
UserDao.initUserInfo(store).then((res) {
18+
if (res != null && res.result) {
19+
NavigatorUtils.goHome(context);
20+
} else {
21+
NavigatorUtils.goLogin(context);
22+
}
23+
});
24+
});
2225
return StoreBuilder<GSYState>(
2326
builder: (context, store) {
24-
new Future.delayed(const Duration(seconds: 2), () {
25-
UserDao.initUserInfo(store).then((res) {
26-
toNext(res);
27-
});
28-
});
2927
return new Container(
3028
color: Colors.white,
3129
child: new Center(
32-
child: new Text("Welcome",
33-
style: new TextStyle(color: Colors.black, fontSize: 22.0)),
30+
child: new Text("Welcome", style: new TextStyle(color: Colors.black, fontSize: 22.0)),
3431
),
3532
);
3633
},

0 commit comments

Comments
 (0)