コード例 #1
0
        protected virtual void inicializarComponente()
        {
            _fotoImage = new Image
            {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                Style             = Estilo.Current[EstiloProduto.PRODUTO_FOTO]
            };
            _fotoImage.SetBinding(Image.SourceProperty, new Binding("FotoUrl"));
            _nomeLabel = new Label {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Style             = Estilo.Current[EstiloProduto.PRODUTO_TITULO]
            };
            _nomeLabel.SetBinding(Label.TextProperty, new Binding("Nome"));
            _descricaoLabel = new Label
            {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                Style             = Estilo.Current[EstiloProduto.PRODUTO_DESCRICAO]
            };
            _descricaoLabel.SetBinding(Label.TextProperty, new Binding("Descricao"));
            _moedaValorLabel = new Label
            {
                Text              = "R$",
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Start,
                Style             = Estilo.Current[EstiloProduto.PRODUTO_PRECO_MOEDA]
            };
            _moedaValorLabel.SetBinding(Label.TextColorProperty, new Binding("PromocaoCor"));
            _valorLabel = new Label
            {
                VerticalOptions   = LayoutOptions.StartAndExpand,
                HorizontalOptions = LayoutOptions.End,
                Style             = Estilo.Current[EstiloProduto.PRODUTO_PRECO_VALOR]
            };
            _valorLabel.SetBinding(Label.TextProperty, new Binding("ValorPromocao", stringFormat: "{0:N2}"));
            _valorLabel.SetBinding(Label.TextColorProperty, new Binding("PromocaoCor"));

            _volumeLabel = new Label {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                Style             = Estilo.Current[EstiloProduto.PRODUTO_VOLUME]
            };
            _volumeLabel.SetBinding(Label.TextProperty, new Binding("VolumeStr"));
            //_volumeLabel.SetBinding(Label.TextColorProperty, new Binding("PromocaoCor"));

            _quantidadeLabel = new Label {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                Style             = Estilo.Current[EstiloProduto.PRODUTO_QUANTIDADE]
            };
            _quantidadeLabel.SetBinding(Label.TextProperty, new Binding("Quantidade"));

            _moedaPromocaoLabel = new Label
            {
                Text              = "R$",
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Start,
                Style             = Estilo.Current[EstiloProduto.PRODUTO_PROMOCAO_MOEDA]
            };
            _valorPromocaoLabel = new Label
            {
                VerticalOptions   = LayoutOptions.StartAndExpand,
                HorizontalOptions = LayoutOptions.End,
                Style             = Estilo.Current[EstiloProduto.PRODUTO_PROMOCAO_VALOR]
            };
            _valorPromocaoLabel.SetBinding(Label.TextProperty, new Binding("Valor", stringFormat: "{0:N2}"));

            var valorLayout = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                Margin            = new Thickness(0, 0, 0, 3),
                Children          =
                {
                    _moedaPromocaoLabel,
                    _valorPromocaoLabel
                }
            };

            AbsoluteLayout.SetLayoutBounds(valorLayout, new Rectangle(0, 0, 1, 1));
            AbsoluteLayout.SetLayoutFlags(valorLayout, AbsoluteLayoutFlags.All);

            var linha = new BoxView
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Fill,
                BackgroundColor   = Estilo.Current.DangerColor,
                HeightRequest     = 1,
            };

            AbsoluteLayout.SetLayoutBounds(linha, new Rectangle(0, 0, 1, 1));
            AbsoluteLayout.SetLayoutFlags(linha, AbsoluteLayoutFlags.All);

            _promocaoStack = new AbsoluteLayout
            {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                Children          =
                {
                    valorLayout,
                    linha
                }
            };
            _promocaoStack.SetBinding(AbsoluteLayout.IsVisibleProperty, new Binding("EmPromocao"));

            _destaqueIcon = new IconImage
            {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                Icon  = "fa-star",
                Style = Estilo.Current[EstiloProduto.PRODUTO_ICONE]
            };
            _destaqueIcon.SetBinding(Label.IsVisibleProperty, new Binding("Destaque"));

            _compartilharButton = new IconImage
            {
                //VerticalOptions = LayoutOptions.CenterAndExpand,
                //HorizontalOptions = LayoutOptions.End,
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                Icon      = "fa-share-alt",
                IconColor = Estilo.Current.PrimaryColor,
                IconSize  = 28,
                Margin    = new Thickness(0, 2)
            };
            var tapGestureRecognizer = new TapGestureRecognizer();

            tapGestureRecognizer.Tapped += (sender, e) =>
            {
                if (!CrossShare.IsSupported)
                {
                    return;
                }

                var produto = (ProdutoInfo)BindingContext;
                if (produto == null)
                {
                    return;
                }

                CrossShare.Current.Share(new ShareMessage
                {
                    //Title = produto.Nome,
                    //Text = "R$ " + produto.ValorFinal.ToString("N2"),
                    //Url = "http://smartappcompras.com.br/site/" + produto.Slug
                    Url = produto.Url
                });
            };
            _compartilharButton.GestureRecognizers.Add(tapGestureRecognizer);

            _removerButton = new IconImage
            {
                VerticalOptions   = LayoutOptions.EndAndExpand,
                HorizontalOptions = LayoutOptions.Start,
                Icon      = "fa-remove",
                IconColor = Estilo.Current.DangerColor,
                IconSize  = 28,
                Margin    = new Thickness(0, 2)
            };
            var tapRemover = new TapGestureRecognizer();

            tapRemover.Tapped += (sender, e) =>
            {
                var produto = _quantidadeButton.Produto;
                if (produto != null)
                {
                    removerProduto(produto);
                }
            };
            _removerButton.GestureRecognizers.Add(tapRemover);

            _quantidadeButton = new QuantidadeVControl
            {
                Margin            = new Thickness(0, 5, 5, 0),
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.End,
                FontFamily        = Estilo.Current.FontDefaultBold,
                WidthRequest      = 40,
                HeightRequest     = 120
            };
            _quantidadeButton.SetBinding(QuantidadeHControl.QuantidadeProperty, new Binding("QuantidadeCarrinho"));
            _quantidadeButton.SetBinding(QuantidadeHControl.ProdutoProperty, new Binding("."));
        }
