- 在 HomeScreen 中添加 GitHub 卡片组件 - 在 SettingsScreen 中添加 GitHub 设置选项 - 在 AuthService 中添加 GitHub 用户名和 token 的存储和读取逻辑 - 删除未使用的 TimeUtils 类
125 lines
2.6 KiB
Dart
125 lines
2.6 KiB
Dart
class GithubEvent {
|
|
final String id;
|
|
final String type;
|
|
final Actor actor;
|
|
final Repo repo;
|
|
final Payload payload;
|
|
final bool public;
|
|
final DateTime createdAt;
|
|
|
|
GithubEvent({
|
|
required this.id,
|
|
required this.type,
|
|
required this.actor,
|
|
required this.repo,
|
|
required this.payload,
|
|
required this.public,
|
|
required this.createdAt,
|
|
});
|
|
|
|
factory GithubEvent.fromJson(Map<String, dynamic> json) {
|
|
return GithubEvent(
|
|
id: json['id'].toString(),
|
|
type: json['type'],
|
|
actor: Actor.fromJson(json['actor']),
|
|
repo: Repo.fromJson(json['repo']),
|
|
payload: Payload.fromJson(json['payload']),
|
|
public: json['public'],
|
|
createdAt: DateTime.parse(json['created_at']),
|
|
);
|
|
}
|
|
}
|
|
|
|
class Actor {
|
|
final int id;
|
|
final String login;
|
|
final String displayLogin;
|
|
final String avatarUrl;
|
|
|
|
Actor({
|
|
required this.id,
|
|
required this.login,
|
|
required this.displayLogin,
|
|
required this.avatarUrl,
|
|
});
|
|
|
|
factory Actor.fromJson(Map<String, dynamic> json) {
|
|
return Actor(
|
|
id: json['id'],
|
|
login: json['login'],
|
|
displayLogin: json['display_login'],
|
|
avatarUrl: json['avatar_url'],
|
|
);
|
|
}
|
|
}
|
|
|
|
class Repo {
|
|
final int id;
|
|
final String name;
|
|
final String url;
|
|
|
|
Repo({required this.id, required this.name, required this.url});
|
|
|
|
factory Repo.fromJson(Map<String, dynamic> json) {
|
|
return Repo(id: json['id'], name: json['name'], url: json['url']);
|
|
}
|
|
}
|
|
|
|
class Payload {
|
|
final String? action;
|
|
final int? pushId;
|
|
final List<Commit>? commits;
|
|
|
|
Payload({this.action, this.pushId, this.commits});
|
|
|
|
factory Payload.fromJson(Map<String, dynamic> json) {
|
|
return Payload(
|
|
action: json['action'],
|
|
pushId: json['push_id'],
|
|
commits:
|
|
json['commits'] != null
|
|
? List<Commit>.from(
|
|
json['commits'].map((x) => Commit.fromJson(x)),
|
|
)
|
|
: null,
|
|
);
|
|
}
|
|
}
|
|
|
|
class Commit {
|
|
final String sha;
|
|
final Author author;
|
|
final String message;
|
|
final bool distinct;
|
|
final String url;
|
|
|
|
Commit({
|
|
required this.sha,
|
|
required this.author,
|
|
required this.message,
|
|
required this.distinct,
|
|
required this.url,
|
|
});
|
|
|
|
factory Commit.fromJson(Map<String, dynamic> json) {
|
|
return Commit(
|
|
sha: json['sha'],
|
|
author: Author.fromJson(json['author']),
|
|
message: json['message'],
|
|
distinct: json['distinct'],
|
|
url: json['url'],
|
|
);
|
|
}
|
|
}
|
|
|
|
class Author {
|
|
final String email;
|
|
final String name;
|
|
|
|
Author({required this.email, required this.name});
|
|
|
|
factory Author.fromJson(Map<String, dynamic> json) {
|
|
return Author(email: json['email'], name: json['name']);
|
|
}
|
|
}
|