1
0
mirror of https://github.com/git-touch/git-touch synced 2025-01-31 08:04:51 +01:00

97 lines
2.8 KiB
Dart
Raw Normal View History

2019-09-14 17:19:33 +08:00
import 'package:flutter/material.dart';
2019-09-25 20:51:23 +08:00
import 'package:git_touch/screens/organization.dart';
2019-09-15 02:05:34 +08:00
import 'package:git_touch/screens/user.dart';
2019-10-02 15:39:47 +08:00
import 'package:git_touch/utils/utils.dart';
2019-09-14 17:19:33 +08:00
import 'package:git_touch/widgets/avatar.dart';
2019-09-15 02:05:34 +08:00
import 'package:git_touch/widgets/link.dart';
2019-09-27 18:23:47 +08:00
import 'package:git_touch/widgets/text_contains_organization.dart';
2019-09-14 17:19:33 +08:00
import 'package:primer/primer.dart';
2019-09-22 01:23:38 +08:00
const userGqlChunk = '''
2019-09-27 21:02:55 +08:00
login
2019-09-22 01:23:38 +08:00
name
avatarUrl
bio
''';
2019-09-14 17:19:33 +08:00
class UserItem extends StatelessWidget {
final String login;
final String name;
final String avatarUrl;
final String bio;
2019-09-15 02:05:34 +08:00
final bool inUserScreen;
2019-09-25 20:51:23 +08:00
final bool isOrganization;
2019-09-14 17:19:33 +08:00
2019-09-27 21:02:55 +08:00
UserItem({
this.login,
2019-09-25 20:51:23 +08:00
this.name,
this.avatarUrl,
this.bio,
this.inUserScreen = false,
this.isOrganization = false,
});
2019-09-27 21:02:55 +08:00
UserItem.fromData(
data, {
this.isOrganization = false,
this.inUserScreen = false,
}) : login = data['login'],
2019-09-25 20:51:23 +08:00
name = data['name'],
avatarUrl = data['avatarUrl'],
2019-09-27 21:02:55 +08:00
bio = data['bio'];
2019-09-14 17:19:33 +08:00
@override
Widget build(BuildContext context) {
2019-10-02 14:58:11 +08:00
return Link(
screenBuilder: inUserScreen
? null
: (_) =>
isOrganization ? OrganizationScreen(login) : UserScreen(login),
child: Container(
2019-10-02 16:09:54 +08:00
padding: CommonStyle.padding,
2019-10-02 14:58:11 +08:00
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
2019-10-02 15:23:33 +08:00
Avatar.large(url: avatarUrl),
2019-10-02 14:58:11 +08:00
SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Text(
name ?? login,
style: TextStyle(
color: PrimerColors.blue500,
fontSize: inUserScreen ? 18 : 16,
fontWeight: FontWeight.w600,
),
2019-09-15 02:05:34 +08:00
),
2019-10-02 14:58:11 +08:00
SizedBox(width: 8),
Text(
login,
style: TextStyle(
color: PrimerColors.gray700,
fontSize: inUserScreen ? 16 : 14),
),
],
),
SizedBox(height: 6),
if (bio != null && bio.isNotEmpty)
TextContainsOrganization(
bio,
2019-09-27 21:02:55 +08:00
style: TextStyle(
color: PrimerColors.gray700,
2019-10-02 14:58:11 +08:00
fontSize: inUserScreen ? 15 : 14),
2019-09-15 02:05:34 +08:00
),
2019-10-02 14:58:11 +08:00
],
),
)
],
),
2019-09-15 02:05:34 +08:00
),
2019-09-14 17:19:33 +08:00
);
}
}