2020-05-14 07:28:12 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:git_touch/models/theme.dart';
|
|
|
|
import 'package:git_touch/utils/utils.dart';
|
|
|
|
import 'package:git_touch/widgets/avatar.dart';
|
|
|
|
import 'package:git_touch/widgets/link.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:timeago/timeago.dart' as timeago;
|
2020-10-08 08:49:46 +02:00
|
|
|
import 'package:github/github.dart' as github;
|
2020-05-14 07:28:12 +02:00
|
|
|
|
|
|
|
class GistsItem extends StatelessWidget {
|
2021-05-16 09:16:35 +02:00
|
|
|
final String? description;
|
2020-05-14 07:28:12 +02:00
|
|
|
final String login;
|
2021-05-16 09:16:35 +02:00
|
|
|
final List<String?> filenames;
|
|
|
|
final String? language;
|
|
|
|
final String? avatarUrl;
|
|
|
|
final DateTime? updatedAt;
|
|
|
|
final String? id;
|
2020-05-14 07:28:12 +02:00
|
|
|
|
|
|
|
GistsItem({
|
2021-05-16 09:16:35 +02:00
|
|
|
required this.description,
|
|
|
|
required this.login,
|
|
|
|
required this.filenames,
|
|
|
|
required this.language,
|
|
|
|
required this.avatarUrl,
|
|
|
|
required this.updatedAt,
|
|
|
|
required this.id,
|
2020-05-14 07:28:12 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final theme = Provider.of<ThemeModel>(context);
|
2021-05-16 09:16:35 +02:00
|
|
|
return LinkWidget(
|
2020-05-14 07:28:12 +02:00
|
|
|
url: '/github/$login/gists/$id',
|
|
|
|
child: Container(
|
|
|
|
padding: CommonStyle.padding,
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Avatar(
|
|
|
|
url: avatarUrl,
|
|
|
|
size: AvatarSize.small,
|
|
|
|
linkUrl: '/github/$login',
|
|
|
|
),
|
|
|
|
SizedBox(width: 8),
|
|
|
|
Expanded(
|
|
|
|
child: Text.rich(
|
|
|
|
TextSpan(children: [
|
|
|
|
TextSpan(
|
|
|
|
text: '$login / ',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 18,
|
|
|
|
color: theme.palette.primary,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
TextSpan(
|
2021-01-31 15:08:37 +01:00
|
|
|
text: filenames[0],
|
2020-05-14 07:28:12 +02:00
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 18,
|
|
|
|
color: theme.palette.primary,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
]),
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
SizedBox(height: 8),
|
2021-05-16 09:16:35 +02:00
|
|
|
if (description != null && description!.isNotEmpty) ...[
|
2020-05-14 07:28:12 +02:00
|
|
|
Text(
|
2021-05-16 09:16:35 +02:00
|
|
|
description!,
|
2020-05-14 07:28:12 +02:00
|
|
|
style: TextStyle(
|
|
|
|
color: theme.palette.secondaryText,
|
|
|
|
fontSize: 16,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(height: 10),
|
|
|
|
],
|
|
|
|
if (updatedAt != null) ...[
|
|
|
|
Text(
|
2021-05-16 09:16:35 +02:00
|
|
|
'Updated ${timeago.format(updatedAt!)}',
|
2020-05-14 07:28:12 +02:00
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
color: theme.palette.tertiaryText,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(height: 10),
|
|
|
|
],
|
|
|
|
DefaultTextStyle(
|
|
|
|
style: TextStyle(color: theme.palette.text, fontSize: 14),
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
if (language != null)
|
|
|
|
Container(
|
|
|
|
width: 12,
|
|
|
|
height: 12,
|
|
|
|
decoration: BoxDecoration(
|
2021-05-16 09:16:35 +02:00
|
|
|
color: convertColor(
|
|
|
|
github.languageColors[language!]),
|
2020-05-14 07:28:12 +02:00
|
|
|
shape: BoxShape.circle,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(width: 4),
|
|
|
|
if (language != null)
|
|
|
|
Text(
|
2021-05-16 09:16:35 +02:00
|
|
|
language!,
|
2020-05-14 07:28:12 +02:00
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
),
|
|
|
|
SizedBox(width: 24),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|