コード例 #2
0
        private void inicializarComponente()
        {
            _fotoImage = new Image
            {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                WidthRequest      = 400,
                HeightRequest     = 300,
                Aspect            = Aspect.AspectFit
            };
            _fotoImage.SetBinding(Image.SourceProperty, new Binding("FotoUrl"));
            _descricaoLabel = new Label
            {
                FontAttributes    = FontAttributes.Bold,
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                TextColor         = Color.FromHex("#777777")
            };
            _descricaoLabel.SetBinding(Label.TextProperty, new Binding("Descricao"));
            _categoriaLabel = new Label
            {
                FontAttributes    = FontAttributes.Bold,
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                TextColor         = Color.FromHex("#777777")
            };
            _categoriaLabel.SetBinding(Label.TextProperty, new Binding("Categoria.Nome"));
            _codigoLabel = new Label
            {
                FontAttributes    = FontAttributes.Bold,
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                TextColor         = Color.FromHex("#777777")
            };
            _codigoLabel.SetBinding(Label.TextProperty, new Binding("Codigo"));
            _moedaValorLabel = new Label
            {
                Text              = "R$",
                FontSize          = 11,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Start
            };
            _moedaValorLabel.SetBinding(Label.TextColorProperty, new Binding("PromocaoCor"));
            _valorFinalLabel = new Label
            {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.End,
                FontFamily        = Estilo.Current.FontDefaultBold,
                FontAttributes    = FontAttributes.Bold,
                FontSize          = 24
            };
            _valorFinalLabel.SetBinding(Label.TextProperty, new Binding("ValorFinal", stringFormat: "{0:N2}"));
            _valorFinalLabel.SetBinding(Label.TextColorProperty, new Binding("PromocaoCor"));

            _volumeLabel = new Label
            {
                FontAttributes    = FontAttributes.Bold,
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                TextColor         = Color.FromHex("#777777")
            };
            _volumeLabel.SetBinding(Label.TextProperty, new Binding("VolumeStr"));

            _quantidadeLabel = new Label
            {
                FontAttributes    = FontAttributes.Bold,
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                TextColor         = Color.FromHex("#777777")
            };
            _quantidadeLabel.SetBinding(Label.TextProperty, new Binding("Quantidade"));

            _moedaPromocaoLabel = new Label
            {
                Text     = "R$",
                FontSize = 11,
                //TextColor = Estilo.Current.D,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Start
            };
            _valorPromocaoLabel = new Label
            {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.End,
                FontFamily        = Estilo.Current.FontDefaultBold,
                //TextColor = Estilo.Current.DangerColor,
                FontAttributes = FontAttributes.Bold,
                FontSize       = 24
            };
            _valorPromocaoLabel.SetBinding(Label.TextProperty, new Binding("Valor", stringFormat: "{0:N2}"));

            var valorLayout = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                Margin            = new Thickness(0, 0, 0, 3),
                Children          =
                {
                    _moedaPromocaoLabel,
                    _valorPromocaoLabel
                }
            };

            AbsoluteLayout.SetLayoutBounds(valorLayout, new Rectangle(0, 0, 1, 1));
            AbsoluteLayout.SetLayoutFlags(valorLayout, AbsoluteLayoutFlags.All);

            var linha = new BoxView
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Fill,
                BackgroundColor   = Estilo.Current.DangerColor,
                HeightRequest     = 1,
            };

            AbsoluteLayout.SetLayoutBounds(linha, new Rectangle(0, 0, 1, 1));
            AbsoluteLayout.SetLayoutFlags(linha, AbsoluteLayoutFlags.All);

            _promocaoStack = new AbsoluteLayout
            {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                Children          =
                {
                    valorLayout,
                    linha
                }
            };
            _promocaoStack.SetBinding(AbsoluteLayout.IsVisibleProperty, new Binding("EmPromocao"));

            _quantidadeButton = new QuantidadeVControl
            {
                Margin            = new Thickness(0, 5, 5, 0),
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.End,
                FontFamily        = Estilo.Current.FontDefaultBold,
                HeightRequest     = 120
            };
            _quantidadeButton.SetBinding(QuantidadeHControl.QuantidadeProperty, new Binding("QuantidadeCarrinho"));
            _quantidadeButton.SetBinding(QuantidadeHControl.ProdutoProperty, new Binding("."));

            _destaqueIcon = new IconImage
            {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                Icon      = "fa-star",
                IconColor = Color.FromHex("#ffc500"),
                IconSize  = 24
            };
            _destaqueIcon.SetBinding(Label.IsVisibleProperty, new Binding("Destaque"));

            _totalView = new TotalCarrinhoView {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.End,
                ExibeQuantidade   = true,
                ExibeTotal        = true
            };

            _empresaLabel = new Label
            {
                HorizontalOptions       = LayoutOptions.Fill,
                VerticalOptions         = LayoutOptions.Start,
                HorizontalTextAlignment = TextAlignment.Center,
                FontAttributes          = FontAttributes.Bold,
                Margin = new Thickness(0, 0, 0, 3),
                Text   = "Smart Tecnologia ®"
            };
        }