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

Commit 5fd7b88

Browse files
committed
Better UI
1 parent 9a65760 commit 5fd7b88

Some content is hidden

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

50 files changed

+1294
-1151
lines changed

CodeHub.Core/CodeHub.Core.iOS.csproj

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@
112112
<Compile Include="ViewModels\Accounts\LoginViewModel.cs" />
113113
<Compile Include="Messages\NotificationCountMessage.cs" />
114114
<Compile Include="Services\IPushNotificationsService.cs" />
115-
<Compile Include="ViewModels\App\AboutViewModel.cs" />
116115
<Compile Include="ViewModels\Source\EditSourceViewModel.cs" />
117116
<Compile Include="Messages\SourceEditMessage.cs" />
118117
<Compile Include="Services\JsonSerializationService.cs" />
@@ -123,7 +122,6 @@
123122
<Compile Include="Messages\GistAddMessage.cs" />
124123
<Compile Include="ViewModels\Repositories\RepositoriesTrendingViewModel.cs" />
125124
<Compile Include="Utils\MarkdownHtmlGenerator.cs" />
126-
<Compile Include="ViewModels\App\SidebarOrderViewModel.cs" />
127125
<Compile Include="Factories\IFeatureFactory.cs" />
128126
<Compile Include="Factories\ILoginFactory.cs" />
129127
<Compile Include="Factories\LoginFactory.cs" />
@@ -150,9 +148,7 @@
150148
<Compile Include="Services\IAccountPreferencesService.cs" />
151149
<Compile Include="Services\IAccountsService.cs" />
152150
<Compile Include="Services\IAlertDialogService.cs" />
153-
<Compile Include="Services\IAnalyticsService.cs" />
154151
<Compile Include="Services\IDefaultValueService.cs" />
155-
<Compile Include="Services\IEnvrionmentService.cs" />
156152
<Compile Include="Services\IHttpClientService.cs" />
157153
<Compile Include="Services\IJsonHttpClientService.cs" />
158154
<Compile Include="Services\IJsonSerializationService.cs" />
@@ -161,7 +157,6 @@
161157
<Compile Include="Services\IViewModelTxService.cs" />
162158
<Compile Include="Services\JsonHttpClientService.cs" />
163159
<Compile Include="Services\ViewModelTxService.cs" />
164-
<Compile Include="Utils\CrashReporting.cs" />
165160
<Compile Include="Utils\CustomObservableCollection.cs" />
166161
<Compile Include="Utils\DateTimeExtensions.cs" />
167162
<Compile Include="Utils\DefaultStartupViewCommand.cs" />
@@ -186,6 +181,8 @@
186181
<Compile Include="ViewModels\WebBrowserViewModel.cs" />
187182
<Compile Include="PresentationValues.cs" />
188183
<Compile Include="ViewModels\Repositories\RepositoriesForkedViewModel.cs" />
184+
<Compile Include="Utils\GitHubAvatar.cs" />
185+
<Compile Include="Utils\GitHubExtensions.cs" />
189186
</ItemGroup>
190187
<ItemGroup />
191188
<ItemGroup>

CodeHub.Core/Services/IAnalyticsService.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

CodeHub.Core/Services/IEnvrionmentService.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

CodeHub.Core/Utils/CrashReporting.cs

Lines changed: 0 additions & 62 deletions
This file was deleted.

