Beispiel #1
0
        /// <summary>
        /// Gets the application page.
        /// </summary>
        public void GetToApplication()
        {
            if (DeviceIsShared)
            {
                CredentialsManager.DeleteSystemCredentials();
                CredentialsManager.DeleteCredentials();
            }
            if (GeofenceManager == null)
            {
                GeofenceManager = new GeofenceManager();
            }
            if (ImageHelper != null)
            {
                ImageHelper.CheckForImageToUpload();
                NetworkManager.AddNetworkStateListener(ImageHelper);
            }
            ActionManager.GetActionList();
            LocationManager = new LocationManager();
            NavBar          = new PheidiTabbedPage();
            if (LocalisationEnabled)
            {
                LocationManager.StartLocalisation();
            }
            if (MainPage == null)
            {
                MainPage = new NavigationPage(new SystemLoginPage());
            }

            MainPage.Navigation.PushAsync(NavBar);
        }
Beispiel #2
0
 public void RemoveCredentials()
 {
     if (StoreService.DoCredentialsExist())
     {
         StoreService.DeleteCredentials();
     }
 }
        public void LogOutUser()
        {
            _credentialsService.DeleteCredentials();

            // other code you want to do
        }
Beispiel #4
0
        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;
        }