From 08e7c99c6431f0152ccb7dbe6b0239e2b8757c42 Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Thu, 12 Sep 2019 21:19:17 +0800 Subject: [PATCH] feat: add issue, pull request and commit entry --- lib/screens/commits.dart | 1 + lib/screens/repo.dart | 80 +++++++++++++++++++++++++++++++++++++--- pubspec.yaml | 1 + 3 files changed, 77 insertions(+), 5 deletions(-) diff --git a/lib/screens/commits.dart b/lib/screens/commits.dart index b6b95cd..a1cc2f9 100644 --- a/lib/screens/commits.dart +++ b/lib/screens/commits.dart @@ -20,6 +20,7 @@ class CommitsScreen extends StatelessWidget { if (cursor != null) { params += ', after: "$cursor"'; } + // TODO: Specify branch var data = await Provider.of(context).query(''' { repository(owner: "$owner", name: "$name") { diff --git a/lib/screens/repo.dart b/lib/screens/repo.dart index bf97d71..0e29bbf 100644 --- a/lib/screens/repo.dart +++ b/lib/screens/repo.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'package:filesize/filesize.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:git_touch/models/settings.dart'; @@ -95,6 +96,10 @@ class RepoScreen extends StatelessWidget { text } } + licenseInfo { + name + nickname + } } } '''); @@ -218,13 +223,78 @@ class RepoScreen extends StatelessWidget { text: Text(payload['primaryLanguage'] == null ? 'Unknown' : payload['primaryLanguage']['name']), - rightWidget: Icon( - CupertinoIcons.right_chevron, - size: 18, - color: PrimerColors.gray300, + rightWidget: Row( + children: [ + Text(filesize(payload['languages']['totalSize'] as int)), + Icon( + CupertinoIcons.right_chevron, + size: 18, + color: PrimerColors.gray300, + ), + ], ), screenBuilder: (_) => ObjectScreen(owner: owner, name: name), - ) + ), + TableViewItem( + leftWidget: Icon(Octicons.issue_opened, size: 20), + text: Text('Issues'), + rightWidget: Row( + children: [ + Text(payload['issues']['totalCount'].toString()), + Icon( + CupertinoIcons.right_chevron, + size: 18, + color: PrimerColors.gray300, + ), + ], + ), + screenBuilder: (_) => IssuesScreen(owner: owner, name: name), + ), + TableViewItem( + leftWidget: Icon(Octicons.git_pull_request, size: 20), + text: Text('Pull requests'), + rightWidget: Row( + children: [ + Text(payload['pullRequests']['totalCount'].toString()), + Icon( + CupertinoIcons.right_chevron, + size: 18, + color: PrimerColors.gray300, + ), + ], + ), + screenBuilder: (_) => + IssuesScreen(owner: owner, name: name, isPullRequest: true), + ), + ]), + BorderView(height: 10), + TableView(items: [ + TableViewItem( + leftWidget: Icon(Octicons.law, size: 20), + text: Text('License'), + rightWidget: Text(payload['licenseInfo'] == null + ? 'Unknown' + : (payload['licenseInfo']['nickname'] ?? + payload['licenseInfo']['name']) + .toString()), + ), + TableViewItem( + leftWidget: Icon(Octicons.history, size: 20), + text: Text('Commits'), + rightWidget: Row( + children: [ + Text(payload['defaultBranchRef']['target']['history'] + ['totalCount'] + .toString()), + Icon( + CupertinoIcons.right_chevron, + size: 18, + color: PrimerColors.gray300, + ), + ], + ), + screenBuilder: (_) => CommitsScreen(owner, name), + ), ]), BorderView(height: 10), if (payload['object'] != null) diff --git a/pubspec.yaml b/pubspec.yaml index de391a9..147cf6b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -33,6 +33,7 @@ dependencies: timeago: ^2.0.18 provider: ^3.1.0 seti: ^0.2.0 + filesize: ^1.0.4 primer: git: url: git://github.com/pd4d10/primer-flutter