diff --git a/CodeHub.Core/ViewModels/App/StartupViewModel.cs b/CodeHub.Core/ViewModels/App/StartupViewModel.cs index c72d1092..9b55d6d4 100644 --- a/CodeHub.Core/ViewModels/App/StartupViewModel.cs +++ b/CodeHub.Core/ViewModels/App/StartupViewModel.cs @@ -4,83 +4,88 @@ using CodeHub.Core.Services; using System.Linq; using CodeHub.Core.Factories; -using System.Threading.Tasks; namespace CodeHub.Core.ViewModels.App { - public class StartupViewModel : BaseStartupViewModel + public class StartupViewModel : BaseStartupViewModel { private readonly ILoginFactory _loginFactory; - private readonly IApplicationService _applicationService; + private readonly IApplicationService _applicationService; public StartupViewModel(ILoginFactory loginFactory, IApplicationService applicationService) - { - _loginFactory = loginFactory; - _applicationService = applicationService; - } + { + _loginFactory = loginFactory; + _applicationService = applicationService; + } - protected async override void Startup() - { - if (!_applicationService.Accounts.Any()) - { - ShowViewModel(); - ShowViewModel(); - return; - } + protected async override void Startup() + { + if (!_applicationService.Accounts.Any()) + { + ShowViewModel(); + ShowViewModel(); + return; + } - var account = GetDefaultAccount() as GitHubAccount; - if (account == null) - { - ShowViewModel(); - return; - } + var account = GetDefaultAccount() as GitHubAccount; + if (account == null) + { + ShowViewModel(); + return; + } - var isEnterprise = account.IsEnterprise || !string.IsNullOrEmpty(account.Password); - if (account.DontRemember) - { - ShowViewModel(); + var isEnterprise = account.IsEnterprise || !string.IsNullOrEmpty(account.Password); + if (account.DontRemember) + { + ShowViewModel(); - //Hack for now - if (isEnterprise) - { - ShowViewModel(new Accounts.AddAccountViewModel.NavObject { IsEnterprise = true, AttemptedAccountId = account.Id }); - } - else - { - ShowViewModel(Accounts.LoginViewModel.NavObject.CreateDontRemember(account)); - } + //Hack for now + if (isEnterprise) + { + ShowViewModel(new Accounts.AddAccountViewModel.NavObject { IsEnterprise = true, AttemptedAccountId = account.Id }); + } + else + { + ShowViewModel(Accounts.LoginViewModel.NavObject.CreateDontRemember(account)); + } - return; - } + return; + } - //Lets login! - try - { - IsLoggingIn = true; - var client = await _loginFactory.LoginAccount(account); - _applicationService.ActivateUser(account, client); - } - catch (GitHubSharp.UnauthorizedException e) - { + //Lets login! + try + { + IsLoggingIn = true; + + Uri accountAvatarUri = null; + Uri.TryCreate(account.AvatarUrl, UriKind.Absolute, out accountAvatarUri); + ImageUrl = accountAvatarUri; + Status = "Logging in as " + account.Username; + + var client = await _loginFactory.LoginAccount(account); + _applicationService.ActivateUser(account, client); + } + catch (GitHubSharp.UnauthorizedException e) + { DisplayAlert("The credentials for the selected account are incorrect. " + e.Message); - ShowViewModel(); - if (isEnterprise) - ShowViewModel(new Accounts.AddAccountViewModel.NavObject { IsEnterprise = true, AttemptedAccountId = account.Id }); - else - ShowViewModel(Accounts.LoginViewModel.NavObject.CreateDontRemember(account)); - } - catch (Exception e) - { + ShowViewModel(); + if (isEnterprise) + ShowViewModel(new Accounts.AddAccountViewModel.NavObject { IsEnterprise = true, AttemptedAccountId = account.Id }); + else + ShowViewModel(Accounts.LoginViewModel.NavObject.CreateDontRemember(account)); + } + catch (Exception e) + { DisplayAlert(e.Message); - ShowViewModel(); - } - finally - { - IsLoggingIn = false; - } + ShowViewModel(); + } + finally + { + IsLoggingIn = false; + } - } + } } } diff --git a/CodeHub.iOS/CodeHub.iOS.csproj b/CodeHub.iOS/CodeHub.iOS.csproj index 247fedfa..3cdb27a4 100644 --- a/CodeHub.iOS/CodeHub.iOS.csproj +++ b/CodeHub.iOS/CodeHub.iOS.csproj @@ -434,6 +434,8 @@ + + diff --git a/CodeHub.iOS/Images/Images.cs b/CodeHub.iOS/Images/Images.cs index a5f36528..8b2eddc4 100755 --- a/CodeHub.iOS/Images/Images.cs +++ b/CodeHub.iOS/Images/Images.cs @@ -48,6 +48,9 @@ public static class Images public static UIImage Language { get { return UIImageHelper.FromFileAuto("Images/language"); } } public static UIImage Unlocked { get { return UIImageHelper.FromFileAuto("Images/unlocked"); } } public static UIImage Locked { get { return UIImageHelper.FromFileAuto("Images/locked"); } } + + public static UIImage LoginUserUnknown { get { return UIImageHelper.FromFileAuto("Images/login_user_unknown"); } } + public static Uri GitHubRepoUrl { diff --git a/CodeHub.iOS/Images/login_user_unknown.png b/CodeHub.iOS/Images/login_user_unknown.png new file mode 100644 index 00000000..2814e998 Binary files /dev/null and b/CodeHub.iOS/Images/login_user_unknown.png differ diff --git a/CodeHub.iOS/Images/login_user_unknown@2x.png b/CodeHub.iOS/Images/login_user_unknown@2x.png new file mode 100644 index 00000000..ba1f10d9 Binary files /dev/null and b/CodeHub.iOS/Images/login_user_unknown@2x.png differ diff --git a/CodeHub.iOS/Theme.cs b/CodeHub.iOS/Theme.cs index 54896532..880e6cf5 100755 --- a/CodeHub.iOS/Theme.cs +++ b/CodeHub.iOS/Theme.cs @@ -164,5 +164,7 @@ public UIColor ApplicationNavigationBarTint } public float FontSizeRatio { get; set; } + + public UIImage LoginUserUnknown { get { return Images.LoginUserUnknown; } } } } diff --git a/lib/CodeFramework b/lib/CodeFramework index 8eb95065..e635eed0 160000 --- a/lib/CodeFramework +++ b/lib/CodeFramework @@ -1 +1 @@ -Subproject commit 8eb9506585d7182918498d304c2514ca410fb537 +Subproject commit e635eed0eb9e0492ec6ba5f4eb0a5c9513f376d8