Beispiel #1
0
            private BorderBox CreateCallButton(DiscountDetailContentUI parentContentUI, string bindingProperty)
            {
                int btnHeight = Device.OnPlatform(50, 50, 64);

                var imgPhone = new Image
                {
                    Source        = parentContentUI.IconPhone,
                    HeightRequest = btnHeight / 1.5,
                    WidthRequest  = btnHeight / 1.5
                };

                var txtPhone = new Label
                {
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    VerticalOptions   = LayoutOptions.CenterAndExpand,
                    Style             = (Style)App.Current.Resources[LabelStyles.DetailPhoneStyle]
                };

                txtPhone.SetBinding(Label.TextProperty, bindingProperty);

                AbsoluteLayout phoneLayout = new AbsoluteLayout
                {
                    BackgroundColor = (Color)App.Current.Resources[MainStyles.MainLightBackgroundColor]
                };

                AbsoluteLayout.SetLayoutFlags(imgPhone, AbsoluteLayoutFlags.PositionProportional);
                AbsoluteLayout.SetLayoutBounds(imgPhone,
                                               new Rectangle(0.1, 0.5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize)
                                               );

                AbsoluteLayout.SetLayoutFlags(txtPhone, AbsoluteLayoutFlags.PositionProportional);
                AbsoluteLayout.SetLayoutBounds(
                    txtPhone,
                    new Rectangle(
                        0.7,                            // X
                        0.5,                            // Y
                        AbsoluteLayout.AutoSize,        // Width
                        AbsoluteLayout.AutoSize)        // Height
                    );

                phoneLayout.Children.Add(imgPhone);
                phoneLayout.Children.Add(txtPhone);

                var borderPhone = new BorderBox();

                borderPhone.HeightRequest = btnHeight - 8;
                borderPhone.BorderWidth   = 1;
                borderPhone.BorderColor   = (Color)App.Current.Resources[MainStyles.MainBackgroundColor];
                borderPhone.Content       = phoneLayout;

                return(borderPhone);
            }
Beispiel #2
0
        public BranchInfoViewTemplate(DiscountDetailContentUI parentContentUi, DiscountDetailViewModel parentViewModel)
        {
            var stackBranch = new StackLayout
            {
                Padding         = new Thickness(20, 10),
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            #region Location

            var gridLocation = new Grid
            {
                RowDefinitions =
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    }
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = GridLength.Auto
                    },
                    new ColumnDefinition {
                        Width = GridLength.Auto
                    },
                    new ColumnDefinition {
                        Width = GridLength.Star
                    }
                }
            };

            var txtDistanceValue = new Label
            {
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Start,
                Style             = LabelStyles.DetailDistanceStyle.FromResources <Style>()
            };
            txtDistanceValue.SetBinding(Label.TextProperty, "DistanceString");

            gridLocation.Children.Add(txtDistanceValue, 0, 0);

            var distanceLabel = new StackLayout
            {
                VerticalOptions = LayoutOptions.Center,
                Margin          = new Thickness(0, 0, 10, 0),
                TranslationY    = 2,
                Spacing         = 0,
                Children        =
                {
                    new Image
                    {
                        Source = parentContentUi.ImgDistance
                    },
                    new Label
                    {
                        Text  = parentContentUi.TxtDistanceScaleValue,
                        Style = LabelStyles.DescriptionStyle.FromResources <Style>()
                    }
                }
            };

            gridLocation.Children.Add(distanceLabel, 1, 0);

            var txtPartnerAddress = new Label
            {
                VerticalOptions = LayoutOptions.CenterAndExpand,
                Style           = LabelStyles.DescriptionStyle.FromResources <Style>()
            };
            txtPartnerAddress.SetBinding(Label.TextProperty, "Address");

            var txtShowOnMap = new Label
            {
                Text          = parentContentUi.TxtShowOnMap,
                Style         = LabelStyles.LinkStyle.FromResources <Style>(),
                LineBreakMode = LineBreakMode.TailTruncation
            };

            var locationLayout = new StackLayout
            {
                VerticalOptions = LayoutOptions.Center,
                Spacing         = 0,
                Children        =
                {
                    txtPartnerAddress,
                    txtShowOnMap
                }
            };

            var tapShowOnMapp = new TapGestureRecognizer();
            tapShowOnMapp.SetBinding(TapGestureRecognizer.CommandParameterProperty, "DocumentId");
            tapShowOnMapp.Tapped += parentViewModel.ShowOnMap_Click;

            locationLayout.GestureRecognizers.Add(tapShowOnMapp);

            gridLocation.Children.Add(locationLayout, 2, 0);

            stackBranch.Children.Add(gridLocation);

            #endregion

            #region Phone list

            var stackPhoneView = new StackLayout
            {
                Padding = new Thickness(0, 4)
            };

            #region phone1

            var tapPhone1 = new TapGestureRecognizer();
            tapPhone1.SetBinding(TapGestureRecognizer.CommandParameterProperty, "Phone1");
            tapPhone1.Tapped += parentViewModel.BtnCall_Click;

            var phone1 = CreateCallButton("Phone1", "PhoneOperatorIcon1");
            phone1.SetBinding(VisualElement.IsVisibleProperty, "IsPhone1Exists");
            phone1.GestureRecognizers.Add(tapPhone1);

            stackPhoneView.Children.Add(phone1);

            #endregion

            #region phone2

            var tapPhone2 = new TapGestureRecognizer();
            tapPhone2.SetBinding(TapGestureRecognizer.CommandParameterProperty, "Phone2");
            tapPhone2.Tapped += parentViewModel.BtnCall_Click;

            var phone2 = CreateCallButton("Phone2", "PhoneOperatorIcon2");
            phone2.SetBinding(VisualElement.IsVisibleProperty, "IsPhone2Exists");
            phone2.GestureRecognizers.Add(tapPhone2);

            stackPhoneView.Children.Add(phone2);

            #endregion

            stackBranch.Children.Add(stackPhoneView);

            #endregion

            View = stackBranch;
        }
