Skip to content

Commit e4514da

Browse files
committed
♿️Attach issues, pull request with url
1 parent be3584f commit e4514da

19 files changed

+70
-32
lines changed

lib/bloc/commit/index.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
export 'commit_bloc.dart';
22
export 'commit_event.dart';
33
export 'commit_model.dart';
4-
export 'commit_page.dart';
5-
export 'commit_screen.dart';
64
export 'commit_state.dart';

lib/bloc/issues/issues_model.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class Issues {
8787
}
8888

8989
class IssuesModel {
90+
String url;
9091
String title;
9192
String createdAt;
9293
String state;
@@ -102,6 +103,7 @@ class IssuesModel {
102103
IssuesModel(
103104
{this.title,
104105
this.createdAt,
106+
this.url,
105107
this.state,
106108
this.number,
107109
this.viewerDidAuthor,
@@ -114,6 +116,7 @@ class IssuesModel {
114116
this.type});
115117

116118
IssuesModel.fromJson(Map<String, dynamic> json) {
119+
url= json['url'];
117120
title = json['title'];
118121
createdAt = json['createdAt'];
119122
state = json['state'];
@@ -134,6 +137,7 @@ class IssuesModel {
134137

135138
Map<String, dynamic> toJson() {
136139
final Map<String, dynamic> data = new Map<String, dynamic>();
140+
data['url'] = this.url;
137141
data['title'] = this.title;
138142
data['createdAt'] = this.createdAt;
139143
data['state'] = this.state;

lib/bloc/notification/notification_event.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class OnLoad extends NotificationEvent {
3131
}
3232
yield LoadingNotificationState();
3333
final list = await _userRepository.getNotificationsList(pageNo: 1);
34-
yield LoadedNotificationState(list: null, pageNo: 2, hasNextPage: list.length == 10);
34+
yield LoadedNotificationState(list: list, pageNo: 2, hasNextPage: list.length == 10);
3535
} catch (_, stackTrace) {
3636
developer.log('$_',
3737
name: 'Load Repository Event', error: _, stackTrace: stackTrace);

lib/bloc/notification/notification_state.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class LoadedNotificationState extends NotificationState {
2323
currentList.addAll(notificationList);
2424
return LoadedNotificationState(list: currentList,pageNo: pageNo,hasNextPage: hasNextPage);
2525
}
26+
27+
bool get isNotNullEmpty => this.list != null && this.list.isNotEmpty;
2628
}
2729

2830
class ErrorNotificationState extends NotificationState {

lib/bloc/search/model/search_userModel.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flutter_github_connect/bloc/User/User_model.dart';
22
import 'package:flutter_github_connect/bloc/issues/issues_model.dart';
33
import 'package:flutter_github_connect/bloc/search/repo_model.dart';
44
import 'package:flutter_github_connect/model/page_info_model.dart';
5+
import 'package:flutter_github_connect/model/pul_request.dart' as pull;
56

67
class SearchModel {
78
Data data;
@@ -66,6 +67,9 @@ class Search {
6667
case GithubSearchType.Issue:
6768
list.add(IssuesModel.fromJson(v));
6869
break;
70+
case GithubSearchType.PullRequest:
71+
list.add(pull.Node.fromJson(v));
72+
break;
6973
default:
7074
list.add(SearchRepo.fromJson(v));
7175
break;

lib/bloc/search/repo_model.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ extension TypeOfSearch on GithubSearchType {
537537
String asString() => {
538538
GithubSearchType.Issue: "ISSUE",
539539
GithubSearchType.ORganisation: "USER",
540-
GithubSearchType.PullRequest: "USER",
540+
GithubSearchType.PullRequest: "ISSUE",
541541
GithubSearchType.Repository : "REPOSITORY",
542542
GithubSearchType.People: "USER",
543543
}[this];

lib/bloc/search/search_state.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'package:flutter_github_connect/bloc/User/User_model.dart';
33
import 'package:flutter_github_connect/bloc/issues/issues_model.dart';
44
import 'package:flutter_github_connect/bloc/search/index.dart';
55
import 'package:flutter_github_connect/bloc/search/model/search_userModel.dart';
6-
6+
import 'package:flutter_github_connect/model/pul_request.dart' as pull;
77
abstract class SearchState extends Equatable {
88
@override
99
List<Object> get props => ([]);
@@ -66,18 +66,18 @@ class LoadedSearchState extends SearchState {
6666
}
6767

6868
// Todo : Need to implement
69-
List<IssuesModel> toPullRequest() {
70-
List<IssuesModel> userList = [];
69+
pull.UserPullRequests toPullRequest() {
70+
List<pull.Node> pullRequestsList = [];
7171
if (list != null) {
7272
list
7373
..forEach((element) {
7474
if (element.type != "PullRequest") {
7575
return;
7676
}
77-
userList.add(element);
77+
pullRequestsList.add(element);
7878
});
7979
}
80-
return userList;
80+
return pull.UserPullRequests(nodes:pullRequestsList );
8181
}
8282

8383
List<IssuesModel> toIssueList() {

lib/model/pul_request.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,11 @@ class Node {
9595
this.createdAt,
9696
this.deletions,
9797
this.files,
98-
this.number
98+
this.number,
99+
this.url,
100+
this.type
99101
});
100-
102+
final String url;
101103
final bool closed;
102104
final String title;
103105
final _Author author;
@@ -109,12 +111,16 @@ class Node {
109111
final int deletions;
110112
final _Files files;
111113
final int number;
114+
/// Type is used for identify type of search pull request
115+
final String type;
112116

113117
factory Node.fromRawJson(String str) => Node.fromJson(json.decode(str));
114118

115119
String toRawJson() => json.encode(toJson());
116120

117121
factory Node.fromJson(Map<String, dynamic> json) => Node(
122+
type: json["__typename"] == null ? null : json["__typename"],
123+
url: json["url"] == null ? null : json["url"],
118124
closed: json["closed"] == null ? null : json["closed"],
119125
title: json["title"] == null ? null : json["title"],
120126
author:
@@ -136,6 +142,8 @@ class Node {
136142
);
137143

138144
Map<String, dynamic> toJson() => {
145+
"__typename": type == null ? null : type,
146+
"url": url == null ? null : url,
139147
"closed": closed == null ? null : closed,
140148
"title": title == null ? null : title,
141149
"author": author == null ? null : author.toJson(),

lib/resources/grapgqlApi/graphql_query_api.dart

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ class Apis {
192192
# }
193193
... on Issue {
194194
__typename
195+
url
195196
title
196197
number
197198
closed
@@ -239,12 +240,26 @@ class Apis {
239240
}
240241
... on PullRequest {
241242
__typename
242-
id
243+
url
244+
number
245+
closed
246+
title
243247
author {
244248
login
245249
avatarUrl
246250
url
247251
}
252+
repository {
253+
nameWithOwner
254+
}
255+
state
256+
closedAt
257+
createdAt
258+
deletions
259+
additions
260+
files {
261+
totalCount
262+
}
248263
}
249264
}
250265
}

lib/resources/grapgqlApi/issues_api.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class IssuesApis {
1010
hasNextPage
1111
}
1212
nodes {
13+
url
1314
title
1415
createdAt
1516
state
@@ -52,6 +53,7 @@ class IssuesApis {
5253
hasNextPage
5354
}
5455
nodes {
56+
url
5557
title
5658
createdAt
5759
state

0 commit comments

Comments
 (0)