2022-09-17 14:35:45 +02:00
|
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/S.dart';
|
2020-02-01 05:14:03 +01:00
|
|
|
import 'package:git_touch/models/auth.dart';
|
|
|
|
import 'package:git_touch/models/gitlab.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';
|
|
|
|
|
2020-02-07 15:26:37 +01:00
|
|
|
class GlMembersScreen extends StatelessWidget {
|
2022-09-21 18:28:21 +02:00
|
|
|
const GlMembersScreen(this.id, this.type);
|
2020-02-01 05:14:03 +01:00
|
|
|
final int id;
|
|
|
|
final String type;
|
|
|
|
|
|
|
|
// https://docs.gitlab.com/ee/api/access_requests.html#valid-access-levels
|
|
|
|
static const accessLevelMap = {
|
|
|
|
10: 'Guest',
|
|
|
|
20: 'Reporter',
|
|
|
|
30: 'Developer',
|
|
|
|
40: 'Maintainer',
|
|
|
|
50: 'Owner',
|
|
|
|
};
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ListStatefulScaffold<GitlabUser, int>(
|
2021-05-16 09:16:35 +02:00
|
|
|
title: AppBarTitle(AppLocalizations.of(context)!.members),
|
2020-10-06 14:52:40 +02:00
|
|
|
fetch: (page) async {
|
2020-10-04 16:10:05 +02:00
|
|
|
page = page ?? 1;
|
|
|
|
final auth = context.read<AuthModel>();
|
|
|
|
final res =
|
|
|
|
await auth.fetchGitlabWithPage('/$type/$id/members?page=$page');
|
|
|
|
return ListPayload(
|
|
|
|
cursor: res.cursor,
|
|
|
|
hasMore: res.hasMore,
|
|
|
|
items: <GitlabUser>[
|
|
|
|
for (var v in res.data) GitlabUser.fromJson(v),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
2020-02-01 05:14:03 +01:00
|
|
|
itemBuilder: (v) {
|
2020-10-08 09:55:26 +02:00
|
|
|
return UserItem.gitlab(
|
2020-02-01 05:14:03 +01:00
|
|
|
avatarUrl: v.avatarUrl,
|
|
|
|
login: v.username,
|
2020-10-08 09:55:26 +02:00
|
|
|
name: v.name,
|
2021-05-16 09:16:35 +02:00
|
|
|
bio: Text(accessLevelMap[v.accessLevel!] ?? ''),
|
2020-10-08 09:55:26 +02:00
|
|
|
id: v.id,
|
2020-02-01 05:14:03 +01:00
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|