Exemplo n.º 1
0
        public CustomerDetailContactView()
        {
            #region labels
            Label contactTitleLabel = new Label()
            {
                Text          = TextResources.Contact,
                TextColor     = Device.OnPlatform(Palette._005, Palette._007, Palette._006),
                FontSize      = Device.OnPlatform(Device.GetNamedSize(NamedSize.Small, typeof(Label)), Device.GetNamedSize(NamedSize.Small, typeof(Label)), Device.GetNamedSize(NamedSize.Small, typeof(Label))),
                LineBreakMode = LineBreakMode.TailTruncation
            };

            Label contactLabel = new Label()
            {
                TextColor     = Palette._006,
                FontSize      = Device.OnPlatform(Device.GetNamedSize(NamedSize.Default, typeof(Label)), Device.GetNamedSize(NamedSize.Medium, typeof(Label)), Device.GetNamedSize(NamedSize.Default, typeof(Label))),
                LineBreakMode = LineBreakMode.TailTruncation
            };
            contactLabel.SetBinding(Label.TextProperty, "Account.DisplayContact");
            #endregion

            #region compose view hierarchy
            Content = new ContentViewWithBottomBorder()
            {
                Content = new UnspacedStackLayout()
                {
                    Children =
                    {
                        contactTitleLabel,
                        contactLabel
                    },
                    Padding = new Thickness(20)
                }
            };
            #endregion
        }
Exemplo n.º 2
0
        public OrderListItemCell()
        {
            StyleId = "disclosure";
            #region primary label
            PrimaryLabel = new Label()
            {
                TextColor     = Palette._006,
                FontSize      = Device.GetNamedSize(NamedSize.Small, typeof(Label)) * 1.2,
                XAlign        = TextAlignment.Start,
                YAlign        = TextAlignment.End,
                LineBreakMode = LineBreakMode.TailTruncation
            };
            PrimaryLabel.SetBinding(
                Label.TextProperty,
                new Binding("Item"));
            #endregion

            #region secondary label
            SecondaryLabel = new Label()
            {
                TextColor     = Palette._007,
                FontSize      = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                XAlign        = TextAlignment.Start,
                YAlign        = TextAlignment.Start,
                LineBreakMode = LineBreakMode.TailTruncation
            };

            SecondaryLabel.SetBinding(
                Label.TextProperty,
                "DueDate",
                converter: new ShortDatePatternConverter());
            #endregion

            #region ternary label
            TernaryLabel = new Label()
            {
                TextColor = Palette._007,
                FontSize  = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                XAlign    = TextAlignment.End,
                YAlign    = TextAlignment.Start,
            };

            TernaryLabel.SetBinding(
                Label.TextProperty,
                "Price",
                converter: new CurrencyDoubleConverter());
            #endregion

            var contentView = new ContentView();

            contentView.Padding = new Thickness(20, 0);

            RelativeLayout labelsRelativeLayout = new RelativeLayout()
            {
                HeightRequest = Sizes.LargeRowHeight
            };

            labelsRelativeLayout.Children.Add(
                view: PrimaryLabel,
                widthConstraint: Constraint.RelativeToParent(parent => parent.Width),
                heightConstraint: Constraint.RelativeToParent(parent => parent.Height / 2));

            labelsRelativeLayout.Children.Add(
                view: SecondaryLabel,
                yConstraint: Constraint.RelativeToParent(parent => parent.Height / 2),
                widthConstraint: Constraint.RelativeToParent(parent => parent.Width / 2),
                heightConstraint: Constraint.RelativeToParent(parent => parent.Height / 2));

            labelsRelativeLayout.Children.Add(
                view: TernaryLabel,
                xConstraint: Constraint.RelativeToView(SecondaryLabel, (parent, view) => view.Width),
                yConstraint: Constraint.RelativeToParent(parent => parent.Height / 2),
                widthConstraint: Constraint.RelativeToParent(parent => parent.Width / 2),
                heightConstraint: Constraint.RelativeToParent(parent => parent.Height / 2));

            contentView.Content = labelsRelativeLayout;

            View = new ContentViewWithBottomBorder()
            {
                Content = contentView
            };
        }
Exemplo n.º 3
0
        public CustomerDetailPhoneView(Page page)
        {
            _Page = page;

            #region labels
            Label phoneTitleLabel = new Label()
            {
                Text          = TextResources.Phone,
                TextColor     = Device.OnPlatform(Palette._005, Palette._007, Palette._006),
                FontSize      = Device.OnPlatform(Device.GetNamedSize(NamedSize.Small, typeof(Label)), Device.GetNamedSize(NamedSize.Small, typeof(Label)), Device.GetNamedSize(NamedSize.Small, typeof(Label))),
                LineBreakMode = LineBreakMode.TailTruncation
            };

            Label phoneLabel = new Label()
            {
                TextColor     = Palette._006,
                FontSize      = Device.OnPlatform(Device.GetNamedSize(NamedSize.Default, typeof(Label)), Device.GetNamedSize(NamedSize.Medium, typeof(Label)), Device.GetNamedSize(NamedSize.Default, typeof(Label))),
                LineBreakMode = LineBreakMode.TailTruncation
            };
            phoneLabel.SetBinding(Label.TextProperty, "Account.Phone");
            #endregion

            #region phone image
            Image phoneImage = new Image()
            {
                Source = new FileImageSource {
                    File = Device.OnPlatform("phone_ios", "phone_android", null)
                },
                Aspect        = Aspect.AspectFit,
                HeightRequest = 25
            };

            // an expanded view to catch touches, because the image is a bit small
            AbsoluteLayout phoneImageTouchView = new AbsoluteLayout()
            {
                WidthRequest  = Sizes.MediumRowHeight,
                HeightRequest = Sizes.MediumRowHeight
            };

            phoneImageTouchView.Children.Add(phoneImage, new Rectangle(.5, .5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize), AbsoluteLayoutFlags.PositionProportional);

            phoneImageTouchView.GestureRecognizers.Add(
                new TapGestureRecognizer()
            {
                Command = new Command(() => OnPhoneTapped(phoneLabel, null))
            });
            #endregion

            #region compose view hierarchy
            StackLayout stackLayout = new UnspacedStackLayout()
            {
                Children =
                {
                    phoneTitleLabel,
                    phoneLabel
                },
                Padding = new Thickness(20)
            };
            AbsoluteLayout absoluteLayout = new AbsoluteLayout();
            absoluteLayout.Children.Add(stackLayout, new Rectangle(0, .5, 1, AbsoluteLayout.AutoSize), AbsoluteLayoutFlags.PositionProportional | AbsoluteLayoutFlags.WidthProportional);
            absoluteLayout.Children.Add(phoneImageTouchView, new Rectangle(.95, .5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize), AbsoluteLayoutFlags.PositionProportional);
            #endregion

            Content = new ContentViewWithBottomBorder()
            {
                Content = absoluteLayout
            };
        }