Esempio n. 1
0
        private async Task searchTableAsync()
        {
            getadvs gn      = new getadvs();
            var     allnews = await gn.GetAllAdvs();

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


            table.ReloadData();
        }
Esempio n. 2
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) =>
                {
                    getadvs gn      = new getadvs();
                    var     allnews = await gn.GetAllAdvs();

                    table.Source = new ListsAdvsModelSource(allnews.ToArray(), this, "");
                    await RefreshAsync();
                };
                useRefreshControl = true;
            }
        }
Esempio n. 3
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();
            this.NavigationItem.Title = "Nuca App";
            getadvs gn   = new getadvs();
            var     news = await gn.GetAdvsById(Id);

            headingLabel = new UILabel()
            {
                Text            = news.title,
                Font            = UIFont.FromName("Helvetica", 22f),
                TextColor       = UIColor.Blue,
                BackgroundColor = UIColor.Clear,
                TextAlignment   = UITextAlignment.Center
            };
            subheadingLabel = new UILabel()
            {
                Text            = news.shortdesc,
                Font            = UIFont.FromName("Helvetica", 20f),
                TextColor       = UIColor.Black,
                BackgroundColor = UIColor.Clear,
                TextAlignment   = UITextAlignment.Right
            };
            linkurl = new UITextView()
            {
                Text                   = news.liqo,
                Font                   = UIFont.FromName("Helvetica", 20f),
                TextColor              = UIColor.Blue,
                BackgroundColor        = UIColor.Clear,
                TextAlignment          = UITextAlignment.Left,
                Editable               = false,
                Selectable             = true,
                DataDetectorTypes      = UIDataDetectorType.Link,
                UserInteractionEnabled = true
            };

            subheadingLabel.LineBreakMode = UILineBreakMode.WordWrap;
            subheadingLabel.Lines         = 0;
            subheadingLabel.SizeToFit();

            linkurl.ShouldInteractWithUrl += delegate
            {
                return(true);
            };

            linkurl.SizeToFit();
            imagepath = new UIImageView()
            {
                ContentMode = UIViewContentMode.ScaleAspectFit,
            };

            ImageService.Instance.LoadUrl(news.image).Into(imagepath);
            headingLabel.Frame    = new CGRect(15, 75, this.View.Bounds.Size.Width - 30, 25);
            imagepath.Frame       = new CGRect(this.View.Bounds.Size.Width / 4, 110, this.View.Bounds.Size.Width / 2, 400);
            subheadingLabel.Frame = new CGRect(15, 515, this.View.Bounds.Size.Width - 30, 50);
            linkurl.Frame         = new CGRect(15, 570, this.View.Bounds.Size.Width - 30, 50);
            this.View.AddSubview(headingLabel.ViewForBaselineLayout);
            this.View.AddSubview(imagepath.ViewForBaselineLayout);
            this.View.AddSubview(subheadingLabel.ViewForBaselineLayout);
            this.View.AddSubview(linkurl.ViewForBaselineLayout);
        }
Esempio 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.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(); };
            searchBar.SearchButtonClicked             += (sender, e) =>
            {
                //  searchTable();
                searchBar.ResignFirstResponder();
            };

            getadvs gn      = new getadvs();
            var     allnews = await gn.GetAllAdvs();

            if (allnews != null)
            {
                table = new UITableView(new CGRect(0, 20, View.Bounds.Width, View.Bounds.Height - 20));
                table.AutoresizingMask   = UIViewAutoresizing.All;
                table.RowHeight          = 435f;
                table.EstimatedRowHeight = 435f;
                table.Source             = new ListsAdvsModelSource(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();
            }
        }