private void BuildLayout() { var rl = new RelativeLayout(); rl.WidthRequest = Math.Min(App.ScreenWidth, Device.OnPlatform(400, 480, 400)); this.Children.Add(rl, Constraint.RelativeToParent(p => (p.Width - rl.WidthRequest) / 2), Constraint.Constant(0)); sortIcon = new Image(); sortIcon.Source = ImageSource.FromResource("TiroApp.Images.search_sort_icon.png"); sortIcon.HeightRequest = 22; sortIcon.WidthRequest = sortIcon.HeightRequest; sortIcon.Margin = new Thickness(5, 10, 5, 0); sortIcon.GestureRecognizers.Add(new TapGestureRecognizer(OnSortClick)); searchBackgroundBig = new Image { Source = ImageSource.FromResource(searchBackgroundBigSource), Aspect = Aspect.Fill, Margin = Device.OnPlatform(new Thickness(5, 0, 5, 0), new Thickness(20, 0, 20, 0), new Thickness(5, 0, 5, 0)) }; var searchBackground = new Image(); searchBackground.Source = ImageSource.FromResource(searchBackgroundSource); searchBackground.HeightRequest = 40; searchBackground.Margin = new Thickness(5, 0, 5, 0); searchBackground.GestureRecognizers.Add(new TapGestureRecognizer(OnSearchCaregoryClick)); var placeBackground = new Image(); placeBackground.Source = ImageSource.FromResource(searchBackgroundSource); placeBackground.HeightRequest = 40; placeBackground.Margin = new Thickness(5, 0, 5, 0); placeLabel = new CustomLabel() { Text = "Anywhere at Anytime", TextColor = Color.Black, FontSize = 13, HorizontalTextAlignment = TextAlignment.Center, FontFamily = UIUtils.FONT_SFUIDISPLAY_REGULAR }; var placeTap = new TapGestureRecognizer((v) => { if (filersPage == null) { filersPage = new SearchFilersPage(); filersPage.OnSelect += FilersPage_OnSelect; } this.Navigation.PushAsync(filersPage); }); placeBackground.GestureRecognizers.Add(placeTap); placeLabel.GestureRecognizers.Add(placeTap); var plus = new Image(); plus.Source = ImageSource.FromResource("TiroApp.Images.plus.png"); plus.HeightRequest = 15; plus.WidthRequest = plus.HeightRequest; plus.GestureRecognizers.Add(new TapGestureRecognizer(OnSearchCaregoryClick)); var calendar = new Image(); calendar.Source = ImageSource.FromResource("TiroApp.Images.calendar.png"); calendar.HeightRequest = 20; calendar.WidthRequest = 22; var filter_1 = MakeCheckBox("Makeup"); var filter_2 = MakeCheckBox("Bridal"); var filter_3 = MakeCheckBox("Gele"); var filter_4 = MakeCheckBox("Eyebrow"); filters = new List <RadioButton> { filter_1, filter_2, filter_3, filter_4 }; var topFilters = new RelativeLayout(); topFilters.HeightRequest = 45; topFilters.WidthRequest = rl.WidthRequest; topFilters.Children.Add(filter_1 , Constraint.Constant(30) , Constraint.RelativeToParent((p) => { return(p.Height / 2 - Utils.GetControlSize(filter_1).Height / 2); })); topFilters.Children.Add(filter_2 , Constraint.RelativeToParent((p) => { return(p.Width / 2); }) , Constraint.RelativeToParent((p) => { return(p.Height / 2 - Utils.GetControlSize(filter_2).Height / 2); })); var bottomFilters = new RelativeLayout(); bottomFilters.HeightRequest = 45; bottomFilters.WidthRequest = rl.WidthRequest; bottomFilters.Children.Add(filter_3 , Constraint.Constant(30) , Constraint.RelativeToParent((p) => { return(p.Height / 2 - Utils.GetControlSize(filter_3).Height / 2); })); bottomFilters.Children.Add(filter_4 , Constraint.RelativeToParent((p) => { return(p.Width / 2); }) , Constraint.RelativeToParent((p) => { return(p.Height / 2 - Utils.GetControlSize(filter_4).Height / 2); })); var searchButton = UIUtils.MakeButton("SEARCH", UIUtils.FONT_SFUIDISPLAY_REGULAR); searchButton.Clicked += SearchButton_Clicked; filtersLayout = new StackLayout { IsVisible = false, BackgroundColor = Color.White, Children = { topFilters, UIUtils.MakeSeparator(true), bottomFilters, searchButton, //new BoxView { Color = Props.BlackoutColor } } }; rl.Children.Add(sortIcon , Constraint.RelativeToParent(p => { return(p.Width - 40); }) , Constraint.Constant(15)); rl.Children.Add(searchBackground , Constraint.Constant(40) , Constraint.Constant(15) , Constraint.RelativeToParent(p => { return(p.Width - 80); })); searchBackgroundBig.IsVisible = false; rl.Children.Add(searchBackgroundBig , Constraint.Constant(40) , Constraint.Constant(15) , Constraint.RelativeToParent(p => { return(p.Width - 80); }) , Constraint.Constant(60)); rl.Children.Add(plus , Constraint.RelativeToParent(p => { return(p.Width - Device.OnPlatform(80, 100, 80)); }) , Constraint.Constant(25)); rl.Children.Add(placeBackground , Constraint.Constant(40) , Constraint.Constant(75) , Constraint.RelativeToParent(p => { return(p.Width - 80); })); rl.Children.Add(placeLabel, Constraint.Constant(45), Constraint.Constant(Device.OnPlatform(85, 82, 85)), Constraint.RelativeToParent(p => p.Width - 85)); rl.Children.Add(calendar , Constraint.Constant(80) , Constraint.Constant(85)); this.Children.Add(filtersLayout , Constraint.Constant(0) , Constraint.Constant(75) , Constraint.RelativeToParent(p => { return(p.Width); })); filtersBoxHolder = new StackLayout { Orientation = StackOrientation.Horizontal }; filtersBoxHolderAdditional = new StackLayout { Orientation = StackOrientation.Horizontal }; rl.Children.Add(filtersBoxHolder , Constraint.Constant(Device.OnPlatform(50, 80, 50)) , Constraint.Constant(24)); rl.Children.Add(filtersBoxHolderAdditional , Constraint.Constant(Device.OnPlatform(50, 80, 50)) , Constraint.Constant(48)); }
public void BuildLayout() { var expressInfo = new CustomLabel { Text = "Tiro Xpress", FontSize = 10, FontFamily = UIUtils.FONT_SFUIDISPLAY_REGULAR, HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.Center, Margin = new Thickness(25, 0, 0, 0) }; modeInfos.Add(expressInfo); var premiumInfo = new CustomLabel { Text = "Tiro Premium", FontSize = 10, FontFamily = UIUtils.FONT_SFUIDISPLAY_REGULAR, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.Center, }; modeInfos.Add(premiumInfo); var luxInfo = new CustomLabel { Text = "Tiro Lux", FontSize = 10, FontFamily = UIUtils.FONT_SFUIDISPLAY_REGULAR, HorizontalOptions = LayoutOptions.EndAndExpand, VerticalOptions = LayoutOptions.Center, Margin = new Thickness(0, 0, 20, 0) }; modeInfos.Add(luxInfo); var info = new StackLayout { Spacing = 0, Orientation = StackOrientation.Horizontal, BackgroundColor = Color.White, Margin = new Thickness(0, 5, 0, 0), Children = { expressInfo, premiumInfo, luxInfo } }; this.Children.Add(info); var expressPrice = new CustomLabel { Text = "5K - 10K", FontSize = 10, FontFamily = UIUtils.FONT_SFUIDISPLAY_REGULAR, HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.Center, Margin = new Thickness(32, 0, 0, 0) }; modePrices.Add(expressPrice); var premiumPrice = new CustomLabel { Text = "10K - 25K", FontSize = 10, FontFamily = UIUtils.FONT_SFUIDISPLAY_REGULAR, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.Center, }; modePrices.Add(premiumPrice); var luxPrice = new CustomLabel { Text = "25K +", FontSize = 10, FontFamily = UIUtils.FONT_SFUIDISPLAY_REGULAR, HorizontalOptions = LayoutOptions.EndAndExpand, VerticalOptions = LayoutOptions.Center, Margin = new Thickness(0, 0, 20, 0) }; modePrices.Add(luxPrice); var prices = new StackLayout { Spacing = 0, Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.EndAndExpand, Margin = new Thickness(0, 5, 0, 0), Children = { expressPrice, premiumPrice, luxPrice } }; expressBtn = new Image { HorizontalOptions = LayoutOptions.StartAndExpand, //VerticalOptions = LayoutOptions.Center, Margin = new Thickness(25, 0, 0, 0), HeightRequest = 50, WidthRequest = 50 }; modeButtons.Add(expressBtn); premiumBtn = new Image { HorizontalOptions = LayoutOptions.CenterAndExpand, //VerticalOptions = LayoutOptions.CenterAndExpand, Margin = new Thickness(0, 0, 0, 0), HeightRequest = 50, WidthRequest = 50 }; modeButtons.Add(premiumBtn); luxBtn = new Image { HorizontalOptions = LayoutOptions.EndAndExpand, //VerticalOptions = LayoutOptions.Center, Margin = new Thickness(0, 0, 10, 0), HeightRequest = 50, WidthRequest = 50 }; modeButtons.Add(luxBtn); for (int i = 0; i < modeButtons.Count; i++) { var btn = modeButtons[i]; var index = i; btn.GestureRecognizers.Add(new TapGestureRecognizer(v => { selectedIndex = index; ChangeButtons(); })); } selectedIndex = 0; double panDX = 0; var pan = new PanGestureRecognizer(); pan.PanUpdated += (o, e) => { switch (e.StatusType) { case GestureStatus.Started: panDX = 0; break; case GestureStatus.Running: panDX = e.TotalX; break; case GestureStatus.Completed: Slide(panDX > 0) ; break; } }; slider = new StackLayout { Spacing = 0, Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.CenterAndExpand, Margin = new Thickness(0, 8, 0, 0), Children = { expressBtn, premiumBtn, luxBtn } }; var sliderHolder = new StackLayout { Spacing = 0, Children = { slider, prices } }; slider.GestureRecognizers.Add(pan); var rl = new RelativeLayout(); var sliderImage = new Image(); sliderImage.Source = ImageSource.FromResource("TiroApp.Images.Slider.png"); sliderImage.VerticalOptions = LayoutOptions.CenterAndExpand; sliderImage.Aspect = Aspect.Fill; rl.Children.Add(sliderImage, Constraint.Constant(0), Constraint.Constant(0) , Constraint.RelativeToParent(p => p.Width) , Constraint.RelativeToParent(p => p.Height - 18)); rl.Children.Add(sliderHolder, Constraint.Constant(0), Constraint.Constant(0) , Constraint.RelativeToParent(p => p.Width) , Constraint.RelativeToParent(p => p.Height - 25)); this.Children.Add(rl); ChangeButtons(); }