2019-09-14 11:19:33 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2022-09-06 18:00:51 +02:00
|
|
|
import 'package:git_touch/graphql/__generated__/github.data.gql.dart';
|
2019-11-08 11:29:08 +01:00
|
|
|
import 'package:git_touch/models/theme.dart';
|
2019-10-02 09:39:47 +02:00
|
|
|
import 'package:git_touch/utils/utils.dart';
|
2019-09-14 11:19:33 +02:00
|
|
|
import 'package:git_touch/widgets/avatar.dart';
|
2019-09-14 20:05:34 +02:00
|
|
|
import 'package:git_touch/widgets/link.dart';
|
2019-11-08 11:29:08 +01:00
|
|
|
import 'package:provider/provider.dart';
|
2019-09-14 11:19:33 +02:00
|
|
|
|
2019-09-21 19:23:38 +02:00
|
|
|
const userGqlChunk = '''
|
2019-09-27 15:02:55 +02:00
|
|
|
login
|
2019-09-21 19:23:38 +02:00
|
|
|
name
|
|
|
|
avatarUrl
|
|
|
|
bio
|
|
|
|
''';
|
|
|
|
|
2021-01-17 15:08:32 +01:00
|
|
|
class GhBioWidget extends StatelessWidget {
|
|
|
|
final GUserItem p;
|
|
|
|
const GhBioWidget(this.p);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final theme = Provider.of<ThemeModel>(context);
|
|
|
|
|
|
|
|
if (isNotNullOrEmpty(p.company)) {
|
|
|
|
return Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Icon(
|
|
|
|
Octicons.organization,
|
|
|
|
size: 15,
|
|
|
|
color: theme.palette.secondaryText,
|
|
|
|
),
|
|
|
|
SizedBox(width: 4),
|
2021-05-16 09:16:35 +02:00
|
|
|
Expanded(child: Text(p.company!, overflow: TextOverflow.ellipsis)),
|
2021-01-17 15:08:32 +01:00
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (isNotNullOrEmpty(p.location)) {
|
|
|
|
return Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Icon(
|
|
|
|
Octicons.location,
|
|
|
|
size: 15,
|
|
|
|
color: theme.palette.secondaryText,
|
|
|
|
),
|
|
|
|
SizedBox(width: 4),
|
2021-05-16 09:16:35 +02:00
|
|
|
Expanded(child: Text(p.location!, overflow: TextOverflow.ellipsis)),
|
2021-01-17 15:08:32 +01:00
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Icon(
|
|
|
|
Octicons.clock,
|
|
|
|
size: 15,
|
|
|
|
color: theme.palette.secondaryText,
|
|
|
|
),
|
|
|
|
SizedBox(width: 4),
|
|
|
|
Expanded(
|
|
|
|
child: Text('Joined on ${dateFormat.format(p.createdAt)}',
|
|
|
|
overflow: TextOverflow.ellipsis)),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-14 11:19:33 +02:00
|
|
|
class UserItem extends StatelessWidget {
|
2021-05-16 09:16:35 +02:00
|
|
|
final String? login;
|
|
|
|
final String? name;
|
|
|
|
final String? avatarUrl;
|
|
|
|
final Widget? bio;
|
2020-02-01 03:32:29 +01:00
|
|
|
final String url;
|
|
|
|
|
2020-10-08 09:55:26 +02:00
|
|
|
UserItem.github({
|
2021-05-16 09:16:35 +02:00
|
|
|
required this.login,
|
|
|
|
required this.name,
|
|
|
|
required this.avatarUrl,
|
|
|
|
required this.bio,
|
2020-05-12 17:31:30 +02:00
|
|
|
}) : url = '/github/$login';
|
2019-09-14 11:19:33 +02:00
|
|
|
|
2021-01-17 15:08:32 +01:00
|
|
|
UserItem.gql(GUserItem p)
|
|
|
|
: login = p.login,
|
|
|
|
name = p.name,
|
|
|
|
avatarUrl = p.avatarUrl,
|
|
|
|
url = '/github/' + p.login,
|
|
|
|
bio = GhBioWidget(p);
|
|
|
|
|
2020-10-08 09:55:26 +02:00
|
|
|
UserItem.gitlab({
|
2021-05-16 09:16:35 +02:00
|
|
|
required this.login,
|
|
|
|
required this.name,
|
|
|
|
required this.avatarUrl,
|
|
|
|
required this.bio,
|
|
|
|
required int? id,
|
2020-10-11 16:18:22 +02:00
|
|
|
}) : url = '/gitlab/user/$id';
|
|
|
|
|
|
|
|
UserItem.gitlabGroup({
|
2021-05-16 09:16:35 +02:00
|
|
|
required this.login,
|
|
|
|
required this.name,
|
|
|
|
required this.avatarUrl,
|
|
|
|
required this.bio,
|
|
|
|
required int? id,
|
2020-10-08 09:55:26 +02:00
|
|
|
}) : url = '/gitlab/group/$id';
|
|
|
|
|
|
|
|
UserItem.gitea({
|
2021-05-16 09:16:35 +02:00
|
|
|
required this.login,
|
|
|
|
required this.name,
|
|
|
|
required this.avatarUrl,
|
|
|
|
required this.bio,
|
2020-10-08 09:55:26 +02:00
|
|
|
}) : url = '/gitea/$login';
|
|
|
|
|
2020-10-17 12:18:26 +02:00
|
|
|
UserItem.gitee({
|
2021-05-16 09:16:35 +02:00
|
|
|
required this.login,
|
|
|
|
required this.name,
|
|
|
|
required this.avatarUrl,
|
|
|
|
required this.bio,
|
2020-10-17 12:18:26 +02:00
|
|
|
}) : url = '/gitee/$login';
|
|
|
|
|
2020-10-08 09:55:26 +02:00
|
|
|
UserItem.bitbucket({
|
2021-05-16 09:16:35 +02:00
|
|
|
required this.login,
|
|
|
|
required this.name,
|
|
|
|
required this.avatarUrl,
|
|
|
|
required this.bio,
|
2020-10-08 09:55:26 +02:00
|
|
|
}) : url = '/bitbucket/$login?team=1';
|
2019-09-14 11:19:33 +02:00
|
|
|
|
2021-01-23 15:08:05 +01:00
|
|
|
UserItem.gogs({
|
2021-05-16 09:16:35 +02:00
|
|
|
required this.login,
|
|
|
|
required this.name,
|
|
|
|
required this.avatarUrl,
|
|
|
|
required this.bio,
|
2021-01-23 15:08:05 +01:00
|
|
|
}) : url = '/gogs/$login';
|
|
|
|
|
2019-09-14 11:19:33 +02:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2019-11-08 11:29:08 +01:00
|
|
|
final theme = Provider.of<ThemeModel>(context);
|
2021-05-16 09:16:35 +02:00
|
|
|
return LinkWidget(
|
2020-02-01 03:32:29 +01:00
|
|
|
url: url,
|
2020-01-02 06:56:50 +01:00
|
|
|
child: Container(
|
|
|
|
padding: CommonStyle.padding,
|
|
|
|
child: Row(
|
2020-10-08 09:55:26 +02:00
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
2020-01-02 06:56:50 +01:00
|
|
|
children: <Widget>[
|
|
|
|
Avatar(url: avatarUrl, size: AvatarSize.large),
|
|
|
|
SizedBox(width: 10),
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Row(
|
2020-12-31 03:21:43 +01:00
|
|
|
textBaseline: TextBaseline.alphabetic,
|
2020-10-08 09:55:26 +02:00
|
|
|
crossAxisAlignment: CrossAxisAlignment.baseline,
|
2020-01-02 06:56:50 +01:00
|
|
|
children: <Widget>[
|
2021-05-16 09:16:35 +02:00
|
|
|
if (name != null && name!.isNotEmpty) ...[
|
2020-10-08 09:55:26 +02:00
|
|
|
Text(
|
2021-05-16 09:16:35 +02:00
|
|
|
name!,
|
2020-10-08 09:55:26 +02:00
|
|
|
style: TextStyle(
|
|
|
|
color: theme.palette.text,
|
|
|
|
fontSize: 18,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(width: 8),
|
|
|
|
],
|
2020-10-08 10:05:12 +02:00
|
|
|
Expanded(
|
|
|
|
child: Text(
|
2021-05-16 09:16:35 +02:00
|
|
|
login!,
|
2020-10-08 10:05:12 +02:00
|
|
|
style: TextStyle(
|
|
|
|
color: theme.palette.text,
|
|
|
|
fontSize: 16,
|
|
|
|
),
|
|
|
|
overflow: TextOverflow.ellipsis,
|
2020-01-12 09:18:37 +01:00
|
|
|
),
|
2020-01-02 06:56:50 +01:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
SizedBox(height: 6),
|
|
|
|
if (bio != null)
|
|
|
|
DefaultTextStyle(
|
2019-09-27 15:02:55 +02:00
|
|
|
style: TextStyle(
|
2020-01-27 08:11:51 +01:00
|
|
|
color: theme.palette.secondaryText,
|
2020-01-27 03:47:34 +01:00
|
|
|
fontSize: 16,
|
2020-01-02 06:56:50 +01:00
|
|
|
),
|
2021-05-16 09:16:35 +02:00
|
|
|
child: bio!,
|
2019-12-21 09:16:17 +01:00
|
|
|
),
|
2020-01-02 06:56:50 +01:00
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
2019-09-14 20:05:34 +02:00
|
|
|
),
|
2019-09-14 11:19:33 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|