@@ -2,6 +2,9 @@ import 'dart:async';
22
33import 'package:flutter/material.dart' ;
44import 'package:gsy_github_app_flutter/common/config/Config.dart' ;
5+ import 'package:gsy_github_app_flutter/common/dao/ReposDao.dart' ;
6+ import 'package:gsy_github_app_flutter/common/utils/EventUtils.dart' ;
7+ import 'package:gsy_github_app_flutter/widget/EventItem.dart' ;
58import 'package:gsy_github_app_flutter/widget/GSYPullLoadWidget.dart' ;
69import 'package:gsy_github_app_flutter/widget/ReposHeaderItem.dart' ;
710
@@ -11,16 +14,23 @@ import 'package:gsy_github_app_flutter/widget/ReposHeaderItem.dart';
1114 * Date: 2018-07-18
1215 */
1316class ReposDetailInfoPage extends StatefulWidget {
17+ final String userName;
18+
19+ final String reposName;
1420 final ReposDetailInfoPageControl reposDetailInfoPageControl;
1521
16- ReposDetailInfoPage (this .reposDetailInfoPageControl);
22+ ReposDetailInfoPage (this .reposDetailInfoPageControl, this .userName, this .reposName );
1723
1824 @override
19- _ReposDetailInfoPageState createState () => _ReposDetailInfoPageState (reposDetailInfoPageControl);
25+ _ReposDetailInfoPageState createState () => _ReposDetailInfoPageState (reposDetailInfoPageControl, userName, reposName );
2026}
2127
2228// ignore: mixin_inherits_from_not_object
2329class _ReposDetailInfoPageState extends State <ReposDetailInfoPage > with AutomaticKeepAliveClientMixin {
30+ final String userName;
31+
32+ final String reposName;
33+
2434 bool isLoading = false ;
2535
2636 int page = 1 ;
@@ -31,51 +41,59 @@ class _ReposDetailInfoPageState extends State<ReposDetailInfoPage> with Automati
3141
3242 final GSYPullLoadWidgetControl pullLoadWidgetControl = new GSYPullLoadWidgetControl ();
3343
34- _ReposDetailInfoPageState (this .reposDetailInfoPageControl);
44+ _ReposDetailInfoPageState (this .reposDetailInfoPageControl, this .userName, this .reposName );
3545
3646 Future <Null > _handleRefresh () async {
37- /* if (isLoading) {
47+ if (isLoading) {
3848 return null ;
3949 }
4050 isLoading = true ;
4151 page = 1 ;
42- var result = await EventDao.getEventDao(_getUserName() , page: page);
43- if (result != null && result.length > 0 ) {
52+ var res = await ReposDao . getRepositoryEventDao (userName, reposName , page: page);
53+ if (res != null && res.result ) {
4454 pullLoadWidgetControl.dataList.clear ();
4555 setState (() {
46- pullLoadWidgetControl.dataList.addAll(result );
56+ pullLoadWidgetControl.dataList.addAll (res.data );
4757 });
4858 }
4959 setState (() {
50- pullLoadWidgetControl.needLoadMore = (result != null && result .length == Config.PAGE_SIZE);
60+ pullLoadWidgetControl.needLoadMore = (res != null && res.data != null && res.data .length == Config .PAGE_SIZE );
5161 });
52- isLoading = false;*/
62+ isLoading = false ;
5363 return null ;
5464 }
5565
5666 Future <Null > _onLoadMore () async {
57- /* if (isLoading) {
67+ if (isLoading) {
5868 return null ;
5969 }
6070 isLoading = true ;
6171 page++ ;
62- var result = await EventDao.getEventDao(_getUserName() , page: page);
63- if (result != null && result.length > 0 ) {
72+ var res = await ReposDao . getRepositoryEventDao (userName, reposName , page: page);
73+ if (res != null && res.result ) {
6474 setState (() {
65- pullLoadWidgetControl.dataList.addAll(result );
75+ pullLoadWidgetControl.dataList.addAll (res.data );
6676 });
6777 }
6878 setState (() {
69- pullLoadWidgetControl.needLoadMore = (result != null);
79+ pullLoadWidgetControl.needLoadMore = (res != null && res.data != null && res.data.length == Config . PAGE_SIZE );
7080 });
71- isLoading = false;*/
81+ isLoading = false ;
7282 return null ;
7383 }
7484
7585 _renderEventItem (index) {
7686 if (index == 0 ) {
7787 return new ReposHeaderItem (reposDetailInfoPageControl.reposHeaderViewModel);
7888 }
89+
90+ EventViewModel eventViewModel = pullLoadWidgetControl.dataList[index - 1 ];
91+ return new EventItem (
92+ pullLoadWidgetControl.dataList[index - 1 ],
93+ onPressed: () {
94+ EventUtils .ActionUtils (context, eventViewModel.eventMap, "" );
95+ },
96+ );
7997 }
8098
8199 @override
0 commit comments