2019-01-27 17:37:44 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2019-01-25 13:35:20 +01:00
|
|
|
import 'package:flutter/cupertino.dart';
|
2019-02-03 08:50:17 +01:00
|
|
|
import '../widgets/refresh_scaffold.dart';
|
|
|
|
import '../widgets/avatar.dart';
|
|
|
|
import '../widgets/link.dart';
|
2019-02-03 16:10:10 +01:00
|
|
|
import '../widgets/list_group.dart';
|
|
|
|
import '../widgets/repo_item.dart';
|
2019-01-31 07:37:25 +01:00
|
|
|
import '../utils/utils.dart';
|
2019-01-27 17:37:44 +01:00
|
|
|
|
|
|
|
Future queryUser(String login) async {
|
|
|
|
var data = await query('''
|
|
|
|
{
|
|
|
|
user(login: "$login") {
|
|
|
|
name
|
|
|
|
avatarUrl
|
|
|
|
bio
|
|
|
|
email
|
|
|
|
starredRepositories {
|
|
|
|
totalCount
|
|
|
|
}
|
|
|
|
followers {
|
|
|
|
totalCount
|
|
|
|
}
|
|
|
|
following {
|
|
|
|
totalCount
|
|
|
|
}
|
2019-02-03 08:50:17 +01:00
|
|
|
repositories(first: 6, ownerAffiliations: OWNER, orderBy: {field: STARGAZERS, direction: DESC}) {
|
|
|
|
totalCount
|
|
|
|
nodes {
|
|
|
|
owner {
|
|
|
|
login
|
|
|
|
}
|
|
|
|
name
|
2019-02-03 16:10:10 +01:00
|
|
|
description
|
2019-02-03 08:50:17 +01:00
|
|
|
stargazers {
|
|
|
|
totalCount
|
|
|
|
}
|
2019-02-03 16:10:10 +01:00
|
|
|
forks {
|
|
|
|
totalCount
|
|
|
|
}
|
|
|
|
primaryLanguage {
|
|
|
|
color
|
|
|
|
name
|
|
|
|
}
|
2019-02-03 08:50:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
pinnedRepositories(first: 6) {
|
|
|
|
nodes {
|
|
|
|
owner {
|
|
|
|
login
|
|
|
|
}
|
|
|
|
name
|
2019-02-03 16:10:10 +01:00
|
|
|
description
|
|
|
|
stargazers {
|
|
|
|
totalCount
|
|
|
|
}
|
|
|
|
forks {
|
|
|
|
totalCount
|
|
|
|
}
|
|
|
|
primaryLanguage {
|
|
|
|
color
|
|
|
|
name
|
|
|
|
}
|
2019-02-03 08:50:17 +01:00
|
|
|
}
|
|
|
|
}
|
2019-01-27 17:37:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
''');
|
|
|
|
return data['user'];
|
|
|
|
}
|
|
|
|
|
|
|
|
final GlobalKey<RefreshIndicatorState> _refreshIndicatorKey =
|
2019-02-03 16:10:10 +01:00
|
|
|
GlobalKey<RefreshIndicatorState>();
|
2019-01-27 17:37:44 +01:00
|
|
|
|
|
|
|
class UserScreen extends StatefulWidget {
|
|
|
|
final String login;
|
|
|
|
|
|
|
|
UserScreen(this.login);
|
|
|
|
|
|
|
|
_UserScreenState createState() => _UserScreenState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _UserScreenState extends State<UserScreen> {
|
2019-02-03 16:10:10 +01:00
|
|
|
Map<String, dynamic> payload = {};
|
2019-01-27 17:37:44 +01:00
|
|
|
|
2019-01-25 13:35:20 +01:00
|
|
|
@override
|
2019-01-27 17:37:44 +01:00
|
|
|
Widget build(BuildContext context) {
|
2019-02-03 08:50:17 +01:00
|
|
|
return RefreshScaffold(
|
|
|
|
onRefresh: () async {
|
|
|
|
var _payload = await queryUser(widget.login);
|
|
|
|
setState(() {
|
|
|
|
payload = _payload;
|
|
|
|
});
|
|
|
|
},
|
2019-02-03 16:10:10 +01:00
|
|
|
title: Text(widget.login),
|
|
|
|
bodyBuilder: () {
|
|
|
|
return Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.all(10),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border(bottom: BorderSide(color: Colors.black12))),
|
|
|
|
child: Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Avatar(
|
|
|
|
login: widget.login,
|
|
|
|
url: payload['avatarUrl'],
|
|
|
|
size: 28,
|
2019-02-03 08:50:17 +01:00
|
|
|
),
|
2019-02-03 16:10:10 +01:00
|
|
|
Padding(padding: EdgeInsets.only(left: 10)),
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Text(payload['name'], style: TextStyle(height: 1.2)),
|
|
|
|
Padding(padding: EdgeInsets.only(top: 10)),
|
|
|
|
Row(children: <Widget>[
|
|
|
|
Icon(
|
|
|
|
Octicons.mail,
|
|
|
|
color: Colors.black54,
|
|
|
|
size: 16,
|
|
|
|
),
|
|
|
|
Padding(padding: EdgeInsets.only(left: 4)),
|
|
|
|
Text(
|
|
|
|
payload['email'],
|
|
|
|
style:
|
|
|
|
TextStyle(color: Colors.black54, fontSize: 16),
|
|
|
|
)
|
|
|
|
])
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
2019-02-03 08:50:17 +01:00
|
|
|
),
|
2019-02-03 16:10:10 +01:00
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.all(10),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border(bottom: BorderSide(color: Colors.black12))),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
children: <Widget>[
|
|
|
|
Link(
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Text(payload['repositories']['totalCount'].toString()),
|
|
|
|
Text('Repos')
|
|
|
|
],
|
|
|
|
),
|
|
|
|
onTap: () {},
|
2019-02-03 08:50:17 +01:00
|
|
|
),
|
2019-02-03 16:10:10 +01:00
|
|
|
Link(
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Text(payload['starredRepositories']['totalCount']
|
|
|
|
.toString()),
|
|
|
|
Text('Stars')
|
|
|
|
],
|
|
|
|
),
|
|
|
|
onTap: () {},
|
2019-02-03 08:50:17 +01:00
|
|
|
),
|
2019-02-03 16:10:10 +01:00
|
|
|
Link(
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Text(payload['followers']['totalCount'].toString()),
|
|
|
|
Text('Followers'),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
onTap: () {
|
|
|
|
// print(1);
|
|
|
|
},
|
2019-02-03 08:50:17 +01:00
|
|
|
),
|
2019-02-03 16:10:10 +01:00
|
|
|
Link(
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Text(payload['following']['totalCount'].toString()),
|
|
|
|
Text('Following')
|
|
|
|
],
|
|
|
|
),
|
|
|
|
onTap: () {},
|
2019-02-03 08:50:17 +01:00
|
|
|
),
|
2019-02-03 16:10:10 +01:00
|
|
|
],
|
|
|
|
),
|
2019-02-03 08:50:17 +01:00
|
|
|
),
|
2019-02-03 16:10:10 +01:00
|
|
|
ListGroup(
|
|
|
|
title: Text('Repos'),
|
|
|
|
items: payload['repositories']['nodes'],
|
|
|
|
itemBuilder: (item) => RepoItem(item),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
2019-02-03 08:50:17 +01:00
|
|
|
);
|
2019-01-25 13:35:20 +01:00
|
|
|
}
|
|
|
|
}
|