Exemplo n.º 1
0
        private async Task searchTableAsync()
        {
            getCities          gn      = new getCities();
            List <CitiesModel> allnews = await gn.GetAllNews();

            table.Source = new ListCitiesModelSource(allnews.ToArray(), this, searchBar.Text);
            //tableSource.PerformSearch(searchBar.Text);


            table.ReloadData();
        }
Exemplo n.º 2
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();
            this.NavigationItem.Title = "Nuca App";
            getCities gn   = new getCities();
            var       news = await gn.GetNewsById(Id);

            imagepath = new UIImageView();
            ImageService.Instance.LoadUrl(news.image).Into(imagepath);
            imagepath.Frame = new CGRect(15, 70, this.View.Bounds.Size.Width - 30, this.View.Bounds.Height - 175);
            this.View.AddSubview(imagepath.ViewForBaselineLayout);
        }
Exemplo n.º 3
0
        // This method will add the UIRefreshControl to the table view if
        // it is available, ie, we are running on iOS 6+
        void AddRefreshControl()
        {
            if (UIDevice.CurrentDevice.CheckSystemVersion(6, 0))
            {
                // the refresh control is available, let's add it
                RefreshControl = new UIRefreshControl();
                RefreshControl.ValueChanged += async(sender, e) =>
                {
                    getCities          gn      = new getCities();
                    List <CitiesModel> allnews = await gn.GetAllNews();

                    table.Source = new ListCitiesModelSource(allnews.ToArray(), this, " ");
                    await RefreshAsync();
                };
                useRefreshControl = true;
            }
        }
Exemplo n.º 4
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            var btn = new UIButton(UIButtonType.Custom);

            btn.Frame = new CGRect(0, 0, 40, 40);
            btn.SetImage(UIImage.FromBundle("barlogo"), UIControlState.Normal);

            showIndicator();
            searchBar = new UISearchBar()
            {
                Placeholder   = " ",
                Prompt        = " ",
                ShowsScopeBar = true
            };
            searchBar.SizeToFit();
            searchBar.AutocorrectionType            = UITextAutocorrectionType.No;
            searchBar.AutocapitalizationType        = UITextAutocapitalizationType.None;
            searchBar.ReturnKeyType                 = UIReturnKeyType.Done;
            searchBar.EnablesReturnKeyAutomatically = false;
            this.NavigationItem.SetLeftBarButtonItem(new UIBarButtonItem(btn), true);
            this.NavigationItem.TitleView  = searchBar;
            searchBar.CancelButtonClicked += (sender, e) =>
            {
                searchBar.ResignFirstResponder();
            };
            searchBar.SelectedScopeButtonIndexChanged += (sender, e) => { searchBar.ResignFirstResponder(); };
            searchBar.SearchButtonClicked             += (sender, e) =>
            {
                //  searchTable();
                searchBar.ResignFirstResponder();
            };
            searchBar.SearchButtonClicked += (sender, e) =>
            {
                //  Search();
            };
            searchBar.TextChanged += (sender, e) =>
            {
                //this is the method that is called when the user searches
                searchTableAsync();
            };
            searchBar.CancelButtonClicked += (sender, e) =>
            {
                searchBar.ResignFirstResponder();
            };
            searchBar.SelectedScopeButtonIndexChanged += (sender, e) => { searchBar.ResignFirstResponder(); };

            getCities          gn      = new getCities();
            List <CitiesModel> allnews = await gn.GetAllNews();

            if (allnews != null)
            {
                table = new UITableView(View.Bounds);
                table.AutoresizingMask   = UIViewAutoresizing.All;
                table.RowHeight          = 100f;
                table.EstimatedRowHeight = 100f;
                table.Source             = new ListCitiesModelSource(allnews.ToArray(), this, " ");
                await RefreshAsync();

                AddRefreshControl();
                //table.TableHeaderView = searchBar;
                Add(table);
                hideIndicator();
                table.Add(RefreshControl);
            }
            else
            {
                var alrt = UIAlertController.Create("Nuca", "يرجي التاكد من الاتصال بالانترنت", UIAlertControllerStyle.Alert);
                alrt.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                PresentViewController(alrt, true, null);
                hideIndicator();
            }
        }