CodeHub.Core/Utils/DateTimeExtensions.cs

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,6 @@ namespace System
22
{
33
public static class DateTimeExtensions
44
{
5-
public static string ToDaysAgo(this DateTimeOffset d)
6-
{
7-
var dt = DateTimeOffset.Now.Subtract(d);
8-
9-
if (dt.TotalDays >= 365)
10-
{
11-
var years = Convert.ToInt32(dt.TotalDays) / 365;
12-
return years + (years > 1 ? " years ago" : " year ago");
13-
}
14-
if (dt.TotalDays >= 30)
15-
{
16-
var months = Convert.ToInt32(dt.TotalDays) / 30;
17-
return months + (months > 1 ? " months ago" : " month ago");
18-
}
19-
if (dt.TotalDays > 1)
20-
{
21-
var days = Convert.ToInt32(dt.TotalDays);
22-
return days + (days > 1 ? " days ago" : " day ago");
23-
}
24-
25-
if (dt.TotalHours > 1)
26-
{
27-
var hours = Convert.ToInt32(dt.TotalHours);
28-
return hours + (hours > 1 ? " hours ago" : " hour ago");
29-
}
30-
31-
if (dt.TotalMinutes > 1)
32-
{
33-
var minutes = Convert.ToInt32(dt.TotalMinutes);
34-
return minutes + (minutes > 1 ? " minutes ago" : " minute ago");
35-
}
36-
37-
return "moments ago";
38-
}
39-
40-
public static int TotalDaysAgo(this DateTime d)
41-
{
42-
return Convert.ToInt32(Math.Round(DateTime.Now.Subtract(d.ToLocalTime()).TotalDays));
43-
}
44-
455
public static int TotalDaysAgo(this DateTimeOffset d)
466
{
477
return Convert.ToInt32(Math.Round(DateTimeOffset.Now.Subtract(d).TotalDays));

CodeHub.Core/Utils/GitHubAvatar.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using System;
2+
using CodeHub.Core.Utilities;
3+
4+
namespace CodeHub.Core.Utilities
5+
{
6+
public class GitHubAvatar
7+
{
8+
public string AvatarUrl { get; }
9+
10+
public static GitHubAvatar Empty
11+
{
12+
get { return new GitHubAvatar((string)null); }
13+
}
14+
15+
public GitHubAvatar(string avatarUrl)
16+
{
17+
AvatarUrl = avatarUrl;
18+
}
19+
20+
public GitHubAvatar(Uri avatarUri)
21+
{
22+
AvatarUrl = avatarUri?.AbsoluteUri;
23+
}
24+
}
25+
}
26+
27+
public static class GitHubAvatarExtensions
28+
{
29+
public static Uri ToUri(this GitHubAvatar @this, int? size = null)
30+
{
31+
if (@this == null || @this.AvatarUrl == null)
32+
return null;
33+
34+
try
35+
{
36+
var baseUri = new UriBuilder(@this.AvatarUrl);
37+
38+
if (size == null)
39+
return baseUri.Uri;
40+
41+
var queryToAppend = "size=" + size.Value;
42+
if (baseUri.Query != null && baseUri.Query.Length > 1)
43+
baseUri.Query = baseUri.Query.Substring(1) + "&" + queryToAppend;
44+
else
45+
baseUri.Query = queryToAppend;
46+
return baseUri.Uri;
47+
}
48+
catch
49+
{
50+
return null;
51+
}
52+
}
53+
}
54+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System;
2+
using GitHubSharp.Models;
3+
using System.Text;
4+
using System.Security.Cryptography;
5+
6+
7+
public static class GitHubExtensions
8+
{
9+
private const string GitHubDefaultGravitar = "https%3A%2F%2Fassets-cdn.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png&r=x&s=140";
10+
11+
public static string GenerateCommiterName(this CommitModel x)
12+
{
13+
if (x.Commit.Author != null && !string.IsNullOrEmpty(x.Commit.Author.Name))
14+
return x.Commit.Author.Name;
15+
if (x.Commit.Committer != null && !string.IsNullOrEmpty(x.Commit.Committer.Name))
16+
return x.Commit.Committer.Name;
17+
if (x.Author != null)
18+
return x.Author.Login;
19+
return x.Committer != null ? x.Committer.Login : "Unknown";
20+
}
21+
22+
public static Uri GenerateGravatarUrl(this CommitModel x)
23+
{
24+
if (x == null)
25+
return null;
26+
27+
try
28+
{
29+
if (x.Author != null && !string.IsNullOrEmpty(x.Author.AvatarUrl))
30+
return new Uri(x.Author.AvatarUrl);
31+
32+
var inputBytes = Encoding.UTF8.GetBytes(x.Commit.Author.Email.Trim().ToLower());
33+
var hash = MD5.Create().ComputeHash(inputBytes);
34+
var sb = new StringBuilder();
35+
for (int i = 0; i < hash.Length; i++)
36+
sb.Append(hash[i].ToString("x2"));
37+
return new Uri(string.Format("http://www.gravatar.com/avatar/{0}?d={1}", sb, GitHubDefaultGravitar));
38+
}
39+
catch
40+
{
41+
return null;
42+
}
43+
}
44+
}
45+
46+

CodeHub.Core/ViewModels/App/AboutViewModel.cs

Lines changed: 0 additions & 29 deletions
This file was deleted.

CodeHub.Core/ViewModels/App/MenuViewModel.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,6 @@ public ICommand GoToRepositoryCommand
164164
get { return new MvxCommand<RepositoryIdentifier>(x => ShowMenuViewModel<RepositoryViewModel>(new RepositoryViewModel.NavObject { Username = x.Owner, Repository = x.Name }));}
165165
}
166166

167-
public ICommand GoToAboutCommand
168-
{
169-
get { return new MvxCommand(() => ShowMenuViewModel<AboutViewModel>(null)); }
170-
}
171-
172167
public ICommand GoToUpgradesCommand
173168
{
174169
get { return new MvxCommand(() => ShowMenuViewModel<UpgradesViewModel>(null)); }

CodeHub.Core/ViewModels/App/SettingsViewModel.cs

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using CodeHub.Core.Services;
77
using System;
88
using System.Threading.Tasks;
9+
using CodeHub.Core.ViewModels.Repositories;
910

1011
namespace CodeHub.Core.ViewModels.App
1112
{
@@ -30,16 +31,11 @@ public ICommand GoToDefaultStartupViewCommand
3031
get { return new MvxCommand(() => ShowViewModel<DefaultStartupViewModel>()); }
3132
}
3233

33-
public ICommand GoToSidebarOrderCommand
34+
public ICommand GoToSourceCodeCommand
3435
{
35-
get { return new MvxCommand(() => ShowViewModel<SidebarOrderViewModel>()); }
36+
get { return new MvxCommand(() => ShowViewModel<RepositoryViewModel>(new RepositoryViewModel.NavObject { Repository = "codehub", Username = "thedillonb" })); }
3637
}
3738

38-
public ICommand DeleteAllCacheCommand
39-
{
40-
get { return new MvxCommand(DeleteCache); }
41-
}
42-
4339
private bool _isSaving;
4440
public bool IsSaving
4541
{
@@ -51,18 +47,6 @@ private set
5147
}
5248
}
5349

54-
public bool AnalyticsEnabled
55-
{
56-
get
57-
{
58-
return GetService<IAnalyticsService>().Enabled;
59-
}
60-
set
61-
{
62-
GetService<IAnalyticsService>().Enabled = value;
63-
}
64-
}
65-
6650
public bool LargeFonts
6751
{
6852
get
@@ -133,24 +117,5 @@ private async Task RegisterPushNotifications(bool enabled)
133117
IsSaving = false;
134118
}
135119
}
136-
137-
private void DeleteCache()
138-
{
139-
if (this.GetApplication().Account.Cache != null)
140-
this.GetApplication().Account.Cache.DeleteAll();
141-
}
142-
143-
public float CacheSize
144-
{
145-
get
146-
{
147-
if (this.GetApplication().Account.Cache == null)
148-
return 0f;
149-
150-
var totalCacheSize = this.GetApplication().Account.Cache.Sum(x => System.IO.File.Exists(x.Path) ? new System.IO.FileInfo(x.Path).Length : 0);
151-
var totalCacheSizeMB = ((float)totalCacheSize / 1024f / 1024f);
152-
return totalCacheSizeMB;
153-
}
154-
}
155120
}
156121
}

0 commit comments

Comments
 (0)