1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-19 11:43:30 +01:00
git-touch-android-ios-app/lib/screens/gitlab/user.dart

55 lines
1.7 KiB
Dart
Raw Normal View History

2019-11-01 18:48:42 +01:00
import 'package:flutter/widgets.dart';
import 'package:git_touch/models/auth.dart';
import 'package:git_touch/scaffolds/refresh_stateful.dart';
import 'package:git_touch/widgets/border_view.dart';
import 'package:git_touch/widgets/repository_item.dart';
import 'package:git_touch/widgets/user_item.dart';
import 'package:provider/provider.dart';
class GitlabUserScreen extends StatelessWidget {
final String username;
GitlabUserScreen(this.username);
@override
Widget build(BuildContext context) {
return RefreshStatefulScaffold(
title: Text('User'),
fetchData: () async {
final items = await Provider.of<AuthModel>(context)
.fetchGitlab('/users?username=$username');
final user = items[0];
final projects = await Provider.of<AuthModel>(context)
.fetchGitlab('/users/${user['id']}/projects') as List;
final langs = await Future.wait(projects.map((p) =>
Provider.of<AuthModel>(context)
.fetchGitlab('/projects/${p['id']}/languages')));
for (var i = 0; i < projects.length; i++) {
projects[i]['language'] = langs[i];
}
return [user, projects];
},
2019-11-02 13:54:23 +01:00
bodyBuilder: (data, _) {
final user = data[0];
final projects = data[1] as List;
2019-11-01 18:48:42 +01:00
return Column(
children: <Widget>[
UserItem(
2019-11-02 13:54:23 +01:00
login: user['username'],
avatarUrl: user['avatar_url'],
name: user['name'],
2019-11-01 18:48:42 +01:00
),
BorderView(height: 10),
Column(
children: projects.map((project) {
2019-11-02 10:50:04 +01:00
return RepositoryItem.gitlab(project);
2019-11-01 18:48:42 +01:00
}).toList(),
)
],
);
},
);
}
}