Ejemplo n.º 1
0
        public SearchFilersPage()
        {
            Utils.SetupPage(this);
            BuildLayout();

            locator = Xamarin.Forms.DependencyService.Get <IGeolocator>();
            locator.PositionChanged += (o, arg) =>
            {
                locator.StopListening();
                if (arg.Position != null)
                {
                    LocationFilter = new LocationFilter()
                    {
                        Lat    = arg.Position.Latitude,
                        Lon    = arg.Position.Longitude,
                        Radius = RADIUS
                    };
                    LocationAddress = "Current location";
                }
            };
            locator.PositionError += (o, arg) =>
            {
                locator.StopListening();
            };
            locator.StopListening();
            locator.StartListening(0, 0);
        }
Ejemplo n.º 2
0
        public static void MuaSearchFree(List <string> categories, Pages.LocationFilter lFilter, Availibility aFilter, Action <ResponseDataJson> callback)
        {
            var body        = new JObject();
            var categoryArr = new JArray();

            body["CategoryFilter"] = categoryArr;
            foreach (var c in categories)
            {
                categoryArr.Add(c);
            }
            if (lFilter != null)
            {
                var obj = new JObject();
                obj["Lat"]             = lFilter.Lat;
                obj["Lon"]             = lFilter.Lon;
                obj["Radius"]          = lFilter.Radius;
                body["LocationFilter"] = obj;
            }
            if (aFilter != null)
            {
                var obj = new JObject();
                obj["From"] = aFilter.DatesFrom[0].ToUniversalTime();
                obj["To"]   = aFilter.DatesTo[0].ToUniversalTime();
                body["AvailibilityFilter"] = obj;
            }
            MakeRequestJson("mua/searchfree", body.ToString(), callback);
        }
Ejemplo n.º 3
0
        private void SearchButton_Clicked(object sender, System.EventArgs e)
        {
            SpinnerShowChange(true);
            searchHeader.filtersLayout.IsVisible = false;
            var            sendData = searchHeader.filters.Where(f => f.IsChecked).Select(f => f.Text).ToList();
            Availibility   aFilter  = null;
            LocationFilter lFilter  = null;

            if (searchHeader.filersPage != null)
            {
                aFilter = searchHeader.filersPage.AvailibilityFilter;
                lFilter = searchHeader.filersPage.LocationFilter;
            }
            var callback = new Action <ResponseDataJson>((data) =>
            {
                SpinnerShowChange(false);
                if (data.Code == ResponseCode.OK)
                {
                    var sellersEl = JArray.Parse(data.Result);
                    muaData       = sellersEl.Select(s => new MuaDataItem((JObject)s));
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        muaList.ItemsSource = null;
                        slider.BuildLayout();
                        SearchHeader_OnSortChanged(null, null);
                    });
                }
                else
                {
                    UIUtils.ShowMessage("Nothing was found", this);
                }
            });

            if (searchHeader.IsFreeMakeover)
            {
                DataGate.MuaSearchFree(sendData, lFilter, aFilter, callback);
            }
            else
            {
                DataGate.DoMUASearchJson(sendData, lFilter, aFilter, callback);
            }
        }
Ejemplo n.º 4
0
        private void BuildLocationLayout(StackLayout main)
        {
            var calendar = new Image();

            calendar.Source        = ImageSource.FromResource("TiroApp.Images.calendar.png");
            calendar.HeightRequest = 20;
            calendar.WidthRequest  = 22;
            var placeBackground = new Image();

            placeBackground.Source        = ImageSource.FromResource("TiroApp.Images.searchBackground.png");
            placeBackground.Aspect        = Aspect.Fill;
            placeBackground.HeightRequest = 44;

            var locationACEntry = new AutoCompleteView();

            locationEntry                  = locationACEntry.EntryText;
            locationEntry.FontFamily       = UIUtils.FONT_SFUIDISPLAY_LIGHT;
            locationEntry.WidthRequest     = 250;
            locationEntry.HeightRequest    = 38;
            locationEntry.FontSize         = 16;
            locationEntry.BackgroundColor  = Color.White;
            locationEntry.Placeholder      = "Use current location";
            locationEntry.PlaceholderColor = Color.Black;
            locationEntry.TextColor        = Color.Black;
            locationEntry.Focused         += (o, a) => { locationEntry.Text = ""; };
            var sh = new PlaceSearchHelper(locationACEntry);

            sh.OnSelected += (o, p) =>
            {
                LocationFilter = new LocationFilter()
                {
                    Lat    = p.Latitude,
                    Lon    = p.Longitude,
                    Radius = RADIUS
                };
                LocationAddress = locationEntry.Text;
            };

            var rl = new RelativeLayout();

            rl.Margin            = new Thickness(0, 10, 0, 10);
            rl.WidthRequest      = Device.OnPlatform(300, 320, 300);
            rl.VerticalOptions   = LayoutOptions.Start;
            rl.HorizontalOptions = LayoutOptions.Center;
            rl.Children.Add(placeBackground, Constraint.Constant(0), Constraint.Constant(0),
                            Constraint.RelativeToParent(p => p.Width), Constraint.Constant(placeBackground.HeightRequest));
            rl.Children.Add(calendar, Constraint.Constant(10), Constraint.Constant(10));
            rl.Children.Add(locationACEntry, Constraint.Constant(40), Constraint.Constant(4));
            //heightConstraint: Constraint.Constant(locationEntry.HeightRequest));

            var useCurrLocation = new CustomLabel()
            {
                HorizontalOptions = LayoutOptions.Center,
                Text                    = "Use Current Location",
                TextColor               = Props.ButtonColor,
                BackgroundColor         = Color.White,
                VerticalOptions         = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                FontSize                = 17,
                FontFamily              = UIUtils.FONT_SFUIDISPLAY_LIGHT,
            };

            useCurrLocation.GestureRecognizers.Add(new TapGestureRecognizer(LocationClicked));

            main.Children.Add(useCurrLocation);
            main.Children.Add(rl);
            var separator = UIUtils.MakeSeparator(true);

            separator.VerticalOptions = LayoutOptions.Start;
            main.Children.Add(separator);
        }