2020-01-31 15:45:40 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
import 'package:git_touch/models/auth.dart';
|
|
|
|
import 'package:git_touch/models/gitlab.dart';
|
|
|
|
import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
2020-02-01 04:40:41 +01:00
|
|
|
import 'package:git_touch/widgets/entry_item.dart';
|
2020-01-31 15:45:40 +01:00
|
|
|
import 'package:git_touch/widgets/repository_item.dart';
|
|
|
|
import 'package:git_touch/widgets/user_header.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:tuple/tuple.dart';
|
|
|
|
import 'package:git_touch/utils/utils.dart';
|
|
|
|
import 'package:timeago/timeago.dart' as timeago;
|
2021-01-05 10:25:19 +01:00
|
|
|
import '../generated/l10n.dart';
|
2020-01-31 15:45:40 +01:00
|
|
|
|
2020-02-07 15:26:37 +01:00
|
|
|
class GlGroupScreen extends StatelessWidget {
|
2020-01-31 15:45:40 +01:00
|
|
|
final int id;
|
2020-02-07 15:26:37 +01:00
|
|
|
GlGroupScreen(this.id);
|
2020-01-31 15:45:40 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-02-01 04:40:41 +01:00
|
|
|
return RefreshStatefulScaffold<Tuple2<GitlabGroup, int>>(
|
2021-01-05 10:25:19 +01:00
|
|
|
title: Text(S.of(context).group),
|
2020-10-06 14:52:40 +02:00
|
|
|
fetch: () async {
|
2020-10-04 14:37:23 +02:00
|
|
|
final auth = context.read<AuthModel>();
|
2020-02-01 04:40:41 +01:00
|
|
|
final res = await Future.wait([
|
|
|
|
auth.fetchGitlab('/groups/$id'),
|
|
|
|
auth.fetchGitlabWithPage('/groups/$id/members?per_page=1')
|
|
|
|
]);
|
|
|
|
return Tuple2(
|
|
|
|
GitlabGroup.fromJson(res[0]),
|
|
|
|
(res[1] as DataWithPage).total,
|
|
|
|
);
|
2020-01-31 15:45:40 +01:00
|
|
|
},
|
|
|
|
bodyBuilder: (data, _) {
|
|
|
|
final p = data.item1;
|
|
|
|
return Column(
|
|
|
|
children: <Widget>[
|
|
|
|
UserHeader(
|
|
|
|
login: p.path,
|
|
|
|
avatarUrl: p.avatarUrl,
|
|
|
|
name: p.name,
|
|
|
|
createdAt: null,
|
|
|
|
bio: p.description,
|
|
|
|
),
|
|
|
|
CommonStyle.border,
|
2020-02-01 04:40:41 +01:00
|
|
|
Row(children: [
|
|
|
|
EntryItem(
|
|
|
|
count: data.item2,
|
|
|
|
text: 'Members',
|
2020-02-01 05:14:03 +01:00
|
|
|
url: '/gitlab/groups/$id/members',
|
2020-02-01 04:40:41 +01:00
|
|
|
),
|
|
|
|
]),
|
|
|
|
CommonStyle.border,
|
2020-01-31 15:45:40 +01:00
|
|
|
Column(
|
|
|
|
children: <Widget>[
|
|
|
|
for (var v in p.projects)
|
|
|
|
RepositoryItem.gl(
|
|
|
|
payload: v,
|
2020-02-01 03:35:55 +01:00
|
|
|
note: 'Updated ${timeago.format(v.lastActivityAt)}',
|
2020-01-31 15:45:40 +01:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|