Skip to content
This repository was archived by the owner on Jul 2, 2022. It is now read-only.

Commit bf24729

Browse files
committed
Lots of improvements
1 parent 873527a commit bf24729

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+964
-607
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
*.suo
44
*.userprefs
55
packages
6+
Components/

CodeHub.Core/CodeHub.Core.iOS.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@
185185
<Compile Include="ViewModels\IFilterableViewModel.cs" />
186186
<Compile Include="ViewModels\WebBrowserViewModel.cs" />
187187
<Compile Include="PresentationValues.cs" />
188+
<Compile Include="ViewModels\Repositories\RepositoriesForkedViewModel.cs" />
188189
</ItemGroup>
189190
<ItemGroup />
190191
<ItemGroup>
@@ -224,7 +225,7 @@
224225
<HintPath>..\packages\Newtonsoft.Json.8.0.2\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
225226
</Reference>
226227
<Reference Include="GitHubSharp">
227-
<HintPath>..\packages\GitHubClient.1.0.8.0\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\GitHubSharp.dll</HintPath>
228+
<HintPath>..\packages\GitHubClient.1.0.9.0\lib\portable-net45+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\GitHubSharp.dll</HintPath>
228229
</Reference>
229230
</ItemGroup>
230231
<ItemGroup />

CodeHub.Core/Services/JsonHttpClientService.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@ namespace CodeFramework.Core.Services
66
public class JsonHttpClientService : IJsonHttpClientService
77
{
88
private readonly IHttpClientService _httpClientService;
9-
private readonly IJsonSerializationService _jsonSerializationService;
109

11-
public JsonHttpClientService(IHttpClientService httpClientService, IJsonSerializationService jsonSerializationService)
10+
public JsonHttpClientService(IHttpClientService httpClientService)
1211
{
1312
_httpClientService = httpClientService;
14-
_jsonSerializationService = jsonSerializationService;
1513
}
1614

1715
public async Task<TMessage> Get<TMessage>(string url)
@@ -20,7 +18,7 @@ public async Task<TMessage> Get<TMessage>(string url)
2018
client.Timeout = new TimeSpan(0, 0, 30);
2119
var response = await client.GetAsync(url);
2220
var data = await response.Content.ReadAsStringAsync();
23-
return _jsonSerializationService.Deserialize<TMessage>(data);
21+
return Newtonsoft.Json.JsonConvert.DeserializeObject<TMessage>(data);
2422
}
2523

2624
}

CodeHub.Core/ViewModels/Issues/IssueViewModel.cs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,18 @@ public string MarkdownDescription
4141
return string.Empty;
4242
return (GetService<IMarkdownService>().Convert(Issue.Body));
4343
}
44-
}
44+
}
45+
46+
private bool _isCollaborator;
47+
public bool IsCollaborator
48+
{
49+
get { return _isCollaborator; }
50+
set
51+
{
52+
_isCollaborator = value;
53+
RaisePropertyChanged(() => IsCollaborator);
54+
}
55+
}
4556

4657
private IssueModel _issueModel;
4758
public IssueModel Issue
@@ -72,7 +83,7 @@ public ICommand GoToAssigneeCommand
7283
return new MvxCommand(() => {
7384
GetService<IViewModelTxService>().Add(Issue.Assignee);
7485
ShowViewModel<IssueAssignedToViewModel>(new IssueAssignedToViewModel.NavObject { Username = Username, Repository = Repository, Id = Id, SaveOnSelect = true });
75-
});
86+
}, () => IsCollaborator);
7687
}
7788
}
7889

@@ -83,7 +94,7 @@ public ICommand GoToMilestoneCommand
8394
return new MvxCommand(() => {
8495
GetService<IViewModelTxService>().Add(Issue.Milestone);
8596
ShowViewModel<IssueMilestonesViewModel>(new IssueMilestonesViewModel.NavObject { Username = Username, Repository = Repository, Id = Id, SaveOnSelect = true });
86-
});
97+
}, () => IsCollaborator);
8798
}
8899
}
89100

@@ -94,7 +105,7 @@ public ICommand GoToLabelsCommand
94105
return new MvxCommand(() => {
95106
GetService<IViewModelTxService>().Add(Issue.Labels);
96107
ShowViewModel<IssueLabelsViewModel>(new IssueLabelsViewModel.NavObject { Username = Username, Repository = Repository, Id = Id, SaveOnSelect = true });
97-
});
108+
}, () => IsCollaborator);
98109
}
99110
}
100111

@@ -105,7 +116,7 @@ public ICommand GoToEditCommand
105116
return new MvxCommand(() => {
106117
GetService<IViewModelTxService>().Add(Issue);
107118
ShowViewModel<IssueEditViewModel>(new IssueEditViewModel.NavObject { Username = Username, Repository = Repository, Id = Id });
108-
}, () => Issue != null);
119+
}, () => Issue != null && IsCollaborator);
109120
}
110121
}
111122

