parent
57f2ab7967
commit
f8f436a382
|
@ -201,3 +201,12 @@ class GitlabIssue {
|
|||
factory GitlabIssue.fromJson(Map<String, dynamic> json) =>
|
||||
_$GitlabIssueFromJson(json);
|
||||
}
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class GitlabStarrer {
|
||||
DateTime starredSince;
|
||||
GitlabUser user;
|
||||
GitlabStarrer();
|
||||
factory GitlabStarrer.fromJson(Map<String, dynamic> json) =>
|
||||
_$GitlabStarrerFromJson(json);
|
||||
}
|
||||
|
|
|
@ -348,3 +348,19 @@ Map<String, dynamic> _$GitlabIssueToJson(GitlabIssue instance) =>
|
|||
'updated_at': instance.updatedAt?.toIso8601String(),
|
||||
'labels': instance.labels,
|
||||
};
|
||||
|
||||
GitlabStarrer _$GitlabStarrerFromJson(Map<String, dynamic> json) {
|
||||
return GitlabStarrer()
|
||||
..starredSince = json['starred_since'] == null
|
||||
? null
|
||||
: DateTime.parse(json['starred_since'] as String)
|
||||
..user = json['user'] == null
|
||||
? null
|
||||
: GitlabUser.fromJson(json['user'] as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$GitlabStarrerToJson(GitlabStarrer instance) =>
|
||||
<String, dynamic>{
|
||||
'starred_since': instance.starredSince?.toIso8601String(),
|
||||
'user': instance.user,
|
||||
};
|
||||
|
|
|
@ -7,6 +7,7 @@ import 'package:git_touch/screens/code_theme.dart';
|
|||
import 'package:git_touch/screens/gh_commits.dart';
|
||||
import 'package:git_touch/screens/gh_org_repos.dart';
|
||||
import 'package:git_touch/screens/gl_commit.dart';
|
||||
import 'package:git_touch/screens/gl_starrers.dart';
|
||||
import 'package:git_touch/screens/gt_commits.dart';
|
||||
import 'package:git_touch/screens/gt_issues.dart';
|
||||
import 'package:git_touch/screens/gt_object.dart';
|
||||
|
@ -144,6 +145,7 @@ class GitlabRouter {
|
|||
GitlabRouter.blob,
|
||||
GitlabRouter.tree,
|
||||
GitlabRouter.project,
|
||||
GitlabRouter.starrers,
|
||||
GitlabRouter.issues,
|
||||
GitlabRouter.mergeRequests,
|
||||
GitlabRouter.commits,
|
||||
|
@ -168,6 +170,8 @@ class GitlabRouter {
|
|||
path: params['path']?.first));
|
||||
static final project = RouterScreen('/projects/:id',
|
||||
(context, params) => GlProjectScreen(int.parse(params['id'].first)));
|
||||
static final starrers = RouterScreen('/projects/:id/starrers',
|
||||
(context, params) => GlStarrersScreen(int.parse(params['id'].first)));
|
||||
static final issues = RouterScreen(
|
||||
'/projects/:id/issues',
|
||||
(context, params) => GlIssuesScreen(
|
||||
|
|
|
@ -96,6 +96,7 @@ class GlProjectScreen extends StatelessWidget {
|
|||
EntryItem(
|
||||
count: p.starCount,
|
||||
text: 'Stars',
|
||||
url: '/gitlab/projects/$id/starrers',
|
||||
),
|
||||
EntryItem(
|
||||
count: p.forksCount,
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
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';
|
||||
import 'package:timeago/timeago.dart' as timeago;
|
||||
|
||||
class GlStarrersScreen extends StatelessWidget {
|
||||
final int id;
|
||||
GlStarrersScreen(this.id);
|
||||
|
||||
Future<ListPayload<GitlabStarrer, int>> _query(BuildContext context,
|
||||
[int page = 1]) async {
|
||||
final auth = Provider.of<AuthModel>(context);
|
||||
final res =
|
||||
await auth.fetchGitlabWithPage('/projects/$id/starrers?page=$page');
|
||||
return ListPayload(
|
||||
cursor: res.cursor,
|
||||
hasMore: res.hasMore,
|
||||
items: <GitlabStarrer>[
|
||||
for (var v in res.data) GitlabStarrer.fromJson(v),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListStatefulScaffold<GitlabStarrer, int>(
|
||||
title: AppBarTitle('Members'),
|
||||
onRefresh: () => _query(context),
|
||||
onLoadMore: (page) => _query(context, page),
|
||||
itemBuilder: (v) {
|
||||
return UserItem(
|
||||
avatarUrl: v.user.avatarUrl,
|
||||
login: v.user.username,
|
||||
bio: Text('Starred ' + timeago.format(v.starredSince)),
|
||||
url: '/gitlab/user/${v.user.id}',
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue