Ejemplo n.º 1
0
        void ConfigureScreen()
        {
            //var navBar = ConfigureNavBar("Adicionar carro", true, true);
            var navBar = new StackLayout();

            SearchEntry = new RoundedBorderedEntry()
            {
                CenteredPlaceholder = true,
                PlaceholderColor    = ColorPalette.DarkBlue,
                Placeholder         = "Qual o tipo do seu carro?".ToUpper(),
                FontAttributes      = FontAttributes.Bold,
                FontSize            = 15,
                TextColor           = ColorPalette.DarkBlue,
                Padding             = new Thickness(50, 30),
                BorderColor         = ColorPalette.DarkBlue,
                BorderWidth         = App.ScreenWidth / 72,
                HorizontalOptions   = LayoutOptions.FillAndExpand,
                VerticalOptions     = LayoutOptions.CenterAndExpand
            };
            this.SearchEntry.SizeChanged += OnSearchSizeChanged;
            SearchIcon = new Icon()
            {
                Color             = ColorPalette.DarkBlue,
                FileName          = "search.svg",
                HeightRequest     = 25,
                WidthRequest      = 25,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Margin            = new Thickness(15, 0, 0, 0)
            };

            SearchIcon.SetBinding(VisualElement.IsVisibleProperty, new Binding(nameof(SearchEntry.Text), source: SearchEntry, converter: new ValueConverter((text) => string.IsNullOrWhiteSpace((string)text))));

            SearchGrid = new Grid()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Margin            = new Thickness(20, 30, 20, 30),
            };

            SearchGrid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(50, GridUnitType.Absolute)
            });
            SearchGrid.ColumnDefinitions.Add(new ColumnDefinition());

            SearchGrid.Children.Add(SearchEntry, 0, 0);
            SearchGrid.Children.Add(SearchIcon, 0, 0);

            Label textSubtitleLabel = new Label()
            {
                Text              = "Tipos populares",
                FontSize          = 14,
                TextColor         = ColorPalette.Gray,
                Margin            = new Thickness(20, 0, 0, 0),
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            RoundedBorderedLabel subtitleLabel = new RoundedBorderedLabel(textSubtitleLabel, Color.Transparent, 0, ColorPalette.ExtraLightGray, new Thickness(0, 5), 0)
            {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            subtitleLabel.Content.HorizontalOptions = subtitleLabel.HorizontalOptions;

            CarSelectionList optionsList = new CarSelectionList()
            {
                ItemsSource       = ViewModel.TypeOptions,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };

            optionsList.SetBinding(ListView.SelectedItemProperty, new Binding(nameof(ViewModel.SelectedType)));


            RoundedButton confirmatioButton = new RoundedButton()
            {
                BackgroundColor = ColorPalette.LightBlue,
                TextColor       = Color.White,
                FontAttributes  = FontAttributes.Bold,
                Text            = "Continuar".ToUpper(),
                Margin          = new Thickness(50, 0, 50, 30),
                FontSize        = 17,
                VerticalOptions = LayoutOptions.End,
                Padding         = new Thickness(10),
                Command         = ViewModel.SelectOption
            };


            Content = new StackLayout()
            {
                Children =
                {
                    navBar,
                    SearchGrid,
                    SearchEntry,
                    subtitleLabel,
                    optionsList,
                    confirmatioButton
                }
            };
        }
Ejemplo n.º 2
0
        void ConfigureScreen()
        {
            NavBar = BaseContentPage.Instance.ConfigureNavBar("Adicionar carro", true);

            SearchEntry = new RoundedBorderedEntry()
            {
                CenteredPlaceholder = true,
                PlaceholderColor    = ColorPalette.DarkBlue,
                Placeholder         = "Qual a marca do seu carro?".ToUpper(),
                FontAttributes      = FontAttributes.Bold,
                FontSize            = 15,
                TextColor           = ColorPalette.DarkBlue,
                BorderColor         = ColorPalette.DarkBlue,
                BorderWidth         = App.ScreenWidth / 72,
                HorizontalOptions   = LayoutOptions.FillAndExpand,
            };



            SearchIcon = new Icon()
            {
                HeightRequest     = 25,
                WidthRequest      = 25,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Margin            = new Thickness(15, 0, 0, 0),
                Color             = ColorPalette.DarkBlue,
                FileName          = "search.svg",
            };
            SearchIcon.SetBinding(VisualElement.IsVisibleProperty, new Binding(nameof(SearchEntry.Text), source: SearchEntry, converter: new ValueConverter((text) => string.IsNullOrWhiteSpace((string)text))));

            SearchGrid = new Grid()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Margin            = new Thickness(20, 30, 20, 30),
            };

            SearchGrid.RowDefinitions.Add(new RowDefinition());
            SearchGrid.ColumnDefinitions.Add(new ColumnDefinition());

            Label textSubtitleLabel = new Label()
            {
                Text              = "Marcas populares",
                FontSize          = 14,
                TextColor         = ColorPalette.Gray,
                Margin            = new Thickness(20, 0, 0, 0),
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            RoundedBorderedLabel subtitleLabel = new RoundedBorderedLabel(textSubtitleLabel, Color.Transparent, 0, ColorPalette.ExtraLightGray, new Thickness(0, 5), 0)
            {
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            subtitleLabel.Content.HorizontalOptions = subtitleLabel.HorizontalOptions;
            int counter = 0;

            optionsList = new CarSelectionList()
            {
                ItemsSource       = ViewModel.BrandOptions,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                ItemTemplate      = new DataTemplate(() =>
                {
                    var option        = ViewModel.BrandOptions[counter];
                    CustomLabel label = new CustomLabel()
                    {
                        VerticalTextAlignment = TextAlignment.Center,
                        CustomPadding         = new Thickness(10, 0, 0, 0),
                        Text            = option.Name,
                        FontSize        = 16,
                        TextColor       = option == ViewModel.SelectedBrand ? ColorPalette.Pink : ColorPalette.Gray,
                        FontAttributes  = FontAttributes.Bold,
                        BackgroundColor = Color.White
                    };
                    CustomViewCell cell = new CustomViewCell(label)
                    {
                        View = label,
                        SelectedTextColor = ColorPalette.Pink,
                        NormalTextColor   = label.TextColor,
                    };

                    counter++;
                    return(cell);
                })
            };
            optionsList.SetBinding(ListView.SelectedItemProperty, new Binding(nameof(ViewModel.SelectedBrand)));
            //optionsList.ItemTapped += ViewModel.OnItemTapped;
            if (App.IsAndroidSDKBelowMarshmallow)
            {
                optionsList.ItemSelected += (sender, args) =>
                {
                    ViewModel.SelectedBrand = args.SelectedItem as CarFilterInfo;
                    optionsList.Layout(optionsList.Bounds);
                }
            }
            ;



            Button confirmatioButton = new Button()
            {
                BackgroundColor = ColorPalette.LightBlue,
                TextColor       = Color.White,
                FontAttributes  = FontAttributes.Bold,
                Text            = "Continuar".ToUpper(),
                //Margin = new Thickness(50, 0, 50, 30),
                FontSize        = 18,
                VerticalOptions = LayoutOptions.End,
                //Padding = new Thickness(10),
                BorderRadius  = 18,
                Margin        = 10,
                HeightRequest = 55,
                Command       = ViewModel.SelectOption
            };

            Children.Clear();
            Children.Add(NavBar);
            Children.Add(SearchEntry);
            Children.Add(SearchGrid);
            Children.Add(subtitleLabel);
            Children.Add(optionsList);
            Children.Add(confirmatioButton);
            SearchEntry.SizeChanged += OnSearchSizeChanged;
            SearchEntry.Completed   += OnTextChanged;
        }