@@ -141,7 +152,9 @@ protected override Task Load(bool forceCacheInvalidation)
141152
{
142153
var t1 = this.RequestModel(this.GetApplication().Client.Users[Username].Repositories[Repository].Issues[Id].Get(), forceCacheInvalidation, response => Issue = response.Data);
143154
Comments.SimpleCollectionLoad(this.GetApplication().Client.Users[Username].Repositories[Repository].Issues[Id].GetComments(), forceCacheInvalidation).FireAndForget();
144-
Events.SimpleCollectionLoad(this.GetApplication().Client.Users[Username].Repositories[Repository].Issues[Id].GetEvents(), forceCacheInvalidation).FireAndForget();
155+
Events.SimpleCollectionLoad(this.GetApplication().Client.Users[Username].Repositories[Repository].Issues[Id].GetEvents(), forceCacheInvalidation).FireAndForget();
156+
this.RequestModel(this.GetApplication().Client.Users[Username].Repositories[Repository].IsCollaborator(this.GetApplication().Account.Username),
157+
forceCacheInvalidation, response => IsCollaborator = response.Data).FireAndForget();
145158
return t1;
146159
}
147160

CodeHub.Core/ViewModels/PullRequests/PullRequestViewModel.cs

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,29 @@ public string MarkdownDescription
4040
get { return PullRequest == null ? string.Empty : (GetService<IMarkdownService>().Convert(PullRequest.Body)); }
4141
}
4242

43-
private bool _merged;
43+
private bool _canPush;
44+
public bool CanPush
45+
{
46+
get { return _canPush; }
47+
set
48+
{
49+
_canPush = value;
50+
RaisePropertyChanged(() => CanPush);
51+
}
52+
}
4453

54+
private bool _isCollaborator;
55+
public bool IsCollaborator
56+
{
57+
get { return _isCollaborator; }
58+
set
59+
{
60+
_isCollaborator = value;
61+
RaisePropertyChanged(() => IsCollaborator);
62+
}
63+
}
64+
65+
private bool _merged;
4566
public bool Merged
4667
{
4768
get { return _merged; }
@@ -100,7 +121,7 @@ public ICommand GoToAssigneeCommand
100121
{
101122
GetService<IViewModelTxService>().Add(Issue.Assignee);
102123
ShowViewModel<IssueAssignedToViewModel>(new IssueAssignedToViewModel.NavObject { Username = Username, Repository = Repository, Id = Id, SaveOnSelect = true });
103-
}, () => Issue != null);
124+
}, () => Issue != null && IsCollaborator);
104125

105126
this.Bind(x => Issue, cmd.RaiseCanExecuteChanged);
106127
_goToAssigneeCommand = cmd;
@@ -122,7 +143,7 @@ public ICommand GoToMilestoneCommand
122143
{
123144
GetService<IViewModelTxService>().Add(Issue.Milestone);
124145
ShowViewModel<IssueMilestonesViewModel>(new IssueMilestonesViewModel.NavObject { Username = Username, Repository = Repository, Id = Id, SaveOnSelect = true });
125-
}, () => Issue != null);
146+
}, () => Issue != null && IsCollaborator);
126147

127148
this.Bind(x => Issue, cmd.RaiseCanExecuteChanged);
128149
_goToMilestoneCommand = cmd;
@@ -144,7 +165,7 @@ public ICommand GoToLabelsCommand
144165
{
145166
GetService<IViewModelTxService>().Add(Issue.Labels);
146167
ShowViewModel<IssueLabelsViewModel>(new IssueLabelsViewModel.NavObject { Username = Username, Repository = Repository, Id = Id, SaveOnSelect = true });
147-
}, () => Issue != null);
168+
}, () => Issue != null && IsCollaborator);
148169

149170
this.Bind(x => Issue, cmd.RaiseCanExecuteChanged);
150171
_goToLabelsCommand = cmd;
@@ -162,7 +183,7 @@ public ICommand GoToEditCommand
162183
{
163184
GetService<IViewModelTxService>().Add(Issue);
164185
ShowViewModel<IssueEditViewModel>(new IssueEditViewModel.NavObject { Username = Username, Repository = Repository, Id = Id });
165-
}, () => Issue != null);
186+
}, () => Issue != null && IsCollaborator);
166187
}
167188
}
168189

