2020-01-28 15:10:44 +01: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;
|
|
|
|
|
|
|
|
class CommitItem extends StatelessWidget {
|
|
|
|
final String url;
|
|
|
|
final String avatarUrl;
|
2020-04-06 07:34:14 +02:00
|
|
|
final String avatarLink;
|
2020-01-28 15:10:44 +01:00
|
|
|
final String message;
|
|
|
|
final String author;
|
|
|
|
final DateTime createdAt;
|
|
|
|
final List<Widget> widgets;
|
|
|
|
CommitItem({
|
|
|
|
@required this.url,
|
|
|
|
@required this.avatarUrl,
|
2020-04-06 07:34:14 +02:00
|
|
|
@required this.avatarLink,
|
2020-01-28 15:10:44 +01:00
|
|
|
@required this.message,
|
|
|
|
@required this.author,
|
|
|
|
@required this.createdAt,
|
|
|
|
this.widgets,
|
|
|
|
});
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final theme = Provider.of<ThemeModel>(context);
|
|
|
|
return Link(
|
|
|
|
url: url,
|
|
|
|
child: Container(
|
|
|
|
padding: CommonStyle.padding,
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
2020-10-11 16:24:13 +02:00
|
|
|
if (avatarUrl != null) ...[
|
|
|
|
Avatar(url: avatarUrl, linkUrl: avatarLink),
|
|
|
|
SizedBox(width: 10),
|
|
|
|
],
|
2020-01-28 15:10:44 +01:00
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Text(
|
|
|
|
message,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 17,
|
|
|
|
color: theme.palette.text,
|
|
|
|
),
|
|
|
|
overflow: TextOverflow.ellipsis,
|
2020-01-28 15:13:53 +01:00
|
|
|
maxLines: 1,
|
2020-01-28 15:10:44 +01:00
|
|
|
),
|
|
|
|
SizedBox(height: 4),
|
2020-01-28 15:13:53 +01:00
|
|
|
Row(
|
2020-01-28 15:10:44 +01:00
|
|
|
children: <Widget>[
|
2020-04-06 07:35:23 +02:00
|
|
|
Text(author,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 15, color: theme.palette.primary)),
|
2020-01-28 15:10:44 +01:00
|
|
|
Text(
|
|
|
|
' committed ${timeago.format(createdAt)}',
|
|
|
|
style: TextStyle(
|
|
|
|
color: theme.palette.secondaryText,
|
|
|
|
fontSize: 15,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (widgets != null) ...widgets,
|
|
|
|
],
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|