Exemplo n.º 1
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) =>
                {
                    getNews           gn      = new getNews();
                    List <PhotoModel> allnews = await gn.GetAllNews();

                    table.Source = new ListsPhotoModelSource(allnews.ToArray(), this, "");
                    await RefreshAsync();
                };
                useRefreshControl = true;
            }
        }
Exemplo n.º 2
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();
            getNews gn   = new getNews();
            var     news = await gn.GetNewsById(Id);

            headingLabel = new UILabel()
            {
                Text            = news.title,
                Font            = UIFont.FromName("Helvetica", 17f),
                TextColor       = UIColor.Black,
                BackgroundColor = UIColor.Clear,
                TextAlignment   = UITextAlignment.Right,
            };
            subheadingLabel = new UILabel()
            {
                Text            = news.dayx + " " + news.date,
                Font            = UIFont.FromName("Helvetica", 15f),
                TextColor       = UIColor.Blue,
                BackgroundColor = UIColor.Clear,
                TextAlignment   = UITextAlignment.Right
            };
            headingLabel.LineBreakMode = UILineBreakMode.WordWrap;
            headingLabel.Lines         = 0;
            headingLabel.SizeToFit();
            imagepath = new UIImageView();

            ImageService.Instance.LoadUrl(news.image).Into(imagepath);
            imagepath.Frame       = new CGRect(15, 100, this.View.Bounds.Size.Width - 30, 175);
            headingLabel.Frame    = new CGRect(15, 290, this.View.Bounds.Size.Width - 30, 85);
            subheadingLabel.Frame = new CGRect(15, 375, this.View.Bounds.Size.Width - 30, 25);
            this.View.AddSubview(imagepath.ViewForBaselineLayout);
            this.View.AddSubview(headingLabel.ViewForBaselineLayout);
            this.View.AddSubview(subheadingLabel.ViewForBaselineLayout);

            //Add(imagepath);
            //Add(headingLabel);
            //Add(subheadingLabel);
            // Perform any additional setup after loading the view, typically from a nib.
        }
Exemplo n.º 3
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            var btn = new UIButton(UIButtonType.Custom);

            btn.Frame = new CGRect(0, 0, 0, 0);

            showIndicator();

            btn.SetImage(UIImage.FromBundle("barlogo"), UIControlState.Normal);
            btn.ContentMode = UIViewContentMode.ScaleAspectFit;

            searchBar = new UISearchBar()
            {
                Placeholder   = " ",
                Prompt        = " ",
                ShowsScopeBar = true
            };
            searchBar.SizeToFit();
            searchBar.AutocorrectionType            = UITextAutocorrectionType.No;
            searchBar.AutocapitalizationType        = UITextAutocapitalizationType.None;
            searchBar.ReturnKeyType                 = UIReturnKeyType.Done;
            searchBar.EnablesReturnKeyAutomatically = false;

            searchBar.SearchButtonClicked += (sender, e) =>
            {
                //  Search();
            };
            searchBar.TextChanged += (sender, e) =>
            {
                //this is the method that is called when the user searches
                searchTable();
            };
            searchBar.CancelButtonClicked += (sender, e) =>
            {
                searchBar.ResignFirstResponder();
            };
            searchBar.SelectedScopeButtonIndexChanged += (sender, e) => { searchBar.ResignFirstResponder(); };
            searchBar.SearchButtonClicked             += (sender, e) =>
            {
                //  searchTable();
                searchBar.ResignFirstResponder();
            };

            this.NavigationItem.SetLeftBarButtonItem(new UIBarButtonItem(btn), true);
            this.NavigationItem.TitleView = searchBar;
            if (Reachability.IsHostReachable("https://newcities-newurban.firebaseio.com"))
            {
                getNews gn = new getNews();
                allnews = await gn.GetAllNews();

                if (allnews != null)
                {
                    table = new UITableView(new CGRect(0, 20, View.Bounds.Width - 5, View.Bounds.Height - 20));
                    table.AutoresizingMask   = UIViewAutoresizing.All;
                    table.RowHeight          = 300f;
                    table.EstimatedRowHeight = 300f;
                    // defaults to Plain style
                    table.Source = new ListsPhotoModelSource(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);
                }
            }
            else
            {
                PhotoModel pm = new PhotoModel();
                pm.id       = 0;
                pm.title    = "يرجي التاكد من الاتصال بالانترنت";
                pm.image    = "";
                pm.date     = DateTime.Today.ToShortDateString();
                pm.dayx     = "";
                pm.longdesc = "";
                // allnews.Add(pm);
                var alrt = UIAlertController.Create("Nuca", "يرجي التاكد من الاتصال بالانترنت", UIAlertControllerStyle.Alert);
                alrt.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                PresentViewController(alrt, true, null);
                hideIndicator();
            }
        }
Exemplo n.º 4
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.NavigationItem.Title = "Nuca App";
            var rightButton = new UIButton(UIButtonType.Custom);

            var rightBarButton = new UIBarButtonItem(rightButton);

            NavigationItem.SetRightBarButtonItems(new UIBarButtonItem[] { rightBarButton }, false);
            rightButton.TouchUpInside += (sender, e) =>
            {
                Console.WriteLine("This button is clicked");
            };

            getNews gn   = new getNews();
            var     news = await gn.GetNewsById(Id);

            headingLabel = new UILabel()
            {
                Text            = news.title,
                Font            = UIFont.FromName("Helvetica", 17f),
                TextColor       = UIColor.Black,
                BackgroundColor = UIColor.Clear,
                TextAlignment   = UITextAlignment.Right,
            };
            subheadingLabel = new UILabel()
            {
                Text            = news.dayx + " " + news.date,
                Font            = UIFont.FromName("Helvetica", 16f),
                TextColor       = UIColor.Blue,
                BackgroundColor = UIColor.Clear,
                TextAlignment   = UITextAlignment.Right
            };
            longdesc = new UITextView()
            {
                Text            = news.longdesc,
                Font            = UIFont.FromName("Helvetica", 16f),
                TextColor       = UIColor.Black,
                BackgroundColor = UIColor.Clear,
                TextAlignment   = UITextAlignment.Right,
            };
            headingLabel.LineBreakMode = UILineBreakMode.WordWrap;
            headingLabel.Lines         = 0;
            headingLabel.SizeToFit();
            longdesc.SizeToFit();
            longdesc.ScrollEnabled = true;

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

            ImageService.Instance.LoadUrl(news.image).Into(imagepath);
            imagepath.Frame       = new CGRect(15, 100, this.View.Bounds.Size.Width - 30, 175);
            headingLabel.Frame    = new CGRect(15, 290, this.View.Bounds.Size.Width - 30, 85);
            subheadingLabel.Frame = new CGRect(15, 375, this.View.Bounds.Size.Width - 30, 25);
            longdesc.Frame        = new CGRect(15, 400, this.View.Bounds.Size.Width - 30, 5000);


            uv = new UIView();

            uv.AddSubview(imagepath.ViewForBaselineLayout);
            uv.AddSubview(headingLabel.ViewForBaselineLayout);
            uv.AddSubview(subheadingLabel.ViewForBaselineLayout);
            uv.AddSubview(longdesc.ViewForBaselineLayout);

            scrollView             = new UIScrollView(new CGRect(0, 0, View.Frame.Width, View.Frame.Height));
            scrollView.ContentSize = new CGSize(this.View.Bounds.Size.Width, scrollView.Bounds.Height + 5000);
            uv.TranslatesAutoresizingMaskIntoConstraints = false;

            scrollView.AddSubview(uv);
            this.View.AddSubview(scrollView);
        }