mirror of
https://github.com/git-touch/git-touch
synced 2024-12-15 09:56:15 +01:00
feat(gt): followers and following
This commit is contained in:
parent
1da807632b
commit
3f324b43fd
@ -33,6 +33,7 @@ import 'package:git_touch/screens/gl_user.dart';
|
||||
import 'package:git_touch/screens/gh_issue.dart';
|
||||
import 'package:git_touch/screens/gh_issue_form.dart';
|
||||
import 'package:git_touch/screens/gh_issues.dart';
|
||||
import 'package:git_touch/screens/gt_users.dart';
|
||||
import 'package:git_touch/screens/login.dart';
|
||||
import 'package:git_touch/screens/gh_object.dart';
|
||||
import 'package:git_touch/screens/gh_pulls.dart';
|
||||
@ -273,6 +274,10 @@ class GiteaRouter {
|
||||
final login = p['login'].first;
|
||||
final tab = p['tab']?.first;
|
||||
switch (tab) {
|
||||
case 'followers':
|
||||
return GtUsersScreen.followers(login);
|
||||
case 'following':
|
||||
return GtUsersScreen.following(login);
|
||||
case 'stars':
|
||||
return GtReposScreen.star(login);
|
||||
case 'repositories':
|
||||
|
@ -112,6 +112,16 @@ class GtUserScreen extends StatelessWidget {
|
||||
text: 'Stars',
|
||||
url: '/gitea/$login?tab=stars',
|
||||
),
|
||||
EntryItem(
|
||||
count: 0,
|
||||
text: 'Followers',
|
||||
url: '/gitea/$login?tab=followers',
|
||||
),
|
||||
EntryItem(
|
||||
count: 0,
|
||||
text: 'Following',
|
||||
url: '/gitea/$login?tab=following',
|
||||
),
|
||||
]),
|
||||
ContributionWidget(weeks: heatmapWeeks),
|
||||
CommonStyle.border,
|
||||
|
42
lib/screens/gt_users.dart
Normal file
42
lib/screens/gt_users.dart
Normal file
@ -0,0 +1,42 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/models/gitea.dart';
|
||||
import 'package:git_touch/scaffolds/list_stateful.dart';
|
||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||
import 'package:git_touch/widgets/user_item.dart';
|
||||
import 'package:git_touch/models/auth.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:timeago/timeago.dart' as timeago;
|
||||
|
||||
class GtUsersScreen extends StatelessWidget {
|
||||
final String login;
|
||||
final String api;
|
||||
|
||||
GtUsersScreen.followers(this.login) : api = '/users/$login/followers';
|
||||
GtUsersScreen.following(this.login) : api = '/users/$login/following';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListStatefulScaffold<GiteaUser, int>(
|
||||
title: AppBarTitle('_title'),
|
||||
onLoadMore: (page) async {
|
||||
page = page ?? 1;
|
||||
final res = await context
|
||||
.read<AuthModel>()
|
||||
.fetchGiteaWithPage('$api?page=$page');
|
||||
return ListPayload(
|
||||
cursor: res.cursor,
|
||||
hasMore: res.hasMore,
|
||||
items: [for (var v in res.data) GiteaUser.fromJson(v)],
|
||||
);
|
||||
},
|
||||
itemBuilder: (payload) {
|
||||
return UserItem(
|
||||
login: payload.login,
|
||||
avatarUrl: payload.avatarUrl,
|
||||
bio: Text('Joined on ${timeago.format(payload.created)}'),
|
||||
url: '/gitea/${payload.login}',
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user