feat: repo item style
This commit is contained in:
parent
814b255f3a
commit
354520d9c1
|
@ -35,6 +35,7 @@ class RepoScreen extends StatelessWidget {
|
|||
__typename
|
||||
login
|
||||
url
|
||||
avatarUrl
|
||||
}
|
||||
name
|
||||
isPrivate
|
||||
|
|
|
@ -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<TrendingScreen> {
|
|||
|
||||
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<TrendingScreen> {
|
|||
onRefresh: _fetchTrendingRepos,
|
||||
bodyBuilder: (payload) {
|
||||
return Column(
|
||||
children: payload.map<Widget>((repo) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(bottom: BorderSide(color: Colors.black12))),
|
||||
child: RepoItem(repo),
|
||||
);
|
||||
}).toList(),
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: join(
|
||||
BorderView(),
|
||||
payload.map<Widget>((item) => RepoItem(item)).toList(),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
|
@ -75,6 +75,7 @@ var warningSpan =
|
|||
var repoChunk = '''
|
||||
owner {
|
||||
login
|
||||
avatarUrl
|
||||
}
|
||||
name
|
||||
description
|
||||
|
|
|
@ -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: <Widget>[
|
||||
Avatar(url: payload['owner']['avatarUrl'], size: 12),
|
||||
SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
children: join(SizedBox(height: 8), <Widget>[
|
||||
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: <Widget>[
|
||||
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: <Widget>[
|
||||
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: <Widget>[
|
||||
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: <Widget>[
|
||||
Icon(Octicons.star,
|
||||
size: 14, color: PrimerColors.gray600),
|
||||
Text(
|
||||
payload['stargazers']['totalCount'].toString()),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
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),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue