mirror of
https://github.com/git-touch/git-touch
synced 2025-01-31 16:14:49 +01:00
improvement(gitlab): repo avatar link
This commit is contained in:
parent
0a83206071
commit
ef1be2faea
@ -2,23 +2,6 @@ import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'gitlab.g.dart';
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class GitlabUserProject {
|
||||
int id;
|
||||
GitlabUser owner;
|
||||
String name;
|
||||
String description;
|
||||
int starCount;
|
||||
int forksCount;
|
||||
String visibility;
|
||||
DateTime createdAt;
|
||||
|
||||
GitlabUserProject();
|
||||
|
||||
factory GitlabUserProject.fromJson(Map<String, dynamic> json) =>
|
||||
_$GitlabUserProjectFromJson(json);
|
||||
}
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class GitlabUser {
|
||||
int id;
|
||||
@ -35,9 +18,7 @@ class GitlabUser {
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class GitlabTodoProject {
|
||||
String pathWithNamespace;
|
||||
|
||||
GitlabTodoProject();
|
||||
|
||||
factory GitlabTodoProject.fromJson(Map<String, dynamic> json) =>
|
||||
_$GitlabTodoProjectFromJson(json);
|
||||
}
|
||||
@ -49,9 +30,7 @@ class GitlabTodo {
|
||||
String actionName;
|
||||
String targetType;
|
||||
GitlabTodoTarget target;
|
||||
|
||||
GitlabTodo();
|
||||
|
||||
factory GitlabTodo.fromJson(Map<String, dynamic> json) =>
|
||||
_$GitlabTodoFromJson(json);
|
||||
}
|
||||
@ -64,9 +43,7 @@ class GitlabTodoTarget {
|
||||
GitlabUser author;
|
||||
String description;
|
||||
DateTime createdAt;
|
||||
|
||||
GitlabTodoTarget();
|
||||
|
||||
factory GitlabTodoTarget.fromJson(Map<String, dynamic> json) =>
|
||||
_$GitlabTodoTargetFromJson(json);
|
||||
}
|
||||
@ -94,11 +71,13 @@ class GitlabProject {
|
||||
String readmeUrl;
|
||||
String webUrl;
|
||||
GitlabProjectNamespace namespace;
|
||||
GitlabUser owner;
|
||||
bool issuesEnabled;
|
||||
int openIssuesCount;
|
||||
bool mergeRequestsEnabled;
|
||||
GitlabProjectStatistics statistics;
|
||||
DateTime lastActivityAt;
|
||||
DateTime createdAt;
|
||||
GitlabProject();
|
||||
factory GitlabProject.fromJson(Map<String, dynamic> json) =>
|
||||
_$GitlabProjectFromJson(json);
|
||||
@ -126,8 +105,8 @@ class GitlabProjectNamespace {
|
||||
int id;
|
||||
String name;
|
||||
String path;
|
||||
String kind;
|
||||
GitlabProjectNamespace();
|
||||
|
||||
factory GitlabProjectNamespace.fromJson(Map<String, dynamic> json) =>
|
||||
_$GitlabProjectNamespaceFromJson(json);
|
||||
}
|
||||
@ -156,9 +135,7 @@ class GitlabEvent {
|
||||
String actionName;
|
||||
String targetType;
|
||||
GitlabEventNote note;
|
||||
|
||||
GitlabEvent();
|
||||
|
||||
factory GitlabEvent.fromJson(Map<String, dynamic> json) =>
|
||||
_$GitlabEventFromJson(json);
|
||||
}
|
||||
@ -168,9 +145,7 @@ class GitlabEventNote {
|
||||
String body;
|
||||
String noteableType;
|
||||
int noteableIid;
|
||||
|
||||
GitlabEventNote();
|
||||
|
||||
factory GitlabEventNote.fromJson(Map<String, dynamic> json) =>
|
||||
_$GitlabEventNoteFromJson(json);
|
||||
}
|
||||
|
@ -6,34 +6,6 @@ part of 'gitlab.dart';
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
GitlabUserProject _$GitlabUserProjectFromJson(Map<String, dynamic> json) {
|
||||
return GitlabUserProject()
|
||||
..id = json['id'] as int
|
||||
..owner = json['owner'] == null
|
||||
? null
|
||||
: GitlabUser.fromJson(json['owner'] as Map<String, dynamic>)
|
||||
..name = json['name'] as String
|
||||
..description = json['description'] as String
|
||||
..starCount = json['star_count'] as int
|
||||
..forksCount = json['forks_count'] as int
|
||||
..visibility = json['visibility'] as String
|
||||
..createdAt = json['created_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['created_at'] as String);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$GitlabUserProjectToJson(GitlabUserProject instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'owner': instance.owner,
|
||||
'name': instance.name,
|
||||
'description': instance.description,
|
||||
'star_count': instance.starCount,
|
||||
'forks_count': instance.forksCount,
|
||||
'visibility': instance.visibility,
|
||||
'created_at': instance.createdAt?.toIso8601String(),
|
||||
};
|
||||
|
||||
GitlabUser _$GitlabUserFromJson(Map<String, dynamic> json) {
|
||||
return GitlabUser()
|
||||
..id = json['id'] as int
|
||||
@ -149,6 +121,9 @@ GitlabProject _$GitlabProjectFromJson(Map<String, dynamic> json) {
|
||||
? null
|
||||
: GitlabProjectNamespace.fromJson(
|
||||
json['namespace'] as Map<String, dynamic>)
|
||||
..owner = json['owner'] == null
|
||||
? null
|
||||
: GitlabUser.fromJson(json['owner'] as Map<String, dynamic>)
|
||||
..issuesEnabled = json['issues_enabled'] as bool
|
||||
..openIssuesCount = json['open_issues_count'] as int
|
||||
..mergeRequestsEnabled = json['merge_requests_enabled'] as bool
|
||||
@ -158,7 +133,10 @@ GitlabProject _$GitlabProjectFromJson(Map<String, dynamic> json) {
|
||||
json['statistics'] as Map<String, dynamic>)
|
||||
..lastActivityAt = json['last_activity_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['last_activity_at'] as String);
|
||||
: DateTime.parse(json['last_activity_at'] as String)
|
||||
..createdAt = json['created_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['created_at'] as String);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$GitlabProjectToJson(GitlabProject instance) =>
|
||||
@ -173,11 +151,13 @@ Map<String, dynamic> _$GitlabProjectToJson(GitlabProject instance) =>
|
||||
'readme_url': instance.readmeUrl,
|
||||
'web_url': instance.webUrl,
|
||||
'namespace': instance.namespace,
|
||||
'owner': instance.owner,
|
||||
'issues_enabled': instance.issuesEnabled,
|
||||
'open_issues_count': instance.openIssuesCount,
|
||||
'merge_requests_enabled': instance.mergeRequestsEnabled,
|
||||
'statistics': instance.statistics,
|
||||
'last_activity_at': instance.lastActivityAt?.toIso8601String(),
|
||||
'created_at': instance.createdAt?.toIso8601String(),
|
||||
};
|
||||
|
||||
GitlabProjectBadge _$GitlabProjectBadgeFromJson(Map<String, dynamic> json) {
|
||||
@ -209,7 +189,8 @@ GitlabProjectNamespace _$GitlabProjectNamespaceFromJson(
|
||||
return GitlabProjectNamespace()
|
||||
..id = json['id'] as int
|
||||
..name = json['name'] as String
|
||||
..path = json['path'] as String;
|
||||
..path = json['path'] as String
|
||||
..kind = json['kind'] as String;
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$GitlabProjectNamespaceToJson(
|
||||
@ -218,6 +199,7 @@ Map<String, dynamic> _$GitlabProjectNamespaceToJson(
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'path': instance.path,
|
||||
'kind': instance.kind,
|
||||
};
|
||||
|
||||
GitlabTreeItem _$GitlabTreeItemFromJson(Map<String, dynamic> json) {
|
||||
|
@ -30,15 +30,8 @@ class GitlabExplore extends StatelessWidget {
|
||||
onLoadMore: (page) => _query(context, page),
|
||||
itemBuilder: (v) {
|
||||
return RepositoryItem.gl(
|
||||
id: v.id,
|
||||
owner: v.namespace.path,
|
||||
avatarUrl: v.avatarUrl,
|
||||
name: v.name,
|
||||
description: v.description,
|
||||
starCount: v.starCount,
|
||||
forkCount: v.forksCount,
|
||||
payload: v,
|
||||
note: 'Updated ${timeago.format(v.lastActivityAt)}',
|
||||
visibility: v.visibility,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@ -23,8 +23,7 @@ class GitlabUserScreen extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return RefreshStatefulScaffold<
|
||||
Tuple2<GitlabUser, Iterable<GitlabUserProject>>>(
|
||||
return RefreshStatefulScaffold<Tuple2<GitlabUser, Iterable<GitlabProject>>>(
|
||||
title: Text(isViewer ? 'Me' : 'User'),
|
||||
fetchData: () async {
|
||||
final auth = Provider.of<AuthModel>(context);
|
||||
@ -35,7 +34,7 @@ class GitlabUserScreen extends StatelessWidget {
|
||||
]);
|
||||
return Tuple2(
|
||||
GitlabUser.fromJson(res[0]),
|
||||
[for (var v in res[1]) GitlabUserProject.fromJson(v)],
|
||||
[for (var v in res[1]) GitlabProject.fromJson(v)],
|
||||
);
|
||||
},
|
||||
action: isViewer
|
||||
@ -62,15 +61,8 @@ class GitlabUserScreen extends StatelessWidget {
|
||||
children: <Widget>[
|
||||
for (var v in projects)
|
||||
RepositoryItem.gl(
|
||||
id: v.id,
|
||||
owner: v.owner.username,
|
||||
avatarUrl: v.owner.avatarUrl,
|
||||
name: v.name,
|
||||
description: v.description,
|
||||
starCount: v.starCount,
|
||||
forkCount: v.forksCount,
|
||||
payload: v,
|
||||
note: 'Created ${timeago.format(v.createdAt)}',
|
||||
visibility: v.visibility,
|
||||
)
|
||||
],
|
||||
)
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:git_touch/models/gitlab.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/widgets/avatar.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@ -36,20 +37,21 @@ class RepositoryItem extends StatelessWidget {
|
||||
});
|
||||
|
||||
RepositoryItem.gl({
|
||||
@required id,
|
||||
@required this.owner,
|
||||
@required this.avatarUrl,
|
||||
@required this.name,
|
||||
@required this.description,
|
||||
@required this.starCount,
|
||||
@required this.forkCount,
|
||||
@required visibility,
|
||||
@required GitlabProject payload,
|
||||
this.primaryLanguageName,
|
||||
this.primaryLanguageColor,
|
||||
this.note,
|
||||
}) : url = '/gitlab/projects/$id',
|
||||
avatarLink = '/gitlab/user/$id',
|
||||
iconData = _buildGlIconData(visibility);
|
||||
}) : owner = payload.namespace.path,
|
||||
avatarUrl = payload.owner?.avatarUrl,
|
||||
name = payload.name,
|
||||
description = payload.description,
|
||||
starCount = payload.starCount,
|
||||
forkCount = payload.forksCount,
|
||||
url = '/gitlab/projects/${payload.id}',
|
||||
avatarLink = payload.namespace.kind == 'group'
|
||||
? '/gitlab/group/${payload.namespace.id}'
|
||||
: '/gitlab/user/${payload.owner.id}',
|
||||
iconData = _buildGlIconData(payload.visibility);
|
||||
|
||||
RepositoryItem.gh({
|
||||
@required this.owner,
|
||||
|
Loading…
x
Reference in New Issue
Block a user