git-touch-android-ios-app/lib/screens/ge_users.dart

53 lines
1.7 KiB
Dart
Raw Normal View History

2022-09-17 14:35:45 +02:00
import 'package:flutter/widgets.dart';
import 'package:git_touch/models/auth.dart';
2020-10-17 12:18:26 +02:00
import 'package:git_touch/models/gitee.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:provider/provider.dart';
class GeUsersScreen extends StatelessWidget {
2022-09-06 18:28:12 +02:00
const GeUsersScreen.followers(String login)
2020-10-17 12:18:26 +02:00
: api = '/users/$login/followers',
title = 'Followers';
2022-09-06 18:28:12 +02:00
const GeUsersScreen.following(String login)
2020-10-17 12:18:26 +02:00
: api = '/users/$login/following',
title = 'Following';
2020-10-17 12:18:26 +02:00
// GeUsersScreen.member(String login)
// : api = '/orgs/$login/members',
// title = "Members";
2022-09-06 18:28:12 +02:00
const GeUsersScreen.stargazers(String owner, String repo)
2020-10-17 12:18:26 +02:00
: api = '/repos/$owner/$repo/stargazers',
title = 'Stargazers';
2022-09-06 18:28:12 +02:00
const GeUsersScreen.watchers(String owner, String repo)
2020-10-17 12:18:26 +02:00
: api = '/repos/$owner/$repo/subscribers',
title = 'Watchers';
2022-09-21 18:28:21 +02:00
final String api;
final String title;
2020-10-17 12:18:26 +02:00
@override
Widget build(BuildContext context) {
return ListStatefulScaffold<GiteeListUser, int>(
title: AppBarTitle(title),
fetch: (page) async {
final res =
await context.read<AuthModel>().fetchGiteeWithPage(api, page: page);
return ListPayload(
cursor: res.cursor,
hasMore: res.hasMore,
items: [for (var v in res.data) GiteeListUser.fromJson(v)],
);
},
itemBuilder: (p) {
return UserItem.gitee(
login: p.login,
name: p.name,
avatarUrl: p.avatarUrl,
2021-05-16 09:16:35 +02:00
bio: Text(p.htmlUrl!),
2020-10-17 12:18:26 +02:00
);
},
);
}
}