mirror of
https://github.com/git-touch/git-touch
synced 2024-12-19 03:33:42 +01:00
55 lines
1.7 KiB
Dart
55 lines
1.7 KiB
Dart
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];
|
|
},
|
|
bodyBuilder: (data, _) {
|
|
final user = data[0];
|
|
final projects = data[1] as List;
|
|
|
|
return Column(
|
|
children: <Widget>[
|
|
UserItem(
|
|
login: user['username'],
|
|
avatarUrl: user['avatar_url'],
|
|
name: user['name'],
|
|
),
|
|
BorderView(height: 10),
|
|
Column(
|
|
children: projects.map((project) {
|
|
return RepositoryItem.gitlab(project);
|
|
}).toList(),
|
|
)
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|