1- import 'dart:async' ;
2-
31import 'package:flutter/material.dart' ;
42import 'package:gsy_github_app_flutter/common/config/Config.dart' ;
53import 'package:gsy_github_app_flutter/common/dao/ReposDao.dart' ;
@@ -44,6 +42,10 @@ class _RepositoryDetailPageState extends State<RepositoryDetailPage> {
4442
4543 final TarWidgetControl tarBarControl = new TarWidgetControl ();
4644
45+ String currentBranch = "master" ;
46+
47+ List <String > branchList = new List ();
48+
4749 _RepositoryDetailPageState (this .userName, this .reposName);
4850
4951 _getReposDetail () async {
@@ -72,11 +74,60 @@ class _RepositoryDetailPageState extends State<RepositoryDetailPage> {
7274 });
7375 }
7476
77+ _getBranchList () async {
78+ var result = await ReposDao .getBranchesDao (userName, reposName);
79+ if (result != null && result.result) {
80+ setState (() {
81+ branchList = result.data;
82+ });
83+ }
84+ }
85+
7586 _refresh () {
7687 this ._getReposDetail ();
7788 this ._getReposStatus ();
7889 }
7990
91+ _renderBranchPopItem (String data, List <String > list, onSelected) {
92+ if (list == null && list.length == 0 ) {
93+ return new Container (height: 0.0 , width: 0.0 );
94+ }
95+ return new Container (
96+ height: 30.0 ,
97+ child: new PopupMenuButton <String >(
98+ child: new FlatButton (
99+ onPressed: null ,
100+ color: Color (GSYColors .primaryValue),
101+ disabledColor: Color (GSYColors .primaryValue),
102+ child: new GSYIConText (
103+ Icons .arrow_drop_up,
104+ data,
105+ GSYConstant .smallTextWhite,
106+ Color (GSYColors .white),
107+ 30.0 ,
108+ padding: 3.0 ,
109+ mainAxisAlignment: MainAxisAlignment .center,
110+ ),
111+ ),
112+ onSelected: onSelected,
113+ itemBuilder: (BuildContext context) {
114+ return _renderHeaderPopItemChild (list);
115+ },
116+ ),
117+ );
118+ }
119+
120+ _renderHeaderPopItemChild (List <String > data) {
121+ List <PopupMenuEntry <String >> list = new List ();
122+ for (String item in data) {
123+ list.add (PopupMenuItem <String >(
124+ value: item,
125+ child: new Text (item),
126+ ));
127+ }
128+ return list;
129+ }
130+
80131 _getBottomWidget () {
81132 List <Widget > bottomWidget = (bottomStatusModel == null )
82133 ? []
@@ -132,18 +183,7 @@ class _RepositoryDetailPageState extends State<RepositoryDetailPage> {
132183 padding: 5.0 ,
133184 mainAxisAlignment: MainAxisAlignment .center,
134185 )),
135- new FlatButton (
136- onPressed: () {},
137- color: Color (GSYColors .primaryValue),
138- child: new GSYIConText (
139- Icons .arrow_drop_up,
140- "master" ,
141- GSYConstant .smallTextWhite,
142- Color (GSYColors .white),
143- 30.0 ,
144- padding: 3.0 ,
145- mainAxisAlignment: MainAxisAlignment .center,
146- ))
186+ _renderBranchPopItem (currentBranch, branchList, (value) {}),
147187 ];
148188 return bottomWidget;
149189 }
@@ -152,6 +192,7 @@ class _RepositoryDetailPageState extends State<RepositoryDetailPage> {
152192 void initState () {
153193 super .initState ();
154194 _refresh ();
195+ _getBranchList ();
155196 }
156197
157198 @override
0 commit comments