2022-09-17 14:35:45 +02:00
|
|
|
import 'package:flutter/widgets.dart';
|
2020-01-28 15:10:44 +01:00
|
|
|
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 {
|
2022-09-06 18:28:12 +02:00
|
|
|
const CommitItem({
|
2021-05-16 09:16:35 +02:00
|
|
|
required this.url,
|
|
|
|
required this.avatarUrl,
|
|
|
|
required this.avatarLink,
|
|
|
|
required this.message,
|
|
|
|
required this.author,
|
|
|
|
required this.createdAt,
|
2020-01-28 15:10:44 +01:00
|
|
|
this.widgets,
|
|
|
|
});
|
2022-09-21 18:28:21 +02:00
|
|
|
final String? url;
|
|
|
|
final String? avatarUrl;
|
|
|
|
final String? avatarLink;
|
|
|
|
final String? message;
|
|
|
|
final String? author;
|
|
|
|
final DateTime? createdAt;
|
|
|
|
final List<Widget>? widgets;
|
2020-01-28 15:10:44 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final theme = Provider.of<ThemeModel>(context);
|
2021-05-16 09:16:35 +02:00
|
|
|
return LinkWidget(
|
2020-01-28 15:10:44 +01:00
|
|
|
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),
|
2022-09-06 18:28:12 +02:00
|
|
|
const SizedBox(width: 10),
|
2020-10-11 16:24:13 +02:00
|
|
|
],
|
2020-01-28 15:10:44 +01:00
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Text(
|
2021-05-16 09:16:35 +02:00
|
|
|
message!,
|
2020-01-28 15:10:44 +01:00
|
|
|
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
|
|
|
),
|
2022-09-06 18:28:12 +02:00
|
|
|
const SizedBox(height: 4),
|
2020-01-28 15:13:53 +01:00
|
|
|
Row(
|
2020-01-28 15:10:44 +01:00
|
|
|
children: <Widget>[
|
2021-05-16 09:16:35 +02:00
|
|
|
Text(author!,
|
2020-04-06 07:35:23 +02:00
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 15, color: theme.palette.primary)),
|
2020-01-28 15:10:44 +01:00
|
|
|
Text(
|
2021-05-16 09:16:35 +02:00
|
|
|
' committed ${timeago.format(createdAt!)}',
|
2020-01-28 15:10:44 +01:00
|
|
|
style: TextStyle(
|
|
|
|
color: theme.palette.secondaryText,
|
|
|
|
fontSize: 15,
|
|
|
|
),
|
|
|
|
),
|
2021-05-16 09:16:35 +02:00
|
|
|
if (widgets != null) ...widgets!,
|
2020-01-28 15:10:44 +01:00
|
|
|
],
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|