diff --git a/lib/graphql/github_user.dart b/lib/graphql/github_user.dart index aa29e98..d68db15 100644 --- a/lib/graphql/github_user.dart +++ b/lib/graphql/github_user.dart @@ -86,6 +86,8 @@ class GithubUserUser extends GithubUserAuditEntryActor String email; + DateTime createdAt; + String websiteUrl; GithubUserStarredRepositoryConnection starredRepositories; @@ -124,6 +126,7 @@ class GithubUserUser extends GithubUserAuditEntryActor company, location, email, + createdAt, websiteUrl, starredRepositories, followers, @@ -618,6 +621,8 @@ class GithubUserOrganization extends GithubUserAuditEntryActor String websiteUrl; + DateTime createdAt; + GithubUserPinnableItemConnection pinnedItems; GithubUserPinnableItemConnection pinnableItems; @@ -644,6 +649,7 @@ class GithubUserOrganization extends GithubUserAuditEntryActor location, email, websiteUrl, + createdAt, pinnedItems, pinnableItems, membersWithRole, @@ -788,6 +794,12 @@ class GithubUserQuery extends GraphQLQuery { arguments: [], directives: [], selectionSet: null), + FieldNode( + name: NameNode(value: 'createdAt'), + alias: null, + arguments: [], + directives: [], + selectionSet: null), FieldNode( name: NameNode(value: 'websiteUrl'), alias: null, @@ -1192,6 +1204,12 @@ class GithubUserQuery extends GraphQLQuery { arguments: [], directives: [], selectionSet: null), + FieldNode( + name: NameNode(value: 'createdAt'), + alias: null, + arguments: [], + directives: [], + selectionSet: null), FieldNode( name: NameNode(value: 'pinnedItems'), alias: null, diff --git a/lib/graphql/github_user.g.dart b/lib/graphql/github_user.g.dart index f32d835..a9f46d0 100644 --- a/lib/graphql/github_user.g.dart +++ b/lib/graphql/github_user.g.dart @@ -44,6 +44,9 @@ GithubUserUser _$GithubUserUserFromJson(Map json) { ..company = json['company'] as String ..location = json['location'] as String ..email = json['email'] as String + ..createdAt = json['createdAt'] == null + ? null + : DateTime.parse(json['createdAt'] as String) ..websiteUrl = json['websiteUrl'] as String ..starredRepositories = json['starredRepositories'] == null ? null @@ -84,6 +87,7 @@ Map _$GithubUserUserToJson(GithubUserUser instance) => 'company': instance.company, 'location': instance.location, 'email': instance.email, + 'createdAt': instance.createdAt?.toIso8601String(), 'websiteUrl': instance.websiteUrl, 'starredRepositories': instance.starredRepositories?.toJson(), 'followers': instance.followers?.toJson(), @@ -475,6 +479,9 @@ GithubUserOrganization _$GithubUserOrganizationFromJson( ..location = json['location'] as String ..email = json['email'] as String ..websiteUrl = json['websiteUrl'] as String + ..createdAt = json['createdAt'] == null + ? null + : DateTime.parse(json['createdAt'] as String) ..pinnedItems = json['pinnedItems'] == null ? null : GithubUserPinnableItemConnection.fromJson( @@ -501,6 +508,7 @@ Map _$GithubUserOrganizationToJson( 'location': instance.location, 'email': instance.email, 'websiteUrl': instance.websiteUrl, + 'createdAt': instance.createdAt?.toIso8601String(), 'pinnedItems': instance.pinnedItems?.toJson(), 'pinnableItems': instance.pinnableItems?.toJson(), 'membersWithRole': instance.membersWithRole?.toJson(), diff --git a/lib/graphql/github_user.graphql b/lib/graphql/github_user.graphql index b095e68..a5c5219 100644 --- a/lib/graphql/github_user.graphql +++ b/lib/graphql/github_user.graphql @@ -10,6 +10,7 @@ query($login: String!) { company location email + createdAt websiteUrl starredRepositories { totalCount @@ -91,6 +92,7 @@ query($login: String!) { location email websiteUrl + createdAt pinnedItems(first: 6) { nodes { __typename diff --git a/lib/screens/search.dart b/lib/screens/search.dart index a70d173..902e9b4 100644 --- a/lib/screens/search.dart +++ b/lib/screens/search.dart @@ -136,7 +136,12 @@ class _SearchScreenState extends State { case 0: return RepositoryItem(data); case 1: - return UserItem.fromData(data); + return UserItem( + login: data['login'], + name: data['name'], + avatarUrl: data['avatarUrl'], + bio: Text(data['bio'] ?? ''), + ); case 2: default: return IssueItem( diff --git a/lib/screens/user.dart b/lib/screens/user.dart index 6000c00..94d5f9a 100644 --- a/lib/screens/user.dart +++ b/lib/screens/user.dart @@ -7,11 +7,11 @@ import 'package:git_touch/screens/users.dart'; import 'package:git_touch/utils/utils.dart'; import 'package:git_touch/widgets/app_bar_title.dart'; import 'package:git_touch/screens/repositories.dart'; +import 'package:git_touch/widgets/avatar.dart'; import 'package:git_touch/widgets/entry_item.dart'; import 'package:git_touch/widgets/repository_item.dart'; import 'package:git_touch/widgets/table_view.dart'; import 'package:git_touch/widgets/text_contains_organization.dart'; -import 'package:git_touch/widgets/user_item.dart'; import 'package:git_touch/models/auth.dart'; import 'package:provider/provider.dart'; import 'package:git_touch/widgets/action_button.dart'; @@ -69,19 +69,92 @@ class UserScreen extends StatelessWidget { ]; } + Widget _buildHeader(BuildContext context, String avatarUrl, String name, + DateTime createdAt, String bio) { + final theme = Provider.of(context); + + return Container( + padding: CommonStyle.padding, + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Row( + children: [ + Avatar(url: avatarUrl, size: AvatarSize.large), + SizedBox(width: 10), + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + if (name != null) ...[ + Text( + name, + style: TextStyle( + color: theme.palette.primary, + fontSize: 19, + fontWeight: FontWeight.w500, + ), + ), + SizedBox(width: 4), + ], + Text( + '($login)', + style: TextStyle( + color: theme.palette.secondaryText, + fontSize: 16, + ), + ), + ], + ), + SizedBox(height: 6), + Row( + children: [ + Icon( + Octicons.clock, + size: 15, + color: theme.palette.secondaryText, + ), + SizedBox(width: 4), + Text( + 'Joined on ${dateFormat.format(createdAt)}', + style: TextStyle( + color: theme.palette.secondaryText, + fontSize: 15, + ), + ), + ], + ), + ], + ), + ) + ], + ), + if (bio != null && bio.isNotEmpty) ...[ + SizedBox(height: 12), + Text( + bio, + style: TextStyle( + color: theme.palette.secondaryText, + fontSize: 17, + ), + ) + ] + ], + ), + ); + } + Widget _buildUser(BuildContext context, GithubUserUser user) { final theme = Provider.of(context); final login = user.login; return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - UserItem( - login: user.login, - name: user.name, - avatarUrl: user.avatarUrl, - bio: Text(user.bio ?? ''), - inUserScreen: true, - ), + _buildHeader( + context, user.avatarUrl, user.name, user.createdAt, user.bio), CommonStyle.border, Row(children: [ EntryItem( @@ -197,13 +270,8 @@ class UserScreen extends StatelessWidget { return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - UserItem( - login: payload.login, - name: payload.name, - avatarUrl: payload.avatarUrl, - bio: Text(payload.description ?? ''), - inUserScreen: true, - ), + _buildHeader(context, payload.avatarUrl, payload.name, + payload.createdAt, payload.description), CommonStyle.border, Row(children: [ EntryItem( diff --git a/lib/screens/users.dart b/lib/screens/users.dart index 1b53e52..0f6ce1b 100644 --- a/lib/screens/users.dart +++ b/lib/screens/users.dart @@ -96,8 +96,6 @@ class UsersScreen extends StatelessWidget { } } - static final _dateFormat = DateFormat.yMMMMd(); - Widget _buildBio(BuildContext context, String company, String location, DateTime createdAt) { final theme = Provider.of(context); @@ -135,7 +133,7 @@ class UsersScreen extends StatelessWidget { color: theme.palette.secondaryText, ), SizedBox(width: 4), - Text('Joined on ${_dateFormat.format(createdAt)}'), + Text('Joined on ${dateFormat.format(createdAt)}'), ], ); } diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index aac7346..386c79f 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -186,3 +186,5 @@ class RouterScreen { HandlerFunc handler; RouterScreen(this.path, this.handler); } + +final dateFormat = DateFormat.yMMMMd();