@@ -136,61 +136,45 @@ class _RepositoryDetailPageState extends State<RepositoryDetailPage> {
136136 return list;
137137 }
138138
139+ _renderBottomItem (var text, var icon, var onPressed) {
140+ return new FlatButton (
141+ onPressed: onPressed,
142+ child: new GSYIConText (
143+ icon,
144+ text,
145+ GSYConstant .smallText,
146+ Color (GSYColors .primaryValue),
147+ 15.0 ,
148+ padding: 5.0 ,
149+ mainAxisAlignment: MainAxisAlignment .center,
150+ ));
151+ }
152+
139153 _getBottomWidget () {
140154 List <Widget > bottomWidget = (bottomStatusModel == null )
141155 ? []
142156 : < Widget > [
143- new FlatButton (
144- onPressed: () {
145- CommonUtils .showLoadingDialog (context);
146- return ReposDao .doRepositoryStarDao (userName, reposName, bottomStatusModel.star).then ((result) {
147- _refresh ();
148- Navigator .pop (context);
149- });
150- },
151- child: new GSYIConText (
152- bottomStatusModel.starIcon,
153- bottomStatusModel.starText,
154- GSYConstant .smallText,
155- Color (GSYColors .primaryValue),
156- 15.0 ,
157- padding: 5.0 ,
158- mainAxisAlignment: MainAxisAlignment .center,
159- )),
160- new FlatButton (
161- onPressed: () {
162- CommonUtils .showLoadingDialog (context);
163- return ReposDao .doRepositoryWatchDao (userName, reposName, bottomStatusModel.watch).then ((result) {
164- _refresh ();
165- Navigator .pop (context);
166- });
167- },
168- child: new GSYIConText (
169- bottomStatusModel.watchIcon,
170- bottomStatusModel.watchText,
171- GSYConstant .smallText,
172- Color (GSYColors .primaryValue),
173- 15.0 ,
174- padding: 5.0 ,
175- mainAxisAlignment: MainAxisAlignment .center,
176- )),
177- new FlatButton (
178- onPressed: () {
179- CommonUtils .showLoadingDialog (context);
180- return ReposDao .createForkDao (userName, reposName).then ((result) {
181- _refresh ();
182- Navigator .pop (context);
183- });
184- },
185- child: new GSYIConText (
186- GSYICons .REPOS_ITEM_FORK ,
187- "fork" ,
188- GSYConstant .smallText,
189- Color (GSYColors .primaryValue),
190- 15.0 ,
191- padding: 5.0 ,
192- mainAxisAlignment: MainAxisAlignment .center,
193- )),
157+ _renderBottomItem (bottomStatusModel.starText, bottomStatusModel.starIcon, () {
158+ CommonUtils .showLoadingDialog (context);
159+ return ReposDao .doRepositoryStarDao (userName, reposName, bottomStatusModel.star).then ((result) {
160+ _refresh ();
161+ Navigator .pop (context);
162+ });
163+ }),
164+ _renderBottomItem (bottomStatusModel.watchText, bottomStatusModel.watchIcon, () {
165+ CommonUtils .showLoadingDialog (context);
166+ return ReposDao .doRepositoryWatchDao (userName, reposName, bottomStatusModel.watch).then ((result) {
167+ _refresh ();
168+ Navigator .pop (context);
169+ });
170+ }),
171+ _renderBottomItem ("fork" , GSYICons .REPOS_ITEM_FORK , () {
172+ CommonUtils .showLoadingDialog (context);
173+ return ReposDao .createForkDao (userName, reposName).then ((result) {
174+ _refresh ();
175+ Navigator .pop (context);
176+ });
177+ }),
194178 _renderBranchPopItem (branchControl.currentBranch, branchList, (value) {
195179 setState (() {
196180 branchControl.currentBranch = value;
@@ -210,6 +194,35 @@ class _RepositoryDetailPageState extends State<RepositoryDetailPage> {
210194 return bottomWidget;
211195 }
212196
197+ ///无奈之举,只能pageView配合tabbar,通过control同步
198+ ///TabView 配合tabbar 在四个页面上问题太多
199+ _renderTabItem () {
200+ var itemList = [
201+ GSYStrings .repos_tab_info,
202+ GSYStrings .repos_tab_readme,
203+ GSYStrings .repos_tab_issue,
204+ GSYStrings .repos_tab_file,
205+ ];
206+ renderItem (String item, int i) {
207+ return new FlatButton (
208+ padding: EdgeInsets .all (0.0 ),
209+ onPressed: () {
210+ topPageControl.jumpTo (MediaQuery .of (context).size.width * i);
211+ },
212+ child: new Text (
213+ item,
214+ style: GSYConstant .smallTextWhite,
215+ maxLines: 1 ,
216+ ));
217+ }
218+
219+ List <Widget > list = new List ();
220+ for (int i = 0 ; i < itemList.length; i++ ) {
221+ list.add (renderItem (itemList[i], i));
222+ }
223+ return list;
224+ }
225+
213226 @override
214227 void initState () {
215228 super .initState ();
@@ -224,50 +237,7 @@ class _RepositoryDetailPageState extends State<RepositoryDetailPage> {
224237 return new GSYTabBarWidget (
225238 type: GSYTabBarWidget .TOP_TAB ,
226239 tarWidgetControl: tarBarControl,
227- tabItems: [
228- ///无奈之举,只能pageView配合tabbar,通过control同步
229- ///TabView 配合tabbar 在四个页面上问题太多
230- new FlatButton (
231- padding: EdgeInsets .all (0.0 ),
232- onPressed: () {
233- topPageControl.jumpTo (0.0 );
234- },
235- child: new Text (
236- GSYStrings .repos_tab_info,
237- style: GSYConstant .smallTextWhite,
238- maxLines: 1 ,
239- )),
240- new FlatButton (
241- padding: EdgeInsets .all (0.0 ),
242- onPressed: () {
243- topPageControl.jumpTo (MediaQuery .of (context).size.width);
244- },
245- child: new Text (
246- GSYStrings .repos_tab_readme,
247- style: GSYConstant .smallTextWhite,
248- maxLines: 1 ,
249- )),
250- new FlatButton (
251- padding: EdgeInsets .all (0.0 ),
252- onPressed: () {
253- topPageControl.jumpTo (MediaQuery .of (context).size.width * 2 );
254- },
255- child: new Text (
256- GSYStrings .repos_tab_issue,
257- style: GSYConstant .smallTextWhite,
258- maxLines: 1 ,
259- )),
260- new FlatButton (
261- padding: EdgeInsets .all (0.0 ),
262- onPressed: () {
263- topPageControl.jumpTo (MediaQuery .of (context).size.width * 3 );
264- },
265- child: new Text (
266- GSYStrings .repos_tab_file,
267- style: GSYConstant .smallTextWhite,
268- maxLines: 1 ,
269- )),
270- ],
240+ tabItems: _renderTabItem (),
271241 tabViews: [
272242 new ReposDetailInfoPage (reposDetailInfoPageControl, userName, reposName, branchControl, key: infoListKey),
273243 new RepositoryDetailReadmePage (userName, reposName, branchControl, key: readmeKey),
0 commit comments