Beispiel #3
0
            public BranchInfoViewTemplate(ListView parentListView, DiscountDetailContentUI parentContentUI, DiscountDetailViewModel parentViewModel)
            {
                IsHighlightSelection = false;

                var stackBranch = new StackLayout
                {
                    Padding         = new Thickness(18, 0),
                    VerticalOptions = LayoutOptions.FillAndExpand
                };

                #region Location
                Grid gridLocation = new Grid
                {
                    RowDefinitions =
                    {
                        new RowDefinition {
                            Height = GridLength.Auto
                        }
                    },
                    ColumnDefinitions =
                    {
                        new ColumnDefinition  {
                            Width = GridLength.Auto
                        },
                        new ColumnDefinition  {
                            Width = GridLength.Auto
                        },
                        new ColumnDefinition  {
                            Width = new GridLength(1, GridUnitType.Star)
                        }
                    }
                };

                var txtDistanceValue = new Label
                {
                    VerticalOptions   = LayoutOptions.Center,
                    HorizontalOptions = LayoutOptions.Start,
                    Style             = (Style)App.Current.Resources[LabelStyles.DetailDistanceStyle]
                };
                txtDistanceValue.SetBinding(Label.TextProperty, "Distance");

                var distanceLabel = new StackLayout
                {
                    VerticalOptions = LayoutOptions.Center,
                    Spacing         = 0,
                    Children        =
                    {
                        new Image
                        {
                            Source = parentContentUI.ImgDistance
                        },
                        new Label
                        {
                            Text  = parentContentUI.TxtDistanceScaleValue,
                            Style = (Style)App.Current.Resources[LabelStyles.DescriptionStyle]
                        }
                    }
                };

                gridLocation.Children.Add(txtDistanceValue, 0, 0);
                gridLocation.Children.Add(distanceLabel, 1, 0);

                var txtPartnerAddress = new Label
                {
                    VerticalOptions = LayoutOptions.CenterAndExpand,
                    Style           = (Style)App.Current.Resources[LabelStyles.DescriptionStyle]
                };
                txtPartnerAddress.SetBinding(Label.TextProperty, "Address");

                var txtShowOnMap = new LabelExtended
                {
                    Text        = parentContentUI.TxtShowOnMap,
                    Style       = (Style)App.Current.Resources[LabelStyles.LinkStyle],
                    IsUnderline = true
                };

                var locationLayout = new StackLayout
                {
                    VerticalOptions = LayoutOptions.Center,
                    Spacing         = 0,
                    Children        =
                    {
                        txtPartnerAddress,
                        txtShowOnMap
                    }
                };

                var viewGesturesShowOnMap = new ViewGestures
                {
                    Content          = locationLayout,
                    DeformationValue = -5,
                };
                viewGesturesShowOnMap.BackgroundColor = (Color)App.Current.Resources[MainStyles.MainLightBackgroundColor];
                viewGesturesShowOnMap.Tap            += parentViewModel.ShowOnMap_Click;
                viewGesturesShowOnMap.SetBinding(ViewGestures.TagProperty, "DocumentId");

                gridLocation.Children.Add(viewGesturesShowOnMap, 2, 0);

                stackBranch.Children.Add(gridLocation);

                #endregion

                #region Phone list
                var stackPhoneView = new StackLayout
                {
                    Padding = Device.OnPlatform(new Thickness(0, 4), new Thickness(0, 4), new Thickness(0, 4, -8, 4)),
                };

                #region phone1
                var phone1 = CreateCallButton(parentContentUI, "Phone1");
                phone1.SetBinding(BorderBox.TagProperty, "Phone1");

                var viewGesturesPhone1 = new ViewGestures
                {
                    Content          = phone1,
                    DeformationValue = -5,
                };
                viewGesturesPhone1.SetBinding(ViewGestures.IsVisibleProperty, "IsPhone1FillIn");
                viewGesturesPhone1.BackgroundColor = (Color)App.Current.Resources[MainStyles.MainLightBackgroundColor];
                viewGesturesPhone1.Tap            += parentViewModel.BtnCall_Click;
                stackPhoneView.Children.Add(viewGesturesPhone1);
                #endregion

                #region phone2
                var phone2 = CreateCallButton(parentContentUI, "Phone2");
                phone2.SetBinding(BorderBox.TagProperty, "Phone2");

                var viewGesturesPhone2 = new ViewGestures
                {
                    Content          = phone2,
                    DeformationValue = -5,
                };
                viewGesturesPhone2.SetBinding(ViewGestures.IsVisibleProperty, "IsPhone2FillIn");
                viewGesturesPhone2.BackgroundColor = (Color)App.Current.Resources[MainStyles.MainLightBackgroundColor];
                viewGesturesPhone2.Tap            += parentViewModel.BtnCall_Click;
                stackPhoneView.Children.Add(viewGesturesPhone2);
                #endregion

                stackBranch.Children.Add(stackPhoneView);
                #endregion

                View = stackBranch;
            }