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