2022-09-20 20:00:03 +02:00
|
|
|
import 'package:antd_mobile/antd_mobile.dart';
|
2022-09-17 14:35:45 +02:00
|
|
|
import 'package:flutter/widgets.dart';
|
2022-09-13 19:19:52 +02:00
|
|
|
import 'package:flutter_gen/gen_l10n/S.dart';
|
2022-09-06 18:00:51 +02:00
|
|
|
import 'package:git_touch/graphql/__generated__/github.data.gql.dart';
|
2021-01-31 15:08:37 +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/markdown_view.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:timeago/timeago.dart' as timeago;
|
|
|
|
|
|
|
|
class ReleaseItem extends StatelessWidget {
|
|
|
|
|
2022-09-06 18:28:12 +02:00
|
|
|
const ReleaseItem(
|
2021-05-16 09:16:35 +02:00
|
|
|
{required this.login,
|
|
|
|
required this.publishedAt,
|
|
|
|
required this.name,
|
|
|
|
required this.tagName,
|
|
|
|
required this.avatarUrl,
|
|
|
|
required this.description,
|
2021-01-31 15:08:37 +01:00
|
|
|
this.releaseAssets});
|
2022-09-21 18:28:21 +02:00
|
|
|
final String? login;
|
|
|
|
final DateTime? publishedAt;
|
|
|
|
final String? name;
|
|
|
|
final String? avatarUrl;
|
|
|
|
final String? tagName;
|
|
|
|
final String? description;
|
|
|
|
final GReleasesData_repository_releases_nodes_releaseAssets? releaseAssets;
|
2021-01-31 15:08:37 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final theme = Provider.of<ThemeModel>(context);
|
|
|
|
return Column(
|
|
|
|
children: [
|
2022-09-06 18:28:12 +02:00
|
|
|
const SizedBox(
|
2021-01-31 15:08:37 +01:00
|
|
|
height: 12,
|
|
|
|
),
|
|
|
|
Row(children: <Widget>[
|
|
|
|
Avatar(url: avatarUrl, size: AvatarSize.large),
|
2022-09-06 18:28:12 +02:00
|
|
|
const SizedBox(width: 10),
|
2021-01-31 15:08:37 +01:00
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Text(
|
2021-05-16 09:16:35 +02:00
|
|
|
tagName!,
|
2021-01-31 15:08:37 +01:00
|
|
|
style: TextStyle(
|
|
|
|
color: theme.palette.primary,
|
|
|
|
fontSize: 18,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-09-06 18:28:12 +02:00
|
|
|
const SizedBox(height: 6),
|
2021-01-31 15:08:37 +01:00
|
|
|
DefaultTextStyle(
|
|
|
|
style: TextStyle(
|
|
|
|
color: theme.palette.secondaryText,
|
|
|
|
fontSize: 16,
|
|
|
|
),
|
2022-09-13 19:19:52 +02:00
|
|
|
child: Text(
|
2022-09-18 19:02:57 +02:00
|
|
|
'${login!} ${AppLocalizations.of(context)!.released} ${timeago.format(publishedAt!)}'),
|
2021-01-31 15:08:37 +01:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
]),
|
2021-05-16 09:16:35 +02:00
|
|
|
if (description != null && description!.isNotEmpty) ...[
|
2021-01-31 15:08:37 +01:00
|
|
|
MarkdownFlutterView(
|
|
|
|
description,
|
|
|
|
),
|
2022-09-06 18:28:12 +02:00
|
|
|
const SizedBox(height: 10),
|
2021-01-31 15:08:37 +01:00
|
|
|
],
|
2021-02-02 15:00:14 +01:00
|
|
|
Card(
|
|
|
|
color: theme.palette.grayBackground,
|
2022-09-06 18:28:12 +02:00
|
|
|
margin: const EdgeInsets.all(0),
|
2021-02-02 15:00:14 +01:00
|
|
|
child: ExpansionTile(
|
|
|
|
title: Text(
|
2022-09-06 18:28:12 +02:00
|
|
|
'Assets (${releaseAssets?.nodes?.length ?? 0})',
|
2021-02-02 15:00:14 +01:00
|
|
|
style: TextStyle(
|
|
|
|
color: theme.palette.secondaryText,
|
|
|
|
fontSize: 18,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
),
|
2021-01-31 15:08:37 +01:00
|
|
|
),
|
2021-02-02 15:00:14 +01:00
|
|
|
children: <Widget>[
|
2022-09-20 20:00:03 +02:00
|
|
|
AntList(
|
2021-06-14 05:28:12 +02:00
|
|
|
items: [
|
|
|
|
if (releaseAssets != null)
|
|
|
|
for (var asset in releaseAssets!.nodes!)
|
2022-09-20 20:00:03 +02:00
|
|
|
AntListItem(
|
2022-09-13 19:19:52 +02:00
|
|
|
child: Text(
|
2021-06-14 05:28:12 +02:00
|
|
|
asset.name,
|
|
|
|
style: TextStyle(
|
|
|
|
color: theme.palette.primary,
|
|
|
|
fontSize: 14,
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
),
|
2021-02-02 15:00:14 +01:00
|
|
|
),
|
2022-09-13 19:19:52 +02:00
|
|
|
extra: IconButton(
|
2021-06-14 05:28:12 +02:00
|
|
|
onPressed: () {
|
|
|
|
theme.push(context, asset.downloadUrl);
|
|
|
|
},
|
2022-09-06 18:28:12 +02:00
|
|
|
icon: const Icon(Ionicons.download_outline)),
|
2022-09-20 20:00:03 +02:00
|
|
|
arrow: null,
|
2021-01-31 15:08:37 +01:00
|
|
|
),
|
2021-06-14 05:28:12 +02:00
|
|
|
],
|
|
|
|
)
|
2021-02-02 15:00:14 +01:00
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
2021-01-31 15:08:37 +01:00
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|