From 1c5b62430ecaf32c4cd3f4dba77495d8d93066d8 Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Sun, 22 Sep 2019 01:23:38 +0800 Subject: [PATCH] feat: organization members --- lib/screens/organization.dart | 16 +++++++++++++++- lib/screens/users.dart | 2 +- lib/utils/utils.dart | 21 --------------------- lib/widgets/repo_item.dart | 21 +++++++++++++++++++++ lib/widgets/user_item.dart | 6 ++++++ 5 files changed, 43 insertions(+), 23 deletions(-) diff --git a/lib/screens/organization.dart b/lib/screens/organization.dart index 8816d83..d317cb9 100644 --- a/lib/screens/organization.dart +++ b/lib/screens/organization.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; +import 'package:git_touch/screens/users.dart'; import 'package:git_touch/widgets/app_bar_title.dart'; +import 'package:git_touch/widgets/entry_item.dart'; import 'package:git_touch/widgets/table_view.dart'; import 'package:git_touch/widgets/user_item.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -58,6 +60,7 @@ class OrganizationScreen extends StatelessWidget { location email websiteUrl + url pinnedItems(first: $pageSize) { nodes { ... on Repository { @@ -65,7 +68,9 @@ class OrganizationScreen extends StatelessWidget { } } } - url + membersWithRole { + totalCount + } } } '''); @@ -98,6 +103,15 @@ class OrganizationScreen extends StatelessWidget { avatarUrl: payload['avatarUrl'], bio: payload['description'], ), + borderView, + Row(children: [ + EntryItem( + count: payload['membersWithRole']['totalCount'], + text: 'Members', + screenBuilder: (context) => + UsersScreen(type: UsersScreenType.orgs, login: login), + ), + ]), borderView1, TableView( hasIcon: true, diff --git a/lib/screens/users.dart b/lib/screens/users.dart index da95ba3..b7c4e89 100644 --- a/lib/screens/users.dart +++ b/lib/screens/users.dart @@ -39,7 +39,7 @@ class UsersScreen extends StatelessWidget { return Tuple3( 'repository', 'owner: "$login", name: "$name"', 'watchers'); case UsersScreenType.orgs: - return Tuple3('', '', ''); // FIXME: + return Tuple3('organization', 'login: "$login"', 'membersWithRole'); default: throw 'Should not be here'; } diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index af7e046..2b3246c 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -85,27 +85,6 @@ var createWarning = var warningSpan = TextSpan(text: 'xxx', style: TextStyle(color: Colors.redAccent)); -var repoChunk = ''' -owner { - login - avatarUrl -} -name -description -isPrivate -isFork -stargazers { - totalCount -} -forks { - totalCount -} -primaryLanguage { - color - name -} -'''; - List join(T seperator, List xs) { List result = []; xs.asMap().forEach((index, x) { diff --git a/lib/widgets/repo_item.dart b/lib/widgets/repo_item.dart index a7388fe..fe1cb21 100644 --- a/lib/widgets/repo_item.dart +++ b/lib/widgets/repo_item.dart @@ -6,6 +6,27 @@ import '../utils/utils.dart'; import '../screens/repo.dart'; import 'link.dart'; +const repoChunk = ''' +owner { + login + avatarUrl +} +name +description +isPrivate +isFork +stargazers { + totalCount +} +forks { + totalCount +} +primaryLanguage { + color + name +} +'''; + class RepoItem extends StatelessWidget { final Map payload; final bool inRepoScreen; diff --git a/lib/widgets/user_item.dart b/lib/widgets/user_item.dart index c3a8bfc..c3a72f7 100644 --- a/lib/widgets/user_item.dart +++ b/lib/widgets/user_item.dart @@ -4,6 +4,12 @@ import 'package:git_touch/widgets/avatar.dart'; import 'package:git_touch/widgets/link.dart'; import 'package:primer/primer.dart'; +const userGqlChunk = ''' + name + avatarUrl + bio +'''; + class UserItem extends StatelessWidget { final String login; final String name;