@@ -3,6 +3,7 @@ import 'package:gsy_github_app_flutter/common/dao/ReposDao.dart';
33import 'package:gsy_github_app_flutter/common/style/GSYStyle.dart' ;
44import 'package:gsy_github_app_flutter/page/RepositoryDetailReadmePage.dart' ;
55import 'package:gsy_github_app_flutter/page/RepostoryDetailInfoPage.dart' ;
6+ import 'package:gsy_github_app_flutter/widget/GSYIConText.dart' ;
67import 'package:gsy_github_app_flutter/widget/GSYTabBarWidget.dart' ;
78import 'package:gsy_github_app_flutter/widget/ReposHeaderItem.dart' ;
89
@@ -24,15 +25,19 @@ class RepositoryDetailPage extends StatefulWidget {
2425}
2526
2627// ignore: mixin_inherits_from_not_object
27- class _RepositoryDetailPageState extends State <RepositoryDetailPage > with AutomaticKeepAliveClientMixin {
28+ class _RepositoryDetailPageState extends State <RepositoryDetailPage > {
2829 ReposHeaderViewModel reposHeaderViewModel = new ReposHeaderViewModel ();
2930
31+ BottomStatusModel bottomStatusModel;
32+
3033 final String userName;
3134
3235 final String reposName;
3336
3437 final ReposDetailInfoPageControl reposDetailInfoPageControl = new ReposDetailInfoPageControl ();
3538
39+ final TarWidgetControl tarBarControl = new TarWidgetControl ();
40+
3641 _RepositoryDetailPageState (this .userName, this .reposName);
3742
3843 _getReposDetail () async {
@@ -44,19 +49,86 @@ class _RepositoryDetailPageState extends State<RepositoryDetailPage> with Automa
4449 }
4550 }
4651
47- @override
48- void didChangeDependencies () {
49- this ._getReposDetail ();
50- super .didChangeDependencies ();
52+ _getReposStatus () async {
53+ var result = await ReposDao .getRepositoryStatusDao (userName, reposName);
54+ print (result.data["star" ]);
55+ print (result.data["watch" ]);
56+ String watchText = result.data["watch" ] ? "UnWatch" : "Watch" ;
57+ String starText = result.data["star" ] ? "UnStar" : "Star" ;
58+ IconData watchIcon = result.data["watch" ] ? GSYICons .REPOS_ITEM_WATCHED : GSYICons .REPOS_ITEM_WATCH ;
59+ IconData starIcon = result.data["star" ] ? GSYICons .REPOS_ITEM_STARED : GSYICons .REPOS_ITEM_STAR ;
60+ BottomStatusModel model = new BottomStatusModel (watchText, starText, watchIcon, starIcon, result.data["watch" ], result.data["star" ]);
61+ bottomStatusModel = model;
62+ setState (() {
63+ tarBarControl.footerButton = _getBottomWidget ();
64+ });
65+ }
66+
67+ _getBottomWidget () {
68+ List <Widget > bottomWidget = (bottomStatusModel == null )
69+ ? []
70+ : < Widget > [
71+ new FlatButton (
72+ onPressed: () => {},
73+ child: new GSYIConText (
74+ bottomStatusModel.starIcon,
75+ bottomStatusModel.starText,
76+ GSYConstant .smallText,
77+ Color (GSYColors .primaryValue),
78+ 15.0 ,
79+ padding: 5.0 ,
80+ mainAxisAlignment: MainAxisAlignment .center,
81+ )),
82+ new FlatButton (
83+ onPressed: () {},
84+ child: new GSYIConText (
85+ bottomStatusModel.watchIcon,
86+ bottomStatusModel.watchText,
87+ GSYConstant .smallText,
88+ Color (GSYColors .primaryValue),
89+ 15.0 ,
90+ padding: 5.0 ,
91+ mainAxisAlignment: MainAxisAlignment .center,
92+ )),
93+ new FlatButton (
94+ onPressed: () {},
95+ child: new GSYIConText (
96+ GSYICons .REPOS_ITEM_FORK ,
97+ "fork" ,
98+ GSYConstant .smallText,
99+ Color (GSYColors .primaryValue),
100+ 15.0 ,
101+ padding: 5.0 ,
102+ mainAxisAlignment: MainAxisAlignment .center,
103+ )),
104+ new FlatButton (
105+ onPressed: () {},
106+ color: Color (GSYColors .primaryValue),
107+ child: new GSYIConText (
108+ Icons .arrow_drop_up,
109+ "master" ,
110+ GSYConstant .smallTextWhite,
111+ Color (GSYColors .white),
112+ 30.0 ,
113+ padding: 3.0 ,
114+ mainAxisAlignment: MainAxisAlignment .center,
115+ ))
116+ ];
117+ return bottomWidget;
51118 }
52119
53120 @override
54- bool get wantKeepAlive => true ;
121+ void initState () {
122+ super .initState ();
123+ this ._getReposDetail ();
124+ this ._getReposStatus ();
125+ }
55126
56127 @override
57128 Widget build (BuildContext context) {
58129 return new GSYTabBarWidget (
59130 type: GSYTabBarWidget .TOP_TAB ,
131+ tarWidgetControl: tarBarControl,
60132 tabItems: [
61133 new Tab (text: GSYStrings .repos_tab_readme),
62134 new Tab (text: GSYStrings .repos_tab_info),
@@ -74,3 +146,14 @@ class _RepositoryDetailPageState extends State<RepositoryDetailPage> with Automa
74146 title: reposName);
75147 }
76148}
149+
150+ class BottomStatusModel {
151+ final String watchText;
152+ final String starText;
153+ final IconData watchIcon;
154+ final IconData starIcon;
155+ final bool star;
156+ final bool watch;
157+
158+ BottomStatusModel (this .watchText, this .starText, this .watchIcon, this .starIcon, this .watch, this .star);
159+ }
0 commit comments