예제 #1
0
        public SearchTabPage()
        {
            searchBar = new CustomSearchBar {
                Placeholder = "Search Summoner"
            };

            searchBar.SearchButtonPressed += async(sender, e) =>
            {
                string searchText = searchBar.Text.Replace(" ", "");
                searchBar.Text = "";
                searchBar.Unfocus();
                try
                {
                    UserDialogs.Instance.ShowLoading("Loading", MaskType.Black);
                    var summoner = await App.api.GetSummonerAsync(region, searchText);

                    icon = string.Format(icon, summoner.Region, summoner.Id);
                    var test = new SearchedSummonerPage(summoner, summoner.Region);
                    UserDialogs.Instance.HideLoading();
                    await Navigation.PushAsync(test);
                }
                catch
                {
                    UserDialogs.Instance.HideLoading();
                    await UserDialogs.Instance.AlertAsync("Try again", "Summoner not found!", "Okay");
                }
            };

            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;
                }
            };
            var adView = new AdMobView {
                WidthRequest = 320, HeightRequest = 50
            };

            Content = new StackLayout
            {
                Children =
                {
                    searchBar,
                    picker,
                    adView
                }
            };
        }
예제 #2
0
        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
                }
            };
        }
예제 #3
0
        public FavoritesMaster()
        {
            var recentTemplate = new DataTemplate(typeof(ImageCell));

            recentTemplate.SetBinding(TextCell.TextProperty, "Name");
            recentTemplate.SetBinding(ImageCell.ImageSourceProperty, "Icon");

            searchBar = new CustomSearchBar {
                Placeholder = "Search Summoner"
            };

            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;
                }
            };

            listview = new ListView
            {
                ItemTemplate        = recentTemplate,
                SeparatorVisibility = SeparatorVisibility.None,
                HasUnevenRows       = true,
                GroupHeaderTemplate = new DataTemplate(typeof(GroupHeader))
            };

            Title = "Test";
            Icon  = "Star.png";

            if (App.FavoriteDatabase.GetItems().Count <= 5)
            {
                listview.HeightRequest = (App.FavoriteDatabase.GetItems().Count * 105) / 2;
            }
            else
            {
                listview.HeightRequest = (5 * 105) / 2;
            }

            var scrollView = new ScrollView
            {
                Content = new StackLayout
                {
                    Children =
                    {
                        listview,
                        new HtmlLabel {
                            Text = "<b>League Summoners</b> isn't endorsed by Riot Games and doesn't reflect the views or opinions of Riot Games or anyone officially involved in producing or managing League of Legends.<br> League of Legends and Riot Games are trademarks or registered trademarks of Riot Games, Inc. League of Legends © Riot Games, Inc.",FontSize                                                                                                                                                                                                                                                                                                                                   = 12
                        }
                    }
                }
            };

            Padding = new Thickness(0, 20, 0, 0);
            Content = new StackLayout
            {
                Children =
                {
                    new Image {
                        Source = "Sona_Splash_6.jpg", HeightRequest = 100, Aspect = Aspect.AspectFill, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand
                    },
                    searchBar,
                    picker,
                    scrollView
                }
            };
        }