2019-09-14 11:19:33 +02:00
|
|
|
import 'package:flutter/material.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-09-27 12:23:47 +02:00
|
|
|
import 'package:git_touch/widgets/text_contains_organization.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
|
|
|
|
''';
|
|
|
|
|
2019-09-14 11:19:33 +02:00
|
|
|
class UserItem extends StatelessWidget {
|
|
|
|
final String login;
|
|
|
|
final String name;
|
|
|
|
final String avatarUrl;
|
|
|
|
final String bio;
|
2019-09-14 20:05:34 +02:00
|
|
|
final bool inUserScreen;
|
2019-09-14 11:19:33 +02:00
|
|
|
|
2019-09-27 15:02:55 +02:00
|
|
|
UserItem({
|
|
|
|
this.login,
|
2019-09-25 14:51:23 +02:00
|
|
|
this.name,
|
|
|
|
this.avatarUrl,
|
|
|
|
this.bio,
|
|
|
|
this.inUserScreen = false,
|
|
|
|
});
|
2019-09-27 15:02:55 +02:00
|
|
|
UserItem.fromData(
|
|
|
|
data, {
|
|
|
|
this.inUserScreen = false,
|
|
|
|
}) : login = data['login'],
|
2019-09-25 14:51:23 +02:00
|
|
|
name = data['name'],
|
|
|
|
avatarUrl = data['avatarUrl'],
|
2019-09-27 15:02:55 +02:00
|
|
|
bio = data['bio'];
|
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);
|
|
|
|
|
2019-10-02 08:58:11 +02:00
|
|
|
return Link(
|
2019-12-12 13:29:56 +01:00
|
|
|
url: '/$login',
|
2019-10-02 08:58:11 +02:00
|
|
|
child: Container(
|
2019-10-02 10:09:54 +02:00
|
|
|
padding: CommonStyle.padding,
|
2019-10-02 08:58:11 +02:00
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
2019-10-02 09:23:33 +02:00
|
|
|
Avatar.large(url: avatarUrl),
|
2019-10-02 08:58:11 +02:00
|
|
|
SizedBox(width: 10),
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
children: <Widget>[
|
|
|
|
Text(
|
|
|
|
name ?? login,
|
|
|
|
style: TextStyle(
|
2019-11-08 11:29:08 +01:00
|
|
|
color: theme.palette.primary,
|
2019-10-02 08:58:11 +02:00
|
|
|
fontSize: inUserScreen ? 18 : 16,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
),
|
2019-09-14 20:05:34 +02:00
|
|
|
),
|
2019-10-02 08:58:11 +02:00
|
|
|
SizedBox(width: 8),
|
|
|
|
Text(
|
|
|
|
login,
|
|
|
|
style: TextStyle(
|
2019-11-08 11:29:08 +01:00
|
|
|
color: theme.palette.secondaryText,
|
2019-10-02 08:58:11 +02:00
|
|
|
fontSize: inUserScreen ? 16 : 14),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
SizedBox(height: 6),
|
|
|
|
if (bio != null && bio.isNotEmpty)
|
|
|
|
TextContainsOrganization(
|
|
|
|
bio,
|
2019-09-27 15:02:55 +02:00
|
|
|
style: TextStyle(
|
2019-11-08 11:29:08 +01:00
|
|
|
color: theme.palette.secondaryText,
|
2019-10-02 08:58:11 +02:00
|
|
|
fontSize: inUserScreen ? 15 : 14),
|
2019-09-14 20:05:34 +02:00
|
|
|
),
|
2019-10-02 08:58:11 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
2019-09-14 20:05:34 +02:00
|
|
|
),
|
2019-09-14 11:19:33 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|