Ejemplo n.º 1
0
        public async Task <PhotoModel> GetNewsById(int id)
        {
            PhotoModel gn = (await firebase.Child("cities").Child("news").OnceAsync <PhotoModel>())
                            .Where(c => c.Object.id == id).Select(item => new PhotoModel
            {
                id       = item.Object.id,
                title    = item.Object.title,
                image    = item.Object.image,
                date     = item.Object.date,
                dayx     = item.Object.dayx,
                longdesc = item.Object.longdesc
            }).FirstOrDefault();

            return(gn);
        }
Ejemplo n.º 2
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            var cell = tableView.DequeueReusableCell(CellIdentifier) as mainTableViewCell;
            //string item = TableItems[indexPath.Row];
            PhotoModel pm = TableItems[indexPath.Row];

            //---- if there are no cells to reuse, create a new one
            if (cell == null)
            {
                cell = new mainTableViewCell(new NSString("tableviewcell"));
            }
            //cell.TextLabel.Text = pm.title;
            //cell.DetailTextLabel.Text = pm.date + " " + pm.dayx;
            //ImageService.Instance.LoadUrl(pm.image).Into(cell.ImageView);
            //cell.ImageView.Image = LoadImage.LoadImageFromURL(pm.image);
            //cell.ImageView.Image = LoadImage.FromUrl(pm.image);
            //}
            cell.UpdateCell(pm.title, pm.dayx + " " + pm.date, pm.image, pm.longdesc);
            return(cell);
        }
Ejemplo 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();
            }
        }