@@ -278,6 +299,10 @@ protected override Task Load(bool forceCacheInvalidation)
278299
Events.SimpleCollectionLoad(this.GetApplication().Client.Users[Username].Repositories[Repository].Issues[Id].GetEvents(), forceCacheInvalidation).FireAndForget();
279300
Comments.SimpleCollectionLoad(this.GetApplication().Client.Users[Username].Repositories[Repository].Issues[Id].GetComments(), forceCacheInvalidation).FireAndForget();
280301
this.RequestModel(this.GetApplication().Client.Users[Username].Repositories[Repository].Issues[Id].Get(), forceCacheInvalidation, response => Issue = response.Data).FireAndForget();
302+
this.RequestModel(this.GetApplication().Client.Users[Username].Repositories[Repository].Get(), forceCacheInvalidation,
303+
response => CanPush = response.Data.Permissions.Push).FireAndForget();
304+
this.RequestModel(this.GetApplication().Client.Users[Username].Repositories[Repository].IsCollaborator(this.GetApplication().Account.Username),
305+
forceCacheInvalidation, response => IsCollaborator = response.Data).FireAndForget();
281306
return t1;
282307
}
283308

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
4+
namespace CodeHub.Core.ViewModels.Repositories
5+
{
6+
public class RepositoriesForkedViewModel : RepositoriesViewModel
7+
{
8+
public RepositoriesForkedViewModel()
9+
{
10+
ShowRepositoryOwner = true;
11+
}
12+
13+
protected override Task Load(bool forceDataRefresh)
14+
{
15+
return Repositories.SimpleCollectionLoad(this.GetApplication().Client.Users[User].Repositories[Repository].GetForks(), forceDataRefresh);
16+
}
17+
18+
public string User
19+
{
20+
get;
21+
private set;
22+
}
23+
24+
public string Repository
25+
{
26+
get;
27+
private set;
28+
}
29+
30+
public void Init(NavObject navObject)
31+
{
32+
User = navObject.User;
33+
Repository = navObject.Repository;
34+
}
35+
36+
public class NavObject
37+
{
38+
public string User { get; set; }
39+
public string Repository { get; set; }
40+
}
41+
}
42+
}
43+

CodeHub.Core/ViewModels/Repositories/RepositoriesTrendingViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ public class RepositoryModel
170170
public string Url { get; set; }
171171
public string Owner { get; set; }
172172
public string Name { get; set; }
173+
public string AvatarUrl { get; set; }
173174
public string Description { get; set; }
174175
public int Stars { get; set; }
175176
public int Forks { get; set; }

CodeHub.Core/ViewModels/Repositories/RepositoryViewModel.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@ public ICommand GoToStargazersCommand
108108
get { return new MvxCommand(() => ShowViewModel<StargazersViewModel>(new StargazersViewModel.NavObject { User = Username, Repository = RepositoryName })); }
109109
}
110110

111+
public ICommand GoToWatchersCommand
112+
{
113+
get { return new MvxCommand(() => ShowViewModel<WatchersViewModel>(new WatchersViewModel.NavObject { User = Username, Repository = RepositoryName })); }
114+
}
115+
116+
public ICommand GoToForkedCommand
117+
{
118+
get { return new MvxCommand(() => ShowViewModel<RepositoriesForkedViewModel>(new RepositoriesForkedViewModel.NavObject { User = Username, Repository = RepositoryName })); }
119+
}
120+
111121
public ICommand GoToEventsCommand
112122
{
113123
get { return new MvxCommand(() => ShowViewModel<RepositoryEventsViewModel>(new RepositoryEventsViewModel.NavObject { Username = Username, Repository = RepositoryName })); }

CodeHub.Core/ViewModels/Repositories/StargazersViewModel.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,38 @@ public class NavObject
3737
public string User { get; set; }
3838
public string Repository { get; set; }
3939
}
40+
}
41+
42+
public class WatchersViewModel : BaseUserCollectionViewModel
43+
{
44+
public string User
45+
{
46+
get;
47+
private set;
48+
}
49+
50+
public string Repository
51+
{
52+
get;
53+
private set;
54+
}
55+
56+
public void Init(NavObject navObject)
57+
{
58+
User = navObject.User;
59+
Repository = navObject.Repository;
60+
}
61+
62+
protected override Task Load(bool forceDataRefresh)
63+
{
64+
return Users.SimpleCollectionLoad(this.GetApplication().Client.Users[User].Repositories[Repository].GetWatchers(), forceDataRefresh);
65+
}
66+
67+
public class NavObject
68+
{
69+
public string User { get; set; }
70+
public string Repository { get; set; }
71+
}
4072
}
4173
}
4274

CodeHub.Core/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="GitHubClient" version="1.0.8.0" targetFramework="xamarinios10" />
3+
<package id="GitHubClient" version="1.0.9.0" targetFramework="xamarinios10" />
44
<package id="modernhttpclient" version="2.4.2" targetFramework="xamarinios10" />
55
<package id="MvvmCross" version="3.5.1" targetFramework="xamarinios10" />
66
<package id="MvvmCross.HotTuna.CrossCore" version="3.5.1" targetFramework="xamarinios10" />

0 commit comments

Comments
 (0)