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-11-03 16:33:24 +01:00
|
|
|
import 'package:git_touch/models/theme.dart';
|
2019-09-08 15:20:12 +02:00
|
|
|
import 'package:git_touch/widgets/avatar.dart';
|
2019-11-03 16:33:24 +01:00
|
|
|
import 'package:provider/provider.dart';
|
2019-02-03 16:10:10 +01:00
|
|
|
import '../utils/utils.dart';
|
|
|
|
import 'link.dart';
|
|
|
|
|
2019-09-23 12:28:33 +02:00
|
|
|
class RepositoryItem extends StatelessWidget {
|
2019-11-02 10:50:04 +01:00
|
|
|
final String owner;
|
|
|
|
final String avatarUrl;
|
|
|
|
final String name;
|
|
|
|
final String description;
|
|
|
|
final IconData iconData;
|
|
|
|
final int starCount;
|
|
|
|
final int forkCount;
|
|
|
|
final String primaryLanguageName;
|
|
|
|
final String primaryLanguageColor;
|
2020-01-11 12:25:33 +01:00
|
|
|
final String note;
|
2019-12-06 14:51:33 +01:00
|
|
|
|
2020-01-11 10:25:01 +01:00
|
|
|
RepositoryItem(
|
|
|
|
this.owner,
|
|
|
|
this.avatarUrl,
|
|
|
|
this.name,
|
|
|
|
this.description,
|
2020-01-11 12:52:17 +01:00
|
|
|
this.starCount,
|
|
|
|
this.forkCount,
|
|
|
|
this.primaryLanguageName,
|
|
|
|
this.primaryLanguageColor,
|
|
|
|
this.note, {
|
2020-01-11 10:25:01 +01:00
|
|
|
this.iconData,
|
2020-01-11 12:52:17 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
RepositoryItem.gh(
|
|
|
|
this.owner,
|
|
|
|
this.avatarUrl,
|
|
|
|
this.name,
|
|
|
|
this.description,
|
2020-01-11 10:25:01 +01:00
|
|
|
this.starCount,
|
|
|
|
this.forkCount,
|
|
|
|
this.primaryLanguageName,
|
|
|
|
this.primaryLanguageColor,
|
2020-01-11 12:52:17 +01:00
|
|
|
this.note, {
|
|
|
|
bool isPrivate,
|
|
|
|
bool isFork,
|
|
|
|
}) : this.iconData = _buildIconData(isPrivate, isFork);
|
|
|
|
|
|
|
|
static IconData _buildIconData(bool isPrivate, bool isFork) {
|
|
|
|
if (isPrivate == true) return Octicons.lock;
|
|
|
|
if (isFork == true) return Octicons.repo_forked;
|
|
|
|
return null;
|
|
|
|
}
|
2019-02-04 11:32:39 +01:00
|
|
|
|
2019-02-03 16:10:10 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2019-11-05 14:22:41 +01:00
|
|
|
final theme = Provider.of<ThemeModel>(context);
|
2020-01-11 10:25:01 +01:00
|
|
|
return Link(
|
|
|
|
url: '/$owner/$name',
|
|
|
|
child: Container(
|
|
|
|
padding: CommonStyle.padding,
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
2020-01-11 10:57:22 +01:00
|
|
|
children: <Widget>[
|
2020-01-11 10:25:01 +01:00
|
|
|
Row(
|
|
|
|
children: <Widget>[
|
2020-01-11 10:57:22 +01:00
|
|
|
Avatar(
|
|
|
|
url: avatarUrl,
|
|
|
|
size: AvatarSize.small,
|
|
|
|
linkUrl: '/$owner',
|
|
|
|
),
|
|
|
|
SizedBox(width: 8),
|
2020-01-26 16:36:58 +01:00
|
|
|
Expanded(
|
|
|
|
child: Text.rich(
|
|
|
|
TextSpan(children: [
|
|
|
|
TextSpan(
|
|
|
|
text: '$owner / ',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 18,
|
2020-01-27 08:11:51 +01:00
|
|
|
color: theme.palette.primary,
|
2020-01-26 16:36:58 +01:00
|
|
|
),
|
2019-12-21 15:01:08 +01:00
|
|
|
),
|
2020-01-26 16:36:58 +01:00
|
|
|
TextSpan(
|
|
|
|
text: name,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 18,
|
2020-01-27 08:11:51 +01:00
|
|
|
color: theme.palette.primary,
|
2020-01-26 16:36:58 +01:00
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
),
|
|
|
|
// overflow: TextOverflow.ellipsis,
|
2020-01-11 10:25:01 +01:00
|
|
|
),
|
2020-01-26 16:36:58 +01:00
|
|
|
]),
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
),
|
2020-01-11 10:25:01 +01:00
|
|
|
),
|
2020-01-11 12:52:17 +01:00
|
|
|
if (iconData != null) ...[
|
|
|
|
SizedBox(width: 6),
|
|
|
|
DefaultTextStyle(
|
|
|
|
child: Icon(iconData,
|
2020-01-27 08:11:51 +01:00
|
|
|
size: 18, color: theme.palette.secondaryText),
|
|
|
|
style: TextStyle(color: theme.palette.secondaryText),
|
2020-01-11 12:52:17 +01:00
|
|
|
),
|
|
|
|
]
|
2020-01-11 10:25:01 +01:00
|
|
|
],
|
2019-12-21 09:16:17 +01:00
|
|
|
),
|
2020-01-11 12:25:33 +01:00
|
|
|
SizedBox(height: 8),
|
2020-01-11 10:57:22 +01:00
|
|
|
if (description != null && description.isNotEmpty) ...[
|
2020-01-11 10:25:01 +01:00
|
|
|
Text(
|
|
|
|
description,
|
|
|
|
style: TextStyle(
|
2020-01-27 08:11:51 +01:00
|
|
|
color: theme.palette.secondaryText,
|
2020-01-11 10:57:22 +01:00
|
|
|
fontSize: 16,
|
2020-01-11 10:25:01 +01:00
|
|
|
),
|
|
|
|
),
|
2020-01-11 10:57:22 +01:00
|
|
|
SizedBox(height: 10),
|
|
|
|
],
|
2020-01-11 12:25:33 +01:00
|
|
|
if (note != null) ...[
|
|
|
|
Text(
|
|
|
|
note,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14,
|
2020-01-27 08:11:51 +01:00
|
|
|
color: theme.palette.tertiaryText,
|
2020-01-11 12:25:33 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(height: 10),
|
|
|
|
],
|
2019-12-21 09:16:17 +01:00
|
|
|
DefaultTextStyle(
|
2020-01-27 08:11:51 +01:00
|
|
|
style: TextStyle(color: theme.palette.text, fontSize: 14),
|
2019-12-21 09:16:17 +01:00
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
2020-01-11 10:57:22 +01:00
|
|
|
if (primaryLanguageName != null) ...[
|
|
|
|
Container(
|
|
|
|
width: 12,
|
|
|
|
height: 12,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: convertColor(primaryLanguageColor),
|
|
|
|
shape: BoxShape.circle,
|
2019-12-21 15:01:08 +01:00
|
|
|
),
|
2019-11-05 14:22:41 +01:00
|
|
|
),
|
2020-01-11 10:57:22 +01:00
|
|
|
SizedBox(width: 4),
|
|
|
|
Text(
|
|
|
|
primaryLanguageName,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
2019-11-05 14:22:41 +01:00
|
|
|
),
|
2020-01-11 10:57:22 +01:00
|
|
|
SizedBox(width: 24),
|
|
|
|
],
|
|
|
|
if (starCount > 0) ...[
|
|
|
|
Icon(Octicons.star,
|
2020-01-27 08:11:51 +01:00
|
|
|
size: 16, color: theme.palette.text),
|
2020-01-11 10:57:22 +01:00
|
|
|
SizedBox(width: 2),
|
|
|
|
Text(numberFormat.format(starCount)),
|
|
|
|
SizedBox(width: 24),
|
|
|
|
],
|
|
|
|
if (forkCount > 0) ...[
|
|
|
|
Icon(Octicons.repo_forked,
|
2020-01-27 08:11:51 +01:00
|
|
|
size: 16, color: theme.palette.text),
|
2020-01-11 10:57:22 +01:00
|
|
|
SizedBox(width: 2),
|
|
|
|
Text(numberFormat.format(forkCount)),
|
|
|
|
],
|
2019-12-21 09:16:17 +01:00
|
|
|
],
|
2019-11-05 14:22:41 +01:00
|
|
|
),
|
2019-12-21 09:16:17 +01:00
|
|
|
),
|
2020-01-11 10:57:22 +01:00
|
|
|
],
|
2020-01-11 10:25:01 +01:00
|
|
|
),
|
2019-02-04 11:32:39 +01:00
|
|
|
),
|
2020-01-11 10:25:01 +01:00
|
|
|
],
|
|
|
|
),
|
2019-02-03 16:10:10 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|