mirror of
https://github.com/git-touch/git-touch
synced 2025-01-20 11:18:29 +01:00
refactor: use id
This commit is contained in:
parent
259d25d376
commit
dc773dbde9
@ -25,11 +25,11 @@ import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:git_touch/models/notification.dart';
|
||||
import 'package:fluro/fluro.dart';
|
||||
import 'screens/news.dart';
|
||||
import 'screens/search.dart';
|
||||
import 'screens/login.dart';
|
||||
import 'screens/issue.dart';
|
||||
import 'screens/trending.dart';
|
||||
import 'package:git_touch/screens/news.dart';
|
||||
import 'package:git_touch/screens/search.dart';
|
||||
import 'package:git_touch/screens/login.dart';
|
||||
import 'package:git_touch/screens/issue.dart';
|
||||
import 'package:git_touch/screens/trending.dart';
|
||||
import 'package:fimber/fimber.dart';
|
||||
|
||||
class Home extends StatefulWidget {
|
||||
@ -137,7 +137,7 @@ class _HomeState extends State<Home> {
|
||||
case 0:
|
||||
return GitlabTodosScreen();
|
||||
case 1:
|
||||
return GitlabUserScreen(auth.activeAccount.login);
|
||||
return GitlabUserScreen(auth.activeAccount.gitlabId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -236,6 +236,7 @@ void main() async {
|
||||
]);
|
||||
|
||||
final List<RouterScreen> routers = [
|
||||
gitlabUserRouter,
|
||||
gitlabBlobRouter,
|
||||
gitlabTreeRouter,
|
||||
gitlabProjectRouter,
|
||||
|
@ -7,11 +7,17 @@ import 'package:git_touch/widgets/repository_item.dart';
|
||||
import 'package:git_touch/widgets/user_item.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
|
||||
final gitlabUserRouter = RouterScreen(
|
||||
'/user/:id',
|
||||
(context, parameters) =>
|
||||
GitlabUserScreen(int.parse(parameters['id'].first)));
|
||||
|
||||
class GitlabUserScreen extends StatelessWidget {
|
||||
final String username;
|
||||
final int id;
|
||||
|
||||
GitlabUserScreen(this.username);
|
||||
GitlabUserScreen(this.id);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -21,10 +27,9 @@ class GitlabUserScreen extends StatelessWidget {
|
||||
fetchData: () async {
|
||||
final auth = Provider.of<AuthModel>(context);
|
||||
|
||||
final v0 = await auth.fetchGitlab('/users?username=$username');
|
||||
final user = GitlabUser.fromJson(v0[0]);
|
||||
|
||||
final v1 = await auth.fetchGitlab('/users/${user.id}/projects');
|
||||
final v0 = await auth.fetchGitlab('/users/$id');
|
||||
final user = GitlabUser.fromJson(v0);
|
||||
final v1 = await auth.fetchGitlab('/users/$id/projects');
|
||||
final projects =
|
||||
(v1 as List).map((v) => GitlabUserProject.fromJson(v)).toList();
|
||||
|
||||
|
@ -62,16 +62,16 @@ class GithubAvatar extends StatelessWidget {
|
||||
class GitlabAvatar extends StatelessWidget {
|
||||
final String url;
|
||||
final double size;
|
||||
final String login;
|
||||
final int id;
|
||||
|
||||
GitlabAvatar({
|
||||
@required this.url,
|
||||
this.size = AvatarSize.medium,
|
||||
this.login,
|
||||
this.id,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Avatar(url: url, size: size, linkUrl: '/$login');
|
||||
return Avatar(url: url, size: size, linkUrl: '/user/$id');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user