Minor refactor

This commit is contained in:
Vishesh Handa
2019-01-07 16:23:01 +01:00
parent 3cdb454482
commit 967fce65b0
2 changed files with 82 additions and 87 deletions

View File

@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:journal/storage/git.dart';
class GitApp extends StatelessWidget {
@override
@ -46,89 +46,3 @@ buildGitButtons() {
),
];
}
Future gitClone() async {
const platform = const MethodChannel('gitjournal.io/git');
print("Going to git clone");
try {
await platform.invokeMethod('gitClone', {
'cloneUrl': "root@bcn.vhanda.in:git/test",
'folderName': "journal",
});
print("Done");
} on PlatformException catch (e) {
print("gitClone Failed: '${e.message}'.");
}
}
Future generateSSHKeys() async {
print("generateSSHKeyss");
try {
const platform = const MethodChannel('gitjournal.io/git');
String publicKey = await platform.invokeMethod('generateSSHKeys', {});
print("Public Key " + publicKey);
} on PlatformException catch (e) {
print("Failed to generateSSHKeys: '${e.message}'.");
}
}
Future gitPull() async {
const platform = const MethodChannel('gitjournal.io/git');
print("Going to git pull");
try {
await platform.invokeMethod('gitPull', {
'folderName': "journal",
});
print("Done");
} on PlatformException catch (e) {
print("gitPull Failed: '${e.message}'.");
}
}
Future gitAdd() async {
const platform = const MethodChannel('gitjournal.io/git');
print("Going to git add");
try {
await platform.invokeMethod('gitAdd', {
'folderName': "journal",
'filePattern': ".",
});
print("Done");
} on PlatformException catch (e) {
print("gitAdd Failed: '${e.message}'.");
}
}
Future gitPush() async {
const platform = const MethodChannel('gitjournal.io/git');
print("Going to git push");
try {
await platform.invokeMethod('gitPush', {
'folderName': "journal",
});
print("Done");
} on PlatformException catch (e) {
print("gitPush Failed: '${e.message}'.");
}
}
Future gitCommit() async {
const platform = const MethodChannel('gitjournal.io/git');
print("Going to git commit");
try {
await platform.invokeMethod('gitCommit', {
'folderName': "journal",
'authorName': "Vishesh Handa",
'authorEmail': "noemail@example.com",
'message': "Default message from GitJournal",
});
print("Done");
} on PlatformException catch (e) {
print("gitCommit Failed: '${e.message}'.");
}
}

81
lib/storage/git.dart Normal file
View File

@ -0,0 +1,81 @@
import 'dart:async';
import 'dart:io';
import 'package:flutter/services.dart';
const platform = const MethodChannel('gitjournal.io/git');
Future gitClone() async {
print("Going to git clone");
try {
await platform.invokeMethod('gitClone', {
'cloneUrl': "root@bcn.vhanda.in:git/test",
'folderName': "journal",
});
print("Done");
} on PlatformException catch (e) {
print("gitClone Failed: '${e.message}'.");
}
}
Future generateSSHKeys() async {
print("generateSSHKeyss");
try {
String publicKey = await platform.invokeMethod('generateSSHKeys', {});
print("Public Key " + publicKey);
} on PlatformException catch (e) {
print("Failed to generateSSHKeys: '${e.message}'.");
}
}
Future gitPull() async {
print("Going to git pull");
try {
await platform.invokeMethod('gitPull', {
'folderName': "journal",
});
print("Done");
} on PlatformException catch (e) {
print("gitPull Failed: '${e.message}'.");
}
}
Future gitAdd() async {
print("Going to git add");
try {
await platform.invokeMethod('gitAdd', {
'folderName': "journal",
'filePattern': ".",
});
print("Done");
} on PlatformException catch (e) {
print("gitAdd Failed: '${e.message}'.");
}
}
Future gitPush() async {
print("Going to git push");
try {
await platform.invokeMethod('gitPush', {
'folderName': "journal",
});
print("Done");
} on PlatformException catch (e) {
print("gitPush Failed: '${e.message}'.");
}
}
Future gitCommit() async {
print("Going to git commit");
try {
await platform.invokeMethod('gitCommit', {
'folderName': "journal",
'authorName': "Vishesh Handa",
'authorEmail': "noemail@example.com",
'message': "Default message from GitJournal",
});
print("Done");
} on PlatformException catch (e) {
print("gitCommit Failed: '${e.message}'.");
}
}