From f9fcf42c98a7c9006e03cc4056dff4622c4d532e Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Tue, 24 Sep 2019 00:34:51 +0800 Subject: [PATCH] feat: add releases --- lib/screens/repository.dart | 12 +++++++++++- lib/utils/utils.dart | 1 - lib/widgets/table_view.dart | 9 +++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/screens/repository.dart b/lib/screens/repository.dart index c187ef7..a959506 100644 --- a/lib/screens/repository.dart +++ b/lib/screens/repository.dart @@ -1,5 +1,4 @@ import 'dart:convert'; - import 'package:filesize/filesize.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; @@ -76,6 +75,9 @@ class RepositoryScreen extends StatelessWidget { pullRequests(states: OPEN) { totalCount } + releases { + totalCount + } languages(first: 10, orderBy: {field: SIZE, direction: DESC}) { totalSize edges { @@ -310,6 +312,14 @@ class RepositoryScreen extends StatelessWidget { }, ), ], + if ((payload['releases']['totalCount'] as int) > 0) + TableViewItem( + leftIconData: Octicons.tag, + text: Text('Releases'), + rightWidget: Text( + (payload['releases']['totalCount'] as int).toString()), + url: payload['url'] + '/releases', + ), TableViewItem( leftIconData: Octicons.law, text: Text('License'), diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index e8508be..9631d42 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -1,5 +1,4 @@ import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/gestures.dart'; diff --git a/lib/widgets/table_view.dart b/lib/widgets/table_view.dart index db3f301..fe859ad 100644 --- a/lib/widgets/table_view.dart +++ b/lib/widgets/table_view.dart @@ -28,6 +28,7 @@ class TableViewItem { final Widget leftWidget; final Widget rightWidget; final void Function() onTap; + final String url; final WidgetBuilder screenBuilder; final bool hideRightChevron; @@ -37,6 +38,7 @@ class TableViewItem { this.leftWidget, this.rightWidget, this.onTap, + this.url, this.screenBuilder, this.hideRightChevron = false, }) : assert(leftIconData == null || leftWidget == null); @@ -86,7 +88,9 @@ class TableView extends StatelessWidget { ), SizedBox(width: 6) ], - if ((item.onTap != null || item.screenBuilder != null) && + if ((item.onTap != null || + item.screenBuilder != null || + item.url != null) && !item.hideRightChevron) Icon(CupertinoIcons.right_chevron, size: 20, color: PrimerColors.gray300) @@ -98,12 +102,13 @@ class TableView extends StatelessWidget { ), ); - if (item.onTap == null && item.screenBuilder == null) { + if (item.onTap == null && item.screenBuilder == null && item.url == null) { return widget; } return Link( onTap: item.onTap, screenBuilder: item.screenBuilder, + url: item.url, child: widget, ); }