コード例 #1
0
        public ProductDetailDescriptionView(CatalogProduct catalogProduct)
        {
            Label nameLabel = new Label()
            { 
                Text = catalogProduct.Name,
                TextColor = Device.OnPlatform(Palette._006, Palette._006, Palette._013),
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            };
            
            Label descriptionLabel = new Label()
            { 
                Text = catalogProduct.Description,
                TextColor = Palette._007,
                FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label))
            };

            Thickness padding = new Thickness(20);

            RelativeLayout relativeLayout = new RelativeLayout();

            relativeLayout.Children.Add(
                view: nameLabel, 
                xConstraint: Constraint.RelativeToParent(parent => 0),
                yConstraint: Constraint.RelativeToParent(parent => 0),
                widthConstraint: Constraint.RelativeToParent(parent => parent.Width)
            );

            relativeLayout.Children.Add(
                view: descriptionLabel, 
                xConstraint: Constraint.RelativeToParent(parent => 0),
                yConstraint: Constraint.RelativeToView(nameLabel, (parent, siblingView) => siblingView.Height + padding.VerticalThickness / 2),
                widthConstraint: Constraint.RelativeToParent(parent => parent.Width)
            );

            Padding = padding;

            Content = relativeLayout;
        }
コード例 #2
0
        public ProductDetailPage(CatalogProduct catalogProduct, bool isPerformingProductSelection = false)
        {
            _CatalogProduct = catalogProduct;

            Title = _CatalogProduct.Name;

            #region productImage
            Image image = new Image()
            {
                Source = _CatalogProduct.ImageUrl,
                Aspect = Aspect.AspectFit
            };
            #endregion

            #region ribbonView
            ProductDetailRibbonView detailRibbon = new ProductDetailRibbonView(_CatalogProduct, isPerformingProductSelection);
            #endregion

            #region descriptionView
            ProductDetailDescriptionView descriptionView = new ProductDetailDescriptionView(_CatalogProduct);
            #endregion

            #region compose view hierarchy
            Content = new ScrollView()
            {
                Content = new UnspacedStackLayout()
                {
                    Children =
                    {
                        image, 
                        detailRibbon,
                        descriptionView
                    }
                }
            };
            #endregion
        }
コード例 #3
0
 public ProductDetailViewModel(CatalogProduct catalogProduct)
 {
     CatalogProduct = catalogProduct;
 }
コード例 #4
0
        public ProductDetailRibbonView(CatalogProduct catalogProduct, bool isPerformingProductSelection = false)
        {
            _CatalogProduct = catalogProduct;

            RelativeLayout relativeLayout = new RelativeLayout();

            BackgroundColor = Palette._009;

            HeightRequest = 20;

            Padding = new Thickness(20, 15);

            if (isPerformingProductSelection)
            {
                Image addToOrderImage = new Image()
                {
                    Aspect = Aspect.AspectFit
                };
                Device.OnPlatform(
                    iOS: () => addToOrderImage.Source = new FileImageSource(){ File = "add_ios_blue" },     
                    Android: () => addToOrderImage.Source = new FileImageSource() { File = "add_android_blue" }
                );

                Label addToOrderTextLabel = new Label()
                {
                    Text = TextResources.Customers_Orders_EditOrder_AddToOrder.ToUpper(),
                    TextColor = Palette._004,
                    XAlign = TextAlignment.Start,
                    YAlign = TextAlignment.Center,
                };

                TapGestureRecognizer addToOrderTapGestureRecognizer = new TapGestureRecognizer()
                { 
                    NumberOfTapsRequired = 1,
                    Command = new Command(AddToOrderTapped)
                };

                addToOrderImage.GestureRecognizers.Add(addToOrderTapGestureRecognizer);
                addToOrderTextLabel.GestureRecognizers.Add(addToOrderTapGestureRecognizer);

                const double imagePaddingPercent = .10;

                relativeLayout.Children.Add(
                    view: addToOrderImage,
                    yConstraint: Constraint.RelativeToParent(parent => parent.Height * imagePaddingPercent),
                    widthConstraint: Constraint.RelativeToParent(parent => parent.Height - (parent.Height * imagePaddingPercent * 2)),
                    heightConstraint: Constraint.RelativeToParent(parent => parent.Height - (parent.Height * imagePaddingPercent * 2)));

                relativeLayout.Children.Add(
                    view: addToOrderTextLabel,
                    xConstraint: Constraint.RelativeToView(addToOrderImage, (parent, view) => view.X + view.Width + parent.Height * imagePaddingPercent),
                    widthConstraint: Constraint.RelativeToView(addToOrderImage, (parent, view) => parent.Width - view.Width),
                    heightConstraint: Constraint.RelativeToParent(parent => parent.Height)
                );
            }

            Label priceValueLabel = new Label()
            {
                Text = string.Format("{0:C}", _CatalogProduct.Price),
                TextColor = Color.White,
                FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                FontAttributes = FontAttributes.Bold,
                XAlign = TextAlignment.End,
                YAlign = TextAlignment.Center
            };

            relativeLayout.Children.Add(
                view: priceValueLabel, 
                xConstraint: Constraint.RelativeToParent(parent => parent.Width * .75), 
                yConstraint: Constraint.RelativeToParent(parent => 0), 
                widthConstraint: Constraint.RelativeToParent(parent => parent.Width * .25), 
                heightConstraint: Constraint.RelativeToParent(parent => parent.Height));

            Content = relativeLayout;
        }