mirror of
https://github.com/git-touch/git-touch
synced 2024-12-15 17:59:35 +01:00
feat(gl): commit screen
This commit is contained in:
parent
0044893bcc
commit
4ea30d0132
@ -178,6 +178,16 @@ class GitlabCommit {
|
||||
_$GitlabCommitFromJson(json);
|
||||
}
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class GitlabDiff {
|
||||
String diff;
|
||||
String newPath;
|
||||
String oldPath;
|
||||
GitlabDiff();
|
||||
factory GitlabDiff.fromJson(Map<String, dynamic> json) =>
|
||||
_$GitlabDiffFromJson(json);
|
||||
}
|
||||
|
||||
@JsonSerializable(fieldRename: FieldRename.snake)
|
||||
class GitlabIssue {
|
||||
String title;
|
||||
|
@ -309,6 +309,20 @@ Map<String, dynamic> _$GitlabCommitToJson(GitlabCommit instance) =>
|
||||
'message': instance.message,
|
||||
};
|
||||
|
||||
GitlabDiff _$GitlabDiffFromJson(Map<String, dynamic> json) {
|
||||
return GitlabDiff()
|
||||
..diff = json['diff'] as String
|
||||
..newPath = json['new_path'] as String
|
||||
..oldPath = json['old_path'] as String;
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$GitlabDiffToJson(GitlabDiff instance) =>
|
||||
<String, dynamic>{
|
||||
'diff': instance.diff,
|
||||
'new_path': instance.newPath,
|
||||
'old_path': instance.oldPath,
|
||||
};
|
||||
|
||||
GitlabIssue _$GitlabIssueFromJson(Map<String, dynamic> json) {
|
||||
return GitlabIssue()
|
||||
..title = json['title'] as String
|
||||
|
@ -6,6 +6,7 @@ import 'package:git_touch/screens/bb_user.dart';
|
||||
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/gt_commits.dart';
|
||||
import 'package:git_touch/screens/gt_issues.dart';
|
||||
import 'package:git_touch/screens/gt_object.dart';
|
||||
@ -146,6 +147,7 @@ class GitlabRouter {
|
||||
GitlabRouter.issues,
|
||||
GitlabRouter.mergeRequests,
|
||||
GitlabRouter.commits,
|
||||
GitlabRouter.commit,
|
||||
GitlabRouter.projectMembers,
|
||||
GitlabRouter.groupMembers,
|
||||
GitlabRouter.issue,
|
||||
@ -182,6 +184,10 @@ class GitlabRouter {
|
||||
'/projects/:id/commits',
|
||||
(context, params) =>
|
||||
GlCommitsScreen(params['id'].first, prefix: params['prefix'].first));
|
||||
static final commit = RouterScreen(
|
||||
'/projects/:id/commit/:sha',
|
||||
(context, params) =>
|
||||
GlCommitScreen(params['id'].first, sha: params['sha'].first));
|
||||
static final projectMembers = RouterScreen(
|
||||
'/projects/:id/members',
|
||||
(context, parameters) =>
|
||||
|
44
lib/screens/gl_commit.dart
Normal file
44
lib/screens/gl_commit.dart
Normal file
@ -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/models/code.dart';
|
||||
import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class GlCommitScreen extends StatelessWidget {
|
||||
final String id;
|
||||
final String sha;
|
||||
GlCommitScreen(this.id, {this.sha});
|
||||
|
||||
Future<List<GitlabDiff>> _query(BuildContext context, [int page = 1]) async {
|
||||
final auth = Provider.of<AuthModel>(context);
|
||||
final res = await auth
|
||||
.fetchGitlabWithPage('/projects/$id/repository/commits/$sha/diff');
|
||||
return (res.data as List).map((v) => GitlabDiff.fromJson(v)).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final code = Provider.of<CodeModel>(context);
|
||||
|
||||
return RefreshStatefulScaffold<List<GitlabDiff>>(
|
||||
title: AppBarTitle('Commits'),
|
||||
fetchData: () => _query(context),
|
||||
bodyBuilder: (items, _) {
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
for (var item in items)
|
||||
Text(
|
||||
item.diff,
|
||||
style: TextStyle(
|
||||
fontFamily: code.fontFamilyUsed,
|
||||
fontSize: 14,
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user