2019-02-03 16:10:10 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2019-02-04 14:38:29 +01:00
|
|
|
import 'package:flutter/cupertino.dart';
|
2019-02-03 16:10:10 +01:00
|
|
|
import '../utils/utils.dart';
|
|
|
|
import '../screens/repo.dart';
|
|
|
|
import 'link.dart';
|
|
|
|
|
|
|
|
class RepoItem extends StatelessWidget {
|
|
|
|
final Map<String, dynamic> item;
|
|
|
|
|
|
|
|
RepoItem(this.item);
|
|
|
|
|
2019-02-04 11:32:39 +01:00
|
|
|
IconData _buildIconData() {
|
|
|
|
if (item['isPrivate']) {
|
|
|
|
return Octicons.lock;
|
|
|
|
}
|
|
|
|
if (item['isFork']) {
|
|
|
|
return Octicons.repo_forked;
|
|
|
|
}
|
|
|
|
return Octicons.repo;
|
|
|
|
}
|
|
|
|
|
2019-02-03 16:10:10 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Link(
|
2019-02-07 12:17:29 +01:00
|
|
|
screenBuilder: (_) => RepoScreen(item['owner']['login'], item['name']),
|
2019-02-03 16:10:10 +01:00
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.all(10),
|
2019-02-04 11:32:39 +01:00
|
|
|
child: Row(
|
2019-02-03 16:10:10 +01:00
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
2019-02-04 11:32:39 +01:00
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
2019-02-03 16:10:10 +01:00
|
|
|
children: <Widget>[
|
2019-02-04 11:32:39 +01:00
|
|
|
Text(
|
2019-02-09 06:42:18 +01:00
|
|
|
item['owner']['login'] + '/' + item['name'],
|
2019-02-04 11:32:39 +01:00
|
|
|
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 15),
|
|
|
|
),
|
|
|
|
Padding(padding: EdgeInsets.only(top: 6)),
|
2019-02-09 06:29:44 +01:00
|
|
|
Text(item['description'] ?? 'No description provided yet'),
|
2019-02-04 11:32:39 +01:00
|
|
|
Padding(padding: EdgeInsets.only(top: 6)),
|
|
|
|
DefaultTextStyle(
|
|
|
|
style: TextStyle(color: Colors.black54, fontSize: 13),
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Icon(Octicons.star, size: 14, color: Colors.black54),
|
|
|
|
Text(item['stargazers']['totalCount'].toString()),
|
|
|
|
Padding(padding: EdgeInsets.only(left: 16)),
|
|
|
|
Icon(Octicons.repo_forked,
|
|
|
|
size: 14, color: Colors.black54),
|
|
|
|
Text(item['forks']['totalCount'].toString()),
|
|
|
|
Padding(padding: EdgeInsets.only(left: 16)),
|
2019-02-09 06:29:44 +01:00
|
|
|
item['primaryLanguage'] == null
|
|
|
|
? Container()
|
|
|
|
: Row(children: <Widget>[
|
|
|
|
Container(
|
|
|
|
width: 10,
|
|
|
|
height: 10,
|
|
|
|
decoration: new BoxDecoration(
|
|
|
|
color: convertColor(
|
|
|
|
item['primaryLanguage']['color']),
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Padding(padding: EdgeInsets.only(left: 4)),
|
|
|
|
Text(item['primaryLanguage']['name']),
|
|
|
|
]),
|
2019-02-04 11:32:39 +01:00
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
2019-02-03 16:10:10 +01:00
|
|
|
],
|
|
|
|
),
|
2019-02-04 11:32:39 +01:00
|
|
|
),
|
|
|
|
Padding(padding: EdgeInsets.only(left: 4)),
|
|
|
|
Icon(_buildIconData(), size: 20, color: Colors.black54),
|
2019-02-03 16:10:10 +01:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|