public DetailsPage(options house, Boolean newPage = false)
        {
            InitializeComponent();
            styleElements();
            fetchStats(house.outcode);
            this.smallDescription = house.short_description;
            this.bigDescription   = house.description;

            try
            {
                houseDetails = house;
                this.newPage = newPage;
                List <options> allHouses = functions.dbPull();
                foreach (var property in allHouses)
                {
                    if (property.listing_id.Equals(houseDetails.listing_id))
                    {
                        houseFavourited = true;
                    }
                }
            }
            catch (Exception)
            { }

            if (houseFavourited)
            {
                favAdded();
            }
            else
            {
                AddNavHeader();
            }

            if (house.listing_status.Equals("sale"))
            {
                payTerm = "";
            }

            Title                 = "House Details";
            imageURL.Source       = house.image_url;
            price.Text            = "£" + house.price + " " + payTerm;
            shortDescription.Text = house.num_bedrooms + " bedrooms " + house.property_type;
            description.Text      = this.smallDescription;
            location.Text         = house.displayable_address;
            agentLogo.Source      = house.agent_logo;
            agentName.Text        = house.agent_name;
            agentNumber.Text      = house.agent_phone;
            propertyType.Text     = house.property_type;

            if (house.property_type.Length < 1)
            {
                propertyType.IsVisible = false;
            }

            if (house.furnished_state != null)
            {
                furnished.Text      = house.furnished_state;
                furnished.IsVisible = true;
            }
        }
Example #2
0
        public async Task <options> getFavorites()
        {
            options house = null;

            try
            {
                string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "database.db3");
                var    db     = new SQLiteConnection(dbPath);
                house = db.Get <options>(1);
            }

            catch (Exception) {}
            return(await Task.FromResult(house));
        }
Example #3
0
        public async Task <Boolean> saveFavorite(options houseDetails)
        {
            Boolean saved = false;

            try
            {
                string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "database.db3");
                var    db     = new SQLiteConnection(dbPath);
                db.CreateTable <options>();
                db.Insert(houseDetails);
                //bookmark.Icon = "bookmarkFull.png";
                //var house = JsonConvert.SerializeObject(houseDetails);
                //Application.Current.Properties["id"] = house;

                //TO DO:
                // Add some notification that the favorite was saved
                saved = true;
            }
            catch (Exception)
            {
                saved = false;
            }
            return(await Task.FromResult(saved));
        }
Example #4
0
        private void renderDisplay(options property)
        {
            // create tap to move to info page
            tgr         = new TapGestureRecognizer();
            tgr.Tapped += (s, e) => onStackClick(property);
            if (property.image_url.Length < 1)
            {
                property.image_url = noImage;
            }
            // create a house image for each search result
            mainImage = new Image()
            {
                Source               = property.image_url, //a 600x300 picture
                WidthRequest         = 600,
                HeightRequest        = 300,
                MinimumHeightRequest = 300,
                MinimumWidthRequest  = 600,
                VerticalOptions      = LayoutOptions.End,
                HorizontalOptions    = LayoutOptions.End,
                Aspect               = Aspect.AspectFill
            };

            if (property.listing_status.Equals("sale"))
            {
                payTerm = "";
            }


            //getImage(property.image_url);

            agentLogo = new Image()
            {
                Source = property.agent_logo,
                Margin = new Thickness(0, 0, 5, 0),
            };

            // add a street name for each search
            streetName = new Label()
            {
                Text     = property.street_name + " - " + property.post_town,
                FontSize = Convert.ToDouble(Application.Current.Properties["fontSize"])
            };

            // add a price
            priceLabel = new Label()
            {
                Text                  = "£" + property.price + " " + this.payTerm,
                TextColor             = functions.priceTextColour(),
                FontSize              = Convert.ToDouble(Application.Current.Properties["priceTextSize"]),
                VerticalTextAlignment = TextAlignment.Center,
                Margin                = new Thickness(5, 0, 0, 0),
            };

            //add a house type
            houseType = new Label()
            {
                Text      = property.num_bedrooms + " " + property.property_type,
                TextColor = Color.White,
                FontSize  = Convert.ToDouble(Application.Current.Properties["fontSize"]),
                HorizontalTextAlignment = TextAlignment.Center,
                Margin = new Thickness(0, 20, 0, 0),
            };

            //add town
            town = new Label()
            {
                Text     = property.post_town,
                FontSize = Convert.ToDouble(Application.Current.Properties["priceTextSize"])
            };

            bottomBorder = new BoxView()
            {
                BackgroundColor = functions.gapColour()
            };
            bottomBorder.HeightRequest = 3;

            StackLayout imageStack = new StackLayout()
            {
                Margin          = -6,
                BackgroundColor = Color.White
            };


            shortDetails = new Label()
            {
                Text      = property.num_bedrooms + " bedrooms " + property.property_type,
                TextColor = functions.textColour(),
                FontSize  = Convert.ToDouble(Application.Current.Properties["fontSize"]),
                //HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment = TextAlignment.Center,
                Margin = new Thickness(5, 0, 0, 0),
            };

            address = new Label()
            {
                Text      = property.displayable_address,
                TextColor = functions.textColour(),
                FontSize  = Convert.ToDouble(Application.Current.Properties["fontSize"]),
                //HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment = TextAlignment.Center,
                Margin = new Thickness(5, 0, 0, 0),
            };

            Button removeBtn = new Button()
            {
                Text            = "Unfavorite",
                BackgroundColor = functions.buttonColour(),
                TextColor       = functions.textColour(),
                Margin          = new Thickness(5, 0, 5, 0),
            };

            removeBtn.Clicked += (o, e) => {
                functions.dbDelete(property);
                App.MasterDetail.IsPresented = false;
                NavigationPage page = new NavigationPage(new FavoritesPage());
                page.BarBackgroundColor = functions.navbarColour();
                App.MasterDetail.Detail = page;
            };



            imageStack.Children.Add(priceLabel);
            imageStack.Children.Add(mainImage);
            imageStack.Children.Add(new BoxView()
            {
                BackgroundColor = functions.backgroundColour(), Margin = -2
            });
            imageStack.GestureRecognizers.Add(tgr);

            // add all elements to the stack layout
            searchTable.Children.Add(imageStack);
            searchTable.Children.Add(createStack(agentLogo, priceLabel, shortDetails, address, tgr, removeBtn));
            searchTable.Children.Add(bottomBorder);
        }
