improvement: user screen style

This commit is contained in:
Rongjian Zhang 2020-01-01 15:58:49 +08:00
parent 3586ee5230
commit 36e772c85f
7 changed files with 120 additions and 19 deletions

View File

@ -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<GithubUser, GithubUserArguments> {
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<GithubUser, GithubUserArguments> {
arguments: [],
directives: [],
selectionSet: null),
FieldNode(
name: NameNode(value: 'createdAt'),
alias: null,
arguments: [],
directives: [],
selectionSet: null),
FieldNode(
name: NameNode(value: 'pinnedItems'),
alias: null,

View File

@ -44,6 +44,9 @@ GithubUserUser _$GithubUserUserFromJson(Map<String, dynamic> 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<String, dynamic> _$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<String, dynamic> _$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(),

View File

@ -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

View File

@ -136,7 +136,12 @@ class _SearchScreenState extends State<SearchScreen> {
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(

View File

@ -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<ThemeModel>(context);
return Container(
padding: CommonStyle.padding,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Row(
children: <Widget>[
Avatar(url: avatarUrl, size: AvatarSize.large),
SizedBox(width: 10),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: <Widget>[
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: <Widget>[
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<ThemeModel>(context);
final login = user.login;
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
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: <Widget>[
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(

View File

@ -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<ThemeModel>(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)}'),
],
);
}

View File

@ -186,3 +186,5 @@ class RouterScreen {
HandlerFunc handler;
RouterScreen(this.path, this.handler);
}
final dateFormat = DateFormat.yMMMMd();