From 3f2b9ed56621bf14ec55d6e65ccc302d12f8ed0e Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Fri, 27 Sep 2019 02:04:27 +0800 Subject: [PATCH] feat: add topics to repo screen --- lib/screens/repository.dart | 8 ++++++++ lib/widgets/repository_item.dart | 26 +++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/lib/screens/repository.dart b/lib/screens/repository.dart index 3e5a94f..93ad572 100644 --- a/lib/screens/repository.dart +++ b/lib/screens/repository.dart @@ -108,6 +108,14 @@ class RepositoryScreen extends StatelessWidget { name spdxId } + repositoryTopics(first: 100) { + nodes { + url + topic { + name + } + } + } } } '''); diff --git a/lib/widgets/repository_item.dart b/lib/widgets/repository_item.dart index c4b9def..713146b 100644 --- a/lib/widgets/repository_item.dart +++ b/lib/widgets/repository_item.dart @@ -94,6 +94,30 @@ class RepositoryItem extends StatelessWidget { ); } + Widget _buildTopics() { + // TODO: link + return Wrap( + spacing: 4, + runSpacing: 4, + children: (payload['repositoryTopics']['nodes'] as List).map((node) { + return Container( + padding: EdgeInsets.symmetric(vertical: 4, horizontal: 8), + decoration: BoxDecoration( + color: PrimerColors.blue000, + borderRadius: BorderRadius.all(Radius.circular(4)), + ), + child: Text( + node['topic']['name'], + style: TextStyle( + fontSize: 12, + color: PrimerColors.blue500, + ), + ), + ); + }).toList(), + ); + } + @override Widget build(BuildContext context) { var widget = Container( @@ -135,7 +159,7 @@ class RepositoryItem extends StatelessWidget { color: PrimerColors.gray700, fontSize: inRepoScreen ? 15 : 14), ), - if (!inRepoScreen) _buildStatus(), + if (inRepoScreen) _buildTopics() else _buildStatus(), ]), ), ),