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

37 lines
1.1 KiB
Dart
Raw Normal View History

2020-02-01 03:32:29 +01:00
import 'package:flutter/material.dart';
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 GlGroupsScreenn extends StatelessWidget {
2020-02-01 03:32:29 +01:00
@override
Widget build(BuildContext context) {
return ListStatefulScaffold<GitlabGroup, int>(
2020-02-01 11:51:33 +01:00
title: AppBarTitle('Groups'),
fetch: (page) async {
2020-10-04 16:10:05 +02:00
page = page ?? 1;
final auth = context.read<AuthModel>();
final res = await auth.fetchGitlabWithPage('/groups?page=$page');
return ListPayload(
cursor: res.cursor,
hasMore: res.hasMore,
items: <GitlabGroup>[
for (var v in res.data) GitlabGroup.fromJson(v),
],
);
},
2020-02-01 03:32:29 +01:00
itemBuilder: (v) {
return UserItem(
avatarUrl: v.avatarUrl,
login: v.path,
bio: Text(v.description ?? ''),
url: '/gitlab/group/${v.id}',
);
},
);
}
}