1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-18 19:22:54 +01:00
git-touch-android-ios-app/lib/widgets/commit_item.dart
2020-01-28 22:13:53 +08:00

72 lines
2.1 KiB
Dart

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;
final String message;
final String author;
final DateTime createdAt;
final List<Widget> widgets;
CommitItem({
@required this.url,
@required this.avatarUrl,
@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>[
Avatar(url: avatarUrl),
SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
message,
style: TextStyle(
fontSize: 17,
color: theme.palette.text,
),
overflow: TextOverflow.ellipsis,
maxLines: 1,
),
SizedBox(height: 4),
Row(
children: <Widget>[
Text(author, style: TextStyle(fontSize: 15)),
Text(
' committed ${timeago.format(createdAt)}',
style: TextStyle(
color: theme.palette.secondaryText,
fontSize: 15,
),
),
if (widgets != null) ...widgets,
],
)
],
),
)
],
),
),
);
}
}