mirror of
https://github.com/git-touch/git-touch
synced 2025-01-31 16:14:49 +01:00
feat(gitlab): group screen
This commit is contained in:
parent
ef1be2faea
commit
d7d05bc72b
@ -12,6 +12,7 @@ import 'package:git_touch/screens/gitea_repo.dart';
|
||||
import 'package:git_touch/screens/gitea_user.dart';
|
||||
import 'package:git_touch/screens/gitlab_blob.dart';
|
||||
import 'package:git_touch/screens/gitlab_commits.dart';
|
||||
import 'package:git_touch/screens/gitlab_group.dart';
|
||||
import 'package:git_touch/screens/gitlab_issue.dart';
|
||||
import 'package:git_touch/screens/gitlab_issues.dart';
|
||||
import 'package:git_touch/screens/gitlab_merge_requests.dart';
|
||||
@ -70,6 +71,7 @@ void main() async {
|
||||
codeThemeRouter,
|
||||
aboutRouter,
|
||||
gitlabUserRouter,
|
||||
gitlabGroupRouter,
|
||||
gitlabBlobRouter,
|
||||
gitlabTreeRouter,
|
||||
gitlabProjectRouter,
|
||||
|
@ -15,6 +15,19 @@ class GitlabUser {
|
||||
_$GitlabUserFromJson(json);
|
||||
}
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class GitlabGroup {
|
||||
int id;
|
||||
String path;
|
||||
String name;
|
||||
String avatarUrl;
|
||||
String description;
|
||||
List<GitlabProject> projects;
|
||||
GitlabGroup();
|
||||
factory GitlabGroup.fromJson(Map<String, dynamic> json) =>
|
||||
_$GitlabGroupFromJson(json);
|
||||
}
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class GitlabTodoProject {
|
||||
String pathWithNamespace;
|
||||
|
@ -28,6 +28,30 @@ Map<String, dynamic> _$GitlabUserToJson(GitlabUser instance) =>
|
||||
'created_at': instance.createdAt?.toIso8601String(),
|
||||
};
|
||||
|
||||
GitlabGroup _$GitlabGroupFromJson(Map<String, dynamic> json) {
|
||||
return GitlabGroup()
|
||||
..id = json['id'] as int
|
||||
..path = json['path'] as String
|
||||
..name = json['name'] as String
|
||||
..avatarUrl = json['avatar_url'] as String
|
||||
..description = json['description'] as String
|
||||
..projects = (json['projects'] as List)
|
||||
?.map((e) => e == null
|
||||
? null
|
||||
: GitlabProject.fromJson(e as Map<String, dynamic>))
|
||||
?.toList();
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$GitlabGroupToJson(GitlabGroup instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'path': instance.path,
|
||||
'name': instance.name,
|
||||
'avatar_url': instance.avatarUrl,
|
||||
'description': instance.description,
|
||||
'projects': instance.projects,
|
||||
};
|
||||
|
||||
GitlabTodoProject _$GitlabTodoProjectFromJson(Map<String, dynamic> json) {
|
||||
return GitlabTodoProject()
|
||||
..pathWithNamespace = json['path_with_namespace'] as String;
|
||||
|
57
lib/screens/gitlab_group.dart
Normal file
57
lib/screens/gitlab_group.dart
Normal file
@ -0,0 +1,57 @@
|
||||
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';
|
||||
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;
|
||||
|
||||
final gitlabGroupRouter = RouterScreen(
|
||||
'/gitlab/group/:id',
|
||||
(context, parameters) =>
|
||||
GitlabGroupScreen(int.parse(parameters['id'].first)));
|
||||
|
||||
class GitlabGroupScreen extends StatelessWidget {
|
||||
final int id;
|
||||
GitlabGroupScreen(this.id);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return RefreshStatefulScaffold<Tuple2<GitlabGroup, Null>>(
|
||||
title: Text('Group'),
|
||||
fetchData: () async {
|
||||
final auth = Provider.of<AuthModel>(context);
|
||||
final res = await Future.wait([auth.fetchGitlab('/groups/$id')]);
|
||||
return Tuple2(GitlabGroup.fromJson(res[0]), null);
|
||||
},
|
||||
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,
|
||||
Column(
|
||||
children: <Widget>[
|
||||
for (var v in p.projects)
|
||||
RepositoryItem.gl(
|
||||
payload: v,
|
||||
note: 'Created ${timeago.format(v.createdAt)}',
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -58,6 +58,7 @@ class UserHeader extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
if (createdAt != null)
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Icon(
|
||||
|
Loading…
x
Reference in New Issue
Block a user