git-touch-android-ios-app/lib/widgets/gists_item.dart

129 lines
4.4 KiB
Dart
Raw Normal View History

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;
class GistsItem extends StatelessWidget {
2021-05-16 09:16:35 +02:00
final String? description;
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;
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,
});
@override
Widget build(BuildContext context) {
final theme = Provider.of<ThemeModel>(context);
2021-05-16 09:16:35 +02:00
return LinkWidget(
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(
text: filenames[0],
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) ...[
Text(
2021-05-16 09:16:35 +02:00
description!,
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!)}',
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!]),
shape: BoxShape.circle,
),
),
SizedBox(width: 4),
if (language != null)
Text(
2021-05-16 09:16:35 +02:00
language!,
overflow: TextOverflow.ellipsis,
),
SizedBox(width: 24),
],
),
),
],
),
),
],
),
),
);
}
}