@@ -40,16 +40,58 @@ class ReposHeaderItem extends StatelessWidget {
4040 );
4141 }
4242
43- @override
44- Widget build (BuildContext context) {
43+ _renderTopicItem (String item) {
44+ return new RawMaterialButton (
45+ onPressed: () {},
46+ materialTapTargetSize: MaterialTapTargetSize .shrinkWrap,
47+ padding: const EdgeInsets .all (0.0 ),
48+ constraints: const BoxConstraints (minWidth: 0.0 , minHeight: 0.0 ),
49+ child: new Container (
50+ padding: EdgeInsets .only (left: 5.0 , right: 5.0 , top: 2.5 , bottom: 2.5 ),
51+ decoration: new BoxDecoration (
52+ borderRadius: BorderRadius .all (Radius .circular (4.0 )),
53+ color: Colors .white30,
54+ border: new Border .all (color: Colors .white30, width: 0.0 ),
55+ ),
56+ child: new Text (
57+ item,
58+ style: GSYConstant .subLightSmallText,
59+ ),
60+ ));
61+ }
62+
63+ ///话题组控件
64+ _renderTopicGroup () {
65+ if (reposHeaderViewModel.topics == null || reposHeaderViewModel.topics.length == 0 ) {
66+ return Container ();
67+ }
68+ List <Widget > list = new List ();
69+ for (String item in reposHeaderViewModel.topics) {
70+ list.add (_renderTopicItem (item));
71+ }
72+ return new Container (
73+ alignment: Alignment .topLeft,
74+ child: Wrap (
75+ spacing: 10.0 ,
76+ runSpacing: 5.0 ,
77+ children: list,
78+ ),
79+ );
80+ }
81+
82+ ///仓库创建和提交状态信息
83+ _getInfoText () {
4584 String createStr = reposHeaderViewModel.repositoryIsFork
4685 ? GSYStrings .repos_fork_at + reposHeaderViewModel.repositoryParentName + '\n '
4786 : GSYStrings .repos_create_at + reposHeaderViewModel.created_at + "\n " ;
4887
4988 String updateStr = GSYStrings .repos_last_commit + reposHeaderViewModel.push_at;
5089
51- String infoText = createStr + ((reposHeaderViewModel.push_at != null ) ? updateStr : '' );
90+ return createStr + ((reposHeaderViewModel.push_at != null ) ? updateStr : '' );
91+ }
5292
93+ @override
94+ Widget build (BuildContext context) {
5395 return new Column (
5496 children: < Widget > [
5597 new GSYCardItem (
@@ -123,7 +165,7 @@ class ReposHeaderItem extends StatelessWidget {
123165 materialTapTargetSize: MaterialTapTargetSize .shrinkWrap,
124166 padding: const EdgeInsets .all (0.0 ),
125167 constraints: const BoxConstraints (minWidth: 0.0 , minHeight: 0.0 ),
126- child: new Text (infoText ,
168+ child: new Text (_getInfoText () ,
127169 style: reposHeaderViewModel.repositoryIsFork ? GSYConstant .actionLightSmallText : GSYConstant .subLightSmallText),
128170 ),
129171 ),
@@ -190,6 +232,7 @@ class ReposHeaderItem extends StatelessWidget {
190232 ),
191233 ],
192234 )),
235+ _renderTopicGroup (),
193236 ],
194237 ),
195238 ),
@@ -226,6 +269,7 @@ class ReposHeaderViewModel {
226269 String created_at = "" ;
227270 String push_at = "" ;
228271 String license = "" ;
272+ List <String > topics;
229273 int allIssueCount = 0 ;
230274 int openIssuesCount = 0 ;
231275 bool repositoryStared = false ;
@@ -243,6 +287,7 @@ class ReposHeaderViewModel {
243287 this .ownerPic = map.owner.avatar_url;
244288 this .repositoryName = reposName;
245289 this .allIssueCount = map.allIssueCount;
290+ this .topics = map.topics;
246291 this .openIssuesCount = map.openIssuesCount;
247292 this .repositoryStar = map.watchersCount != null ? map.watchersCount.toString () : "" ;
248293 this .repositoryFork = map.forksCount != null ? map.forksCount.toString () : "" ;
0 commit comments