mirror of
https://github.com/git-touch/git-touch
synced 2025-01-31 16:14:49 +01:00
parent
d152750afb
commit
79fe174b10
@ -92,6 +92,7 @@ class GitlabProject {
|
|||||||
GitlabProjectStatistics statistics;
|
GitlabProjectStatistics statistics;
|
||||||
DateTime lastActivityAt;
|
DateTime lastActivityAt;
|
||||||
DateTime createdAt;
|
DateTime createdAt;
|
||||||
|
String defaultBranch;
|
||||||
GitlabProject();
|
GitlabProject();
|
||||||
factory GitlabProject.fromJson(Map<String, dynamic> json) =>
|
factory GitlabProject.fromJson(Map<String, dynamic> json) =>
|
||||||
_$GitlabProjectFromJson(json);
|
_$GitlabProjectFromJson(json);
|
||||||
|
@ -162,7 +162,8 @@ GitlabProject _$GitlabProjectFromJson(Map<String, dynamic> json) {
|
|||||||
: DateTime.parse(json['last_activity_at'] as String)
|
: DateTime.parse(json['last_activity_at'] as String)
|
||||||
..createdAt = json['created_at'] == null
|
..createdAt = json['created_at'] == null
|
||||||
? null
|
? null
|
||||||
: DateTime.parse(json['created_at'] as String);
|
: DateTime.parse(json['created_at'] as String)
|
||||||
|
..defaultBranch = json['default_branch'] as String;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> _$GitlabProjectToJson(GitlabProject instance) =>
|
Map<String, dynamic> _$GitlabProjectToJson(GitlabProject instance) =>
|
||||||
@ -184,6 +185,7 @@ Map<String, dynamic> _$GitlabProjectToJson(GitlabProject instance) =>
|
|||||||
'statistics': instance.statistics,
|
'statistics': instance.statistics,
|
||||||
'last_activity_at': instance.lastActivityAt?.toIso8601String(),
|
'last_activity_at': instance.lastActivityAt?.toIso8601String(),
|
||||||
'created_at': instance.createdAt?.toIso8601String(),
|
'created_at': instance.createdAt?.toIso8601String(),
|
||||||
|
'default_branch': instance.defaultBranch,
|
||||||
};
|
};
|
||||||
|
|
||||||
GitlabProjectBadge _$GitlabProjectBadgeFromJson(Map<String, dynamic> json) {
|
GitlabProjectBadge _$GitlabProjectBadgeFromJson(Map<String, dynamic> json) {
|
||||||
|
@ -148,12 +148,14 @@ class GitlabRouter {
|
|||||||
static final group = RouterScreen('/group/:id',
|
static final group = RouterScreen('/group/:id',
|
||||||
(context, p) => GitlabGroupScreen(int.parse(p['id'].first)));
|
(context, p) => GitlabGroupScreen(int.parse(p['id'].first)));
|
||||||
static final blob = RouterScreen(
|
static final blob = RouterScreen(
|
||||||
'/projects/:id/blob',
|
'/projects/:id/blob/:ref',
|
||||||
(context, params) => GitlabBlobScreen(int.parse(params['id'].first),
|
(context, params) => GitlabBlobScreen(
|
||||||
|
int.parse(params['id'].first), params['ref'].first,
|
||||||
path: params['path']?.first));
|
path: params['path']?.first));
|
||||||
static final tree = RouterScreen(
|
static final tree = RouterScreen(
|
||||||
'/projects/:id/tree',
|
'/projects/:id/tree/:ref',
|
||||||
(context, params) => GitlabTreeScreen(int.parse(params['id'].first),
|
(context, params) => GitlabTreeScreen(
|
||||||
|
int.parse(params['id'].first), params['ref'].first,
|
||||||
path: params['path']?.first));
|
path: params['path']?.first));
|
||||||
static final project = RouterScreen('/projects/:id',
|
static final project = RouterScreen('/projects/:id',
|
||||||
(context, params) => GitlabProjectScreen(int.parse(params['id'].first)));
|
(context, params) => GitlabProjectScreen(int.parse(params['id'].first)));
|
||||||
|
@ -10,8 +10,9 @@ import 'package:provider/provider.dart';
|
|||||||
|
|
||||||
class GitlabBlobScreen extends StatelessWidget {
|
class GitlabBlobScreen extends StatelessWidget {
|
||||||
final int id;
|
final int id;
|
||||||
|
final String ref;
|
||||||
final String path;
|
final String path;
|
||||||
GitlabBlobScreen(this.id, {this.path});
|
GitlabBlobScreen(this.id, this.ref, {this.path});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -19,7 +20,7 @@ class GitlabBlobScreen extends StatelessWidget {
|
|||||||
title: AppBarTitle(path ?? ''),
|
title: AppBarTitle(path ?? ''),
|
||||||
fetchData: () async {
|
fetchData: () async {
|
||||||
final res = await Provider.of<AuthModel>(context).fetchGitlab(
|
final res = await Provider.of<AuthModel>(context).fetchGitlab(
|
||||||
'/projects/$id/repository/files/${path.urlencode}?ref=master'); // TODO:
|
'/projects/$id/repository/files/${path.urlencode}?ref=$ref');
|
||||||
return GitlabBlob.fromJson(res);
|
return GitlabBlob.fromJson(res);
|
||||||
},
|
},
|
||||||
action: ActionEntry(iconData: Icons.settings, url: '/choose-code-theme'),
|
action: ActionEntry(iconData: Icons.settings, url: '/choose-code-theme'),
|
||||||
|
@ -115,7 +115,7 @@ class GitlabProjectScreen extends StatelessWidget {
|
|||||||
leftIconData: Octicons.code,
|
leftIconData: Octicons.code,
|
||||||
text: Text(langs.keys.isEmpty ? 'Code' : langs.keys.first),
|
text: Text(langs.keys.isEmpty ? 'Code' : langs.keys.first),
|
||||||
rightWidget: Text(filesize(p.statistics.repositorySize)),
|
rightWidget: Text(filesize(p.statistics.repositorySize)),
|
||||||
url: '/gitlab/projects/$id/tree',
|
url: '/gitlab/projects/$id/tree/${p.defaultBranch}',
|
||||||
),
|
),
|
||||||
if (p.issuesEnabled)
|
if (p.issuesEnabled)
|
||||||
TableViewItem(
|
TableViewItem(
|
||||||
|
@ -10,8 +10,9 @@ import 'package:git_touch/utils/utils.dart';
|
|||||||
|
|
||||||
class GitlabTreeScreen extends StatelessWidget {
|
class GitlabTreeScreen extends StatelessWidget {
|
||||||
final int id;
|
final int id;
|
||||||
|
final String ref;
|
||||||
final String path;
|
final String path;
|
||||||
GitlabTreeScreen(this.id, {this.path});
|
GitlabTreeScreen(this.id, this.ref, {this.path});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -19,11 +20,14 @@ class GitlabTreeScreen extends StatelessWidget {
|
|||||||
return RefreshStatefulScaffold<Iterable<GitlabTreeItem>>(
|
return RefreshStatefulScaffold<Iterable<GitlabTreeItem>>(
|
||||||
title: AppBarTitle(path ?? 'Files'),
|
title: AppBarTitle(path ?? 'Files'),
|
||||||
fetchData: () async {
|
fetchData: () async {
|
||||||
var url = '/projects/$id/repository/tree';
|
final uri = Uri(
|
||||||
if (path != null) {
|
path: '/projects/$id/repository/tree',
|
||||||
url += '?path=' + path;
|
queryParameters: {
|
||||||
}
|
'ref': ref,
|
||||||
final res = await auth.fetchGitlab(url);
|
...(path == null ? {} : {'path': path})
|
||||||
|
},
|
||||||
|
);
|
||||||
|
final res = await auth.fetchGitlab(uri.toString());
|
||||||
return (res as List).map((v) => GitlabTreeItem.fromJson(v));
|
return (res as List).map((v) => GitlabTreeItem.fromJson(v));
|
||||||
},
|
},
|
||||||
bodyBuilder: (data, _) {
|
bodyBuilder: (data, _) {
|
||||||
@ -37,9 +41,9 @@ class GitlabTreeScreen extends StatelessWidget {
|
|||||||
url: (() {
|
url: (() {
|
||||||
switch (item.type) {
|
switch (item.type) {
|
||||||
case 'tree':
|
case 'tree':
|
||||||
return '/gitlab/projects/$id/tree?path=${item.path.urlencode}';
|
return '/gitlab/projects/$id/tree/$ref?path=${item.path.urlencode}';
|
||||||
case 'blob':
|
case 'blob':
|
||||||
return '/gitlab/projects/$id/blob?path=${item.path.urlencode}';
|
return '/gitlab/projects/$id/blob/$ref?path=${item.path.urlencode}';
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user