mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-09-10 21:13:57 +08:00

This reverts commit 763cbf8493c610dec0e7e344bee40ad331e7a272. This reverts commit ddad699b259bafe6c7ed630e7afc2eb38b7825e6. This is causing way too many problems - On Android with GitHub we occasionally get a User Cancelled exception. On iOS this doesn't work < ios11 I prefer keeping my way till then. Even though it doesn't support KeepAlive on Android.
63 lines
1.5 KiB
Dart
63 lines
1.5 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
typedef OAuthCallback = void Function(GitHostException);
|
|
|
|
abstract class GitHost {
|
|
void init(OAuthCallback oAuthCallback);
|
|
Future launchOAuthScreen();
|
|
|
|
Future<UserInfo> getUserInfo();
|
|
Future<List<GitHostRepo>> listRepos();
|
|
Future<GitHostRepo> createRepo(String name);
|
|
Future<GitHostRepo> getRepo(String name);
|
|
Future addDeployKey(String sshPublicKey, String repoFullName);
|
|
}
|
|
|
|
class UserInfo {
|
|
String name;
|
|
String email;
|
|
String username;
|
|
|
|
UserInfo({
|
|
@required this.name,
|
|
@required this.email,
|
|
@required this.username,
|
|
});
|
|
}
|
|
|
|
class GitHostRepo {
|
|
final String fullName;
|
|
final String cloneUrl;
|
|
final DateTime updatedAt;
|
|
|
|
GitHostRepo({
|
|
@required this.fullName,
|
|
@required this.cloneUrl,
|
|
@required this.updatedAt,
|
|
});
|
|
|
|
@override
|
|
String toString() {
|
|
return 'GitRepo{fulleName: $fullName, cloneUrl: $cloneUrl, updatedAt: $updatedAt}';
|
|
}
|
|
}
|
|
|
|
class GitHostException implements Exception {
|
|
static const OAuthFailed = GitHostException("OAuthFailed");
|
|
static const MissingAccessCode = GitHostException("MissingAccessCode");
|
|
static const RepoExists = GitHostException("RepoExists");
|
|
static const CreateRepoFailed = GitHostException("CreateRepoFailed");
|
|
static const DeployKeyFailed = GitHostException("DeployKeyFailed");
|
|
static const GetRepoFailed = GitHostException("GetRepoFailed");
|
|
|
|
final String cause;
|
|
const GitHostException(this.cause);
|
|
|
|
@override
|
|
String toString() {
|
|
return "GitHostException: " + cause;
|
|
}
|
|
}
|