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-01-30 08:09:27 +01:00
|
|
|
import 'package:git_touch/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
|
|
|
|
repositories {
|
|
|
|
totalCount
|
|
|
|
}
|
|
|
|
starredRepositories {
|
|
|
|
totalCount
|
|
|
|
}
|
|
|
|
followers {
|
|
|
|
totalCount
|
|
|
|
}
|
|
|
|
following {
|
|
|
|
totalCount
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
''');
|
|
|
|
return data['user'];
|
|
|
|
}
|
|
|
|
|
|
|
|
final GlobalKey<RefreshIndicatorState> _refreshIndicatorKey =
|
|
|
|
new GlobalKey<RefreshIndicatorState>();
|
|
|
|
|
|
|
|
class UserScreen extends StatefulWidget {
|
|
|
|
final String login;
|
|
|
|
|
|
|
|
UserScreen(this.login);
|
|
|
|
|
|
|
|
_UserScreenState createState() => _UserScreenState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _UserScreenState extends State<UserScreen> {
|
|
|
|
var user = null;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
queryUser(widget.login).then((_user) {
|
|
|
|
setState(() {
|
|
|
|
user = _user;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2019-01-25 13:35:20 +01:00
|
|
|
|
|
|
|
@override
|
2019-01-27 17:37:44 +01:00
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return SafeArea(
|
|
|
|
child: RefreshIndicator(
|
|
|
|
key: _refreshIndicatorKey,
|
|
|
|
onRefresh: () async {
|
|
|
|
var _user = await queryUser(widget.login);
|
|
|
|
setState(() {
|
|
|
|
user = _user;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.symmetric(vertical: 20.0),
|
|
|
|
child: ClipOval(
|
|
|
|
child: Image.network(
|
|
|
|
user['avatarUrl'],
|
|
|
|
fit: BoxFit.fill,
|
|
|
|
width: 64,
|
|
|
|
height: 64,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
children: <Widget>[
|
|
|
|
GestureDetector(
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Text(user['followers']['totalCount'].toString()),
|
|
|
|
Text('Followers'),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
onTap: () {
|
|
|
|
// print(1);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Text(user['following']['totalCount'].toString()),
|
|
|
|
Text('Following')
|
|
|
|
],
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
2019-01-25 13:35:20 +01:00
|
|
|
}
|
|
|
|
}
|