public void StoreCredentials(string credentials) { if (!StoreService.DoCredentialsExist()) { StoreService.SaveCredentials(credentials); } }
public loginXaml() { InitializeComponent(); storeService = DependencyService.Get <ICredentialsService>(); NavigationPage.SetHasNavigationBar(this, true); LoginText.Text = "Welcome to League Summoners!\nSelect the region and search your summoner name!"; searchImage.Source = "NaughtyTeemo.png"; search.SearchButtonPressed += async(sender, e) => { var summonerName = search.Text.Replace(" ", ""); var summoner = await App.api.GetSummonerAsync(region, summonerName); var doCredentialsExist = storeService.DoCredentialsExist(); if (!doCredentialsExist) { storeService.SaveCredentials(summoner.Name, summoner.Region.ToString(), summoner.Id.ToString()); } //NavigationPage.SetHasNavigationBar(this, false); Application.Current.MainPage = new TabbedPages(summoner, region); await Navigation.PopToRootAsync(); }; search.ScopeChanged += (sender, e) => { region = App.regFromString(search.SelectedScopeText); }; }
private void Button_Clicked(object sender, EventArgs e) { try { Person p = new Person(); p.UserName = UserName.Text; p.Password = Password.Text; p = App.DAUtil.SelectEmployee(p); //Navigation.PopModalAsync(); if (p != null && p.ID > 0) { DependencyService.Get <ICredentialsService>().DeleteCredentials(); bool doCredentialsExist = storeService.DoCredentialsExist(); if (!doCredentialsExist) { storeService.SaveCredentials(p.UserName, p.Password); } //Navigation.PushModalAsync(new DemoPage()); Navigation.InsertPageBefore(new DemoPage(), this); Navigation.PopAsync(); } else { DisplayAlert("Alert", "UserName and Password inValid", "OK"); } //LoginPage = new NavigationPage(new MainPage()); } catch (Exception ex) { DisplayAlert("Error", ex.InnerException.ToString(), "OK"); } }
async Task OnAppearing(object sender, EventArgs e) { Debug.WriteLine("Appearing called"); //Check if user previously logged in or not //if (credentialsService.DoCredentialsExist ()) { //LoggedInId = credentialsService.UserId; //Debug.WriteLine ("CredentialsExist, LoggedInId: " + LoggedInId); if (credentialsService.DoCredentialsExist()) { if (App.PromptForAuthentication) { Debug.WriteLine("Triggering touchid auth"); await TouchIdBtnTapped(); } else { Debug.WriteLine("PromptForAuthentication is false - so not triggering any auth"); IsSetupOnDeviceRequired = false; UserCanTriggerAuthentication = true; } } else { IsSetupOnDeviceRequired = true; UserCanTriggerAuthentication = false; LoggedInId = ""; } }
public App() { CredentialsService = new CredentialsService(); if (CredentialsService.DoCredentialsExist()) { MainPage = new NavigationPage(new HomePage()); } else { MainPage = new NavigationPage(new LoginPage()); } }
public App() { InitializeComponent(); DependencyService.Register <JournalDataStore>(); DependencyService.Register <EntryDataStore>(); CredentialsService = new CredentialsService(); if (CredentialsService.DoCredentialsExist()) { MainPage = new NavigationPage(new JournalsPage()); } else { MainPage = new NavigationPage(new LoginPage()); } }
public App() { CredentialsService = new CredentialsService(); InitializeComponent(); if (CredentialsService.DoCredentialsExist()) { MainPage = new NavigationPage(new MainPage()); } else { MainPage = new NavigationPage(new LoginPage()); } /* * if (Device.RuntimePlatform == Device.iOS) * MainPage = new MainPage(); * * else * MainPage = new NavigationPage(new MainPage());*/ }
async void OnLoginButtonClicked(object sender, EventArgs e) { string userName = usernameEntry.Text; string password = passwordEntry.Text; var isValid = AreCredentialsCorrect(userName, password); if (isValid) { bool doCredentialsExist = storeService.DoCredentialsExist(); if (!doCredentialsExist) { storeService.SaveCredentials(userName, password); } Navigation.InsertPageBefore(new HomePage(), this); await Navigation.PopAsync(); } else { messageLabel.Text = "Login failed"; passwordEntry.Text = string.Empty; } }
public bool IsLoggedIn() { return(_credentialsService.DoCredentialsExist()); }
public LoginPage() { var label = new Label { Text = "Search for your profile name" }; storeService = DependencyService.Get <ICredentialsService>(); NavigationPage.SetHasNavigationBar(this, true); searchBar = new CustomSearchBar { Placeholder = "Search Summoner" }; searchBar.SearchButtonPressed += async(sender, e) => { var summonerName = searchBar.Text.Replace(" ", ""); var summoner = await App.api.GetSummonerAsync(region, summonerName); var doCredentialsExist = storeService.DoCredentialsExist(); if (!doCredentialsExist) { storeService.SaveCredentials(summoner.Name, summoner.Region.ToString(), summoner.Id.ToString()); } //NavigationPage.SetHasNavigationBar(this, false); Application.Current.MainPage = new TabbedPages(summoner, summoner.Region); await Navigation.PopToRootAsync(); }; picker = new Picker(); picker.Title = "Region"; picker.Items.Add(Region.euw.ToString().ToUpper()); picker.Items.Add(Region.eune.ToString().ToUpper()); picker.Items.Add(Region.na.ToString().ToUpper()); picker.Items.Add(Region.kr.ToString().ToUpper()); picker.Items.Add(Region.br.ToString().ToUpper()); picker.Items.Add(Region.lan.ToString().ToUpper()); picker.Items.Add(Region.las.ToString().ToUpper()); picker.Items.Add(Region.oce.ToString().ToUpper()); picker.Items.Add(Region.ru.ToString().ToUpper()); picker.Items.Add(Region.tr.ToString().ToUpper()); picker.SelectedIndex = 0; picker.SelectedIndexChanged += (sender, args) => { switch (picker.SelectedIndex) { case 0: region = Region.euw; break; case 1: region = Region.eune; break; case 2: region = Region.na; break; case 3: region = Region.kr; break; case 4: region = Region.br; break; case 5: region = Region.lan; break; case 6: region = Region.las; break; case 7: region = Region.oce; break; case 8: region = Region.ru; break; case 9: region = Region.tr; break; } }; Content = new StackLayout { Children = { searchBar, picker, label } }; }
public App() { var current = Connectivity.NetworkAccess; if (current == NetworkAccess.Internet) { Constants.isOnline = true; } else { Constants.isOnline = false; } CredentialsService = new CredentialsService(); InitializeComponent(); Constants.LocalFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); Constants.WifiOnly = App.Current.Properties.ContainsKey("WiFi") ? App.Current.Properties["WiFi"].ToString() : "False"; // load the lms settings /// GetLMSSettings(); Styles s = new Styles(); try { if (Application.Current.Properties.ContainsKey("ProgramID")) { Constants.Logo = new Uri(Constants.Url + "/FormatResource.ashx/programLearnerView_" + Application.Current.Properties["ProgramID"].ToString() + "/logo.gif"); } if (Application.Current.Properties.ContainsKey("HeaderColour")) { Constants.HeaderColour = Application.Current.Properties["HeaderColour"].ToString(); } // Constants.Logo = new Uri(Constants.Url + "/FormatResource.ashx/programLearnerView_" + CredentialsService.HomeDomain + "/logo.gif"); if (Application.Current.Properties.ContainsKey("MenuBGColour")) { Constants.MenuBackgroundColour = Application.Current.Properties["MenuBGColour"].ToString(); } if (Application.Current.Properties.ContainsKey("MenuTextColour")) { Constants.MenuTextColour = Application.Current.Properties["MenuTextColour"].ToString(); } }catch (Exception ex) { Crashes.TrackError(ex); } if (CredentialsService.DoCredentialsExist() && !String.IsNullOrEmpty(CredentialsService.HomeDomain) && !String.IsNullOrEmpty(CredentialsService.UserID)) { // added a try catch just incase the param hasn't been created. // then we need to force a log in to retrieve the blob location try { s.LabelColour("fontColor", Application.Current.Properties["HeadingTextColour"].ToString()); s.SpinnerColour("bgColor", Application.Current.Properties["HeadingTextColour"].ToString()); // need to set a variable for the width of the current device if (Application.Current.Properties.ContainsKey("HeaderColour")) { Constants.HeaderColour = Application.Current.Properties["HeaderColour"].ToString(); } Constants.Logo = new Uri(Constants.Url + "/FormatResource.ashx/programLearnerView_" + CredentialsService.HomeDomain + "/logo.gif"); if (Application.Current.Properties.ContainsKey("MenuBGColour")) { Constants.MenuBackgroundColour = Application.Current.Properties["MenuBGColour"].ToString(); } if (Application.Current.Properties.ContainsKey("MenuTextColour")) { Constants.MenuTextColour = Application.Current.Properties["MenuTextColour"].ToString(); } Constants.BlobLocation = CredentialsService.BlobLoc; MainPage = new MainPage(); Constants.deviceWidth = Application.Current.MainPage.Width; } catch (Exception e) { MainPage = new NavigationPage(new Login()); Constants.deviceWidth = Application.Current.MainPage.Width; } } else { MainPage = new NavigationPage(new Login()); Constants.deviceWidth = Application.Current.MainPage.Width; } }
public ProfilePage(Summoner summoner, Region region) { InitializeComponent(); search.IsVisible = false; nameText.BackgroundColor = Color.FromRgba(0, 0, 0, 0.6); Title = "Profile"; storeService = DependencyService.Get <ICredentialsService>(); var logoutButton = new ToolbarItem { Text = "Logout", Priority = 1 }; var searchButton = new ToolbarItem { Text = "Search", Icon = "Search.png", Priority = 0 }; ToolbarItems.Add(logoutButton); ToolbarItems.Add(searchButton); logoutButton.Clicked += async(sender, e) => { var logout = await UserDialogs.Instance.ConfirmAsync("", "Are you sure you want to Logout?", "Yes", "No"); if (logout) { if (storeService.DoCredentialsExist()) { storeService.DeleteCredentials(); Application.Current.MainPage = new NavigationPage(new loginXaml()); await Navigation.PopToRootAsync(); } } }; search.ScopeChanged += (sender, e) => { searchRegion = App.regFromString(search.SelectedScopeText); }; searchButton.Clicked += (sender, e) => { if (search.IsFocused) { search.Unfocus(); searchFilterControl.Unfocus(); } else { search.IsVisible = true; search.Focus(); } }; search.SearchButtonPressed += async(sender, e) => { string searchText = System.Net.WebUtility.HtmlEncode(search.Text); //search.Text.Replace(" ", ""); search.Text = ""; search.Unfocus(); try { UserDialogs.Instance.ShowLoading("Loading", MaskType.Black); var searchedSummoner = await App.api.GetSummonerAsync(searchRegion, searchText); icon = string.Format(icon, searchedSummoner.Region, searchedSummoner.Id); var test = new SearchedSummonerPage(searchedSummoner, searchedSummoner.Region); UserDialogs.Instance.HideLoading(); await Navigation.PushAsync(test); } catch { UserDialogs.Instance.HideLoading(); await UserDialogs.Instance.AlertAsync("Try again", "Summoner not found!", "Okay"); } }; var task = Task.Run(async() => { if (freqPlayedChamp.Source == null) { GameList = await api.GetRecentGamesAsync(region, summoner.Id); var freqPlayed = GameList.GroupBy(q => q.ChampionId) .OrderByDescending(gp => gp.Count()) .Select(g => g.Key) .First(); var championPlayedMost = await staticApi.GetChampionAsync(Reg, (int)freqPlayed, new List <ChampionData> { ChampionData.skins }); freqPlayedChamp.Source = new UriImageSource { Uri = new Uri(string.Format(skinString, championPlayedMost.Key, championPlayedMost.Skins[0].Num)), CachingEnabled = false }; updated = true; } }); task.Wait(); search.Unfocused += (sender, e) => { search.IsVisible = false; }; Reg = region; Summoner = summoner; filterControl = new FilterControl { Items = new List <string> { "Match History", "Ranked", "Current Game", "Champions" } }; filterControl.SelectedIndex = 0; contentViewFilter.Content = filterControl; //contentVue.VerticalOptions = LayoutOptions.FillAndExpand; nameText.Text = "\n\t\t " + summoner.Name; summonerIcon.Source = new UriImageSource { Uri = new Uri(string.Format(icon, region, summoner.Id)), CachingEnabled = true }; switch (App.device.HardwareVersion) { case "iPhone SE": case "iPhone 5S": case "iPhone 5S GSM": case "iPhone 5S CDMA": case "iPhone 5": case "iPhone 5 GSM": case "iPhone 5 CDMA": contentVue.HeightRequest = 230; break; case "iPhone 6": case "iPhone 6S": case "iPhone 7": contentVue.HeightRequest = 330; break; case "iPhone 6+": case "iPhone 6s+": case "iPhone 6 Plus": case "iPhone 6S Plus": case "iPhone 7 Plus": case "iPhone 7+": contentVue.HeightRequest = 410; break; } try { allLeagues = api.GetLeagues(region, new List <int> { (int)summoner.Id }); ranked5v5League = allLeagues[summoner.Id].Single(x => x.Queue == Queue.RankedSolo5x5); filterControl.Items = new List <string> { "Match History", "Ranked", "Current Game" }; } catch { filterControl.Items = new List <string> { "Match History", "Current Game" }; } filterControl.SelectedIndexChanged += async(object sender, EventArgs e) => { UserDialogs.Instance.ShowLoading("Loading", MaskType.Black); try { allLeagues = await api.GetLeaguesAsync(region, new List <int> { (int)summoner.Id }); ranked5v5League = allLeagues[summoner.Id].Single(x => x.Queue == Queue.RankedSolo5x5); switch (filterControl.SelectedIndex) { case 0: var MatchList = await loadMatchHistory(summoner, region, this); contentVue.Content = MatchList; UserDialogs.Instance.HideLoading(); break; case 1: var statsPage = await loadRanked(summoner, summoner.Region, this); contentVue.Content = statsPage; UserDialogs.Instance.HideLoading(); break; case 2: currentGameView = await loadCurrentGameView(summoner, summoner.Region, this); contentVue.Content = currentGameView; UserDialogs.Instance.HideLoading(); break; } } catch { switch (filterControl.SelectedIndex) { case 0: var MatchList = await loadMatchHistory(summoner, region, this); contentVue.Content = MatchList; UserDialogs.Instance.HideLoading(); break; case 1: currentGameView = await loadCurrentGameView(summoner, summoner.Region, this); contentVue.Content = currentGameView; UserDialogs.Instance.HideLoading(); break; } } }; var soloRankString = ""; var soloIcon = ""; var flexRankString = ""; var flexIcon = ""; try { div = ranked5v5League.Entries.Where(x => x.PlayerOrTeamId == summoner.Id.ToString()).Select(x => x.Division).Single(); var soloLP = ranked5v5League.Entries.FirstOrDefault(x => x.PlayerOrTeamName == summoner.Name).LeaguePoints; soloRankString = ranked5v5League.Tier + " " + div + " " + soloLP + "LP\nSolo Queue"; switch (ranked5v5League.Tier) { case RiotSharp.LeagueEndpoint.Enums.Tier.Bronze: soloIcon = "Bronze.png"; break; case RiotSharp.LeagueEndpoint.Enums.Tier.Silver: soloIcon = "Silver.png"; break; case RiotSharp.LeagueEndpoint.Enums.Tier.Gold: soloIcon = "Gold.png"; break; case RiotSharp.LeagueEndpoint.Enums.Tier.Platinum: soloIcon = "Platinum.png"; break; case RiotSharp.LeagueEndpoint.Enums.Tier.Diamond: soloIcon = "Diamond.png"; break; case RiotSharp.LeagueEndpoint.Enums.Tier.Master: soloIcon = "Master.png"; break; case RiotSharp.LeagueEndpoint.Enums.Tier.Challenger: soloIcon = "Challenger.png"; break; } } catch { soloRankString = "Unranked"; soloIcon = "Unranked.png"; } try { rankedFlexLeague = allLeagues[summoner.Id].Single(x => x.Queue == Queue.RankedFlexSR); flexDiv = rankedFlexLeague.Entries.Where(x => x.PlayerOrTeamId == summoner.Id.ToString()).Select(x => x.Division).Single(); var flexLP = rankedFlexLeague.Entries.FirstOrDefault(x => x.PlayerOrTeamName == summoner.Name).LeaguePoints; flexRankString = rankedFlexLeague.Tier + " " + flexDiv + " " + flexLP + "LP\nFlex 5v5"; switch (rankedFlexLeague.Tier) { case RiotSharp.LeagueEndpoint.Enums.Tier.Bronze: flexIcon = "Bronze.png"; break; case RiotSharp.LeagueEndpoint.Enums.Tier.Silver: flexIcon = "Silver.png"; break; case RiotSharp.LeagueEndpoint.Enums.Tier.Gold: flexIcon = "Gold.png"; break; case RiotSharp.LeagueEndpoint.Enums.Tier.Platinum: flexIcon = "Platinum.png"; break; case RiotSharp.LeagueEndpoint.Enums.Tier.Diamond: flexIcon = "Diamond.png"; break; case RiotSharp.LeagueEndpoint.Enums.Tier.Master: flexIcon = "Master.png"; break; case RiotSharp.LeagueEndpoint.Enums.Tier.Challenger: flexIcon = "Challenger.png"; break; } } catch { flexRankString = "Unranked"; flexIcon = "Unranked.png"; } var grid = new Grid { RowDefinitions = { new RowDefinition { Height = new GridLength(50, GridUnitType.Absolute) } }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(50, GridUnitType.Absolute) }, new ColumnDefinition { Width = GridLength.Auto }, new ColumnDefinition { Width = new GridLength(50, GridUnitType.Absolute) }, new ColumnDefinition { Width = GridLength.Auto }, } }; grid.Children.Add(new Image { Source = soloIcon }, 0, 0); grid.Children.Add(new Label { TextColor = Color.White, Text = soloRankString }, 1, 0); grid.Children.Add(new Image { Source = flexIcon }, 2, 0); grid.Children.Add(new Label { TextColor = Color.White, Text = flexRankString }, 3, 0); grid.BackgroundColor = Color.FromRgba(0, 0, 0, 0.6); rankedImagesStuff.Content = grid; }