diff --git a/lib/screens/repo.dart b/lib/screens/repo.dart index 847afa7..2213db7 100644 --- a/lib/screens/repo.dart +++ b/lib/screens/repo.dart @@ -35,6 +35,7 @@ class RepoScreen extends StatelessWidget { __typename login url + avatarUrl } name isPrivate diff --git a/lib/screens/trending.dart b/lib/screens/trending.dart index c1cffee..820cac9 100644 --- a/lib/screens/trending.dart +++ b/lib/screens/trending.dart @@ -1,5 +1,6 @@ import 'dart:convert'; import 'package:flutter/material.dart'; +import 'package:git_touch/utils/utils.dart'; import 'package:http/http.dart' as http; import '../scaffolds/refresh.dart'; import '../widgets/repo_item.dart'; @@ -16,9 +17,7 @@ class _TrendingScreenState extends State { return items.map((item) { return { - 'owner': { - 'login': item['author'], - }, + 'owner': {'login': item['author'], 'avatarUrl': item['avatar']}, 'name': item['name'], 'description': item['description'], 'stargazers': { @@ -46,13 +45,11 @@ class _TrendingScreenState extends State { onRefresh: _fetchTrendingRepos, bodyBuilder: (payload) { return Column( - children: payload.map((repo) { - return Container( - decoration: BoxDecoration( - border: Border(bottom: BorderSide(color: Colors.black12))), - child: RepoItem(repo), - ); - }).toList(), + crossAxisAlignment: CrossAxisAlignment.stretch, + children: join( + BorderView(), + payload.map((item) => RepoItem(item)).toList(), + ), ); }, ); diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index c1da43b..bdec2e1 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -75,6 +75,7 @@ var warningSpan = var repoChunk = ''' owner { login + avatarUrl } name description diff --git a/lib/widgets/repo_item.dart b/lib/widgets/repo_item.dart index 8b5d9d6..f9b3009 100644 --- a/lib/widgets/repo_item.dart +++ b/lib/widgets/repo_item.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; +import 'package:git_touch/widgets/avatar.dart'; import 'package:primer/primer.dart'; import '../utils/utils.dart'; import '../screens/repo.dart'; @@ -29,56 +30,87 @@ class RepoItem extends StatelessWidget { child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ + Avatar(url: payload['owner']['avatarUrl'], size: 12), + SizedBox(width: 8), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: join(SizedBox(height: 8), [ Text( - (showOwner ? (payload['owner']['login'] + '/') : '') + + (showOwner ? (payload['owner']['login'] + ' / ') : '') + payload['name'], - style: TextStyle(fontWeight: FontWeight.w600, fontSize: 16), + style: TextStyle( + fontWeight: FontWeight.w500, + fontSize: 16, + color: PrimerColors.blue500, + ), ), - SizedBox(height: 6), - Text( - payload['description'] ?? 'No description provided yet', - style: TextStyle(color: PrimerColors.gray600, fontSize: 14), - ), - SizedBox(height: 6), + payload['description'] == null || + (payload['description'] as String).isEmpty + ? null + : Text( + payload['description'], + style: TextStyle( + color: PrimerColors.gray600, fontSize: 14), + ), DefaultTextStyle( - style: TextStyle(color: PrimerColors.gray600, fontSize: 13), + style: TextStyle( + color: PrimerColors.gray600, + fontSize: 13, + fontWeight: FontWeight.w500, + ), child: Row( children: [ - Icon(Octicons.star, - size: 14, color: PrimerColors.gray600), - Text(payload['stargazers']['totalCount'].toString()), - SizedBox(width: 16), - Icon(Octicons.repo_forked, - size: 14, color: PrimerColors.gray600), - Text(payload['forks']['totalCount'].toString()), - SizedBox(width: 16), - payload['primaryLanguage'] == null - ? Container() - : Row(children: [ - Container( - width: 10, - height: 10, - decoration: BoxDecoration( - color: convertColor( - payload['primaryLanguage']['color']), - shape: BoxShape.circle, - ), - ), - Padding(padding: EdgeInsets.only(left: 4)), - Text(payload['primaryLanguage']['name']), - ]), + SizedBox( + width: 100, + child: Row(children: [ + Container( + width: 10, + height: 10, + decoration: BoxDecoration( + color: convertColor( + payload['primaryLanguage'] == null + ? null + : payload['primaryLanguage']['color']), + shape: BoxShape.circle, + ), + ), + SizedBox(width: 4), + Text(payload['primaryLanguage'] == null + ? 'Unknown' + : payload['primaryLanguage']['name']), + ]), + ), + SizedBox( + width: 100, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Icon(Octicons.star, + size: 14, color: PrimerColors.gray600), + Text( + payload['stargazers']['totalCount'].toString()), + ], + ), + ), + SizedBox( + width: 100, + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Icon(Octicons.repo_forked, + size: 14, color: PrimerColors.gray600), + Text(payload['forks']['totalCount'].toString()) + ], + ), + ), ], ), ) - ], + ]), ), ), - Padding(padding: EdgeInsets.only(left: 4)), - Icon(_buildIconData(), size: 20, color: Colors.black54), + Icon(_buildIconData(), size: 18, color: PrimerColors.gray600), ], ), );