Example #5
0
 async void onStackClick(options house)
 {
     // create a details page and pre-render it
     DetailsPage page = new DetailsPage(house, true);
     await Navigation.PushAsync(page);
 }
 // click event handler when result row is clicked
 async void onStackClick(options house)
 {
     // create a details page and render it
     await Navigation.PushAsync(new DetailsPage(house));
 }
        private void renderDisplay(options property)
        {
            // create tap to move to info page
            tgr         = new TapGestureRecognizer();
            tgr.Tapped += (s, e) => onStackClick(property);
            // create a house image for each search result
            mainImage = new Image()
            {
                // Source = property.image_url, //a 600x300 picture
                WidthRequest         = 600,
                HeightRequest        = 300,
                MinimumHeightRequest = 300,
                MinimumWidthRequest  = 600,
                VerticalOptions      = LayoutOptions.End,
                HorizontalOptions    = LayoutOptions.End,
                Aspect = Aspect.AspectFill,
            };

            Label favorites = new Label()
            {
                TextColor = functions.priceTextColour(),
                Text      = "",
                FontSize  = Convert.ToDouble(Application.Current.Properties["priceTextSize"])
            };

            if (property.getFavorite())
            {
                favorites.Text = "Favorite";
            }

            if (property.image_url.Length > 0)
            {
                mainImage.Source = new UriImageSource
                {
                    Uri = new Uri(property.image_url)
                };
            }
            else
            {
                mainImage.Source = noImage;
            }

            agentLogo = new Image()
            {
                Source = property.agent_logo,
                Margin = new Thickness(0, 0, 5, 0),
            };

            // add a street name for each search
            streetName = new Label()
            {
                Text     = property.street_name + " - " + property.post_town,
                FontSize = Convert.ToDouble(Application.Current.Properties["fontSize"])
            };

            // add a price
            priceLabel = new Label()
            {
                Text                  = "£" + property.price + " " + payTerm,
                TextColor             = functions.priceTextColour(),
                FontSize              = Convert.ToDouble(Application.Current.Properties["priceTextSize"]),
                VerticalTextAlignment = TextAlignment.Center,
                Margin                = new Thickness(5, 0, 0, 0),
            };

            //add a house type
            houseType = new Label()
            {
                Text      = property.num_bedrooms + " " + property.property_type,
                TextColor = Color.White,
                FontSize  = Convert.ToDouble(Application.Current.Properties["fontSize"]),
                HorizontalTextAlignment = TextAlignment.Center,
                Margin = new Thickness(0, 20, 0, 0),
            };

            //add town
            town = new Label()
            {
                Text     = property.post_town,
                FontSize = Convert.ToDouble(Application.Current.Properties["fontSize"])
            };

            bottomBorder = new BoxView()
            {
                BackgroundColor = functions.gapColour()
            };
            bottomBorder.HeightRequest = 3;

            StackLayout imageStack = new StackLayout()
            {
                Margin          = -6,
                BackgroundColor = Color.White
            };


            shortDetails = new Label()
            {
                Text                  = property.num_bedrooms + " bedrooms " + property.property_type,
                TextColor             = functions.textColour(),
                FontSize              = Convert.ToDouble(Application.Current.Properties["fontSize"]),
                VerticalTextAlignment = TextAlignment.Center,
                Margin                = new Thickness(5, 0, 0, 0),
            };

            address = new Label()
            {
                Text                  = property.displayable_address,
                TextColor             = functions.textColour(),
                FontSize              = Convert.ToDouble(Application.Current.Properties["fontSize"]),
                VerticalTextAlignment = TextAlignment.Center,
                Margin                = new Thickness(5, 0, 0, 0),
            };

            imageStack.Children.Add(mainImage);
            imageStack.GestureRecognizers.Add(tgr);

            // add all elements to the stack layout
            searchTable.Children.Add(imageStack);
            searchTable.Children.Add(createStack(agentLogo, priceLabel, shortDetails, address, tgr, favorites));
            searchTable.Children.Add(new BoxView()
            {
                BackgroundColor = functions.buttonColour()
            });
            searchTable.Children.Add(bottomBorder);
        }