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

74 lines
2.1 KiB
Dart
Raw Normal View History

2022-09-23 20:22:17 +02:00
import 'package:antd_mobile/antd_mobile.dart';
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/utils/utils.dart';
import 'package:git_touch/widgets/avatar.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) {
2022-09-23 20:22:17 +02:00
return AntListItem(
onClick: () {
context.pushUrl(url!);
},
child: Row(
children: <Widget>[
if (avatarUrl != null) ...[
Avatar(url: avatarUrl, linkUrl: avatarLink),
const SizedBox(width: 10),
],
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
message!,
style: TextStyle(
fontSize: 17,
2022-09-24 20:46:37 +02:00
color: AntTheme.of(context).colorText,
2020-01-28 15:10:44 +01:00
),
2022-09-23 20:22:17 +02:00
overflow: TextOverflow.ellipsis,
maxLines: 1,
),
const SizedBox(height: 4),
Row(
children: <Widget>[
Text(author!,
2020-01-28 15:10:44 +01:00
style: TextStyle(
2022-09-24 20:46:37 +02:00
fontSize: 15,
color: AntTheme.of(context).colorPrimary)),
2022-09-23 20:22:17 +02:00
Text(
' committed ${timeago.format(createdAt!)}',
style: TextStyle(
2022-09-24 20:46:37 +02:00
color: AntTheme.of(context).colorTextSecondary,
2022-09-23 20:22:17 +02:00
fontSize: 15,
2020-01-28 15:10:44 +01:00
),
2022-09-23 20:22:17 +02:00
),
if (widgets != null) ...widgets!,
],
)
],
),
)
],
2020-01-28 15:10:44 +01:00
),
);
}
}